From b2607b88691c867c36a22b47975585fbb3f51708 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 29 May 2018 21:49:01 +0100 Subject: [PATCH 1/3] GPII-2992: Stop narrator from staying active after acceptance tests by waiting for AT to start. --- .../node_modules/registeredAT/registeredAT.js | 21 +++++++---- .../registeredAT/test/testRegisteredAT.js | 37 +++++++++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/gpii/node_modules/registeredAT/registeredAT.js b/gpii/node_modules/registeredAT/registeredAT.js index b0f0b3e97..908a49d32 100644 --- a/gpii/node_modules/registeredAT/registeredAT.js +++ b/gpii/node_modules/registeredAT/registeredAT.js @@ -78,7 +78,7 @@ gpii.windows.registeredAT = fluid.freezeRecursive({ * @param {String} options.startCommand Overrides the command used to start the AT application. * @param {String} options.processName Overrides the executable to terminate when disabling. * @param {String} options.utilman Overrides the command for utilman.exe - * @return {*} + * @return {Promise} Resolves when the AT has started or stopped. */ gpii.windows.enableRegisteredAT = function (name, enable, options) { var defaultOptions = { @@ -87,9 +87,10 @@ gpii.windows.enableRegisteredAT = function (name, enable, options) { }; options = fluid.extend(defaultOptions, options); + var startPromise; if (!options.configOnly) { if (enable) { - gpii.windows.startRegisteredAT(name, options); + startPromise = gpii.windows.startRegisteredAT(name, options); } else { gpii.windows.stopRegisteredAT(name, options); } @@ -99,7 +100,7 @@ gpii.windows.enableRegisteredAT = function (name, enable, options) { // The AT will have enabled itself when it starts, so only update the registry when disabling. if (enable && !options.configOnly) { - promise.resolve(); + fluid.promise.follow(startPromise, promise); } else { // On Windows 7/8, if there's more than one action value in the registry then it will display the Ease of Access // Centre. (This could be because when the first AT is loaded, it then invokes yet another instance of utilman, @@ -215,14 +216,17 @@ gpii.windows.whilePendingAT = function (options) { * @param {Object} [options] Options * @param {String} options.startCommand Overrides the command used to start the AT application. * @param {Object} options.atInfo Overrides the AT information taken from the registry. + * @return {Promise} Resolves when the AT has started. */ gpii.windows.startRegisteredAT = function (name, options) { var command; + var atInfo; + if (options && options.startCommand) { command = options.startCommand; } else { // StartExe + StartParams is the command to execute - var atInfo = gpii.windows.getATInformation(name, ["StartExe", "StartParams"]); + atInfo = gpii.windows.getATInformation(name, ["StartExe", "StartParams", "ATExe"]); if (options && options.atInfo) { atInfo = fluid.extend(atInfo, options.atInfo); } @@ -232,10 +236,14 @@ gpii.windows.startRegisteredAT = function (name, options) { } } + var promise = fluid.promise(); // Before executing the command, make sure utilman isn't already running. gpii.windows.waitForProcessTermination("utilman.exe").then(function () { gpii.windows.nativeExec(command); + fluid.promise.follow(gpii.windows.waitForProcessStart(atInfo.ATExe), promise); }); + + return promise; }; /** @@ -246,7 +254,6 @@ gpii.windows.startRegisteredAT = function (name, options) { * @param {Object} [options] Options * @param {String} options.processName Overrides the executable name to terminate. * @param {Object} options.atInfo Overrides the AT information taken from the registry. - * @return {Promise} A promise that will resolve when the application has closed. */ gpii.windows.stopRegisteredAT = function (name, options) { var exeName; @@ -262,7 +269,7 @@ gpii.windows.stopRegisteredAT = function (name, options) { exeName = atInfo.ATExe; } - var promiseTogo = gpii.windows.killProcessByName(exeName); + gpii.windows.killProcessByName(exeName); // Remove the registry key that's used to transfer settings to the secure desktop, otherwise these settings // will override any future settings. Really, the AT should do this when it closes, unfortunately it doesn't get @@ -271,8 +278,6 @@ gpii.windows.stopRegisteredAT = function (name, options) { var regPath = gpii.windows.registeredAT.settingsTransfer.path + "\\" + name; gpii.windows.deleteRegistryKey(gpii.windows.registeredAT.settingsTransfer.baseKey, regPath); } - - return promiseTogo; }; /** diff --git a/gpii/node_modules/registeredAT/test/testRegisteredAT.js b/gpii/node_modules/registeredAT/test/testRegisteredAT.js index 761c9bf43..b5d323608 100644 --- a/gpii/node_modules/registeredAT/test/testRegisteredAT.js +++ b/gpii/node_modules/registeredAT/test/testRegisteredAT.js @@ -253,3 +253,40 @@ jqUnit.asyncTest("Testing pending AT", function () { } ]); }); + +// Test starting and stopping Narrator. +jqUnit.asyncTest("Testing real AT", function () { + + jqUnit.expect(4); + + var timeout = null; + var timer = setTimeout(function () { + if (timeout) { + jqUnit.fail("Timeout: " + timeout); + } + }, 10000); + + timeout = "enableRegisteredAT(true)"; + var p = gpii.windows.enableRegisteredAT("Narrator", true); + jqUnit.assertTrue("enableRegisteredAT must return a promise", fluid.isPromise(p)); + + p.then(function () { + var running = gpii.windows.isProcessRunning("Narrator.exe"); + + jqUnit.assertTrue("Narrator must be running", running); + + timeout = "enableRegisteredAT(false)"; + var p = gpii.windows.enableRegisteredAT("Narrator", false); + jqUnit.assertTrue("enableRegisteredAT must return a promise", fluid.isPromise(p)); + + p.then(function () { + var running = gpii.windows.isProcessRunning("Narrator.exe"); + + jqUnit.assertFalse("Narrator must no longer be running", running); + + clearTimeout(timer); + jqUnit.start(); + + }, jqUnit.fail); + }, jqUnit.fail); +}); From dfe828a8cd4baa511be1cec0d142da0a2c3cde68 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 29 May 2018 21:59:05 +0100 Subject: [PATCH 2/3] GPII-2992: Pointing to relevant universal branch. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8f5aaf41..25a603aa8 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.20180504T120509Z.a5e50ed", + "gpii-universal": "stegru/universal#GPII-2992", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From bb4661a38816d72f41464d909c83d57f6467be5a Mon Sep 17 00:00:00 2001 From: ste Date: Thu, 7 Jun 2018 15:01:29 +0100 Subject: [PATCH 3/3] GPII-2992: Fixed kettle require --- gpii/node_modules/processReporter/test/all-tests.js | 2 +- gpii/node_modules/userListeners/test/all-tests.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/processReporter/test/all-tests.js b/gpii/node_modules/processReporter/test/all-tests.js index fff9138df..6e9269054 100644 --- a/gpii/node_modules/processReporter/test/all-tests.js +++ b/gpii/node_modules/processReporter/test/all-tests.js @@ -12,7 +12,7 @@ "use strict"; var fluid = require("gpii-universal"), - kettle = fluid.require("kettle"); + kettle = fluid.require("%kettle"); kettle.loadTestingSupport(); diff --git a/gpii/node_modules/userListeners/test/all-tests.js b/gpii/node_modules/userListeners/test/all-tests.js index 908d89a52..3e42ea7d6 100644 --- a/gpii/node_modules/userListeners/test/all-tests.js +++ b/gpii/node_modules/userListeners/test/all-tests.js @@ -19,7 +19,7 @@ "use strict"; var fluid = require("gpii-universal"), - kettle = fluid.require("kettle"); + kettle = fluid.require("%kettle"); kettle.loadTestingSupport();