diff --git a/gpii/node_modules/registeredAT/registeredAT.js b/gpii/node_modules/registeredAT/registeredAT.js index 6f5302671..9db647f24 100644 --- a/gpii/node_modules/registeredAT/registeredAT.js +++ b/gpii/node_modules/registeredAT/registeredAT.js @@ -127,6 +127,41 @@ gpii.windows.enableRegisteredAT = function (name, enable, options) { return promise; }; + +gpii.windows.enableRegisteredAT.queryProcessReporter = function (entry) { + return gpii.processReporter.find(entry.options.queryProcess); +}; + +gpii.windows.enableRegisteredAT.set = function (settingsArray) { + return gpii.settingsHandlers.transformPayload(settingsArray, function (entry) { + var registryName = entry.options.registryName; + var enable = entry.settings.running; + + // get current value: + var oldValue = gpii.windows.enableRegisteredAT.queryProcessReporter(entry); + gpii.windows.enableRegisteredAT(registryName, enable, entry.options); + + return { + settings: { + running: { + "oldValue": oldValue, + "newValue": enable + } + } + }; + }); +}; + +gpii.windows.enableRegisteredAT.get = function (settingsArray) { + return gpii.settingsHandlers.transformPayload(settingsArray, function (entry) { + return { + settings: { + running: gpii.windows.enableRegisteredAT.queryProcessReporter(entry) + } + }; + }); +}; + /** * Waits while there are pending actions for utilman. * diff --git a/gpii/node_modules/registeredAT/test/testRegisteredAT.js b/gpii/node_modules/registeredAT/test/testRegisteredAT.js index 134d1765b..761c9bf43 100644 --- a/gpii/node_modules/registeredAT/test/testRegisteredAT.js +++ b/gpii/node_modules/registeredAT/test/testRegisteredAT.js @@ -1,7 +1,7 @@ /* * Built-in AT Unit Tests * - * Copyright 2015 Raising the Floor - International + * Copyright 2015, 2017 Raising the Floor - International * * Licensed under the New BSD license. You may not use this file except in * compliance with this License. @@ -170,6 +170,51 @@ jqUnit.asyncTest("Testing AT start and stop", function () { }); }); +jqUnit.asyncTest("Testing enableRegisteredAT.set/get functions", function () { + jqUnit.expect(3); + + var testData = gpii.tests.windows.registeredAT.atStartStopTest.testData; + + // Take a copy of the built-in "waitfor" command, to ensure a unique process name. + shelljs.cp(path.join(process.env.SystemRoot, "/System32/waitfor.exe"), testData.StartExe); + // Remove it at the end + teardowns.push(function () { + gpii.windows.killProcessByName(testData.ATExe); + gpii.windows.waitForProcessTermination(testData.ATExe).then(function () { + shelljs.rm(testData.StartExe); + }); + }); + + var pid = gpii.windows.findProcessByName(testData.ATExe); + jqUnit.assertEquals("The process should not already be running.", null, pid); + + gpii.windows.startRegisteredAT(testData.appName, {atInfo: testData}); + + // Timeout waiting for the process start/end after 5 seconds. + var waitOptions = { timeout: 5000 }; + + // Wait for it to start. + gpii.windows.waitForProcessStart(testData.ATExe, waitOptions) + .then(function () { + jqUnit.assert("We just started the new process."); + + // Tell the process to stop now. + gpii.windows.stopRegisteredAT(testData.appName, {atInfo: testData}); + + // Wait for it to die + gpii.windows.waitForProcessTermination(testData.ATExe, waitOptions) + .then(function () { + jqUnit.assert("Child process terminated."); + jqUnit.start(); + }, function () { + jqUnit.fail("Process should have terminated."); + }); + + }, function () { + jqUnit.fail("Failed to detect process start."); + }); +}); + jqUnit.asyncTest("Testing pending AT", function () { jqUnit.expect(3); var testData = gpii.tests.windows.registeredAT.atPendingTest; diff --git a/package.json b/package.json index 3cc00e52b..fc5af29f6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "edge": "6.5.1", "edge-js": "8.8.1", "ffi": "2.0.0", - "gpii-universal": "0.3.0-dev.20180314T153442Z.bcc35970", + "gpii-universal": "0.3.0-dev.20180427T101505Z.dad9bfb", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0",