diff --git a/documentation/CanopyMatchMaker.md b/documentation/CanopyMatchMaker.md index 51df9a45f..b0aed4d79 100644 --- a/documentation/CanopyMatchMaker.md +++ b/documentation/CanopyMatchMaker.md @@ -25,13 +25,16 @@ To ensure that several conflicting solutions (e.g. two screenreaders) are not la The apptology is described in more details here: [Apptology.md](Apptology.md). +## Dispositions +As described below, the matchmaker will assign a disposition to each solution based on priority and canopy matching. There are three dispositions available: "accept", "reject" and "deactivate". "accept" means that the solution will be accepted (and started, if relevant for that solution). "reject" means we do not do anything to the solution. "deactivate" means that we ensure that the solution is not running (i.e. running stop if required). The latter case is relevant for solutions that are conflicting with other solutions that the user might need. + ## Disposing from prioriy: Explicit priorities are declared in the NP sets metadata section and will always be a floating point value of 1024 or more. Implicit priorities are deduced from application specific settings. When a user has application specific settings for a solution a priority of 512 is set for that solution. Goes through all solutions from high priority to low. If a solution already has a disposition, it is ignored. Else it will be selected (accepted). Any solution with the same type, but a lower priority (or no priority) will be rejected. If there are two or more solutions of the same priority _and_ the same type (even partly), these will be considered a "tie". All lower-priority solutions of this type will still be rejected. The tied solutions will have their current disposition and priority removed and left to be disposed by some other disposal algorithm. ## Disposing from Canopy -The Canopy matching strategy is used for deciding how to dispose solutions in case no priorities are available or there is a priority-tie between two applications of the same type. +The Canopy matching strategy is used for deciding how to dispose solutions in case no priorities are available or there is a priority-tie between two applications of the same type. * The canopy approach is based on a vectorial "fitness measure" of a solution plus a lexicographical ordering * It is similar to the strategy used in resolving CSS rules. @@ -45,7 +48,7 @@ The Canopy matching strategy is used for deciding how to dispose solutions in ca * Compute capabilities of solution * Compute vector of prefix depths for each leaf el path from NP set * Sort vector in descending order of fitness ("fitness vector") -* Rank solutions by fitness using lexicographic ordering +* Rank solutions by fitness using lexicographic ordering *The canopy matching* * Compute fitness vectors for each solution and sort in rank order diff --git a/documentation/FlowManager.md b/documentation/FlowManager.md index 5be1ee654..6ee2d47b5 100644 --- a/documentation/FlowManager.md +++ b/documentation/FlowManager.md @@ -115,7 +115,7 @@ OR if the last login/logout process for finished less than 5 seconds a } ] }, - "settingsHandlers": { + "handlers": { "configs": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { diff --git a/documentation/MatchMakerFramework.md b/documentation/MatchMakerFramework.md index d966c5751..5311298a3 100644 --- a/documentation/MatchMakerFramework.md +++ b/documentation/MatchMakerFramework.md @@ -148,7 +148,7 @@ The input for these POST requests will be in the following format. Note that it ### Return payload -The return payload from at call to `/match` should be in the following format: +The return payload from at call to `/match` should be in the following format. The "active" key expresses whether the application should be set to running. A `true` value means that it should be running, `undefined` means we leave it in its current run state and `false` mean we should actively ensure that it is not running. ``` { diff --git a/documentation/SolutionsRegistryFormat.md b/documentation/SolutionsRegistryFormat.md index 25e5be802..75ef3c7bc 100644 --- a/documentation/SolutionsRegistryFormat.md +++ b/documentation/SolutionsRegistryFormat.md @@ -7,14 +7,14 @@ Each entry in the solution registry should have a unique ID (`Solution.id` in th "Solution.id": { "name": "My Solution" "contexts": { ... }, - "settingsHandlers": { ... }, + "handlers": { ... }, "configure": [ .. ], "restore": [ .. ], "update": [ .. ], "start": [ .. ], "stop": [ .. ], "isInstalled": [ .. ], - + // Not yet supported. Post-Cloud4All features. "install": [ ... ], "uninstall": [ ... ], @@ -38,12 +38,12 @@ The `contexts` block describes what the required context is for the solution to } ``` -### settingsHandlers -The `settingsHandlers` block is unique and one of the most important blocks in the solutions registry entry. It consists of zero or more settingsHandler entries, each keyed by an arbitrary name (that is unique within this solutions settingsHandlers block). Inside each settingsHandler entry, the properties for that settingsHandler is provided. The entries in the settingsHandlers block can be referred to from the other lifecycle blocks of the solutions registry entry. The settingsHandlers block is mandatory. +### handlers +The `handlers` block is unique and one of the most important blocks in the solutions registry entry. It consists of zero or more settingsHandler or LaunchHandler entries, each keyed by an arbitrary name (that is unique within this solutions handlers block). Inside each handler entry, the properties for that handler is provided. The entries in the settingsHandlers block can be referred to from the other lifecycle blocks of the solutions registry entry. The handlers block is mandatory. **Example settingsHandlers block**: ``` -"settingsHandlers": { +"handlers": { "myconf": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -116,7 +116,7 @@ These four lifecycle blocks have different meanings to the system but has the sa * `start`: Launch/start the solution * `stop`: Stop/kill the solution -Each of these lifecycle blocks allow the same content - which is an array with entries that are either references to settingsHandlers blocks or customized lifecycle blocks. To reference a settingsHandler block, the keyword `settings.` is used, where `` should be replaced with the name of a settingsHandler block. In the case of `configure` and `start`, a consequence of referencing a settingsHandler is that the settings given in the settingsHandler and users preferences set will be applied to that solution (and their original values will be saved to the system - if the user just logged in). In the case of `restore` and `stop`, the settings that have previously been written using the settingshandler(s) in question will be restored. Alternative to referencings setting and restoring settings, arbitrary lifecycle actions are allowed - the syntax for this is an object that contains at least a `type` key for the function to call. None of these blocks are mandatory. +Each of these lifecycle blocks allow the same content - which is an array with entries that are either references to settingsHandlers blocks or customized lifecycle blocks. To reference a settingsHandler block, the keyword `settings.` is used, where `` should be replaced with the name of a settingsHandler block. In the case of `configure` and `start`, a consequence of referencing a settingsHandler is that the settings given in the settingsHandler and users preferences set will be applied to that solution (and their original values will be saved to the system - if the user just logged in). In the case of `restore` and `stop`, the settings that have previously been written using the settingshandler(s) in question will be restored. Alternative to referencings setting and restoring settings, arbitrary lifecycle actions are allowed - the syntax for this is an object that contains at least a `type` key for the function to call. None of these blocks are mandatory. **Example blocks**: ``` @@ -144,7 +144,7 @@ Each of these lifecycle blocks allow the same content - which is an array with e The `update` block works very similarly to the configure, restore, start and stop blocks. It describes what should happen when the configuration needs to be updated (e.g. due to context changes, PCP adjustments, etc). -The format of the `update` block allows for the same entries as the configure, restore, start and stop blocks - that is: arbitrary lifecycle action blocks and `settings.`. Unlike for the other lifecycle blocks, the `update` block furthermore allows references to the `start`, `stop` and `configure` blocks. This is one by putting a string with the name of that block. When the system encounters one of these references, the entries of that block will be run. +The format of the `update` block allows for the same entries as the configure, restore, start and stop blocks - that is: arbitrary lifecycle action blocks and `settings.`. Unlike for the other lifecycle blocks, the `update` block furthermore allows references to the `start`, `stop` and `configure` blocks. This is done by putting a string with the name of that block. When the system encounters one of these references, the entries of that block will be run. **Example block**: ``` @@ -204,7 +204,7 @@ This is run before configuration to ensure that the application is actually read **Example Entry**: ``` -"isConfigurable": [{ +"isConfigurable": [{ "type": "gpii.reporter.fileExists", "path": "${{environment}.XDG_DATA_HOME}/orca/user-settings.conf"" }] diff --git a/gpii/node_modules/canopyMatchMaker/src/CanopyMatchMakerUtilities.js b/gpii/node_modules/canopyMatchMaker/src/CanopyMatchMakerUtilities.js index e773b3468..b08f88afd 100644 --- a/gpii/node_modules/canopyMatchMaker/src/CanopyMatchMakerUtilities.js +++ b/gpii/node_modules/canopyMatchMaker/src/CanopyMatchMakerUtilities.js @@ -103,7 +103,7 @@ gpii.canopyMatchMaker.utils.disposeFromCanopy = function (leaves, ranked, solrec for (var i = 0; i < ranked.length; ++i) { var sol = solrecs[ranked[i]]; - if (sol.disposition === "reject") { + if (sol.disposition === "reject" || sol.active === false) { continue; } @@ -117,6 +117,7 @@ gpii.canopyMatchMaker.utils.disposeFromCanopy = function (leaves, ranked, solrec } if (inCanopy) { sol.disposition = "accept"; + sol.active = true; sol.dispositionReason = "Was the solution of this type that best fit user preferences"; gpii.matchMakerFramework.utils.rejectFromTypes(data.solutionTypes[sol.index], data.solutionTypeMapping, solrecs, "Another solution (" + sol.index + diff --git a/gpii/node_modules/canopyMatchMaker/test/CanopyMatchMakerTests.js b/gpii/node_modules/canopyMatchMaker/test/CanopyMatchMakerTests.js index f2651f678..5422710ef 100644 --- a/gpii/node_modules/canopyMatchMaker/test/CanopyMatchMakerTests.js +++ b/gpii/node_modules/canopyMatchMaker/test/CanopyMatchMakerTests.js @@ -94,7 +94,7 @@ var matchFixtures = [ } } }, { - description: "Two magnifier preferences->best fit is launched", + description: "Two magnifier preferences->best fit is launched, the other one should not run", input: require("./data/full_mm_payload2.json"), preferences: { "gpii-default": { @@ -115,6 +115,12 @@ var matchFixtures = [ "http://registry.gpii.net/common/magnification": 150, "http://registry.gpii.net/common/invertColours": true } + }, + "fakemag1": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -140,6 +146,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/magnification": 150 } + }, + "fakemag2": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -172,6 +184,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/pitch": 0.8 } + }, + "fakemag2": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -205,6 +223,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/magnification": 150 } + }, + "fakemag1": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -243,6 +267,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/magnification": 150 } + }, + "fakemag1": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -282,6 +312,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/magnification": 150 } + }, + "fakemag2": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -323,6 +359,12 @@ var matchFixtures = [ "http://registry.gpii.net/common/magnification": 150, "http://registry.gpii.net/common/invertColours": true } + }, + "fakemag1": { + "active": false, + "settings": { + "http://registry.gpii.net/common/magnification": 150 + } } } } @@ -348,6 +390,10 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/applications/fakemag2": {} } + }, + "fakemag1": { + "active": false, + "settings": {} } } } @@ -374,6 +420,12 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/applications/fakemag1": {} } + }, + "fakemag2": { + "active": false, + "settings": { + "http://registry.gpii.net/applications/fakemag2": {} + } } } } @@ -432,6 +484,13 @@ var matchFixtures = [ "settings": { "http://registry.gpii.net/common/magnification": 150 } + }, + "fakemag2": { + "active": false, + "settings": { + "http://registry.gpii.net/applications/fakemag2": {}, + "http://registry.gpii.net/common/magnification": 150 + } } } } diff --git a/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload1.json b/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload1.json index 6f2dc7e5f..b1d19afe8 100644 --- a/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload1.json +++ b/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload1.json @@ -37,7 +37,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { @@ -68,7 +68,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "otherconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [] diff --git a/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload2.json b/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload2.json index 178fb961b..f4ec155aa 100644 --- a/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload2.json +++ b/gpii/node_modules/canopyMatchMaker/test/data/full_mm_payload2.json @@ -34,7 +34,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -59,7 +59,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -98,7 +98,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -125,7 +125,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { diff --git a/gpii/node_modules/canopyMatchMaker/test/web/js/CanopyMatchMakerUtilitiesTests.js b/gpii/node_modules/canopyMatchMaker/test/web/js/CanopyMatchMakerUtilitiesTests.js index d27d56b1c..53a929942 100644 --- a/gpii/node_modules/canopyMatchMaker/test/web/js/CanopyMatchMakerUtilitiesTests.js +++ b/gpii/node_modules/canopyMatchMaker/test/web/js/CanopyMatchMakerUtilitiesTests.js @@ -26,7 +26,7 @@ var gpii = fluid.registerNamespace("gpii"); fluid.registerNamespace("gpii.tests.canopyMatchMaker"); var magnifier = { - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.integrationTesting.mockSettingsHandler", "capabilities": ["display.screenEnhancement"], @@ -48,7 +48,7 @@ var magnifier = { }; var lesserMagnifier = { - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.integrationTesting.mockSettingsHandler", "capabilitiesTransformations": { @@ -200,7 +200,7 @@ var disposeStrategyFixtures = [ "solution": { "name": "Test dummy", "contexts": {}, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { @@ -239,7 +239,7 @@ var disposeStrategyFixtures = [ "solution": { "name": "Test dummy 2", "contexts": {}, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [] diff --git a/gpii/node_modules/contextManager/src/ContextManager.js b/gpii/node_modules/contextManager/src/ContextManager.js index 9299f0b11..e3c955b70 100644 --- a/gpii/node_modules/contextManager/src/ContextManager.js +++ b/gpii/node_modules/contextManager/src/ContextManager.js @@ -172,7 +172,7 @@ gpii.contextManager.contextChanged = function (that, lifecycleManager, forceCont that.updateActiveContextName(fullPayload, forceContextName); if (oldActiveContext === fullPayload.activeContextName) { - fluid.log("contextManager: Same context as before (" + oldActiveContext + ") so doing nothing"); + fluid.log(fluid.logLevel.TRACE, "contextManager: Same context as before (" + oldActiveContext + ") so doing nothing"); return; } fluid.log("contextManager: New active contexts: " + fullPayload.activeContextName); diff --git a/gpii/node_modules/contextManager/test/data/standardMMInput.json b/gpii/node_modules/contextManager/test/data/standardMMInput.json index 9a7ad1570..3fa02bbdb 100644 --- a/gpii/node_modules/contextManager/test/data/standardMMInput.json +++ b/gpii/node_modules/contextManager/test/data/standardMMInput.json @@ -68,7 +68,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration1": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -148,7 +148,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configs": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -252,7 +252,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { diff --git a/gpii/node_modules/contextManager/test/data/standardMMOutput.json b/gpii/node_modules/contextManager/test/data/standardMMOutput.json index cf518c076..2b2405707 100644 --- a/gpii/node_modules/contextManager/test/data/standardMMOutput.json +++ b/gpii/node_modules/contextManager/test/data/standardMMOutput.json @@ -13,7 +13,7 @@ ] }, "active": true, - "settingsHandlers": { + "handlers": { "configs": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -128,7 +128,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { diff --git a/gpii/node_modules/flatMatchMaker/src/FlatMatchMaker.js b/gpii/node_modules/flatMatchMaker/src/FlatMatchMaker.js index de14b458c..30a733809 100644 --- a/gpii/node_modules/flatMatchMaker/src/FlatMatchMaker.js +++ b/gpii/node_modules/flatMatchMaker/src/FlatMatchMaker.js @@ -99,7 +99,10 @@ if (solrec.priority !== undefined) { accepted = true; } - solrec.disposition = accepted ? "accept" : "reject"; + fluid.extend(solrec, { + disposition: accepted ? "accept" : "reject", + active: accepted ? true : false // always true if accepted + }); }); return solrecs; }; diff --git a/gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js b/gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js index 328263549..89e9e7053 100644 --- a/gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js +++ b/gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js @@ -55,7 +55,7 @@ "solution": { "name": "Test dummy", "contexts": {}, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { @@ -94,7 +94,7 @@ "solution": { "name": "Test dummy 2", "contexts": {}, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [] diff --git a/gpii/node_modules/flatMatchMaker/test/data/full_mm_payload1.json b/gpii/node_modules/flatMatchMaker/test/data/full_mm_payload1.json index 6f2dc7e5f..b1d19afe8 100644 --- a/gpii/node_modules/flatMatchMaker/test/data/full_mm_payload1.json +++ b/gpii/node_modules/flatMatchMaker/test/data/full_mm_payload1.json @@ -37,7 +37,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { @@ -68,7 +68,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "otherconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [] diff --git a/gpii/node_modules/flowManager/test/data/browserChannel_solutionsRegistry.json b/gpii/node_modules/flowManager/test/data/browserChannel_solutionsRegistry.json index 0f06106c9..cbc13b73d 100644 --- a/gpii/node_modules/flowManager/test/data/browserChannel_solutionsRegistry.json +++ b/gpii/node_modules/flowManager/test/data/browserChannel_solutionsRegistry.json @@ -9,7 +9,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.webSockets", "options": { @@ -34,7 +34,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.webSockets", "options": { diff --git a/gpii/node_modules/flowManager/test/data/matchmaker.output.payload.json b/gpii/node_modules/flowManager/test/data/matchmaker.output.payload.json index 363a29558..559f33fed 100644 --- a/gpii/node_modules/flowManager/test/data/matchmaker.output.payload.json +++ b/gpii/node_modules/flowManager/test/data/matchmaker.output.payload.json @@ -181,7 +181,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "options": { @@ -256,7 +256,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "capabilities": [], @@ -338,7 +338,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "capabilities": [], @@ -375,7 +375,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ @@ -414,7 +414,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "capabilities": [], @@ -489,7 +489,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "capabilities": [], @@ -523,7 +523,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.gsettings", "capabilities": [], @@ -557,7 +557,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.orca", "options": { @@ -1070,7 +1070,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.alsa", "capabilities": [], @@ -1118,7 +1118,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ @@ -1165,7 +1165,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ @@ -1212,7 +1212,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ @@ -1251,7 +1251,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.xrandr", "capabilities": [] @@ -1276,7 +1276,7 @@ } ] }, - "settingsHandlers": [ + "handlers": [ { "type": "gpii.settingsHandlers.webSockets", "options": { diff --git a/gpii/node_modules/flowManager/test/data/update_solutionsRegistry.json b/gpii/node_modules/flowManager/test/data/update_solutionsRegistry.json index af7ccf22d..fb9112e81 100644 --- a/gpii/node_modules/flowManager/test/data/update_solutionsRegistry.json +++ b/gpii/node_modules/flowManager/test/data/update_solutionsRegistry.json @@ -9,7 +9,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [], diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index 42cbf5159..fef7b589c 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -133,15 +133,25 @@ var gpii = fluid.registerNamespace("gpii"); args: ["{that}", "{arguments}.0", "{arguments}.1", "{arguments}.2", "{arguments}.3", "{arguments}.4"] // solutionId, settingsHandlers, actions, session, rootAction }, - invokeSettingsHandler: { - funcName: "gpii.lifecycleManager.invokeSettingsHandler", - args: ["{that}", "{arguments}.0", "{arguments}.1", "{arguments}.2"] - // solutionId, settingsHandlers, isMultiSH + invokeSettingsHandlerGet: { + funcName: "gpii.lifecycleManager.invokeSettingsHandlerGet", + args: ["{that}", "{arguments}.0", "{arguments}.1"] + // solutionId, settingsHandlers + }, + invokeSettingsHandlerSet: { + funcName: "gpii.lifecycleManager.invokeSettingsHandlerSet", + args: ["{that}", "{arguments}.0", "{arguments}.1"] + // solutionId, settingsHandlers }, restoreSnapshot: { funcName: "gpii.lifecycleManager.restoreSnapshot", args: ["{that}", "{arguments}.0"] // originalSettings + }, + getSolutionRunningState: { + funcName: "gpii.lifecycleManager.getSolutionRunningState", + args: ["{that}", "{arguments}.0", "{arguments}.1", "{arguments}.2"] + // solutionId, solution, session } } }); @@ -216,21 +226,14 @@ var gpii = fluid.registerNamespace("gpii"); /** Transforms the handlerSpec (handler part of the transformer's response payload) to a form * accepted by a settingsHandler - we use a 1-element array holding the payload for a single solution * per handler - * @param isMultiSH {boolean} is a flag denoting whether it's a multi-settingshandler solution - * If it is, a supported settings block is required for each entry */ - gpii.lifecycleManager.specToSettingsHandler = function (solutionId, handlerSpec, isMultiSH) { + gpii.lifecycleManager.specToSettingsHandler = function (solutionId, handlerSpec) { var returnObj = {}, settings = {}; if (handlerSpec.supportedSettings === undefined) { - if (isMultiSH) { - fluid.fail("Solution " + solutionId + " has multiple settingshandlers but is missing " + - "the 'supportedSettings' directive. Will not set the settings for this settingshandler"); - } else { - // if supportedSettings directive is not present, pass all settings: - settings = handlerSpec.settings; - } + // if supportedSettings directive is not present, pass all settings: + settings = handlerSpec.settings; } else { // we cant simply use fluid.filterKeys because that wont handle the cases where // there are 'undefined' values for the keys in handlerSpec.settings @@ -243,13 +246,12 @@ var gpii = fluid.registerNamespace("gpii"); } } } - returnObj[solutionId] = [{ settings: settings, options: handlerSpec.options }]; - return returnObj; // NB array removed here + return returnObj; }; // Transform the response from the handler SET to a format that we can persist in models before passing to handler SET on restore @@ -264,20 +266,27 @@ var gpii = fluid.registerNamespace("gpii"); return fluid.get(armoured, [solutionId, 0]); }; - /** + gpii.lifecycleManager.invokeSettingsHandlerGet = function (that, solutionId, handlerSpec) { + // first prepare the payload for the settingsHandler in question - a more efficient + // implementation might bulk together payloads destined for the same handler + var settingsHandlerPayload = gpii.lifecycleManager.specToSettingsHandler(solutionId, handlerSpec); + var resolvedName = that.nameResolver.resolveName(handlerSpec.type, "settingsHandler"); + return gpii.settingsHandlers.dispatchSettingsHandlerGet(resolvedName, settingsHandlerPayload); + }; + + /** * @param handlerSpec {Object} A single settings handler specification - * @param isMultiSH {Boolean} [optional] if present and true, the solution has multiple settingshandlers * Payload example: * http://wiki.gpii.net/index.php/Settings_Handler_Payload_Examples * Transformer output: * http://wiki.gpii.net/index.php/Transformer_Payload_Examples */ - gpii.lifecycleManager.invokeSettingsHandler = function (that, solutionId, handlerSpec, isMultiSH) { + gpii.lifecycleManager.invokeSettingsHandlerSet = function (that, solutionId, handlerSpec) { // first prepare the payload for the settingsHandler in question - a more efficient // implementation might bulk together payloads destined for the same handler - var settingsHandlerPayload = gpii.lifecycleManager.specToSettingsHandler(solutionId, handlerSpec, isMultiSH); + var settingsHandlerPayload = gpii.lifecycleManager.specToSettingsHandler(solutionId, handlerSpec); var resolvedName = that.nameResolver.resolveName(handlerSpec.type, "settingsHandler"); - var setSettingsPromise = gpii.settingsHandlers.dispatchSettingsHandler(resolvedName, settingsHandlerPayload, that.options.retryOptions); + var setSettingsPromise = gpii.settingsHandlers.dispatchSettingsHandlerSet(resolvedName, settingsHandlerPayload, that.options.retryOptions); var togo = fluid.promise(); setSettingsPromise.then(function (handlerResponse) { @@ -311,22 +320,39 @@ var gpii = fluid.registerNamespace("gpii"); return value; }; + /** Remove all the settings blocks from a solutions registry entry + */ + gpii.lifecycleManager.removeSettingsBlocks = function (solutionEntry) { + solutionEntry.handlers = fluid.transform(solutionEntry.handlers, function (handler) { + return fluid.filterKeys(handler, "settings", true); + }); + return solutionEntry; + }; + /** Applies snapshotted settings from a single settingsHandler block attached to a single solution into the "originalSettings" * model snapshot area in the LifecycleManager's session. Tightly bound to executeSettingsAction, executes one-to-one with it * with almost identical argument list. */ - gpii.lifecycleManager.recordSnapshotInSession = function (that, snapshot, solutionId, solutionRecord, session, settingsHandlerBlockName, rootAction) { - var toSnapshot = fluid.copy(solutionRecord); - toSnapshot.settingsHandlers = {}; - toSnapshot.settingsHandlers[settingsHandlerBlockName] = snapshot; - if (rootAction === "start") { - session.applier.change(["originalSettings", solutionId], toSnapshot); - } else if (rootAction === "update") { - // if we're doing an update, keep the settings that are already stored from the + if (rootAction === "start" || rootAction === "update") { + var toSnapshot = gpii.lifecycleManager.removeSettingsBlocks(fluid.copy(solutionRecord)); + + // Disabled the removing of all settingshandlers blocks to ensure that we have them available when restoring the system. + // This is particularly relevant for launch handlers, where we will need to run the "get" directives on logout to decide + // whether we an application is running or not, and consequently, whether to run the "update" or "stop" block + // toSnapshot.settingsHandlers = {}; + toSnapshot.handlers[settingsHandlerBlockName] = snapshot; + // keep the settings that are already stored from the // original snapshot, but augment it with any settings from the new snapshot // that were not present in the original snapshot. - // This workflow is tested in LifecycleManagerTests.js "Updating with normal reference to settingsHandler block, and 'undefined' value stored in snapshot" + // + // This is relevant when doing an update for obvious reasons + // (and tested) in LifecycleManagerTests.js "Updating with normal reference to settingsHandler block, and 'undefined' value stored in snapshot" + // + // It is also relevant for logins ("start" root action), in case a solution is already running. + // This would trigger a call to its "update" block. If that in turn eg. looks like the following + // [ "stop", "configure", "start" ] we would want the original state recorded during the "stop" + // action to persist - even when the "start" block is later run var mergedSettings = fluid.extend(true, {}, toSnapshot, session.model.originalSettings[solutionId]); var cleanedSettings = gpii.lifecycleManager.transformSolutionSettings(mergedSettings, gpii.lifecycleManager.cleanDeletes); session.applier.change(["originalSettings", solutionId], cleanedSettings); @@ -354,27 +380,30 @@ var gpii = fluid.registerNamespace("gpii"); * @param settingsHandlerBlockName {String} should be a reference to a settings block from the * settingsHandlers section. * @param rootAction {String} The root action on the LifecycleManager which is being serviced: "start", "stop", - * "update" or "restore" + * "update", "restore" or "isRunning" * @return {Function} a nullary function (a task), that once executed will set the settings returning a promise * that will be resolved once the settings are successfully set. - */ - gpii.lifecycleManager.executeSettingsAction = function (that, solutionId, solutionRecord, session, - settingsHandlerBlockName, rootAction) { - var isMultiSH = Object.keys(solutionRecord.settingsHandlers).length > 1; - var settingsHandlerBlock = solutionRecord.settingsHandlers[settingsHandlerBlockName]; + */ + gpii.lifecycleManager.executeSettingsAction = function (that, solutionId, solutionRecord, session, settingsHandlerBlockName, rootAction) { + var settingsHandlerBlock = solutionRecord.handlers[settingsHandlerBlockName]; if (settingsHandlerBlock === undefined) { fluid.fail("Reference to non-existing settingsHandler block named " + settingsHandlerBlockName + " in solution " + solutionId); } return function () { var expanded = session.localResolver(settingsHandlerBlock); - var settingsPromise = that.invokeSettingsHandler(solutionId, expanded, isMultiSH); - settingsPromise.then(function (snapshot) { - session.applier.change(["appliedSolutions", solutionId], solutionRecord); - gpii.lifecycleManager.recordSnapshotInSession(that, snapshot, solutionId, solutionRecord, session, - settingsHandlerBlockName, rootAction); - }); - return gpii.lifecycleManager.wrapRestorePromise(settingsPromise, rootAction); + if (rootAction === "isRunning") { // only run get and return directly if where checking for running applications + return that.invokeSettingsHandlerGet(solutionId, expanded); + } else { + var settingsPromise = that.invokeSettingsHandlerSet(solutionId, expanded); + + settingsPromise.then(function (snapshot) { + session.applier.change(["appliedSolutions", solutionId], solutionRecord); + gpii.lifecycleManager.recordSnapshotInSession(that, snapshot, solutionId, solutionRecord, session, + settingsHandlerBlockName, rootAction); + }); + return gpii.lifecycleManager.wrapRestorePromise(settingsPromise, rootAction); + } }; }; @@ -390,7 +419,7 @@ var gpii = fluid.registerNamespace("gpii"); */ gpii.lifecycleManager.transformSolutionSettings = function (solutionSettings, transformer) { var togo = fluid.copy(solutionSettings); // safe since armoured - togo.settingsHandlers = fluid.transform(solutionSettings.settingsHandlers, function (handlerBlock) { + togo.handlers = fluid.transform(solutionSettings.handlers, function (handlerBlock) { return gpii.settingsHandlers.transformOneSolutionSettings(handlerBlock, transformer); }); return togo; @@ -479,20 +508,29 @@ var gpii = fluid.registerNamespace("gpii"); // the settings handler block) if (action.indexOf("settings.") === 0) { var settingsHandlerBlockName = action.substring("settings.".length); - return gpii.lifecycleManager.executeSettingsAction(that, solutionId, solutionRecord, session, - settingsHandlerBlockName, rootAction); + if (actionBlock === "isRunning") { + // if we're just checking for the run state, dont actually modify the solutionRecord with settings: + var tmpSolutionRecord = fluid.copy(solutionRecord); + fluid.set(tmpSolutionRecord, [ "handlers", settingsHandlerBlockName, "settings"], { running: null }); + return gpii.lifecycleManager.executeSettingsAction(that, solutionId, tmpSolutionRecord, session, settingsHandlerBlockName, rootAction); + } else { + // if this is related to launching, overwrite entry with the appropriate settings, + // that is: { running: true } if we're in a start block, else { running: false } + if (actionBlock === "start" || actionBlock === "stop") { + var launchSettings = { running: actionBlock === "start" ? true : false }; + fluid.set(solutionRecord, [ "handlers", settingsHandlerBlockName, "settings"], launchSettings); + } + return gpii.lifecycleManager.executeSettingsAction(that, solutionId, solutionRecord, session, settingsHandlerBlockName, rootAction); + } } else if (actionBlock === "update") { // Keywords: "start", "stop", "configure" are allowed here as well, and // and will result in evaluating the respective block // TODO (GPII-1230) Fix this up so we don't always run the full start and stops (including) // system restoration, etc. - if (action === "start" || action === "configure") { - return that.executeActions(solutionId, solutionRecord, session, action, rootAction); - } else if (action === "stop") { - // This branch is used when an "update" action requires a stop and start of the solution - var unarmoured = gpii.lifecycleManager.transformSolutionSettings( - session.model.originalSettings[solutionId], gpii.settingsHandlers.changesToSettings); - return that.executeActions(solutionId, unarmoured, session, "stop", rootAction); + if (action === "start" || action === "configure" || action === "stop") { + return function () { + return that.executeActions(solutionId, solutionRecord, session, action, rootAction); + }; } else { fluid.fail("Unrecognised string action in LifecycleManager: " + action + " inside 'update' section for solution " + solutionId); @@ -536,6 +574,38 @@ var gpii = fluid.registerNamespace("gpii"); return fluid.promise.sequence(promises); }; + /** + * Based on the current state of an application (ie. if it is running or not) and the desired state, + * this function returns an array of actions for the lifecycle manager to run to get it to its + * recorded state + * + * @param currentRunState {boolean}: True if application is currently running + * @param desiredRunState {boolean}: True if application should be running + * @param isRestore {boolean}: If this is true, a "restore" will be used as the configuration action + * in the array that is returned. Else a "configure" will be used. In general, isRestore should be provided and + * true only of this is called by the logout/restore functionality of the system. + * @return {Array} An array of actions (strings) that needs to be run to restore the application + * to its original state + */ + gpii.lifecycleManager.calculateLifecycleActions = function (currentRunState, desiredRunState, isRestore) { + var configurationType = isRestore ? "restore" : "configure"; + var actions; + if (currentRunState === true) { // if it's already running + if (desiredRunState === false) { // and it was not running on start + actions = [ "stop", configurationType ]; + } else { // else update it + actions = [ "update" ]; + } + } else { // if it is not running + if (desiredRunState === true) { // and it was running when we started + actions = [ configurationType, "start" ]; + } else { // just restore settings + actions = [ "restore" ]; + } + } + return actions; + }; + /** Common utility used by gpii.lifecycleManager.stop and gpii.lifecycleManager.restoreSnapshot * @param session {gpii.lifecycleManager.session} which must contain * * A `originalSettings` snapshot in its model @@ -544,13 +614,28 @@ var gpii = fluid.registerNamespace("gpii"); * @return {Promise} A promise for the action of restoring the system */ gpii.lifecycleManager.restoreSystem = function (that, session, rootAction) { - var promises = fluid.transform(session.model.originalSettings, function (changesSolutionRecord, solutionId) { - var solutionRecord = gpii.lifecycleManager.transformSolutionSettings(changesSolutionRecord, gpii.settingsHandlers.changesToSettings); - return that.applySolution(solutionId, solutionRecord, session, [ "stop", "restore" ], rootAction); + var tasks = []; + fluid.each(session.model.originalSettings, function (changesSolutionRecord, solutionId) { + tasks.push(function () { + // check the current state of the solution to decide whether we should run the + // "restore", "update, or "stop" + return that.getSolutionRunningState(solutionId, changesSolutionRecord, session); + }); + tasks.push(function () { + if (!fluid.isDestroyed(that)) { // See above comment for GPII-580 + var solutionRecord = gpii.lifecycleManager.transformSolutionSettings(changesSolutionRecord, gpii.settingsHandlers.changesToSettings); + var recordedRunState = gpii.lifecycleManager.getSolutionRunningStateFromSnapshot(solutionRecord); + var currentRunState = session.model.runningOnLogin[solutionId]; + + var actions = gpii.lifecycleManager.calculateLifecycleActions(currentRunState, recordedRunState, true); + // build structure for returned values (for later reset) + return that.applySolution(solutionId, solutionRecord, session, actions, rootAction); + } + }); }); + var sequence = fluid.promise.sequence(tasks); - // TODO: In theory we could stop all solutions in parallel - var sequence = fluid.promise.sequence(fluid.values(promises)); + // // TODO: In theory we could stop all solutions in parallel return sequence; }; @@ -574,6 +659,29 @@ var gpii = fluid.registerNamespace("gpii"); }); }; + gpii.lifecycleManager.getSolutionRunningStateFromSnapshot = function (solutionSnapshot) { + // get isRunning entry from snapshot and block to run: + var isRunningBlock = fluid.makeArray(solutionSnapshot.isRunning)[0]; + if (isRunningBlock && isRunningBlock.indexOf("settings.") === 0) { + var settingsHandlerBlockName = isRunningBlock.substring("settings.".length); + var recordedState = fluid.get(solutionSnapshot, ["ha", settingsHandlerBlockName, "settings", "running"]); + return recordedState; + } + }; + + gpii.lifecycleManager.getSolutionRunningState = function (that, solutionId, solutionRecord, session) { + if (!fluid.isDestroyed(that)) { + var promise = that.executeActions(solutionId, solutionRecord, session, "isRunning", "isRunning"); + var togo = fluid.promise(); + promise.then(function (val) { + var isRunning = fluid.get(val, [0, solutionId, 0, "settings", "running"]); + session.applier.change(["runningOnLogin", solutionId], isRunning); + togo.resolve(isRunning); + }); + return togo; + } + }; + /** * The lifecycleManager queue is used to hold the high-level actions that needs to happen, * such as starting the login process, starting logout process, starting the update process. @@ -703,9 +811,19 @@ var gpii = fluid.registerNamespace("gpii"); fluid.each(lifecycleInstructions, function (solution, solutionId) { tasks.push(function () { if (!fluid.isDestroyed(that)) { // See above comment for GPII-580 + // check the current state of the solution to decide whether we should run the + // "update", "start" or "stop" directive + return that.getSolutionRunningState(solutionId, solution, session); + } + }); + tasks.push(function () { + if (!fluid.isDestroyed(that)) { // See above comment for GPII-580 + // if solution is already running, call "update" directive - else use "start" directive + var isRunning = session.model.runningOnLogin[solutionId]; + var actions = gpii.lifecycleManager.calculateLifecycleActions(isRunning, solution.active); + // build structure for returned values (for later reset) - return that.applySolution(solutionId, solution, session, - (solution.active ? [ "configure", "start" ] : [ "configure" ]), "start"); + return that.applySolution(solutionId, solution, session, actions, "start"); } }); }); diff --git a/gpii/node_modules/lifecycleManager/test/js/LifecycleManagerTests.js b/gpii/node_modules/lifecycleManager/test/js/LifecycleManagerTests.js index 061b54d04..dd450f99c 100644 --- a/gpii/node_modules/lifecycleManager/test/js/LifecycleManagerTests.js +++ b/gpii/node_modules/lifecycleManager/test/js/LifecycleManagerTests.js @@ -2,7 +2,7 @@ GPII Lifecycle Manager Tests Copyright 2012 OCAD University -Copyright 2012 Raising The Floor - International +Copyright 2012, 2017 Raising The Floor - International Licensed under the New BSD license. You may not use this file except in compliance with this License. @@ -64,16 +64,55 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt return togo; }; - gpii.tests.lifecycleManager.buildSettingsHandlersEntry = function (settings) { - return { - "settingsHandlers": { + /** + * Used by a bunch of the tests to avoid having to write out the almost-identical full set of lifecycle + * instructions for each test. Instead one can have a "base set" of lifecycle instructions + * that can be shared across multiple tests/multiple phases of a single test, and then use + * this function to extend base set to match the specific test/test phase. + * + * The function takes an unlimited number of arguments. The first argument is mandatory and must + * be a set of lifecycle instructions entries keyed by solution ids. While the system wont explode + * if entries for multiple solutions are provided, only the "first" solution entry will be + * extended. The remaining arguments will be fluid.extended onto the first argument. + * + * @currentInstructions {Object} a set of lifecycle instructions keyed by a solution id. For example, + * this could be the output of the buildLifecycleInstructions function. + * @arguments {..Object..} The remaining arguments should be valid lifecycleInstructions that will + * be extended onto the original + * @return {Object} The original lifecycle instructions, but with the remaining arguments fluid.extend'ed + * onto the first solution entry in the currentInstructions + */ + gpii.tests.lifecycleManager.extendLifecycleInstructions = function (currentInstructions) { + var togo = fluid.copy(currentInstructions); + var solId = Object.keys(currentInstructions)[0]; + + for (var i = 1; i < arguments.length; ++i) { + togo[solId] = fluid.extend(true, {}, togo[solId], arguments[i]); + } + + return togo; + }; + + gpii.tests.lifecycleManager.buildSettingsHandlersEntry = function (settings, setRunning) { + var togo = { + "handlers": { "myconf": { "type": "gpii.tests.lifecycleManager.mockSettingsHandler", - "settings": settings, + "options": {} + }, + "launcher": { + "type": "gpii.tests.lifecycleManager.mockLaunchHandler", "options": {} } } }; + if (settings !== undefined) { + fluid.set(togo, [ "handlers", "myconf", "settings" ], settings); + } + if (setRunning !== undefined) { + fluid.set(togo, [ "handlers", "launcher", "settings" ], { running: setRunning }); + } + return togo; }; gpii.tests.lifecycleManager.noUpdateLifecycle = { @@ -100,7 +139,27 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt ] }; - gpii.tests.lifecycleManager.configurationSpec = gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle = { + "active": true, + "configure": [ + "settings.myconf" + ], + "restore": [ + "settings.myconf" + ], + "start": [ + "settings.launcher" + ], + "stop": [ + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" + ] + }; + + gpii.tests.lifecycleManager.configurationSpec = gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), gpii.tests.lifecycleManager.noUpdateLifecycle, { "update": [ "settings.myconf" ] }); @@ -123,81 +182,6 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt }, "options": {} }] - }, - "If supportedSettings directive is present, only supported settings are passed": { - request: { - "type": "gpii.gsettings.set", - "options": {}, - "supportedSettings": { - "weirdSetting": {} - }, - "settings": { - "weirdSetting": "foo", - "otherSetting": "bar" - } - }, - response: [{ - "settings": { - "weirdSetting": "foo" - }, - "options": {} - }] - }, - "If supportedSettings directive and we have a multi SH solution, we should still be good": { - request: { - "type": "gpii.gsettings.set", - "options": {}, - "supportedSettings": { - "weirdSetting": {} - }, - "settings": { - "weirdSetting": "foo", - "otherSetting": "bar" - } - }, - isMultiSH: true, - response: [{ - "settings": { - "weirdSetting": "foo" - }, - "options": {} - }] - }, - "If supportedSettings directive is present - test no matching": { - request: { - "type": "gpii.gsettings.set", - "options": {}, - "supportedSettings": { - "thirdSetting": {} - }, - "settings": { - "weirdSetting": "foo", - "otherSetting": "bar" - } - }, - response: [{ - "settings": {}, - "options": {} - }] - }, - "Works with `undefined` values for settings (required when restoring)": { - request: { - "type": "gpii.gsettings.set", - "options": {}, - "supportedSettings": { - "weirdSetting": {} - }, - "settings": { - "weirdSetting": undefined, - "otherSetting": undefined - } - }, - response: [{ - "settings": { - "weirdSetting": undefined - }, - "options": {} - }] } }; @@ -261,11 +245,15 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt userToken: 123 }; - gpii.tests.lifecycleManager.startPayload = fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: gpii.tests.lifecycleManager.configurationSpec - } - }); + gpii.tests.lifecycleManager.buildStartPayload = function (lifecycleInstructions) { + return fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { + activeConfiguration: { + lifecycleInstructions: lifecycleInstructions + } + }); + }; + + gpii.tests.lifecycleManager.startPayload = gpii.tests.lifecycleManager.buildStartPayload(gpii.tests.lifecycleManager.configurationSpec); gpii.tests.lifecycleManager.sampleActiveSession = { 123: { @@ -311,10 +299,31 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt gpii.tests.lifecycleManager.backingMockSettingsHandler = null; // initialised in every test that requires it - gpii.tests.lifecycleManager.initBackingMock = function () { - gpii.tests.lifecycleManager.backingMockSettingsHandler = gpii.test.integration.mockSettingsHandler(); + gpii.tests.lifecycleManager.initBackingMock = function (origSettings, setRunning) { + gpii.tests.lifecycleManager.backingMockSettingsHandler = gpii.test.integration.mockSettingsHandler({ + optionsPathKey: function (options, solutionId) { + return "settings|" + solutionId; + } + }); + gpii.tests.lifecycleManager.backingMockLaunchHandler = gpii.test.integration.mockSettingsHandler({ + optionsPathKey: function (options, solutionId) { + return "launch|" + solutionId; + } + }); + + var settings = origSettings === undefined ? // use default if no parameter is given + gpii.tests.lifecycleManager.settingsHandlerOriginalSystemSettings : + origSettings; + + setRunning = (setRunning === undefined) ? false : setRunning; // default to false + var launchSettings = gpii.tests.lifecycleManager.launchHandlerOriginalSystemSettingsRunning(setRunning); // initialise the mock with the initial settings expected at the end of the test - gpii.tests.lifecycleManager.backingMockSettingsHandler.set(gpii.tests.lifecycleManager.settingsHandlerOriginalSystemSettings); + gpii.tests.lifecycleManager.backingMockSettingsHandler.set(settings); + gpii.tests.lifecycleManager.backingMockLaunchHandler.set(launchSettings); + // and ensure our 'local' storage is reset + gpii.tests.lifecycleManager.staticRepository.settingsHandler = undefined; + gpii.tests.lifecycleManager.staticRepository.launchHandler = undefined; + gpii.tests.lifecycleManager.staticRepository.launchHandlerCalls = 0; }; gpii.tests.lifecycleManager.mockSettingsHandler = { @@ -332,20 +341,35 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt } }; - gpii.tests.lifecycleManager.assertExpectedExec = function () { - jqUnit.assertDeepEq("Exec handler fired with expected arguments", { - "command": gpii.tests.lifecycleManager.fakeEnvironment.JAWS_DIR + "jaws.exe", - args: ["-settingsDirectory", gpii.tests.lifecycleManager.fakeEnvironment.WINDIR] - }, gpii.tests.lifecycleManager.staticRepository.execHandler); - }; - - gpii.tests.lifecycleManager.assertNoExec = function () { - jqUnit.assertUndefined("Exec handler has not been fired", - gpii.tests.lifecycleManager.staticRepository.execHandler); + gpii.tests.lifecycleManager.mockLaunchHandler = { + set: function (data) { + var togo = fluid.promise(); + gpii.invokeLater(function () { + gpii.tests.lifecycleManager.staticRepository.launchHandlerCalls++; + gpii.tests.lifecycleManager.staticRepository.launchHandler = data; + var response = gpii.resolveSync(gpii.tests.lifecycleManager.backingMockLaunchHandler.set(data)); + togo.resolve(response); + }, 100); + return togo; + }, + get: function (data) { + return gpii.resolveSync(gpii.tests.lifecycleManager.backingMockLaunchHandler.get(data)); + } }; - gpii.tests.lifecycleManager.assertExpectedSettingsHandler = function (message, expected) { - jqUnit.assertDeepEq("expected input sent to settingsHandler" + message, expected, gpii.tests.lifecycleManager.staticRepository.settingsHandler); + gpii.tests.lifecycleManager.createSettingsHandlerPayload = function (solutionId, settings) { + if (settings === undefined) { + return undefined; + } else { + var togo = {}; + togo[solutionId] = [ + { + options: {}, + settings: settings + } + ]; + return togo; + } }; gpii.tests.lifecycleManager.settingsHandlerOriginalSystemSettings = { @@ -356,16 +380,30 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt "iamasetting": 200, "undefSetting": undefined }, - "options": {} + "options": { + // "storePath": "settingsBlock1" + } }], "other.application": [{ "settings": { "mysetting": "Hello World" }, - "type": "gpii.tests.lifecycleManager.mockSettingsHandler" + "options": { + // "storePath": "settingsBlock1" + } }] }; + gpii.tests.lifecycleManager.launchHandlerOriginalSystemSettingsRunning = function (setRunning) { + return { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": setRunning + } + }] + }; + }; + gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings = { "org.gnome.desktop.a11y.magnifier": [{ "settings": { @@ -386,342 +424,584 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt }] }; - gpii.tests.lifecycleManager.updateTestDefs = fluid.freezeRecursive([{ - name: "Updating with the same prefs and values as already applied", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }) - }, { - name: "single pref changed without 'update' directive in solution registry entry", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle) + gpii.tests.lifecycleManager.startTestDefs = [{ + name: "Solution with only start and stop blocks (GPII-2106)", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + { + "active": true, + "start": [ + "settings.launcher" + ], + "stop": [ + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" + ] } - }), - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle), - // dont expect changes on update due to missing 'update' directive - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle) + ), + originalSettings: undefined, + runningOnLogin: false, + appliedSettings: {}, + runningAfterLogin: true, + expectedLaunchHandlerCalls: 2 }, { - name: "Updating with normal reference to settingsHandler block, single settings", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }) - }, { - name: "Updating with normal reference to settingsHandler block, multiple settings", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-color": "green", "cross-hairs-clip": false }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }) - }, { - name: "Updating with reference to 'configure' directive, single settings", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "configure" ] }) + name: "solution with only configure and restore blocks", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + { + "active": true, + "restore": [ + "settings.myconf" + ], + "configure": [ + "settings.myconf" + ], + "isRunning": [ + "settings.launcher" + ] } - }), - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "configure" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "green" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "configure" ] }), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "configure" ] }) + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: undefined, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: undefined, + expectedLaunchHandlerCalls: 0 }, { - name: "Updating with normal reference to settingsHandler block, and a setting not in the original settings applied to the system", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-color": "green", "iamasetting": 100 }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "green", "iamasetting": 100 }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red", "iamasetting": 200 }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }) + name: "Solution with all lifecycle blocks", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: true, + expectedLaunchHandlerCalls: 2 }, { - name: "Updating with normal reference to settingsHandler block, and a an application not in the original settings applied to the system", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("other.application", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "mysetting": "Hallow World" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: fluid.extend(true, {}, - gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - gpii.tests.lifecycleManager.buildLifecycleInstructions("other.application", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "mysetting": "Hallow World" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] })), - expectedOriginalSettings: fluid.extend(true, {}, - gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - gpii.tests.lifecycleManager.buildLifecycleInstructions("other.application", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "mysetting": "Hello World" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] })) + name: "solution with active: false", // no launch handler calls + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "active": false } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: undefined, + expectedLaunchHandlerCalls: 0 }, { - // TODO: What is the difference between this test and the next one? Also, eliminate the massive duplication - name: "Updating with normal reference to settingsHandler block, and 'undefined' value stored in snapshot", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: fluid.extend(true, {}, - gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "undefSetting": "some value" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] })) - } - }), - expectedFirstAppliedSettings: { - "org.gnome.desktop.a11y.magnifier": [{ - "options": {}, - "settings": { - "cross-hairs-clip": true, - "undefSetting": "some value" - } - }] - }, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "undefSetting": "some other value" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "undefSetting": "some other value" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: { - "org.gnome.desktop.a11y.magnifier": { - "active": true, + name: "solution with active: undefined", // expect no launch handler calls + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + { + "active": undefined, "configure": [ "settings.myconf" ], "restore": [ "settings.myconf" ], - "settingsHandlers": { - "myconf": { - "options": {}, - "settings": { - "cross-hairs-clip": false, - "undefSetting": gpii.undefinedEncoding - }, - "type": "gpii.tests.lifecycleManager.mockSettingsHandler" - } - }, "start": [ - { - "args": [ - "-settingsDirectory", - "${{environment}.WINDIR}" - ], - "command": "${{environment}.JAWS_DIR}jaws.exe", - "name": "exec", - "type": "gpii.tests.lifecycleManager.mockExecHandler" - } + "settings.launcher" ], "stop": [ - { - "pid": "${{exec}.pid}", - "type": "gpii.tests.lifecycleManager.mockKillHandler" - } + "settings.launcher" ], + "isRunning": [ + "settings.launcher" + ] + } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: undefined, + expectedLaunchHandlerCalls: 0 + }, { + name: "running on login - 'update' with reference to settings handler block", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "settings.myconf" ] } - } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: true, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: undefined, + expectedLaunchHandlerCalls: 0 }, { - name: "Updating with normal reference to settingsHandler block, and 'undefined' value stored in snapshot on update", - activeSessions: gpii.tests.lifecycleManager.sampleActiveSession, - startPayload: gpii.tests.lifecycleManager.startPayload, - updateSpec: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "undefSetting": "some value" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedAppliedSolutions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red", "undefSetting": "some value" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "settings.myconf" ] }), - expectedOriginalSettings: { - "org.gnome.desktop.a11y.magnifier": { - "active": true, + name: "running on login - 'update' with reference to 'configure' block", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { + "update": [ + "configure" + ] + } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: true, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: undefined, + expectedLaunchHandlerCalls: 0 + }, { + name: "running on login - 'update' with reference to 'stop', 'configure' and 'start' blocks", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { + "update": [ + "stop", + "configure", + "start" + ] + } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: true, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: true, + expectedLaunchHandlerCalls: 4 // we run start/stop cycle both on login and logout + }, { + name: "running on login - with active: false", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { + "active": false + } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: true, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: false, + expectedLaunchHandlerCalls: 2 + }, { + name: "running on login - with active: undefined", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + { + "active": undefined, "configure": [ "settings.myconf" ], "restore": [ "settings.myconf" ], - "settingsHandlers": { - "myconf": { - "options": {}, - "settings": { - "cross-hairs-clip": false, - "cross-hairs-color": "red", - "undefSetting": undefined - }, - "type": "gpii.tests.lifecycleManager.mockSettingsHandler" - } - }, "start": [ - { - "args": [ - "-settingsDirectory", - "${{environment}.WINDIR}" - ], - "command": "${{environment}.JAWS_DIR}jaws.exe", - "name": "exec", - "type": "gpii.tests.lifecycleManager.mockExecHandler" - } + "settings.launcher" ], "stop": [ - { - "pid": "${{exec}.pid}", - "type": "gpii.tests.lifecycleManager.mockKillHandler" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "update": [ - "settings.myconf" + "stop", + "configure", + "start" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: true, + appliedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterLogin: true, + expectedLaunchHandlerCalls: 4 // we run start/stop cycle both on login and logout + }]; + + + gpii.tests.lifecycleManager.updateTestDefs = [{ + name: "Updating with the same prefs and values as already applied", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "settings.myconf" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + expectedLaunchHandlerCalls: 2 + }, { + name: "single pref changed without 'update' directive in solution registry entry", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, // dont expect these to apply + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + expectedLaunchHandlerCalls: 2 + }, { + name: "Updating with normal reference to settingsHandler block, single settings", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "settings.myconf" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-color": "green" }, + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": true, "cross-hairs-color": "green" }, + expectedLaunchHandlerCalls: 2 + }, { + name: "Updating with normal reference to settingsHandler block, multiple settings", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "settings.myconf" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": false, "cross-hairs-color": "green" }, + expectedLaunchHandlerCalls: 2 + }, { + name: "Updating with reference to 'configure' directive, single settings", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-color": "green" }, + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": true, "cross-hairs-color": "green" }, + expectedLaunchHandlerCalls: 2 + }, { + name: "Updating with normal reference to settingsHandler block, and a setting not in the original settings applied to the system", + basePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "settings.myconf" ] } + ), + originalSettings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }, + runningOnLogin: false, + loginSettings: { "cross-hairs-clip": true, "cross-hairs-color": "red" }, + runningAfterLogin: true, + updateSettings: { "cross-hairs-color": "green", "iamasetting": 100 }, + runningAfterUpdate: true, + expectedSettings: { "cross-hairs-clip": true, "cross-hairs-color": "green", "iamasetting": 100 }, + originalSettingsAfterUpdate: { "cross-hairs-clip": false, "cross-hairs-color": "red", "iamasetting": undefined }, + expectedLaunchHandlerCalls: 2 + }]; + + gpii.tests.lifecycleManager.completeLifecycleTests = [{ + name: "Updating with normal reference to settingsHandler block, and an application not in the original settings applied to the system", + expect: 9, + expectedLaunchHandlerCalls: 2, + runningOnLogin: false, + originalSettings: { + "org.gnome.desktop.a11y.magnifier": [{ options: {}, settings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }}] + }, + loginPayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" })), + expectedOriginal: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }, false)), + expectedAfterLogin: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }, true)), + runningAfterLogin: true, + updatePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions("other.application", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "mysetting": "Hallow World" }), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + expectedAfterUpdate: fluid.extend(true, {}, + gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }, true), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + gpii.tests.lifecycleManager.buildLifecycleInstructions("other.application", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "mysetting": "Hallow World" }), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] })), + expectedOriginalSettingsAfterUpdate: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "cross-hairs-color": "red" }, false), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + originalSettingsAfterUpdate: { + "other.application": [{ + "options": {}, + "settings": { + "mysetting": undefined + } + }] + }, + runningAfterUpdate: true + }, { + name: "Updating with normal reference to settingsHandler block, and 'undefined' value stored in snapshot", + expect: 9, + expectedLaunchHandlerCalls: 2, + runningOnLogin: false, + originalSettings: { + "org.gnome.desktop.a11y.magnifier": [{ options: {}, settings: { "cross-hairs-clip": false, "cross-hairs-color": "red" }}] + }, + loginPayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true })), + expectedOriginal: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false }, false)), + expectedAfterLogin: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true }, true)), + runningAfterLogin: true, + updatePayload: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "undefSetting": "some other value" }), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + expectedAfterUpdate: gpii.tests.lifecycleManager.buildLifecycleInstructions( + "org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "undefSetting": "some other value" }, true), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + expectedOriginalSettingsAfterUpdate: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", + gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": false, "undefSetting": undefined }, false), + gpii.tests.lifecycleManager.standardLifecycle, + { "update": [ "configure" ] }), + originalSettingsAfterUpdate: gpii.tests.lifecycleManager.createSettingsHandlerPayload("org.gnome.desktop.a11y.magnifier", { "cross-hairs-clip": false, "undefSetting": undefined }), + runningAfterUpdate: true + }]; + + gpii.tests.lifecycleManager.checkFinalSettingsPayload = function (msg, expSettings, store) { + var expectedLastSettings; + if (expSettings === undefined) { + expectedLastSettings = expSettings; + } else { + // change to the format that is stoed by the mock settingshandler: + expectedLastSettings = { + "org.gnome.desktop.a11y.magnifier": [ + { + "options": {}, + "settings": expSettings + } + ] + }; } - }]); + jqUnit.assertDeepEq(msg, expectedLastSettings, store); + }; - gpii.tests.lifecycleManager.buildSequentialUpdateTests = function () { - jqUnit.module("Sequential update tests"); - fluid.each(gpii.tests.lifecycleManager.updateTestDefs, function (test) { - jqUnit.asyncTest("gpii.lifecycleManager.update() with active user session: " + test.name, function () { - gpii.tests.lifecycleManager.setup(); - jqUnit.expect(5); - - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); - gpii.tests.lifecycleManager.initBackingMock(); - - lifecycleManager.start(test.startPayload).then(function () { - var updatePayload = fluid.extend(true, {}, test.startPayload, { - activeConfiguration: { - lifecycleInstructions: test.updateSpec - } + /** + * expects an input with the following: + * name: name of the test + * expect: number of tests to expect + * expectedLaunchHandlerCalls: number of luanch handler calls to expect (incl. logout) + * originalSettings: the original settings to apply to the system (ie. before login) + * runningOnLogin: boolean - if the magnifier should be running before login + * loginPayload: payload to send to the start() function + * expectedOriginal: the expected "originalSettings" of the session after login + * expectedAfterLogin: the expected "appliedSolutions" of the session after login + * runningAfterLogin: boolean - if the magnifier should be running after login + * --- The below keys are optional and will trigger an update cycle if present. --- + * updatePayload: payload to send to the update() function + * expectedAfterUpdate: the expected "appliedSOlutions" of the session after update call + * expectedOriginalSettingsAfterUpdate: the original after a call to update() has been done, + * originalSettingsAfterUpdate: the settings that the system should reset to (ie. last call to settingsHandler) + * runningAfterUpdate: boolean - if the magnifier should be running after update + */ + gpii.tests.lifecycleManager.runSequentialLifecycleTest = function (testDef) { + var originalRunSetting = testDef.expectedLaunchHandlerCalls === 0 ? undefined : testDef.runningOnLogin; + jqUnit.asyncTest(testDef.name, function () { + gpii.tests.lifecycleManager.setup(); + jqUnit.expect(testDef.expect); + var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); + gpii.tests.lifecycleManager.initBackingMock(testDef.originalSettings, testDef.runningOnLogin); + + lifecycleManager.start(gpii.tests.lifecycleManager.buildStartPayload(testDef.loginPayload)).then(function (success) { + jqUnit.assertTrue("gpii.lifecycleManager.start() succeeds", success); + var session = lifecycleManager.getSession(123); // always just use the default user token + jqUnit.assertDeepEq("Checking appliedSolutions after start", testDef.expectedAfterLogin, session.model.appliedSolutions); + + var originalSettings = session.model.originalSettings; + jqUnit.assertDeepEq("Checking originalSettings after start", gpii.lifecycleManager.transformAllSolutionSettings(testDef.expectedOriginal, gpii.settingsHandlers.settingsToChanges), originalSettings); + + var stopCycle = function () { + lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { + jqUnit.assertDeepEq("Session not running after stop", lifecycleManager.getSession(123)); + jqUnit.assertEquals("Number of calls to launch handler", testDef.expectedLaunchHandlerCalls, gpii.tests.lifecycleManager.staticRepository.launchHandlerCalls); + // Check that last calls to launch and settings handlers were actually the ones resetting to expected state + jqUnit.assertDeepEq("checking last payload sent to settingshandler:", testDef.originalSettingsAfterUpdate || testDef.originalSettings, gpii.tests.lifecycleManager.staticRepository.settingsHandler); + + // Check that last calls to launch and settings handlers were actually the ones resetting to expected state + gpii.tests.lifecycleManager.checkFinalSettingsPayload("checking last set launch settings", (originalRunSetting === undefined) ? undefined : { running: originalRunSetting }, gpii.tests.lifecycleManager.staticRepository.launchHandler); + jqUnit.start(); }); - gpii.tests.lifecycleManager.assertExpectedExec(); - var expectedFirstAppliedSettings = (test.expectedFirstAppliedSettings !== undefined) ? test.expectedFirstAppliedSettings : gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings; - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - on start", expectedFirstAppliedSettings); - - lifecycleManager.update(updatePayload).then(function () { - var session = lifecycleManager.getSession(test.startPayload.userToken); - var appliedSolutions = session.model.appliedSolutions; - var originalSettings = session.model.originalSettings; - jqUnit.assertDeepEq("Checking appliedSolutions after update", test.expectedAppliedSolutions, appliedSolutions); - var expected = gpii.lifecycleManager.transformAllSolutionSettings(test.expectedOriginalSettings, gpii.settingsHandlers.settingsToChanges); + }; + if (testDef.updatePayload) { + lifecycleManager.update(gpii.tests.lifecycleManager.buildStartPayload(testDef.updatePayload)).then(function () { + jqUnit.assertDeepEq("Checking appliedSolutions after update", testDef.expectedAfterUpdate, session.model.appliedSolutions); + var expected = gpii.lifecycleManager.transformAllSolutionSettings(testDef.expectedOriginalSettingsAfterUpdate, gpii.settingsHandlers.settingsToChanges); jqUnit.assertDeepEq("Checking originalSettings after update", expected, originalSettings); - lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { - jqUnit.assertDeepEq("Session not running after stop", lifecycleManager.getSession(test.startPayload.userToken)); - jqUnit.start(); - }); + }); - }); + stopCycle(); + } else { + stopCycle(); + } }); }); }; - gpii.tests.lifecycleManager.buildAsyncUpdateTests = function () { - jqUnit.module("Asynchronous update tests"); - fluid.each(gpii.tests.lifecycleManager.updateTestDefs, function (test) { - jqUnit.asyncTest("gpii.lifecycleManager.update() with active user session: " + test.name, function () { - gpii.tests.lifecycleManager.setup(); - jqUnit.expect(5); - - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); - gpii.tests.lifecycleManager.initBackingMock(); + /** + * expects an input with the following: + * name: name of the test + * expect: number of tests to expect + * expectedLaunchHandlerCalls: number of luanch handler calls to expect (incl. logout) + * originalSettings: the original settings to apply to the system (ie. before login) + * runningOnLogin: boolean - if the magnifier should be running before login + * loginPayload: payload to send to the start() function + * expectedOriginal: the expected "originalSettings" of the session after login + * expectedAfterLogin: the expected "appliedSolutions" of the session after login + * runningAfterLogin: boolean - if the magnifier should be running after login + * --- The below keys are optional and will trigger an update cycle if present. --- + * updatePayload: payload to send to the update() function + * expectedAfterUpdate: the expected "appliedSOlutions" of the session after update call + * expectedOriginalSettingsAfterUpdate: the original after a call to update() has been done, + * originalSettingsAfterUpdate: the settings that the system should reset to (ie. last call to settingsHandler) + * runningAfterUpdate: boolean - if the magnifier should be running after update + */ + gpii.tests.lifecycleManager.runAsyncLifecycleTest = function (testDef) { + var originalRunSetting = testDef.expectedLaunchHandlerCalls === 0 ? undefined : testDef.runningOnLogin; + jqUnit.asyncTest(testDef.name, function () { + gpii.tests.lifecycleManager.setup(); + jqUnit.expect(testDef.expect); + var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); + gpii.tests.lifecycleManager.initBackingMock(testDef.originalSettings, testDef.runningOnLogin); + var session, + originalSettings; + + lifecycleManager.start(gpii.tests.lifecycleManager.buildStartPayload(testDef.loginPayload)).then(function (success) { + session = lifecycleManager.getSession(123); // always just use the default user token + jqUnit.assertTrue("gpii.lifecycleManager.start() succeeds", success); + jqUnit.assertDeepEq("Checking appliedSolutions after start", testDef.expectedAfterLogin, session.model.appliedSolutions); + originalSettings = session.model.originalSettings; + jqUnit.assertDeepEq("Checking originalSettings after start", gpii.lifecycleManager.transformAllSolutionSettings(testDef.expectedOriginal, gpii.settingsHandlers.settingsToChanges), originalSettings); + }); - var updatePayload = fluid.extend(true, {}, test.startPayload, { - activeConfiguration: { - lifecycleInstructions: test.updateSpec - } - }); + if (testDef.updatePayload) { + lifecycleManager.update(gpii.tests.lifecycleManager.buildStartPayload(testDef.updatePayload)).then(function () { + jqUnit.assertDeepEq("Checking appliedSolutions after update", testDef.expectedAfterUpdate, session.model.appliedSolutions); + var expected = gpii.lifecycleManager.transformAllSolutionSettings(testDef.expectedOriginalSettingsAfterUpdate, gpii.settingsHandlers.settingsToChanges); + jqUnit.assertDeepEq("Checking originalSettings after update", expected, originalSettings); - lifecycleManager.start(test.startPayload).then(function () { - gpii.tests.lifecycleManager.assertExpectedExec(); - var expectedFirstAppliedSettings = (test.expectedFirstAppliedSettings !== undefined) ? test.expectedFirstAppliedSettings : gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings; - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - on start", expectedFirstAppliedSettings); }); + } - lifecycleManager.update(updatePayload).then(function () { - var session = lifecycleManager.getSession(test.startPayload.userToken); - var appliedSolutions = session.model.appliedSolutions; - var originalSettings = session.model.originalSettings; - jqUnit.assertDeepEq("Checking appliedSolutions after update", test.expectedAppliedSolutions, appliedSolutions); - var expected = gpii.lifecycleManager.transformAllSolutionSettings(test.expectedOriginalSettings, gpii.settingsHandlers.settingsToChanges); - jqUnit.assertDeepEq("Checking originalSettings after update", expected, originalSettings); - }); + lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { + jqUnit.assertDeepEq("Session not running after stop", lifecycleManager.getSession(123)); + jqUnit.assertEquals("Number of calls to launch handler", testDef.expectedLaunchHandlerCalls, gpii.tests.lifecycleManager.staticRepository.launchHandlerCalls); + // Check that last calls to launch and settings handlers were actually the ones resetting to expected state + jqUnit.assertDeepEq("checking last payload sent to settingshandler:", testDef.originalSettingsAfterUpdate || testDef.originalSettings, gpii.tests.lifecycleManager.staticRepository.settingsHandler); - lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { - jqUnit.assertDeepEq("Session not running after stop", lifecycleManager.getSession(test.startPayload.userToken)); - jqUnit.start(); - }); + // Check that last calls to launch and settings handlers were actually the ones resetting to expected state + gpii.tests.lifecycleManager.checkFinalSettingsPayload("checking last set launch settings", (originalRunSetting === undefined) ? undefined : { running: originalRunSetting }, gpii.tests.lifecycleManager.staticRepository.launchHandler); + jqUnit.start(); }); }); }; + gpii.tests.lifecycleManager.buildUpdateTests = function () { + fluid.each(gpii.tests.lifecycleManager.updateTestDefs, function (test) { + var expectedOriginal = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.originalSettings, test.runningOnLogin)); + var loginPayload = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.loginSettings)); + var expectedAfterLogin = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.loginSettings, test.runningAfterLogin)); + var updatePayload = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.updateSettings)); + var expectedAfterUpdate = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.expectedSettings, test.runningAfterUpdate)); + + var originalSettingsAfterUpdate = test.originalSettingsAfterUpdate || test.originalSettings; + var expectedOriginalSettingsAfterUpdate = gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(originalSettingsAfterUpdate, test.runningOnLogin)); + + var testDef = { + name: "gpii.lifecycleManager.update() with active user session: " + test.name, + expect: 9, + expectedLaunchHandlerCalls: test.expectedLaunchHandlerCalls, + originalSettings: gpii.tests.lifecycleManager.createSettingsHandlerPayload("org.gnome.desktop.a11y.magnifier", test.originalSettings), + runningOnLogin: test.runningOnLogin, + loginPayload: loginPayload, + expectedOriginal: expectedOriginal, + expectedAfterLogin: expectedAfterLogin, + runningAfterLogin: test.runningAfterLogin, + updatePayload: updatePayload, + expectedAfterUpdate: expectedAfterUpdate, + expectedOriginalSettingsAfterUpdate: expectedOriginalSettingsAfterUpdate, + runningAfterUpdate: test.runningAfterUpdate, + originalSettingsAfterUpdate: gpii.tests.lifecycleManager.createSettingsHandlerPayload("org.gnome.desktop.a11y.magnifier", originalSettingsAfterUpdate) + }; + + gpii.tests.lifecycleManager.runSequentialLifecycleTest(testDef); + gpii.tests.lifecycleManager.runAsyncLifecycleTest(testDef); + }); + }; + + gpii.tests.lifecycleManager.buildStartTests = function () { + fluid.each(gpii.tests.lifecycleManager.startTestDefs, function (test) { + var testDef = { + name: "gpii.lifecycleManager.start()/stop(): " + test.name, + expect: 7, + expectedLaunchHandlerCalls: test.expectedLaunchHandlerCalls, + runningOnLogin: test.runningOnLogin, + originalSettings: gpii.tests.lifecycleManager.createSettingsHandlerPayload("org.gnome.desktop.a11y.magnifier", test.originalSettings), + loginPayload: gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.appliedSettings)), + expectedAfterLogin: gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.appliedSettings, test.runningAfterLogin)), + runningAfterLogin: test.runningAfterLogin, + // only expect launch handler settings to be in the original snapshot if we've run a launchHandler call during login + expectedOriginal: gpii.tests.lifecycleManager.extendLifecycleInstructions(test.basePayload, + gpii.tests.lifecycleManager.buildSettingsHandlersEntry(test.originalSettings, test.expectedLaunchHandlerCalls === 0 ? undefined : test.runningOnLogin)) + }; + + gpii.tests.lifecycleManager.runSequentialLifecycleTest(testDef); + gpii.tests.lifecycleManager.runAsyncLifecycleTest(testDef); + }); + }; + gpii.tests.lifecycleManager.settingsToChanges = function (expected) { return gpii.settingsHandlers.transformOneSolutionSettings(expected, gpii.settingsHandlers.settingsToChanges); }; @@ -738,23 +1018,9 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt jqUnit.test("gpii.lifecycleManager.specToSettingsHandler()", function () { fluid.each(gpii.tests.lifecycleManager.specToSettingsHandlerTests, function (spec, name) { jqUnit.expect(1); - var response = gpii.lifecycleManager.specToSettingsHandler("fake.solution", spec.request, spec.isMultiSH); + var response = gpii.lifecycleManager.specToSettingsHandler("fake.solution", spec.request); jqUnit.assertDeepEq(name, { "fake.solution": spec.response }, response); }); - - // Test for fail if a multi settingshandler solution doesn't have a supportedSettings directive - var failingFunc = function () { - gpii.lifecycleManager.specToSettingsHandler("fake.solution", { - "type": "gpii.gsettings.set", - "options": {}, - "settings": { - "weirdSetting": "foo", - "otherSetting": "bar" - } - }, true); - }; - jqUnit.expectFrameworkDiagnostic("Expect failure if no supportedSettings for multiple SH solution", - failingFunc, "missing the 'supportedSettings' directive"); }); jqUnit.test("gpii.lifecycleManager.responseToSnapshot() no settings", function () { @@ -772,64 +1038,35 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt jqUnit.assertDeepEq("responseToSnapshot returning the correct payload", expected, response); }); - jqUnit.asyncTest("gpii.lifecycleManager.invokeSettingsHandler()", function () { + jqUnit.asyncTest("gpii.lifecycleManager.invokeSettingsHandlerSet()", function () { jqUnit.expect(2); var lifecycleManager = gpii.lifecycleManager(); gpii.tests.lifecycleManager.initBackingMock(); - var snapshotPromise = lifecycleManager.invokeSettingsHandler("org.gnome.desktop.a11y.magnifier", gpii.tests.lifecycleManager.invokeSettingsHandlersRequest); + var snapshotPromise = lifecycleManager.invokeSettingsHandlerSet("org.gnome.desktop.a11y.magnifier", gpii.tests.lifecycleManager.invokeSettingsHandlersRequest); var expected = gpii.tests.lifecycleManager.settingsToChanges(gpii.tests.lifecycleManager.invokeSettingsHandlersExpectedSnapshot); snapshotPromise.then(function (snapshot) { jqUnit.assertDeepEq("invokeSettingsHandlers produced snapshot", expected, snapshot); - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - standalone", gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings); + jqUnit.assertDeepEq("expected input sent to settingsHandler", gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings, gpii.tests.lifecycleManager.staticRepository.settingsHandler); jqUnit.start(); }); }); - jqUnit.asyncTest("gpii.lifecycleManager.start() and stop()", function () { - gpii.tests.lifecycleManager.setup(); - // 2 tests for the settingsHandler (see mockSettingsHandler function above) - // 2 tests for the launchHandler (see mockLaunchHandler function above) - // and the two asserts below - jqUnit.expect(5); - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); + jqUnit.asyncTest("gpii.lifecycleManager.invokeSettingsHandlerGet()", function () { + jqUnit.expect(1); + var lifecycleManager = gpii.lifecycleManager(); gpii.tests.lifecycleManager.initBackingMock(); - - var promise = lifecycleManager.start(gpii.tests.lifecycleManager.startPayload); - promise.then(function () { - gpii.tests.lifecycleManager.assertExpectedExec(); - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - on start", gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings); - var stopPromise = lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions); - stopPromise.then(function () { - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - on stop", gpii.tests.lifecycleManager.settingsHandlerExpectedInputRestoreSettings); - jqUnit.assertEquals("Expected pid has been sent to kill handler", - 8839, gpii.tests.lifecycleManager.staticRepository.killHandler.pid); - gpii.tests.lifecycleManager.assertNoActiveSessions(lifecycleManager, "stop: Stop message to lifecycle manager"); - jqUnit.start(); - }); - }); - }); - - // tests for active: false and active: undefined. - // active: true is tested in all the other tests - var activeValues = [ false, undefined ]; - fluid.each(activeValues, function (active) { - jqUnit.asyncTest("gpii.lifecycleManager.start() with active: " + (active === undefined ? "undefined" : active), function () { - //reset the exec values - gpii.tests.lifecycleManager.setup(); - - jqUnit.expect(2); - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); - gpii.tests.lifecycleManager.initBackingMock(); - - // set up payload with active false - var activeFalsePayload = fluid.copy(gpii.tests.lifecycleManager.startPayload); - fluid.set(activeFalsePayload, [ "activeConfiguration", "lifecycleInstructions", "org.gnome.desktop.a11y.magnifier", "active" ], active); - - lifecycleManager.start(activeFalsePayload).then(function () { - gpii.tests.lifecycleManager.assertExpectedSettingsHandler(" - on start", gpii.tests.lifecycleManager.settingsHandlerExpectedInputNewSettings); - gpii.tests.lifecycleManager.assertNoExec(); - jqUnit.start(); - }); + var snapshotPromise = lifecycleManager.invokeSettingsHandlerGet("org.gnome.desktop.a11y.magnifier", gpii.tests.lifecycleManager.invokeSettingsHandlersRequest); + var expected = { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "cross-hairs-clip": false, + "cross-hairs-color": "red" + } + }] + }; + snapshotPromise.then(function (snapshot) { + jqUnit.assertDeepEq("invokeSettingsHandlerGet produced snapshot", expected, snapshot); + jqUnit.start(); }); }); @@ -842,76 +1079,11 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt }); }); - gpii.tests.lifecycleManager.buildSequentialUpdateTests(); - gpii.tests.lifecycleManager.buildAsyncUpdateTests(); - - - jqUnit.asyncTest("gpii.lifecycleManager.update() tests for 'stop' reference", function () { - // initial payload: - var startPayload = fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "stop" ] }) - } - }); - - gpii.tests.lifecycleManager.setup(); - jqUnit.expect(3); - - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); - gpii.tests.lifecycleManager.initBackingMock(); - - lifecycleManager.start(startPayload).then(function () { - // check that things have 'started' - gpii.tests.lifecycleManager.assertExpectedExec(); - - lifecycleManager.update(startPayload).then(function () { - // check that things have 'stopped' - jqUnit.assertEquals("Expected pid has been sent to kill handler", - 8839, gpii.tests.lifecycleManager.staticRepository.killHandler.pid); - lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { - gpii.tests.lifecycleManager.assertNoActiveSessions(lifecycleManager, "no active sessions running after stop"); - jqUnit.start(); - }); - }); - }); - }); - - jqUnit.asyncTest("gpii.lifecycleManager.update() tests for 'stop' and 'start' reference", function () { - // initial payload: - var startPayload = fluid.extend(true, {}, gpii.tests.lifecycleManager.userOptions, { - activeConfiguration: { - lifecycleInstructions: gpii.tests.lifecycleManager.buildLifecycleInstructions("org.gnome.desktop.a11y.magnifier", - gpii.tests.lifecycleManager.buildSettingsHandlersEntry({ "cross-hairs-clip": true, "cross-hairs-color": "red" }), - gpii.tests.lifecycleManager.noUpdateLifecycle, - { "update": [ "stop", "start" ] }) - } - }); - - gpii.tests.lifecycleManager.setup(); - jqUnit.expect(4); - - var lifecycleManager = gpii.lifecycleManager(gpii.tests.lifecycleManager.testOptions); - gpii.tests.lifecycleManager.initBackingMock(); - - lifecycleManager.start(startPayload).then(function () { - // check that things have 'started' - gpii.tests.lifecycleManager.assertExpectedExec(); - - lifecycleManager.update(startPayload).then(function () { - // check that things have 'stopped' - jqUnit.assertEquals("Expected pid has been sent to kill handler", - 8839, gpii.tests.lifecycleManager.staticRepository.killHandler.pid); - gpii.tests.lifecycleManager.assertExpectedExec(); - - lifecycleManager.stop(gpii.tests.lifecycleManager.userOptions).then(function () { - gpii.tests.lifecycleManager.assertNoActiveSessions(lifecycleManager, "no active sessions running after stop"); - jqUnit.start(); - }); - }); - }); + gpii.tests.lifecycleManager.buildUpdateTests(); + gpii.tests.lifecycleManager.buildStartTests(); + fluid.each(gpii.tests.lifecycleManager.completeLifecycleTests, function (testDef) { + gpii.tests.lifecycleManager.runSequentialLifecycleTest(testDef); + gpii.tests.lifecycleManager.runAsyncLifecycleTest(testDef); }); }; })(); diff --git a/gpii/node_modules/matchMakerFramework/src/MatchMakerUtilities.js b/gpii/node_modules/matchMakerFramework/src/MatchMakerUtilities.js index 60d74bd5e..5e553bc31 100644 --- a/gpii/node_modules/matchMakerFramework/src/MatchMakerUtilities.js +++ b/gpii/node_modules/matchMakerFramework/src/MatchMakerUtilities.js @@ -189,10 +189,10 @@ var fluid = fluid || require("infusion"), var leaves = gpii.matchMakerFramework.utils.computeLeaves(context.preferences); var disposed = strategy(leaves, tmpSolrecs, data, ontologyMetadata); - togo[contextId] = []; + togo[contextId] = {}; fluid.each(disposed, function (solrec, solid) { - if (solrec.disposition === "accept") { - togo[contextId].push(solid); + if (solrec.disposition === "accept") { // only output accepted solutions + togo[contextId][solid] = solrec.active; // true if it should be running } }); }); @@ -270,6 +270,7 @@ var fluid = fluid || require("infusion"), // if no ties, mark the current solution as "accept" if (tied.length === 0) { solrecs[solutionId].disposition = "accept"; + solrecs[solutionId].active = true; solrecs[solutionId].dispositionReason = "Has a higher priority (" + priority + ") than any solution of the same type"; } else { @@ -301,6 +302,7 @@ var fluid = fluid || require("infusion"), delete solrecs[tiedSolutionId].priority; delete solrecs[tiedSolutionId].disposition; delete solrecs[tiedSolutionId].dispositionReason; + delete solrecs[tiedSolutionId].active; }); }; @@ -327,8 +329,9 @@ var fluid = fluid || require("infusion"), for (var solutionId in solutionTypeMapping[type]) { var sol = solrecs[solutionId]; if (!sol.disposition) { - sol.disposition = "reject"; - sol.dispositionReason = disposeReason || "Solution rejected due to its type of " + type; + sol.disposition = "accept"; + sol.active = false; + sol.dispositionReason = disposeReason || "Solution accepted but deactivated due to its type of " + type; } } }); @@ -435,11 +438,11 @@ var fluid = fluid || require("infusion"), applications: {} }; var appBlock = togo.inferredConfiguration[contextId].applications; - fluid.each(solArray, function (solutionId) { + fluid.each(solArray, function (active, solutionId) { var filteredSettings = gpii.matchMakerFramework.utils.filterPreferencesForSolution(solutionId, fullModel.preferences.contexts[contextId].preferences, fullModel.solutionsRegistryEntries[solutionId]); appBlock[solutionId] = { - active: true, - settings:filteredSettings + active: active, + settings: filteredSettings }; // TODO: add metadata sections }); diff --git a/gpii/node_modules/matchMakerFramework/test/js/CanopyMatchMakerTests.js b/gpii/node_modules/matchMakerFramework/test/js/CanopyMatchMakerTests.js deleted file mode 100644 index 179323e50..000000000 --- a/gpii/node_modules/matchMakerFramework/test/js/CanopyMatchMakerTests.js +++ /dev/null @@ -1,191 +0,0 @@ -/* - * GPII Canopy MatchMaker Tests - * - * Copyright 2012 OCAD University - * Copyright 2012 Raising The Floor - International - * - * Licensed under the New BSD license. You may not use this file except in - * compliance with this License. - * - * The research leading to these results has received funding from the European Union's - * Seventh Framework Programme (FP7/2007-2013) - * under grant agreement no. 289016. - * - * You may obtain a copy of the License at - * https://github.com/GPII/universal/blob/master/LICENSE.txt - */ - -/* global jqUnit, fluid */ - -var gpii = fluid.registerNamespace("gpii"); - -(function () { - "use strict"; - - fluid.registerNamespace("gpii.tests.canopyMatchMaker"); - - var magnifier = { - "settingsHandlers": { - "myconf": { - "type": "gpii.integrationTesting.mockSettingsHandler", - "capabilities": ["display.screenEnhancement"], - "capabilitiesTransformations": { - "mag-factor": "display.screenEnhancement.magnification", - "show-cross-hairs": "display.screenEnhancement.-provisional-showCrosshairs", - "mouse-tracking": { - "transform": { - "type": "fluid.transforms.valueMapper", - "defaultInputPath": "display.screenEnhancement.tracking", - "match": { - "mouse": "centered" - } - } - } - } - } - } - }; - - var lesserMagnifier = { - "settingsHandlers": { - "myconf": { - "type": "gpii.integrationTesting.mockSettingsHandler", - "capabilitiesTransformations": { - "mag-factor": "display.screenEnhancement.magnification" - } - }, - "yourconf": { - "type": "gpii.integrationTesting.mockSettingsHandler", - "capabilities": "display.screenEnhancement.magnification" - } - } - }; - - var magnifierLeaves = [ - "display.screenEnhancement.magnification", - "display.screenEnhancement.-provisional-showCrosshairs", - "display.screenEnhancement.tracking", - "display.screenEnhancement" - ]; - - var magnifierSkeleton = { - display: { - screenEnhancement: { - magnification: {}, - "-provisional-showCrosshairs": {}, - tracking: {} - } - } - }; - - var escapedLeaves = [ - "display.screenReader.applications.nvda\\.screenReader" - ]; - - var escapedSkeleton = { - display: { - screenReader: { - applications: { - "nvda.screenReader": {} - } - } - } - }; - - var sammyProfile = { - "display": { - "screenEnhancement": { - "fontSize": 24, - "foregroundColor": "white", - "backgroundColor": "black", - "fontFace": { - "fontName": ["Comic Sans"], - "genericFontFace": "sans serif" - }, - "magnification": 2.0, - "tracking": ["mouse"], - "invertImages": true, - "-provisional-showCrosshairs": true - } - } - }; - - var sammyLeaves = [ - "display.screenEnhancement.-provisional-showCrosshairs", - "display.screenEnhancement.backgroundColor", - "display.screenEnhancement.fontFace.fontName.0", - "display.screenEnhancement.fontFace.genericFontFace", - "display.screenEnhancement.fontSize", - "display.screenEnhancement.foregroundColor", - "display.screenEnhancement.invertImages", - "display.screenEnhancement.magnification", - "display.screenEnhancement.tracking.0" - ]; - - var expandFitness = function (fitnesses) { - return fluid.transform(fitnesses, function (fit, index) { - return { - fitness: fit, - index: index - }; - }); - }; - - var extractIndices = function (solns) { - return fluid.transform(solns, function (soln) { - return soln.index; - }); - }; - - gpii.tests.canopyMatchMaker.runTests = function () { - jqUnit.module("Utilities"); - - jqUnit.test("Path Utilities", function () { - jqUnit.assertEquals("Exact depth", 0, gpii.matchMakerFramework.utils.prefixLength("display.screenEnhancement.fontSize", sammyProfile)); - jqUnit.assertEquals("Near depth", 0, gpii.matchMakerFramework.utils.prefixLength("display.screenEnhancement.fontSize", sammyProfile)); - jqUnit.assertEquals("Mid depth", -1, gpii.matchMakerFramework.utils.prefixLength("display.unrecognizable", sammyProfile)); - jqUnit.assertEquals("Far depth", -2, gpii.matchMakerFramework.utils.prefixLength("display.unrecognizable.thing", sammyProfile)); - var skeleton = gpii.matchMakerFramework.utils.pathsToSkeleton(magnifierLeaves); - jqUnit.assertDeepEq("Computed model skeleton", magnifierSkeleton, skeleton); - - var skeleton2 = gpii.matchMakerFramework.utils.pathsToSkeleton(escapedLeaves); - jqUnit.assertDeepEq("Computed model escaped skeleton", escapedSkeleton, skeleton2); - }); - - jqUnit.test("Fitness computation", function () { - var fitness = gpii.matchMaker.canopy.computeFitness(sammyLeaves, magnifierSkeleton); - var expected = [0, 0, -1, -1, -1, -1, -1, -2, -3]; - jqUnit.assertDeepEq("Computed fitness vector", expected, fitness); - - var fitnesses = [ - [-1, -3, 0], - [0, 0, 0], - [0, 0], - [0, 0, 0, 0], - [-1, -3, -1] - ]; - var solns = gpii.matchMaker.canopy.sortSolutions(expandFitness(fitnesses)); - var indices = extractIndices(solns); - var expected2 = [3, 1, 2, 0, 4]; - jqUnit.assertDeepEq("Ranked fitnesses", expected2, indices); - }); - - jqUnit.module("MatchMaker"); - jqUnit.test("Rank and dispose solutions", function () { - var solutions = [lesserMagnifier, - magnifier - ]; - var expanded = gpii.matchMakerFramework.utils.expandSolutions(solutions, { "*": "*" }); - var ranked = gpii.matchMaker.canopy.rankSolutions(sammyLeaves, expanded); - var indices = extractIndices(ranked); - var expected = [1, 0]; - jqUnit.assertDeepEq("Ranked solutions", expected, indices); - - var disposed = gpii.matchMaker.canopy.disposeSolutionsImpl(sammyLeaves, ranked); - var itions = gpii.matchMakerFramework.utils.extractDispositions(disposed); - expected = ["reject", "accept"]; - jqUnit.assertDeepEq("Disposed solutions", expected, itions); - }); - }; - -})(); diff --git a/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesDisposeFromPriorityTests.js b/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesDisposeFromPriorityTests.js index f088d22eb..8827bf34e 100644 --- a/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesDisposeFromPriorityTests.js +++ b/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesDisposeFromPriorityTests.js @@ -92,37 +92,39 @@ var fluid = fluid || require("infusion"), } }; - // "undefined" disposition means that the solution is either tied with another solution - // or not present on the device. Decisions are based on priority and solution type - see + // `undefined` disposition means that the solution is either tied with another solution + // or not present on the device. `true` means that the solution should be configured and + // launched on startup, and `false` means configured but NOT launched on startup. + // Decisions are based on priority and solution type - see // the data block above. var testData = [{ description: "Tie between highest priority, rest rejected", priorities: [2, 2, 1, 1, 1], - expectedDispositions: [undefined, undefined, "reject", "reject", "reject"] + expectedDispositions: [undefined, undefined, false, false, false] }, { description: "Single highest priority wins, rest rejected", priorities: [2, 1, 1, 1, 1], - expectedDispositions: ["accept", "reject", "reject", "reject", "reject"] + expectedDispositions: [true, false, false, false, false] }, { // description: "Only solution covering all required solution types selected", // priorities: [2, 1, 2, 1, 1], - // expectedDispositions: ["accept", "reject", "reject", "reject", "reject"] + // expectedDispositions: [true, "reject", "reject", "reject", "reject"] // }, { description: "Highest priority selected, solution type equivalents remove", priorities: [2, 1, 3, 1, 2], - expectedDispositions: ["reject", "reject", "accept", "reject", "accept"] + expectedDispositions: [false, false, true, false, true] }, { description: "Tie between multiple solutions of different types", priorities: [2, 1, 2, 2, 2], - expectedDispositions: [undefined, "reject", undefined, undefined, undefined] + expectedDispositions: [undefined, false, undefined, undefined, undefined] }, { description: "Tie between multiple solutions of different types #2", priorities: [2, 1, 2, 1, 2], - expectedDispositions: [undefined, "reject", undefined, "reject", undefined] + expectedDispositions: [undefined, false, undefined, false, undefined] // }, { // description: "", // priorities: [1, null, 2, null, null], - // expectedDispositions: ["accept", undefined, "reject", undefined, undefined] + // expectedDispositions: [true, undefined, "reject", undefined, undefined] }]; @@ -168,8 +170,9 @@ var fluid = fluid || require("infusion"), gpii.matchMakerFramework.utils.disposeFromPriority(input.solrecs, input.data); fluid.each(fullData.solIds, function (solId, index) { - var msg = "Expecting solution " + solId + " to have disposition: " + expectedDispositions[index]; - jqUnit.assertEquals(msg, expectedDispositions[index], input.solrecs[solId].disposition); + var msg = "Expecting solution " + solId + " to be: " + expectedDispositions[index]; + var actual = input.solrecs[solId].disposition ? input.solrecs[solId].active : undefined; + jqUnit.assertEquals(msg, expectedDispositions[index], actual); }); }; diff --git a/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesTests.js b/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesTests.js index 764010577..6761812a2 100644 --- a/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesTests.js +++ b/gpii/node_modules/matchMakerFramework/test/js/MatchMakerUtilitiesTests.js @@ -190,7 +190,7 @@ var fluid = fluid || require("infusion"), model: { "name": "GNOME Shell Magnifier", "contexts": {}, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "options": { @@ -287,9 +287,9 @@ var fluid = fluid || require("infusion"), { description: "Basic payloads", disposed: { - "gpii-default": [ - "mac.dummy" - ] + "gpii-default": { + "mac.dummy": true + } }, fullModel: { "userToken": "mac", @@ -330,7 +330,7 @@ var fluid = fluid || require("infusion"), } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { @@ -361,7 +361,7 @@ var fluid = fluid || require("infusion"), } ] }, - "settingsHandlers": { + "handlers": { "otherconf": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [] @@ -573,7 +573,7 @@ var fluid = fluid || require("infusion"), } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -610,7 +610,7 @@ var fluid = fluid || require("infusion"), } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -648,7 +648,7 @@ var fluid = fluid || require("infusion"), } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { diff --git a/gpii/node_modules/processReporter/README.md b/gpii/node_modules/processReporter/README.md index d305fa449..0370f4e82 100644 --- a/gpii/node_modules/processReporter/README.md +++ b/gpii/node_modules/processReporter/README.md @@ -1,12 +1,16 @@ Process Reporter === +<<<<<<< HEAD +The Process Reporter uses the information stored in the `isRunning` block of a solutions registry entry to decide whether a solution is running. For example, the `isRunning` block for the Linux screen reader Orca (the solution entry `org.gnome.orca`) is as follows: +======= A fluid component that can be used to acquire information about the processes associated with a GPII solution. In particular, it can determine the running status of a solution. ### Process Reporter API Given a solutions registry entry, the Process Reporter uses the information stored in the `isRunning` block to determine whether a solution has been launched and is currently running. For example, the `isRunning` block for the Orca screen reader (the solution entry `org.gnome.orca`) is as follows: + ``` "isRunning": [ { @@ -25,6 +29,7 @@ The Process Reporter's invoker `handleIsRunning(entry)` uses the `type` property If the solutions registry entry does not have an `isRunning` block, then its run-state is not defined, and `handleIsRunning()` returns `undefined`. Most solutions run-state is based on a corresponding entry in the underlying OS's process or tasklist table. For example, the Linux/GNOME solution `org.gnome.orca` is running if the `orca` screen reader process is running. Similarly, on Windows, `org.nvda-project` is running if there is an `nvda` process in the tasklist. +>>>>>>> 701e0260df860ee1339fc8bb0b686ecf78c97c12 Some solutions, however, are not strictly process-oriented. An example is the GNOME Shell screen magnifier (solution `org.gnome.desktop.a11y.magnifier`). The magnifier is not a separate process, but is built into GNOME Shell. The magnifier is running if (1) the `gnome-shell` process is running and (2) the `org.gnome.desktop.a11y.applications screen-magnifier-enabled` GSetting is `true`. diff --git a/gpii/node_modules/processReporter/index.js b/gpii/node_modules/processReporter/index.js index 5c534537c..2839dbc9a 100644 --- a/gpii/node_modules/processReporter/index.js +++ b/gpii/node_modules/processReporter/index.js @@ -6,5 +6,3 @@ fluid.module.register("processReporter", __dirname, require); require("./src/processesBridge.js"); require("./src/ProcessReporter.js"); - - diff --git a/gpii/node_modules/processReporter/src/ProcessReporter.js b/gpii/node_modules/processReporter/src/ProcessReporter.js index 06182adf3..2ad3a4dac 100644 --- a/gpii/node_modules/processReporter/src/ProcessReporter.js +++ b/gpii/node_modules/processReporter/src/ProcessReporter.js @@ -54,7 +54,7 @@ gpii.processReporter.neverRunning = function () { }; /** - * Runs the 'isRunning' entries of the 'entry' argument. If no 'isRunning' block is not present + * Runs the 'isRunning' entries of the 'entry' argument. If no 'isRunning' block is present * undefined is returned */ gpii.processReporter.handleIsRunning = function (entry) { diff --git a/gpii/node_modules/settingsHandlers/index.js b/gpii/node_modules/settingsHandlers/index.js index 9b3e1ebe1..0d0199a92 100644 --- a/gpii/node_modules/settingsHandlers/index.js +++ b/gpii/node_modules/settingsHandlers/index.js @@ -9,3 +9,4 @@ require("./src/XMLSettingsHandler.js"); require("./src/JSONSettingsHandler.js"); require("./src/WebSocketsSettingsHandler.js"); require("./src/NoSettingsHandler.js"); +require("./src/LaunchHandlers.js"); diff --git a/gpii/node_modules/settingsHandlers/src/LaunchHandlers.js b/gpii/node_modules/settingsHandlers/src/LaunchHandlers.js new file mode 100644 index 000000000..aab4720b1 --- /dev/null +++ b/gpii/node_modules/settingsHandlers/src/LaunchHandlers.js @@ -0,0 +1,79 @@ +/* + * GPII Launch Handlers + * + * Copyright 2017 Raising the Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/GPII/universal/blob/master/LICENSE.txt + */ + +"use strict"; + +var fluid = fluid || require("infusion"), + gpii = fluid.registerNamespace("gpii"); + +/** + * The flexibleHandler is a highly customizable launch handler that is implemented to handle all + * the cases in which a solutions launch-cycle is too complex or specific to efficiently be handled + * in one of the standard launchHandlers. + * + * Besides the normal launch handler options like retryOptions and verifySettings, the flexible handler + * supports three directives: `getState`, `setTrue` and `setFalse`. + * + * `getState`: equals the launchHandlers "get" functionality, and should return a boolean value indicating + * whether the application is running or not. The content of this directive will be sent to the + * processReporters' handleIsRunning function + * `setTrue`: Is run when a "true" value is sent to the launch handler. The content of this block should + * be an array of objects that can be run as graded functions in infusion. The result of runnings these + * blocks should be that the application is running + * `setFalse`: Identical to `setTrue` but is run when a "false" is sent to the launch handler. The result from + * running the blocks in this directive should be that the application is closed/not running. + */ +fluid.registerNamespace("gpii.launchHandlers.flexibleHandler"); + +gpii.launchHandlers.flexibleHandler.set = function (payload) { + return fluid.transform(payload, function (allSettingsBlocks, solutionId) { + return fluid.transform(allSettingsBlocks, function (handlerData) { + // find desire state { running: X } + var desiredState = handlerData.settings.running; + if (desiredState !== true && desiredState !== false) { + fluid.fail("Unable to set the launch state of ", solutionId, " to ", desiredState); + } + + // get current state + var currentState = gpii.launchHandlers.flexibleHandler.executeGetBlock(handlerData.options, solutionId); + + // if not in desired state + if (currentState !== desiredState) { + desiredState === true ? + gpii.launchHandlers.flexibleHandler.executeSetBlock(handlerData, "setTrue") : + gpii.launchHandlers.flexibleHandler.executeSetBlock(handlerData, "setFalse"); + } + + return gpii.settingsHandlers.setSettings(handlerData, { running: currentState }); + }); + }); +}; + +gpii.launchHandlers.flexibleHandler.get = function (payload) { + return fluid.transform(payload, function (allSettingsBlocks, solutionId) { + return fluid.transform(allSettingsBlocks, function (handlerData) { + var currentState = gpii.launchHandlers.flexibleHandler.executeGetBlock(handlerData.options, solutionId); + return { settings: { running: currentState }}; + }); + }); +}; + +gpii.launchHandlers.flexibleHandler.executeSetBlock = function (mainEntry, blockName) { + var setBlocks = fluid.get(mainEntry, [ "options", blockName ]); + fluid.each(fluid.makeArray(setBlocks), function (setBlock) { + fluid.invokeGradedFunction(setBlock.type, setBlock); + }); +}; + +gpii.launchHandlers.flexibleHandler.executeGetBlock = function (options) { + return gpii.processReporter.handleIsRunning({ isRunning: options.getState }); +}; diff --git a/gpii/node_modules/settingsHandlers/src/settingsHandlerUtilities.js b/gpii/node_modules/settingsHandlers/src/settingsHandlerUtilities.js index 50fa0a4d2..8dbc85354 100644 --- a/gpii/node_modules/settingsHandlers/src/settingsHandlerUtilities.js +++ b/gpii/node_modules/settingsHandlers/src/settingsHandlerUtilities.js @@ -55,6 +55,32 @@ gpii.toPromise = function (value) { fluid.registerNamespace("gpii.settingsHandlers"); +/** + * Filters out all the settings from the `settings` argument which are + * not in the `supportedSettings` argument + * + * @param settings {Object} Object in which each key is a setting name that is to be filtered. This + * object will be modified. + * @param supportedSettings {Object} Object in which each key is a setting name that will be filtered by + * @return {Object} the `settings`, filtered by the `supportedSettings` entries, meaning that + * any setting that is not in supportedSettings will not be in the return object. + */ +gpii.settingsHandlers.filterSupportedSettings = function (settings, supportedSettings) { + if (supportedSettings === undefined || settings === undefined) { + return settings; + } else { + var filteredSettings = {}; + // we cant simply use fluid.filterKeys because that wont handle the cases where + // there are 'undefined' values for the keys in handlerSpec.settings + for (var settingName in supportedSettings) { + if (settingName in settings) { + filteredSettings[settingName] = settings[settingName]; + } + } + return filteredSettings; + } +}; + // TODO: These utilities all clearly form part of some wider idiom of "payload handling" without some underpinnings // for which they are rather hard to follow. For example, they could benefit from some form of "JSON type system" // (whether provided via JSON schema or otherwise) in order to provide landmarks within the payloads, as well @@ -72,9 +98,9 @@ fluid.registerNamespace("gpii.settingsHandlers"); * @return The transformed payload-structured value */ gpii.settingsHandlers.transformPayload = function (payload, handler) { - return fluid.transform(payload, function (oneSolution, solutionPath) { + return fluid.transform(payload, function (oneSolution, solutionId) { return fluid.transform(oneSolution, function (oneSetting, settingPath) { - var path = [solutionPath, settingPath]; + var path = [solutionId, settingPath]; return handler(oneSetting, path, oneSolution); }); }); @@ -89,10 +115,14 @@ gpii.settingsHandlers.transformPayload = function (payload, handler) { gpii.settingsHandlers.transformOneSolutionSettings = function (oneSolution, handler, path) { path = path || []; var togo = fluid.censorKeys(oneSolution, "settings"); - togo.settings = fluid.transform(oneSolution.settings, function (oneSetting, settingKey) { + var newSettings = fluid.transform(oneSolution.settings, function (oneSetting, settingKey) { var innerPath = path.concat(["settings", settingKey]); return handler(oneSetting, innerPath, oneSolution); }); + if (newSettings !== undefined) { // ignore undefined settings blocks + togo.settings = newSettings; + } + return togo; }; @@ -109,7 +139,6 @@ gpii.settingsHandlers.transformPayloadSettings = function (payload, handler) { /** Extract just the settings (eliminating "options") from the nested settingsHandler blocks for a full payload (top-level keys are solution ids) * - this is used from gpii.settingsHandlers.comparePayloads and gpii.test.checkConfiguration */ - gpii.settingsHandlers.extractSettingsBlocks = function (payload) { return gpii.settingsHandlers.transformPayload(payload, function (oneSolution) { return fluid.filterKeys(oneSolution, "settings"); @@ -138,16 +167,16 @@ gpii.settingsHandlers.numberify = function (payload) { * @return A promise yielding the combined payload expected from a top-level settings handler - this * will resolve synchronously if the supplied handler function is synchronous ("ZALGO" notwithstanding) **/ - gpii.settingsHandlers.invokeSettingsHandler = function (handler, payload) { var worklist = []; var response = gpii.settingsHandlers.transformPayload(payload, function (element, path) { + var solutionId = path[0]; // first entry of path will always be solution ID // Note shallow copy performed within filterKeys var directLoad = fluid.filterKeys(element, ["settings", "options"]); var others = fluid.censorKeys(element, ["settings", "options"]); worklist.push({ path: path, - result: handler(directLoad), + result: handler(directLoad, solutionId), others: others }); return {}; // construct isomorphic skeleton of response @@ -262,8 +291,43 @@ gpii.settingsHandlers.checkRereadSettings = function (that) { } }; +gpii.settingsHandlers.dispatchSettingsHandler = function (resolvedName, payload, operation, retryOptions) { + return (operation === "get") ? + gpii.settingsHandlers.dispatchSettingsHandlerGet(resolvedName, payload) : + gpii.settingsHandlers.dispatchSettingsHandlerSet(resolvedName, payload, retryOptions); +}; + /** - * Called to invoke settings handlers. Based on the first verifySettings option found in the payload, + * Called to invoke settings handlers' get functionality. + + * Structure of 'payload' argument is: + * { + * "some.app.id": [{ + * "settings": { ... }, + * "options": { + * ... + * } + * }] + * } + * @param resolvedName {String} The resolved "trunk name" of the settings handler to be invoked - e.g. gpii.windows.registrySettingsHandler + * @param payload {Object} The full payload that would be sent to the SET method of the settings handler + * @return a promise that will yield the original payload of the invoked GET method + */ +gpii.settingsHandlers.dispatchSettingsHandlerGet = function (resolvedName, payload) { + // TODO "gpii.lifecycleManager.specToSettingsHandler" is the one responsible for this awkward + // layout of the settings handler payload - all of this infrastructure will have to be updated + // and cleaned up at some point + try { + return gpii.settingsHandlers.invokeGetHandler(resolvedName, payload); + } catch (e) { + fluid.log(fluid.logLevel.WARN, "Error received when dispatching settingsHandler.get " + resolvedName + " with payload ", + payload, ": " + e); + return fluid.promise().reject(e); + } +}; + +/** + * Called to invoke settings handlers' set function. Based on the first verifySettings option found in the payload, * the settingshandler will be invoked with retrying enabled (if true) or without it (false). * Structure of 'payload' argument is: * { @@ -283,7 +347,7 @@ gpii.settingsHandlers.checkRereadSettings = function (that) { * @return a promise that will yield the original payload of the invoked SET method. In the case * that retrying is enabled, a rejection occurs if the GET payloads never match after the end of the nominated retry period */ -gpii.settingsHandlers.dispatchSettingsHandler = function (resolvedName, payload, retryOptions) { +gpii.settingsHandlers.dispatchSettingsHandlerSet = function (resolvedName, payload, retryOptions) { // TODO "gpii.lifecycleManager.specToSettingsHandler" is the one responsible for this awkward // layout of the settings handler payload - all of this infrastructure will have to be updated // and cleaned up at some point @@ -295,12 +359,16 @@ gpii.settingsHandlers.dispatchSettingsHandler = function (resolvedName, payload, gpii.settingsHandlers.invokeRetryingHandler(resolvedName, payload, retryOptions) : gpii.settingsHandlers.invokeSetHandler(resolvedName, payload); } catch (e) { - fluid.log(fluid.logLevel.WARN, "Error received when dispatching settingsHandler " + resolvedName + " with payload ", + fluid.log(fluid.logLevel.WARN, "Error received when dispatching settingsHandler.set " + resolvedName + " with payload ", payload, ": " + e); return fluid.promise().reject(e); } }; +gpii.settingsHandlers.invokeGetHandler = function (resolvedName, payload) { + return gpii.toPromise(fluid.invokeGlobalFunction(resolvedName + ".get", [payload])); +}; + gpii.settingsHandlers.invokeSetHandler = function (resolvedName, payload) { return gpii.toPromise(fluid.invokeGlobalFunction(resolvedName + ".set", [payload])); }; @@ -315,8 +383,12 @@ gpii.settingsHandlers.invokeSetHandler = function (resolvedName, payload) { * that matches, or else a rejection if the GET payloads never match after the end of the nominated retry period */ gpii.settingsHandlers.invokeRetryingHandler = function (resolvedName, payload, retryOptions) { + // solution entry options overwrites any component options on retrying + var solutionIds = fluid.keys(payload); + var solutionRetryOptions = fluid.get(payload, [solutionIds[0], 0, "options", "retryOptions"]); + var mergedRetryOptions = fluid.extend(true, {}, retryOptions, solutionRetryOptions); var that = { - retryOptions: retryOptions, + retryOptions: mergedRetryOptions, retries: 1, payload: payload, resolvedName: resolvedName, diff --git a/gpii/node_modules/settingsHandlers/test/web/html/LaunchHandlerTest.html b/gpii/node_modules/settingsHandlers/test/web/html/LaunchHandlerTest.html new file mode 100644 index 000000000..4e66b8577 --- /dev/null +++ b/gpii/node_modules/settingsHandlers/test/web/html/LaunchHandlerTest.html @@ -0,0 +1,36 @@ + + + + + GPII Launch Handler Tests + + + + + + + + + + + + + + + + + + + + + +

GPII Launch Handlers Tests

+

+
+

+
    + + + + diff --git a/gpii/node_modules/settingsHandlers/test/web/js/LaunchHandlerTests.js b/gpii/node_modules/settingsHandlers/test/web/js/LaunchHandlerTests.js new file mode 100644 index 000000000..9e9c9f6a1 --- /dev/null +++ b/gpii/node_modules/settingsHandlers/test/web/js/LaunchHandlerTests.js @@ -0,0 +1,347 @@ +/* + * Launch Handler Tests + * + * Copyright 2017 Raising the Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/GPII/universal/blob/master/LICENSE.txt + */ + +/* global fluid, jqUnit, gpii */ + +"use strict"; + +(function () { + // TODO: Rewrite all these tests into browser-style jqUnit tests, leaving just + // a stub tester here to test filesystem integration + + fluid.registerNamespace("gpii.tests"); + fluid.registerNamespace("gpii.tests.flexibleHandler"); + + + fluid.defaults("gpii.tests.flexibleHandler.assertDirective", { + gradeNames: "fluid.function", + argumentMap: {} + }); + + gpii.tests.flexibleHandler.assertDirective = function () { + jqUnit.assertTrue("Assertion block", true); + }; + + fluid.defaults("gpii.tests.flexibleHandler.failBlock", { + gradeNames: "fluid.function", + argumentMap: {} + }); + + gpii.tests.flexibleHandler.failBlock = function () { + jqUnit.assertTrue("Asserted that this block should not be called", false); + }; + + fluid.defaults("gpii.tests.flexibleHandler.returnTrue", { + gradeNames: "fluid.function", + argumentMap: {} + }); + + gpii.tests.flexibleHandler.returnTrue = function () { + return true; + }; + + fluid.defaults("gpii.tests.flexibleHandler.returnFalse", { + gradeNames: "fluid.function", + argumentMap: {} + }); + + gpii.tests.flexibleHandler.returnFalse = function () { + return false; + }; + + gpii.tests.flexibleHandler.assertBlock = { + "type": "gpii.tests.flexibleHandler.assertDirective" + }; + + gpii.tests.flexibleHandler.reportRunning = { + "type": "gpii.tests.flexibleHandler.returnTrue" + }; + + gpii.tests.flexibleHandler.reportNotRunning = { + "type": "gpii.tests.flexibleHandler.returnFalse" + }; + + gpii.tests.flexibleHandler.basicTestDefs = [ + { + description: "Passing true to handler if already running should not execute start block", + expect: 1, + input: { + settings: { + "running": true + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportRunning + } + }, + expectedSettings: { + "running": { + "newValue": true, + "oldValue": true + } + } + }, { + description: "Passing false to handler if already not running should not execute stop block", + expect: 1, + input: { + settings: { + "running": false + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + }, + expectedSettings: { + "running": { + "newValue": false, + "oldValue": false + } + } + }, { + description: "Passing true to handler if solution is not running should execute start block", + expect: 2, + input: { + settings: { + "running": true + }, + options: { + "setTrue": gpii.tests.flexibleHandler.assertBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + }, + expectedSettings: { + "running": { + "newValue": true, + "oldValue": false + } + } + }, { + description: "Passing false to handler if solution is running should execute stop block", + expect: 2, + input: { + settings: { + "running": false + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.assertBlock, + "getState": gpii.tests.flexibleHandler.reportRunning + } + }, + expectedSettings: { + "running": { + "newValue": false, + "oldValue": true + } + } + }, { + description: "Testing for multiple start blocks", + expect: 3, + input: { + settings: { + "running": true + }, + options: { + "setTrue": [ + gpii.tests.flexibleHandler.assertBlock, + gpii.tests.flexibleHandler.assertBlock + ], + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + }, + expectedSettings: { + "running": { + "newValue": true, + "oldValue": false + } + } + }, { + description: "Testing for multiple stop blocks", + expect: 3, + input: { + settings: { + "running": false + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": [ + gpii.tests.flexibleHandler.assertBlock, + gpii.tests.flexibleHandler.assertBlock + ], + "getState": gpii.tests.flexibleHandler.reportRunning + } + }, + expectedSettings: { + "running": { + "newValue": false, + "oldValue": true + } + } + } + ]; + + fluid.each(gpii.tests.flexibleHandler.basicTestDefs, function (spec) { + jqUnit.test(spec.description, function () { + jqUnit.expect(spec.expect); + var actual = gpii.launchHandlers.flexibleHandler.set({ + "my.solution1": [ + spec.input + ] + }); + // build expected return payload: + jqUnit.assertDeepEq("Return payload is correct", spec.expectedSettings, actual["my.solution1"][0].settings); + }); + }); + + gpii.tests.flexibleHandler.extraTestDefs = [ + { + description: "Multiple solution entries sent - both should attempt to start", + expect: 3, + input: { + "my.solution1": [ + { + settings: { + "running": true + }, + options: { + "setTrue": gpii.tests.flexibleHandler.assertBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ], + "my.solution2": [ + { + settings: { + "running": true + }, + options: { + "setTrue": gpii.tests.flexibleHandler.assertBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ] + }, + expected: { + "my.solution1": [ + { + settings: { + running: { + "newValue": true, + "oldValue": false + } + }, + options: { + "setTrue": gpii.tests.flexibleHandler.assertBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ], + "my.solution2": [ + { + settings: { + running: { + "newValue": true, + "oldValue": false + } + }, + options: { + "setTrue": gpii.tests.flexibleHandler.assertBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ] + } + }, + { + description: "Multiple solution entries sent - different actions", + expect: 2, + input: { + "my.solution1": [ + { + settings: { + "running": false + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.assertBlock, + "getState": gpii.tests.flexibleHandler.reportRunning + } + } + ], + "my.solution2": [ + { + settings: { + "running": false + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ] + }, + expected: { + "my.solution1": [ + { + settings: { + running: { + "newValue": false, + "oldValue": true + } + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.assertBlock, + "getState": gpii.tests.flexibleHandler.reportRunning + } + } + ], + "my.solution2": [ + { + settings: { + running: { + "newValue": false, + "oldValue": false + } + }, + options: { + "setTrue": gpii.tests.flexibleHandler.failBlock, + "setFalse": gpii.tests.flexibleHandler.failBlock, + "getState": gpii.tests.flexibleHandler.reportNotRunning + } + } + ] + } + } + ]; + + fluid.each(gpii.tests.flexibleHandler.extraTestDefs, function (spec) { + jqUnit.test(spec.description, function () { + jqUnit.expect(spec.expect); + var actual = gpii.launchHandlers.flexibleHandler.set(spec.input); + // build expected return payload: + jqUnit.assertDeepEq("Return payload is correct", spec.expected, actual); + }); + }); + + +})(); diff --git a/gpii/node_modules/settingsHandlers/test/web/js/SettingsHandlerUtilitiesTests.js b/gpii/node_modules/settingsHandlers/test/web/js/SettingsHandlerUtilitiesTests.js index d88a96cbe..d41c32833 100644 --- a/gpii/node_modules/settingsHandlers/test/web/js/SettingsHandlerUtilitiesTests.js +++ b/gpii/node_modules/settingsHandlers/test/web/js/SettingsHandlerUtilitiesTests.js @@ -26,6 +26,67 @@ fluid.registerNamespace("gpii.tests"); fluid.registerNamespace("gpii.tests.settingsHandlersUtilitiesTests"); + gpii.tests.settingsHandlersUtilitiesTests.filterSupportedSettingsSpecs = { + "If supportedSettings is undefined, return settings": { + settings: { + "weirdSetting": "foo" + }, + supportedSettings: undefined, + expected: { + "weirdSetting": "foo" + } + }, + "If settings is undefined, return undefined": { + settings: undefined, + supportedSettings: { + "weirdSetting": {} + }, + expected: undefined + }, + "Filter by supportedSettings": { + settings: { + "weirdSetting": "foo", + "otherSetting": "bar" + }, + supportedSettings: { + "weirdSetting": {} + }, + expected: { + "weirdSetting": "foo" + } + }, + "If supportedSettings directive is present - test no matching": { + settings: { + "weirdSetting": "foo", + "otherSetting": "bar" + }, + supportedSettings: { + "thirdSetting": {} + }, + expected: {} + }, + "Works with `undefined` values for settings (required when restoring)": { + settings: { + "weirdSetting": undefined, + "otherSetting": undefined + }, + supportedSettings: { + "weirdSetting": {} + }, + expected: { + "weirdSetting": undefined + } + } + }; + + jqUnit.test("filterSupportedSettings tests", function () { + fluid.each(gpii.tests.settingsHandlersUtilitiesTests, function (test, name) { + var result = gpii.settingsHandlers.filterSupportedSettings(test.settings, test.supportedSettings); + jqUnit.assertDeepEq(name, test.expected, result); + }); + }); + + jqUnit.test("settingsHandlers.setSettings", function () { // check simple json structure var result = gpii.settingsHandlers.setSettings( diff --git a/gpii/node_modules/testing/src/Mocks.js b/gpii/node_modules/testing/src/Mocks.js index 43dd690b6..d62d808db 100644 --- a/gpii/node_modules/testing/src/Mocks.js +++ b/gpii/node_modules/testing/src/Mocks.js @@ -216,7 +216,8 @@ fluid.defaults("gpii.test.integration.mockSettingsHandler", { }, setImpl: { funcName: "gpii.test.integration.mockSettingsHandler.setImpl", - args: ["{that}", "{arguments}.0"] + args: ["{that}", "{arguments}.0", "{arguments}.1"] + // set payload, solutionId }, get: { funcName: "gpii.test.integration.mockSettingsHandler.get", @@ -224,17 +225,18 @@ fluid.defaults("gpii.test.integration.mockSettingsHandler", { }, getImpl: { funcName: "gpii.test.integration.mockSettingsHandler.getImpl", - args: ["{that}", "{arguments}.0"] + args: ["{that}", "{arguments}.0", "{arguments}.1"] + // get payload, solutionId } } }); -gpii.test.integration.resolveHandlerKey = function (that, payload) { +gpii.test.integration.resolveHandlerKey = function (that, payload, solutionId) { var pathKey = that.options.optionsPathKey; if (typeof(pathKey) === "string") { return fluid.get(payload.options, pathKey); } else if (typeof(pathKey) === "function") { - return pathKey(payload.options); + return pathKey(payload.options, solutionId); } }; @@ -269,9 +271,9 @@ gpii.test.integration.mockSettingsHandler.returnAsyncResponse = function (value, } }; -gpii.test.integration.mockSettingsHandler.setImpl = function (that, payload) { +gpii.test.integration.mockSettingsHandler.setImpl = function (that, payload, solutionId) { var setSettings = function () { - var key = gpii.test.integration.resolveHandlerKey(that, payload); + var key = gpii.test.integration.resolveHandlerKey(that, payload, solutionId); var oldStore = fluid.copy(that.settingsStore[key]) || {}; var store = (that.settingsStore[key] = that.settingsStore[key] || {}); var applySettings = function () { @@ -293,8 +295,8 @@ gpii.test.integration.mockSettingsHandler.set = function (that, payload) { return gpii.settingsHandlers.invokeSettingsHandler(that.setImpl, payload); }; -gpii.test.integration.mockSettingsHandler.getImpl = function (that, payload) { - var key = gpii.test.integration.resolveHandlerKey(that, payload); +gpii.test.integration.mockSettingsHandler.getImpl = function (that, payload, solutionId) { + var key = gpii.test.integration.resolveHandlerKey(that, payload, solutionId); var store = that.settingsStore[key] || {}; var response = fluid.transform(payload.settings, function (value, key) { return store[key]; @@ -313,6 +315,14 @@ gpii.test.integration.registrySettingsHandlerKey = function (options) { return options.hKey + "|" + options.path; }; +gpii.test.integration.flexibleHandlerKey = function (options, solutionId) { + return solutionId + ".flexibleHandler"; +}; + +gpii.test.integration.gsettingsLaunchKey = function (options) { + return options.schema + "|" + options.key; +}; + fluid.defaults("gpii.test.integration.mockSettingsHandlerRegistry", { gradeNames: ["fluid.component"], rootPath: "gpii.test.integration.mockSettingsHandlers", // the global names for mocks will be deposited in here @@ -370,6 +380,9 @@ fluid.defaults("gpii.test.integration.mockSettingsHandlerRegistry.universal", { "gpii.settingsHandlers.JSONSettingsHandler": { optionsPathKey: "filename" }, + "gpii.launchHandlers.flexibleHandler": { + optionsPathKey: gpii.test.integration.flexibleHandlerKey + }, "gpii.settingsHandlers.webSockets" : {} } }); @@ -384,7 +397,10 @@ fluid.defaults("gpii.test.integration.mockSettingsHandlerRegistry.windows", { // delaying: true, optionsPathKey: "setAction" }, - "gpii.windows.displaySettingsHandler": {} + "gpii.windows.displaySettingsHandler": {}, + "gpii.windows.enableRegisteredAT": { + optionsPathKey: "registryName" + } } }); @@ -404,6 +420,9 @@ fluid.defaults("gpii.test.integration.mockSettingsHandlerRegistry.linux", { }, "gpii.xrandr": { optionsPathKey: "NONE" + }, + "gpii.gsettings.launch": { + optionsPathKey: gpii.test.integration.gsettingsLaunchKey } } }); diff --git a/gpii/node_modules/testing/src/Testing.js b/gpii/node_modules/testing/src/Testing.js index 8f123b3f4..f53355467 100644 --- a/gpii/node_modules/testing/src/Testing.js +++ b/gpii/node_modules/testing/src/Testing.js @@ -133,7 +133,7 @@ gpii.test.operateSettings = function (settingsHandlers, nameResolver, method) { var ret = {}; fluid.each(settingsHandlers, function (handlerBlock, handlerID) { var resolvedName = nameResolver ? nameResolver.resolveName(handlerID, "settingsHandler") : handlerID; - var response = fluid.invokeGlobalFunction(resolvedName + "." + method, [handlerBlock]); + var response = gpii.settingsHandlers.dispatchSettingsHandler(resolvedName, handlerBlock, method); ret[handlerID] = response; }); var togo = gpii.test.settleStructure(ret); @@ -143,6 +143,15 @@ gpii.test.operateSettings = function (settingsHandlers, nameResolver, method) { return togo; }; +/** + * Used for settings the initial settings of an application. This is among other used for tests + * where an application needs to be running on user login + */ +gpii.test.setInitialSettingsState = function (settingsHandlers, nameResolver, onComplete) { + var promise = gpii.test.setSettings(settingsHandlers, nameResolver); + promise.then(onComplete); +}; + /** Snapshot the state of all settingsHandlers by stashing them in a member named `orig` on the supplied settingsStore * @param settingsHandlers {Object} A map of settings handler names to `settingsHandler` blocks as seen in the `settingsHandlers` * option of a `gpii.test.common.testCaseHolder` @@ -155,7 +164,8 @@ gpii.test.operateSettings = function (settingsHandlers, nameResolver, method) { gpii.test.snapshotSettings = function (settingsHandlers, settingsStore, nameResolver, onComplete) { var origPromise = gpii.test.getSettings(settingsHandlers, nameResolver); origPromise.then(function (origSettings) { - settingsStore.orig = origSettings; + // any settings already defined in settingsStore.org overwrites the ones read by snapshotter + settingsStore.orig = fluid.extend(true, origSettings, settingsStore.orig); onComplete(); }); }; @@ -169,19 +179,15 @@ gpii.test.extractSettingsBlocks = function (settingsHandlers) { return fluid.transform(settingsHandlers, gpii.settingsHandlers.extractSettingsBlocks); }; -gpii.test.checkConfiguration = function (settingsHandlers, nameResolver, onComplete) { +gpii.test.checkConfiguration = function (settingsHandlers, nameResolver, onComplete, customMsg) { var configPromise = gpii.test.getSettings(settingsHandlers, nameResolver); configPromise.then(function (config) { var noOptions = gpii.test.extractSettingsBlocks(settingsHandlers); - jqUnit.assertDeepEq("Checking that settings are set", noOptions, config); + jqUnit.assertDeepEq(customMsg || "Checking that settings are set", noOptions, config); onComplete(); }); }; -gpii.test.onExecExit = function (result, processSpec) { - jqUnit.assertTrue("Checking the process with command: " + processSpec, result); -}; - gpii.test.logoutRequestListen = function (data) { jqUnit.assertNotEquals("Successful logout message returned " + data, -1, data.indexOf("was successfully logged out.")); @@ -195,6 +201,19 @@ gpii.test.checkRestoredConfiguration = function (settingsHandlers, settingsStore }); }; +gpii.test.checkRestoredInitialState = function (initialSettings, nameResolver, onComplete) { + if (initialSettings === undefined) { + jqUnit.assertTrue("No initial settings defined, so not checking", true); + onComplete(); + return; + } + var currentSettingsPromise = gpii.test.getSettings(initialSettings, nameResolver); + currentSettingsPromise.then(function (currentSettings) { + jqUnit.assertDeepEq("Checking that initital settings are also properly reset", gpii.test.extractSettingsBlocks(initialSettings), currentSettings); + onComplete(); + }); +}; + gpii.test.common.receiveVariableResolver = function (testCaseHolder, variableResolver) { testCaseHolder.variableResolver = variableResolver; }; @@ -233,12 +252,16 @@ fluid.defaults("gpii.test.common.testCaseHolder", { settingsStore: {} }, mergePolicy: { - "settingsHandlers": "noexpand" + "settingsHandlers": "noexpand", + "initialState": "noexpand" }, events: { onSnapshotComplete: null, + onInitialStateSet: null, + onInitialStateConfirmed: null, onCheckConfigurationComplete: null, - onCheckRestoredConfigurationComplete: null + onCheckRestoredConfigurationComplete: null, + onCheckRestoredInitialStateComplete: null }, distributeOptions: { "common.testCaseHolder.variableResolver": { @@ -299,26 +322,6 @@ gpii.test.common.receiveComponent = function (testCaseHolder, component, name) { }; -// Will return the part of a test sequence that tests for the process state based on the -// 'expectedKey' parameter -gpii.test.createProcessChecks = function (processList, expectedKey) { - var sequence = []; - // For each process, run the command, then check that we get the expected output - fluid.each(processList, function (process, pindex) { - sequence.push({ - func: "{exec}.exec", - args: [ - fluid.model.composeSegments("{tests}.options.processes", pindex), - fluid.model.composeSegments("{tests}.options.processes", pindex, expectedKey) - ] - }, { - event: "{exec}.events.onExecExit", - listener: "gpii.test.onExecExit" - }); - }); - return sequence; -}; - /** Expand material in a `gpii.test.common.testCaseHolder` fixture's options using the variableResolver fished out of the real implementation, * and place it at a public member for the assertions to use * @param testCaseHolder {gpii.test.common.testCaseHolder} a testCaseHolder with some expandable material in its options @@ -334,7 +337,26 @@ gpii.test.expandSettings = function (testCaseHolder, members) { }; // TODO: remove these clumsy constants once https://issues.fluidproject.org/browse/FLUID-5903 is implemented -gpii.test.initialSequence = fluid.freezeRecursive([ +gpii.test.initalStateSequence = fluid.freezeRecursive([ + { + func: "gpii.test.expandSettings", + args: [ "{tests}", "initialState" ] + }, { + func: "gpii.test.setInitialSettingsState", + args: [ "{tests}.initialState", "{nameResolver}", "{testCaseHolder}.events.onInitialStateSet.fire"] + }, { + event: "{testCaseHolder}.events.onInitialStateSet", + listener: "fluid.identity" + }, { + func: "gpii.test.checkConfiguration", + args: ["{tests}.initialState", "{nameResolver}", "{testCaseHolder}.events.onInitialStateConfirmed.fire", "Confirming initial state"] + }, { + event: "{testCaseHolder}.events.onInitialStateConfirmed", + listener: "fluid.identity" + } +]); + +gpii.test.snapshotSequence = fluid.freezeRecursive([ { func: "gpii.test.expandSettings", args: [ "{tests}", "settingsHandlers" ] @@ -378,6 +400,12 @@ gpii.test.checkSequence = fluid.freezeRecursive([ }, { event: "{testCaseHolder}.events.onCheckRestoredConfigurationComplete", listener: "fluid.identity" + }, { // anything in the intial state should also be restored upon logout + func: "gpii.test.checkRestoredInitialState", + args: [ "{tests}.initialState", "{nameResolver}", "{testCaseHolder}.events.onCheckRestoredInitialStateComplete.fire"] + }, { + event: "{testCaseHolder}.events.onCheckRestoredInitialStateComplete", + listener: "fluid.identity" } ]); @@ -393,25 +421,21 @@ gpii.test.push = function (array, elements) { /** Build a test fixture for integration/acceptance tests operating the stereotypical workflow - * snapshot, login, expectConfigured, logout and expectRestored */ - gpii.test.buildSingleTestFixture = function (testDef, rootGrades) { - var processes = testDef.processes || []; testDef.gradeNames = fluid.makeArray(testDef.gradeNames).concat(fluid.makeArray(rootGrades)); - testDef.expect = 4 + processes.length * 2; + testDef.expect = 5; testDef.sequence = fluid.makeArray(testDef.sequence); gpii.test.unshift(testDef.sequence, gpii.test.loginSequence); - gpii.test.unshift(testDef.sequence, gpii.test.initialSequence); - - // For each process, run the command, then check that we get the expected output - testDef.sequence = testDef.sequence.concat(gpii.test.createProcessChecks(processes, "expectConfigured")); + gpii.test.unshift(testDef.sequence, gpii.test.snapshotSequence); + if (testDef.initialState) { + gpii.test.unshift(testDef.sequence, gpii.test.initalStateSequence); + testDef.expect++; + } gpii.test.push(testDef.sequence, gpii.test.logoutSequence); - // Check that the processes are in the expected state after logout - testDef.sequence = testDef.sequence.concat(gpii.test.createProcessChecks(processes, "expectRestored")); - gpii.test.push(testDef.sequence, gpii.test.checkSequence); return testDef; @@ -443,8 +467,8 @@ gpii.test.recordToTestDefs = function (record) { var testDefs = fluid.copy(fluid.getGlobalValue(record.testDefs)); fluid.each(testDefs, function (testDef) { testDef.config = { - configName: record.configName, - configPath: record.configPath + configName: testDef.configName || record.configName, + configPath: testDef.configPath || record.configPath }; }); return testDefs; diff --git a/gpii/node_modules/transformer/src/js/Transformer.js b/gpii/node_modules/transformer/src/js/Transformer.js index e2816e49f..b24ccb225 100644 --- a/gpii/node_modules/transformer/src/js/Transformer.js +++ b/gpii/node_modules/transformer/src/js/Transformer.js @@ -37,8 +37,8 @@ fluid.registerNamespace("gpii.transformer"); * @return {Object} - the modified settingshandler object - ready to be passed to the lifecycle manager */ gpii.transformer.transformOneSettingsHandler = function (settingsHandler, oneUserSolution, solutionId) { - // TODO GPII-1223: throw app specific settings in the correct locations if there are multiple handlers var settings = fluid.copy(oneUserSolution.settings["http://registry.gpii.net/applications/" + solutionId]); + // extract any common terms that were defined in the application block and delete them from the settings block var scopedCommon = {}; fluid.each(settings, function (val, key) { @@ -48,13 +48,16 @@ fluid.registerNamespace("gpii.transformer"); } }); + // filter to only keep relevant application specific settings + settings = gpii.settingsHandlers.filterSupportedSettings(settings, settingsHandler.supportedSettings); + if (settingsHandler.capabilitiesTransformations) { var inferred = fluid.model.transformWithRules(oneUserSolution.settings, settingsHandler.capabilitiesTransformations); var inferredScoped = (scopedCommon === undefined || $.isEmptyObject(scopedCommon)) ? {} : fluid.model.transformWithRules(scopedCommon, settingsHandler.capabilitiesTransformations); settings = fluid.extend(true, {}, inferred, inferredScoped, settings); } - settingsHandler.settings = settings; + settingsHandler.settings = settings || {}; delete settingsHandler.capabilitiesTransformations; delete settingsHandler.capabilities; return settingsHandler; diff --git a/gpii/node_modules/transformer/test/html/TransformerTests.html b/gpii/node_modules/transformer/test/html/TransformerTests.html index fa0cb2373..89f60b398 100644 --- a/gpii/node_modules/transformer/test/html/TransformerTests.html +++ b/gpii/node_modules/transformer/test/html/TransformerTests.html @@ -19,6 +19,7 @@ + diff --git a/gpii/node_modules/transformer/test/js/TransformerTests.js b/gpii/node_modules/transformer/test/js/TransformerTests.js index a90d94969..5a313314f 100644 --- a/gpii/node_modules/transformer/test/js/TransformerTests.js +++ b/gpii/node_modules/transformer/test/js/TransformerTests.js @@ -37,7 +37,7 @@ fluid.setLogging(true); } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -54,6 +54,14 @@ fluid.setLogging(true); } }, "capabilities": [], + "supportedSettings": { + "Invert": {}, + "Magnification": {}, + "FollowMouse": {}, + "FollowCaret": {}, + "FollowFocus": {}, + "MagnificationMode": {} + }, "capabilitiesTransformations": { "Invert": "http://registry\\.gpii\\.net/common/invertColours", "Magnification": { @@ -130,7 +138,7 @@ fluid.setLogging(true); } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.XMLHandler.set", "options": { @@ -196,7 +204,7 @@ fluid.setLogging(true); } }; - var testFixtures = [ + gpii.tests.transformer.configurationToSettingsTestSpecs = [ { name: "Application specific settings for the same application", input: { @@ -222,7 +230,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -243,10 +251,64 @@ fluid.setLogging(true); "FollowFocus": 0, "FollowMouse": 1, "Invert": false + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings + } + } + } + } + }, { + name: "Application specific settings filtered by supported settings", + input: { + "applications": { + "com.microsoft.windows.magnifier": { + "active": true, + "settings": { + "http://registry.gpii.net/applications/com.microsoft.windows.magnifier": { + "FollowFocus": 0, + "FollowCaret": 1, + "FollowMouse": 1, + "Invert": false, + "wrongSetting": 200 } } } } + }, + expected: { + "com.microsoft.windows.magnifier": { + "active": true, + "name": testSolutionsEntry["com.microsoft.windows.magnifier"].name, + "start": testSolutionsEntry["com.microsoft.windows.magnifier"].start, + "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, + "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, + "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, + "handlers": { + "conf": { + "type": "gpii.windows.registrySettingsHandler.set", + "options": { + "dataTypes": { + "FollowCaret": "REG_DWORD", + "FollowFocus": "REG_DWORD", + "FollowMouse": "REG_DWORD", + "Invert": "REG_DWORD", + "Magnification": "REG_DWORD", + "MagnificationMode": "REG_DWORD", + "ZoomIncrement": "REG_DWORD" + }, + "hKey": "HKEY_CURRENT_USER", + "path": "Software\\Microsoft\\ScreenMagnifier" + }, + "settings": { + "FollowCaret": 1, + "FollowFocus": 0, + "FollowMouse": 1, + "Invert": false + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings + } + } + } } }, { name: "Common terms only", @@ -268,7 +330,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -288,13 +350,14 @@ fluid.setLogging(true); "FollowCaret": 1, "FollowFocus": 0, "FollowMouse": 1 - } + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings } } } } }, { - name: "Application scoped common terms are converted to application specific files", + name: "Application scoped common terms are converted to application specific settings", input: { "applications": { "com.microsoft.windows.magnifier": { @@ -315,7 +378,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -331,6 +394,7 @@ fluid.setLogging(true); "hKey": "HKEY_CURRENT_USER", "path": "Software\\Microsoft\\ScreenMagnifier" }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings, "settings": { "Invert": true } @@ -361,7 +425,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -377,6 +441,7 @@ fluid.setLogging(true); "hKey": "HKEY_CURRENT_USER", "path": "Software\\Microsoft\\ScreenMagnifier" }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings, "settings": { "Invert": true } @@ -408,7 +473,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -427,7 +492,8 @@ fluid.setLogging(true); "settings": { "Invert": false, "FollowFocus": 0 - } + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings } } } @@ -456,7 +522,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -475,7 +541,8 @@ fluid.setLogging(true); "settings": { "Invert": false, "FollowFocus": 0 - } + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings } } } @@ -503,7 +570,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -521,7 +588,8 @@ fluid.setLogging(true); }, "settings": { "Invert": false - } + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings } } } @@ -554,7 +622,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["com.microsoft.windows.magnifier"].stop, "configure": testSolutionsEntry["com.microsoft.windows.magnifier"].configure, "restore": testSolutionsEntry["com.microsoft.windows.magnifier"].restore, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.windows.registrySettingsHandler.set", "options": { @@ -572,7 +640,8 @@ fluid.setLogging(true); }, "settings": { "Invert": false - } + }, + "supportedSettings": testSolutionsEntry["com.microsoft.windows.magnifier"].settingsHandlers.conf.supportedSettings } } }, @@ -583,7 +652,7 @@ fluid.setLogging(true); "stop": testSolutionsEntry["eu.singularlogic.pixelsense.sociable"].stop, "configure": testSolutionsEntry["eu.singularlogic.pixelsense.sociable"].configure, "restore": testSolutionsEntry["eu.singularlogic.pixelsense.sociable"].restore, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.XMLHandler.set", "options": { @@ -632,7 +701,7 @@ fluid.setLogging(true); jqUnit.module("Tester"); jqUnit.test("Transformation tests", function () { - fluid.each(testFixtures, function (test) { + fluid.each(gpii.tests.transformer.configurationToSettingsTestSpecs, function (test) { var result = gpii.transformer.configurationToSettings(test.input, testSolutionsEntry); jqUnit.assertDeepEq(test.name, test.expected, result); }); diff --git a/testData/deviceReporter/acceptanceTests/linux_builtIn.json b/testData/deviceReporter/acceptanceTests/linux_builtIn.json index e0fbf462b..23b554fb1 100644 --- a/testData/deviceReporter/acceptanceTests/linux_builtIn.json +++ b/testData/deviceReporter/acceptanceTests/linux_builtIn.json @@ -10,5 +10,8 @@ }, { "id": "org.gnome.desktop.a11y.keyboard" + }, + { + "id": "org.gnome.desktop.a11y.applications.onscreen-keyboard" } ] diff --git a/testData/deviceReporter/installedSolutions.json b/testData/deviceReporter/installedSolutions.json index 661255cba..3718082dc 100644 --- a/testData/deviceReporter/installedSolutions.json +++ b/testData/deviceReporter/installedSolutions.json @@ -8,11 +8,11 @@ }, { - "id": "org.gnome.shell.overrides" + "id": "fakemag2" }, { - "id": "org.gnome.desktop.wm.preferences" + "id": "fakescreenreader1" }, { diff --git a/testData/preferences/acceptanceTests/os_common.json b/testData/preferences/acceptanceTests/os_common.json index ce069a2cc..fc3f21153 100644 --- a/testData/preferences/acceptanceTests/os_common.json +++ b/testData/preferences/acceptanceTests/os_common.json @@ -16,8 +16,9 @@ "http://registry.gpii.net/common/cursorAcceleration": 1, "http://registry.gpii.net/common/cursorSpeed": 1, "http://registry.gpii.net/common/stickyKeys": true, - "http://registry.gpii.net/common/debounceEnabled": true, - "http://registry.gpii.net/common/debounceInterval": 1 + "http://registry.gpii.net/common/debounceEnable": true, + "http://registry.gpii.net/common/debounceInterval": 1, + "http://registry.gpii.net/common/onScreenKeyboardEnabled": true } } } diff --git a/testData/processReporter/runningSolutions.json b/testData/processReporter/runningSolutions.json deleted file mode 100644 index 8abfd8459..000000000 --- a/testData/processReporter/runningSolutions.json +++ /dev/null @@ -1,172 +0,0 @@ -[ - { - "id": "org.gnome.desktop.interface", - "runnning": true - }, - - { - "id": "org.gnome.shell.overrides", - "runnning": true - }, - - { - "id": "org.gnome.desktop.wm.preferences", - "runnning": true - }, - - { - "id": "org.gnome.nautilus", - "runnning": true - }, - - { - "id": "org.gnome.desktop.a11y.keyboard", - "runnning": true - }, - - { - "id": "org.gnome.desktop.a11y.applications.onscreen-keyboard", - "runnning": true - }, - - { - "id": "org.gnome.orca", - "runnning": true - }, - - { - "id": "org.gnome.desktop.a11y.magnifier", - "runnning": true - }, - - { - "id": "com.microsoft.windows.magnifier", - "runnning": true - }, - - { - "id": "com.microsoft.windows.onscreenKeyboard", - "runnning": true - }, - - { - "id": "org.nvda-project", - "runnning": true - }, - - { - "id": "org.gnome.desktop.interface", - "runnning": true - }, - - { - "id": "org.gnome.nautilus", - "runnning": true - }, - - { - "id": "trace.easyOne.communicator.windows", - "runnning": true - }, - - { - "id": "trace.easyOne.communicator.linux", - "runnning": true - }, - - { - "id": "trace.easyOne.sudan.windows", - "runnning": true - }, - - { - "id": "trace.easyOne.sudan.linux", - "runnning": true - }, - - { - "id": "webinsight.webAnywhere.windows", - "runnning": true - }, - - { - "id": "webinsight.webAnywhere.linux", - "runnning": true - }, - - { - "id": "com.texthelp.readWriteGold", - "runnning": true - }, - - { - "id": "net.opendirective.maavis", - "runnning": true - }, - - { - "id": "com.microsoft.windows.highContrast", - "runnning": true - }, - - { - "id": "com.microsoft.windows.mouseTrailing", - "runnning": true - }, - - { - "id": "com.microsoft.windows.cursors", - "runnning": true - }, - - { - "id": "com.android.activitymanager", - "runnning": true - }, - - { - "id": "com.android.talkback", - "runnning": true - }, - - { - "id": "com.android.freespeech", - "runnning": true - }, - - { - "id": "org.chrome.cloud4chrome", - "runnning": true - }, - - { - "id": "com.android.settings.secure", - "runnning": true - }, - - { - "id": "com.android.audioManager", - "runnning": true - }, - - { - "id": "com.android.persistentConfiguration", - "runnning": true - }, - - { - "id": "org.alsa-project", - "runnning": true - }, - - { - "id": "org.freedesktop.xrandr", - "runnning": true - }, - - { - "id": "com.android.settings.system", - "runnning": true - } - -] diff --git a/testData/solutions/android.json5 b/testData/solutions/android.json5 index 0bd3bed6c..33d9f3e46 100644 --- a/testData/solutions/android.json5 +++ b/testData/solutions/android.json5 @@ -7,18 +7,30 @@ "version": ">=0.1" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/screenReaderTTSEnabled" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.androidActivityManager.startFreespeech" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.androidActivityManager.startFreespeech" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ] }, @@ -30,23 +42,36 @@ "version": ">=0.1" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/screenReaderTTSEnabled" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.androidActivityManager.startTalkback" + }, + "setFalse": { + "type": "gpii.androidActivityManager.stopTalkback" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.androidActivityManager.startTalkback" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.androidActivityManager.stopTalkback" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ] }, @@ -60,7 +85,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.androidPersistentConfiguration", "supportedSettings": { @@ -164,7 +189,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.androidAudioManager.volume", "supportedSettings": { @@ -219,7 +244,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.androidSettings", "options": { @@ -288,7 +313,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.androidSettings", "options": { @@ -373,7 +398,7 @@ "version": ">=0.1" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.XMLHandler", "supportedSettings": { @@ -415,28 +440,43 @@ } }, "inverseCapabilitiesTransformations": {} + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.androidActivityManager.startActivityByPackageName", + "packageName": "se.omnitor.ecmobile" + }, + "setFalse": [ + { + "type": "gpii.androidActivityManager.stopActivityByPackageName", + "packageName": "se.omnitor.ecmobile" + }, + { + "type": "gpii.androidActivityManager.goToHomeScreen" + } + ], + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, + "start": [ + "settings.launcher" + ], + "stop": [ + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" + ], "configure": [ "settings.configuration" ], "restore": [ "settings.configuration" - ], - "start": [ - { - "type": "gpii.androidActivityManager.startActivityByPackageName", - "packageName": "se.omnitor.ecmobile" - } - ], - "stop": [ - { - "type": "gpii.androidActivityManager.stopActivityByPackageName", - "packageName": "se.omnitor.ecmobile" - }, - { - "type": "gpii.androidActivityManager.goToHomeScreen" - } ] }, @@ -450,7 +490,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { diff --git a/testData/solutions/darwin.json5 b/testData/solutions/darwin.json5 index c5117ea61..98d09b9a8 100644 --- a/testData/solutions/darwin.json5 +++ b/testData/solutions/darwin.json5 @@ -8,7 +8,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -46,7 +46,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -85,7 +85,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { diff --git a/testData/solutions/linux.json5 b/testData/solutions/linux.json5 index 1dbbb1dde..85e755e11 100644 --- a/testData/solutions/linux.json5 +++ b/testData/solutions/linux.json5 @@ -9,7 +9,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "options": { @@ -83,6 +83,16 @@ } ] } + }, + "launcher": { + "type": "gpii.gsettings.launch", + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + }, + "supportedSettings": { + "running": {} + } } }, "update": [ @@ -95,34 +105,19 @@ "settings.configuration" ], "start": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-magnifier-enabled true" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-magnifier-enabled false" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { "type": "gpii.packageKit.find", "name": "gnome-shell" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "gnome-shell" - }, - { - "type": "gpii.processReporter.checkSetting", - "schema": "org.gnome.desktop.a11y.applications", - "setting": "screen-magnifier-enabled", - "value": true - } ] }, @@ -136,7 +131,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "supportedSettings": { @@ -245,12 +240,6 @@ "type": "gpii.packageKit.find", "name": "gsettings-desktop-schemas" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "dunno" - } ] }, @@ -263,7 +252,7 @@ }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "supportedSettings": { @@ -290,12 +279,6 @@ "type": "gpii.packageKit.find", "name": "nautilus" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "nautilus" - } ] }, @@ -307,37 +290,37 @@ "version": ">=2.6.26" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/onScreenKeyboardEnabled" ] + }, + "launching": { + "type": "gpii.gsettings.launch", + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } } }, + "update": [ + ], "start": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true" - } + "settings.launching" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false" - } + "settings.launching" + ], + "isRunning": [ + "settings.launching" ], "isInstalled": [ { "type": "gpii.packageKit.find", "name": "gnome-shell" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "caribou" - } ] }, @@ -349,7 +332,7 @@ "version": ">=2.6.26" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "supportedSettings": { @@ -421,12 +404,6 @@ "type": "gpii.packageKit.find", "name": "gsettings-desktop-schemas" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "gnome-settings-daemon" - } ] }, @@ -439,7 +416,7 @@ }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "capabilities": [], @@ -471,7 +448,7 @@ }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.gsettings", "capabilities": [ @@ -503,7 +480,7 @@ "version": ">=2.6.26" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.orca", "options": { @@ -1121,8 +1098,20 @@ } ] } + }, + "launcher": { + "type": "gpii.gsettings.launch", + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } } }, + "update": [ + "stop", + "configure", + "start" + ], "configure": [ "settings.configuration" ], @@ -1130,28 +1119,19 @@ "settings.configuration" ], "start": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled true" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled false" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { "type": "gpii.packageKit.find", "name": "orca" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "orca" - } ] }, @@ -1165,7 +1145,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.alsa", "supportedSettings": { @@ -1201,12 +1181,6 @@ "type": "gpii.packageKit.find", "name": "alsa-lib" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "alsactl" - } ] }, @@ -1220,25 +1194,38 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/simplification" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "google-chrome http://easyone.gpii.net/user/${{userToken}}" + }, + "setFalse": { + "type": "gpii.launch.exec", + "command": "pkill -2 chrome" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.launch.exec", - "command": "google-chrome http://easyone.gpii.net/user/${{userToken}}" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "pkill -2 chrome" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { @@ -1253,12 +1240,6 @@ "type": "gpii.packageKit.find", "name": "google-chrome-unstable" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "chrome" - } ] }, @@ -1272,25 +1253,38 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/simplification" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "google-chrome http://easyone.gpii.net/sudan" + }, + "setFalse": { + "type": "gpii.launch.exec", + "command": "pkill -2 chrome" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.launch.exec", - "command": "google-chrome http://easyone.gpii.net/sudan" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "pkill -2 chrome" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { @@ -1305,12 +1299,6 @@ "type": "gpii.packageKit.find", "name": "google-chrome-unstable" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "chrome" - } ] }, @@ -1324,25 +1312,38 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/screenReaderTTSEnabled" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "google-chrome http://webanywhere.cs.washington.edu/beta/?starting_url=http%3A%2F%2Fcloud4all.info" + }, + "setFalse": { + "type": "gpii.launch.exec", + "command": "pkill -2 chrome" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.launch.exec", - "command": "google-chrome http://webanywhere.cs.washington.edu/beta/?starting_url=http%3A%2F%2Fcloud4all.info" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "pkill -2 chrome" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { @@ -1357,12 +1358,6 @@ "type": "gpii.packageKit.find", "name": "google-chrome-unstable" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "chrome" - } ] }, @@ -1374,7 +1369,7 @@ "version": ">=2.6.26" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.xrandr", "capabilities": [], @@ -1386,14 +1381,8 @@ "configure": [ "settings.configuration" ], - "stop": [ + "restore": [ "settings.configuration" - ], - "isInstalled": [ - { - "type": "gpii.packageKit.find", - "name": "libXrandr" - } ] }, @@ -1401,11 +1390,11 @@ "name": "UIO+", "contexts": { "OS": [{ - "id": "win32", - "version": ">=5.0" + "id": "linux", + "version": ">=5.0" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.webSockets", "options": { @@ -1516,8 +1505,6 @@ "restore": [ "settings.configuration" ], - "start": [], - "stop": [], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" diff --git a/testData/solutions/web.json5 b/testData/solutions/web.json5 index 18aac81e9..5f0c80442 100644 --- a/testData/solutions/web.json5 +++ b/testData/solutions/web.json5 @@ -8,7 +8,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -79,7 +79,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "myconf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -187,7 +187,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -283,7 +283,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -356,7 +356,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -424,14 +424,16 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { "language": {}, "contrastTheme": {}, "fontSize": {}, - "timeOut": {} + "timeOut": {}, + "buttonSize": {}, + "fontFace": {} }, "capabilities": [ "http://registry\\.gpii\\.net/common/highContrastTheme", @@ -499,7 +501,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "conf": { "type": "gpii.settingsHandlers.noSettings", "supportedSettings": { @@ -511,8 +513,14 @@ "signLanguageEnabled": {}, "signLanguage": {}, "interpreterType": {}, + "interpreterName": {}, "pictogramsEnabled": {}, - "simplifiedUiEnabled": {} + "simplifiedUiEnabled": {}, + "textStyle": {}, + "lineSpacing": {}, + "contrastTheme": {}, + "inputsLarger": {} + }, "capabilities": [ "http://registry\\.gpii\\.net/common/highContrastTheme", @@ -598,4 +606,3 @@ } } } - diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 330940903..384990f7b 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -8,7 +8,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration1": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -554,11 +554,6 @@ "inverseCapabilitiesTransformations": { "http://registry\\.gpii\\.net/common/speechSynthesizer": "Options\\.PrimarySynthesizer", "http://registry\\.gpii\\.net/common/speechRate": "ENU-Global\\.Rate", - "http://registry\\.gpii\\.net/common/speechRate": "ENU-JAWSCursor\\.Rate", - "http://registry\\.gpii\\.net/common/speechRate": "ENU-Keyboard\\.Rate", - "http://registry\\.gpii\\.net/common/speechRate": "ENU-MenuAndDialog\\.Rate", - "http://registry\\.gpii\\.net/common/speechRate": "ENU-Message\\.Rate", - "http://registry\\.gpii\\.net/common/speechRate": "ENU-PCCursor\\.Rate", "http://registry\\.gpii\\.net/common/pitch": { "transform": { "type": "fluid.transforms.linearScale", @@ -612,6 +607,42 @@ } } } + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20 + }, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "jfw" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\JAWS17.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "jfw.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "fsSynth32.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "jhookldr.exe" + } + ] + } } }, "configure": [ @@ -628,16 +659,18 @@ "start" ], "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\JAWS17.exe\\}\"" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "jfw.exe" - } + "settings.launcher" + ], + "update": [ + "stop", + "configure", + "start" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { @@ -647,12 +680,6 @@ "subPath": "", "dataType": "REG_SZ" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "jaws" - } ] }, @@ -666,7 +693,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.XMLHandler", "options": { @@ -702,6 +729,34 @@ "ApplicationSettings.Spelling.SpellAsIType.$t": {}, "ApplicationSettings.Speech.optAutoUseScreenReading.$t": {} } + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "verifySettings": true, + "retryOptions": { + rewriteEvery: 0, + numRetries: 40 + }, + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_CURRENT_USER\\Software\\Texthelp\\Read&Write11\\InstallPath}\\ReadAndWrite.exe\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "ReadAndWrite.exe" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "ReadAndWrite" + } + ] + } } }, "configure": [ @@ -716,16 +771,18 @@ "start" ], "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_CURRENT_USER\\Software\\Texthelp\\Read&Write11\\InstallPath}\\ReadAndWrite.exe\"" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "ReadAndWrite.exe" - } + "settings.launcher" + ], + "update": [ + "stop", + "configure", + "start" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { @@ -735,12 +792,6 @@ "subPath": "InstallPath", "dataType": "REG_SZ" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "readandwrite" - } ] }, @@ -754,7 +805,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.registrySettingsHandler", "options": { @@ -908,43 +959,45 @@ } ] } + }, + "launcher": { + "type": "gpii.windows.enableRegisteredAT", + "options": { + "verifySettings": true, + "retryOptions": { + "rewriteEvery": 0, + "numRetries": 20, + "retryInterval": 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } } }, - "configure": [ - "settings.configure" - ], - "restore": [ - "settings.configure" - ], "start": [ - { - "type": "gpii.windows.enableRegisteredAT", - "name": "magnifierpane", - "enable": true - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.enableRegisteredAT", - "name": "magnifierpane", - "enable": false - } + "settings.launcher" ], "update": [ "stop", "configure", "start" ], + "isRunning": [ + "settings.launcher" + ], + "configure": [ + "settings.configure" + ], + "restore": [ + "settings.configure" + ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "Magnify" - } ] }, @@ -958,7 +1011,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.registrySettingsHandler", "options": { @@ -986,38 +1039,39 @@ "literalValue": 0 } } + }, + "launcher": { + "type": "gpii.windows.enableRegisteredAT", + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } } }, + "start": [ + "settings.launcher" + ], + "stop": [ + "settings.launcher" + ], + "update": [ + "stop", + "configure", + "start" + ], + "isRunning": [ + "settings.launcher" + ], "configure": [ "settings.configure" ], "restore": [ "settings.configure" ], - "start": [ - { - "type": "gpii.windows.enableRegisteredAT", - "name": "osk", - "enable": true - } - ], - "stop": [ - { - "type": "gpii.windows.enableRegisteredAT", - "name": "osk", - "enable": false - } - ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "osk" - } ] }, @@ -1032,7 +1086,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.registrySettingsHandler", "options": { @@ -1308,7 +1362,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configs": { "type": "gpii.settingsHandlers.INISettingsHandler", "options": { @@ -1475,7 +1529,6 @@ "grc": "test\\grc", "eo": "eo", "es": "es", - "es-ES": "es", "es-419": "es-la", "et": "et", "fi": "fi", @@ -1516,8 +1569,7 @@ "vi": "vi", "zh-cmn": "zh", "cmn": "zh", - "zh-yue": "zh-yue", - "zh-yue": "yue" + "zh-yue": "zh-yue" } } } @@ -1644,7 +1696,6 @@ "test\\grc": "grc", "eo": "eo", "es": "es", - "es": "es-ES", "es-la": "es-419", "et": "et", "fi": "fi", @@ -1685,38 +1736,62 @@ "vi": "vi", "zh": "zh-cmn", "zh-yue": "zh-yue", - "yue": "zh-yue" } } ] } + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20 + }, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "nvda" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "nvda_service.exe" + },{ + "type": "gpii.windows.closeProcessByName", + "filename": "nvda.exe" + } + ] + } } }, - "configure": [ - "settings.configs" + "start": [ + "settings.launcher" ], - "restore": [ - "settings.configs" + "stop": [ + "settings.launcher" ], "update": [ - "stop", - "configure", - "start" + "stop", + "configure", + "start" ], - "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe\\}\"" - } + "isRunning": [ + "settings.launcher" ], - "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "nvda_service.exe" - },{ - "type": "gpii.windows.closeProcessByName", - "filename": "nvda.exe" - } + "configure": [ + "settings.configs" + ], + "restore": [ + "settings.configs" ], "isInstalled": [ { @@ -1726,12 +1801,6 @@ "subPath": "", "dataType": "REG_SZ" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "nvda" - } ] }, @@ -1746,25 +1815,38 @@ ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/simplification" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" http://easyone.gpii.net/user/${{userToken}}" + }, + "setFalse": { + "type": "gpii.windows.closeProcessByName", + "filename": "firefox.exe" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" http://easyone.gpii.net/user/${{userToken}}" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "firefox.exe" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], // Although there are no settings to deal with, we need to pass through // the "configure" action in order to proceed with the "stop" directive @@ -1777,12 +1859,6 @@ { "type": "gpii.deviceReporter.alwaysInstalled" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "firefox" - } ] }, @@ -1796,36 +1872,43 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/pictorialSimplification" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" http://easyone.gpii.net/sudan" + }, + "setFalse": { + "type": "gpii.windows.closeProcessByName", + "filename": "firefox.exe" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" http://easyone.gpii.net/sudan" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "firefox.exe" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "firefox" - } ] }, @@ -1839,36 +1922,43 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.settingsHandlers.noSettings", "capabilities": [ "http://registry\\.gpii\\.net/common/screenReaderTTSEnabled" ] + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" \"http://webanywhere.cs.washington.edu/beta/?starting_url=http%3A%2F%2Fcloud4all.info\"" + }, + "setFalse": { + "type": "gpii.windows.closeProcessByName", + "filename": "firefox.exe" + }, + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, - "start": [ - { - "type": "gpii.launch.exec", - "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\}\" \"http://webanywhere.cs.washington.edu/beta/?starting_url=http%3A%2F%2Fcloud4all.info\"" - } + "start": [ + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "firefox.exe" - } + "settings.launcher" + ], + "isRunning": [ + "settings.launcher" ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" } - ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "firefox" - } ] }, @@ -1883,7 +1973,7 @@ ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { @@ -1945,6 +2035,34 @@ ] }, "inverseCapabilitiesTransformations": {} + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "verifySettings": true, + "retryOptions": { + "rewriteEvery": 0, + "numRetries": 20 + }, + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "${{environment}.ComSpec} /c \"cd ${{environment}.MAAVIS_HOME} && MaavisPortable.cmd\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "firefox.exe" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "MaavisPortable" + } + ] + } } }, "configure": [ @@ -1954,26 +2072,22 @@ "settings.configuration" ], "start": [ - { - "type": "gpii.launch.exec", - "command": "${{environment}.ComSpec} /c \"cd ${{environment}.MAAVIS_HOME} && MaavisPortable.cmd\"" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.windows.closeProcessByName", - "filename": "firefox.exe" - } + "settings.launcher" ], - "isInstalled": [ - { - "type": "gpii.deviceReporter.alwaysInstalled" - } + "update": [ + "stop", + "configure", + "start" ], "isRunning": [ + "settings.launcher" + ], + "isInstalled": [ { - "type": "gpii.processReporter.find", - "command": "MaavisPortable" + "type": "gpii.deviceReporter.alwaysInstalled" } ] }, @@ -1988,7 +2102,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { @@ -2106,7 +2220,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { @@ -2166,7 +2280,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { @@ -2383,7 +2497,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { @@ -2528,7 +2642,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.spiSettingsHandler", "options": { @@ -2601,7 +2715,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.windows.displaySettingsHandler", "capabilities": [ @@ -2643,7 +2757,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.displaySettingsHandler", "supportedSettings": { @@ -2695,7 +2809,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.windows.registrySettingsHandler", "options": { @@ -2973,28 +3087,39 @@ } ] } + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": [{ + "type": "gpii.windows.spiSettingsHandler.updateCursors" + }], + "getState": [{ + "type": "gpii.processReporter.neverRunning" + }] + } } }, - "configure": [ - "settings.configure" - ], - "restore": [ - "settings.configure", - { - "type": "gpii.windows.spiSettingsHandler.updateCursors" - } + "start": [ + "settings.launcher" ], + "stop": [], "update": [ "configure", "start" ], - "start": [ + "isRunning": [ + "settings.launcher" + ], + "configure": [ + "settings.configure" + ], + "restore": [ + "settings.configure", { "type": "gpii.windows.spiSettingsHandler.updateCursors" } ], - "stop": [ - ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" @@ -3012,7 +3137,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.XMLHandler", "options": { @@ -3061,6 +3186,29 @@ } }, "inverseCapabilitiesTransformations": {} + }, + "launcher": { + "type": "gpii.launchHandlers.flexibleHandler", + "options": { + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "C:\\Sociable\\Cloud4All.exe" + } + ], + "setFalse": [ + { + "type": "gpii.launch.exec", + "command": "C:\\Sociable\\Cloud4All.exe -stop" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "Cloud4Allcd " + } + ] + } } }, "configure": [ @@ -3069,23 +3217,19 @@ "restore": [ "settings.configuration" ], + "isRunning": [ + "settings.launcher" + ], "start": [ - { - "type": "gpii.launch.exec", - "command": "C:\\Sociable\\Cloud4All.exe" - } + "settings.launcher" ], "stop": [ - { - "type": "gpii.launch.exec", - "command": "C:\\Sociable\\Cloud4All.exe -stop" - } + "settings.launcher" ], - "isRunning": [ - { - "type": "gpii.processReporter.find", - "command": "Cloud4Allcd " - } + "update": [ + "stop", + "configure", + "start" ] }, @@ -3097,7 +3241,7 @@ "version": ">=5.0" }] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.webSockets", "options": { @@ -3208,8 +3352,6 @@ "update": [ "configure" ], - "start": [], - "stop": [], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" @@ -3226,7 +3368,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configure": { "type": "gpii.settingsHandlers.noSettings", "liveness": "OSRestart", diff --git a/tests/CloseConflictingAppsTests.js b/tests/CloseConflictingAppsTests.js new file mode 100644 index 000000000..52ba5d84a --- /dev/null +++ b/tests/CloseConflictingAppsTests.js @@ -0,0 +1,266 @@ +/* + * GPII Tests for ensuring that two conflicting apps will not be launched + * + * These are integration tests for ensuring that eg. two screenreaders will not be active at the same time on + * the system. Besides the obvious case of checking that the MM doesn't launch two screenreaders on login, + * it is also tested that an already running screenreader will be closed if the matchmaker finds that another + * (conflicting) matchmaker should be launched. + * + * Copyright 2016 Raising The Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/GPII/universal/blob/master/LICENSE.txt + */ +"use strict"; + +var fluid = require("infusion"), + gpii = fluid.registerNamespace("gpii"); + +fluid.require("%universal"); + +gpii.loadTestingSupport(); + +fluid.registerNamespace("gpii.tests.conflictingApps"); + +gpii.tests.conflictingApps.jawsHandlerEntry = function (running) { + return { + "com.freedomscientific.jaws": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "jfw" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\JAWS17.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "jfw.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "fsSynth32.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "jhookldr.exe" + } + ] + } + }] + }; +}; + +gpii.tests.conflictingApps.NVDAHandlerEntry = function (running) { + return { + "org.nvda-project": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "nvda" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "nvda_service.exe" + },{ + "type": "gpii.windows.closeProcessByName", + "filename": "nvda.exe" + } + ] + } + }] + }; +}; + +gpii.tests.conflictingApps.testDefs = [ + { + name: "Only one screenreader is launched", + userToken: "screenreader_common", + initialState: { + "gpii.launchHandlers.flexibleHandler": fluid.extend({}, + gpii.tests.conflictingApps.jawsHandlerEntry(false), + gpii.tests.conflictingApps.NVDAHandlerEntry(false)) + }, + settingsHandlers: { + + "gpii.settingsHandlers.INISettingsHandler": { + "org.nvda-project": [ + { + "settings": { + "speech.espeak.rate": 17, + "speech.espeak.volume": 75, + "speech.espeak.pitch": 15, + "speech.espeak.rateBoost": true, + "speech.symbolLevel": 300, + "speech.espeak.voice": "en\\en-wi", + "reviewCursor.followFocus": false, + "reviewCursor.followCaret": true, + "reviewCursor.followMouse": true, + "keyboard.speakTypedWords": true, + "keyboard.speakTypedCharacters": false, + "presentation.reportHelpBalloons": false, + "speech.espeak.sayCapForCapitals": true + }, + "options": { + "filename": "${{environment}.APPDATA}\\nvda\\nvda.ini", + "allowNumberSignComments": true, + "allowSubSections": true + } + } + ], + "com.freedomscientific.jaws": [ + { + "settings": { + "Voice Profiles.ActiveVoiceProfileName": "GPII", + "options.SayAllIndicateCaps": true, + "options.TypingEcho": 2 + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\enu\\DEFAULT.JCF" + } + }, + + { + "settings": { + "ENU-Global.Rate": 400, + "ENU-Global.Punctuation": 3, + "ENU-Global.Pitch": 16, + "ENU-Message.Rate": 400, + "ENU-Message.Punctuation": 3, + "ENU-Message.Pitch": 16, + "ENU-Keyboard.Rate": 400, + "ENU-Keyboard.Punctuation": 3, + "ENU-Keyboard.Pitch": 16, + "ENU-PCCursor.Rate": 400, + "ENU-PCCursor.Punctuation": 3, + "ENU-PCCursor.Pitch": 16, + "ENU-JAWSCursor.Rate": 400, + "ENU-JAWSCursor.Punctuation": 3, + "ENU-JAWSCursor.Pitch": 16, + "ENU-MenuAndDialog.Rate": 400, + "ENU-MenuAndDialog.Punctuation": 3, + "ENU-MenuAndDialog.Pitch": 16 + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\VoiceProfiles\\GPII.VPF" + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": fluid.extend({}, + gpii.tests.conflictingApps.jawsHandlerEntry(false), + gpii.tests.conflictingApps.NVDAHandlerEntry(true)) + } + }, { + name: "Conflicting screenreader (jaws) is closed is Only one screenreader is launched", + userToken: "screenreader_common", + initialState: { + "gpii.launchHandlers.flexibleHandler": fluid.extend({}, + gpii.tests.conflictingApps.jawsHandlerEntry(true), + gpii.tests.conflictingApps.NVDAHandlerEntry(false)) + }, + settingsHandlers: { + + "gpii.settingsHandlers.INISettingsHandler": { + "org.nvda-project": [ + { + "settings": { + "speech.espeak.rate": 17, + "speech.espeak.volume": 75, + "speech.espeak.pitch": 15, + "speech.espeak.rateBoost": true, + "speech.symbolLevel": 300, + "speech.espeak.voice": "en\\en-wi", + "reviewCursor.followFocus": false, + "reviewCursor.followCaret": true, + "reviewCursor.followMouse": true, + "keyboard.speakTypedWords": true, + "keyboard.speakTypedCharacters": false, + "presentation.reportHelpBalloons": false, + "speech.espeak.sayCapForCapitals": true + }, + "options": { + "filename": "${{environment}.APPDATA}\\nvda\\nvda.ini", + "allowNumberSignComments": true, + "allowSubSections": true + } + } + ], + "com.freedomscientific.jaws": [ + { + "settings": { + "Voice Profiles.ActiveVoiceProfileName": "GPII", + "options.SayAllIndicateCaps": true, + "options.TypingEcho": 2 + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\enu\\DEFAULT.JCF" + } + }, + + { + "settings": { + "ENU-Global.Rate": 400, + "ENU-Global.Punctuation": 3, + "ENU-Global.Pitch": 16, + "ENU-Message.Rate": 400, + "ENU-Message.Punctuation": 3, + "ENU-Message.Pitch": 16, + "ENU-Keyboard.Rate": 400, + "ENU-Keyboard.Punctuation": 3, + "ENU-Keyboard.Pitch": 16, + "ENU-PCCursor.Rate": 400, + "ENU-PCCursor.Punctuation": 3, + "ENU-PCCursor.Pitch": 16, + "ENU-JAWSCursor.Rate": 400, + "ENU-JAWSCursor.Punctuation": 3, + "ENU-JAWSCursor.Pitch": 16, + "ENU-MenuAndDialog.Rate": 400, + "ENU-MenuAndDialog.Punctuation": 3, + "ENU-MenuAndDialog.Pitch": 16 + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\VoiceProfiles\\GPII.VPF" + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": fluid.extend({}, + gpii.tests.conflictingApps.jawsHandlerEntry(false), + gpii.tests.conflictingApps.NVDAHandlerEntry(true)) + } + } +]; + +module.exports = gpii.test.bootstrap({ + testDefs: "gpii.tests.conflictingApps.testDefs", + configName: "gpii.tests.multiScreenreader.config", + configPath: "%universal/tests/configs" +}, ["gpii.test.integration.testCaseHolder.windows"], + module, require, __dirname); diff --git a/tests/ContextIntegrationTests.js b/tests/ContextIntegrationTests.js index 288979d6c..919c90f46 100644 --- a/tests/ContextIntegrationTests.js +++ b/tests/ContextIntegrationTests.js @@ -34,4 +34,3 @@ gpii.tests.contextIntegration.baseTestDef = { kettle.test.bootstrapServer(gpii.test.buildSegmentedFixtures( gpii.tests.contextIntegration.fixtures, gpii.tests.contextIntegration.baseTestDef)); - diff --git a/tests/JournalIntegrationTests.js b/tests/JournalIntegrationTests.js index cedc34098..8cfc89838 100644 --- a/tests/JournalIntegrationTests.js +++ b/tests/JournalIntegrationTests.js @@ -36,7 +36,7 @@ gpii.tests.journal.testDef = gpii.tests.windows.builtIn[0]; gpii.tests.journal.initialSettings = { "gpii.windows.spiSettingsHandler": { - "some.app.id": [{ + "com.microsoft.windows.mouseTrailing": [{ "settings": { "MouseTrails": { "value": 20 @@ -50,7 +50,7 @@ gpii.tests.journal.initialSettings = { }] }, "gpii.windows.registrySettingsHandler": { - "some.app.id": [{ // magnifier stuff + "com.microsoft.windows.magnifier": [{ // magnifier stuff "settings": { "Invert": 1, "Magnification": 200, @@ -76,7 +76,7 @@ gpii.tests.journal.initialSettings = { ] }, "gpii.windows.displaySettingsHandler": { - "some.app.id": [{ + "com.microsoft.windows.screenResolution": [{ "settings": { "screen-resolution": { "width": 800, @@ -85,6 +85,31 @@ gpii.tests.journal.initialSettings = { "screen-dpi": 1 } }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }] + } +}; + +gpii.tests.journal.settingsAfterCrash = { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }] } }; @@ -324,8 +349,8 @@ gpii.tests.journal.stashInitial = function (settingsHandlersPayload, settingsSto var settingsHandlers = fluid.copy(testCaseHolder.options.settingsHandlers); // We eliminate the last blocks since our initial settings state does not include them, and the blocks // with values all `undefined` will confuse jqUnit.assertDeepEq in gpii.test.checkConfiguration - settingsHandlers["gpii.windows.spiSettingsHandler"]["some.app.id"].length = 1; - settingsHandlers["gpii.windows.registrySettingsHandler"]["some.app.id"].length = 1; + settingsHandlers["gpii.windows.spiSettingsHandler"] = fluid.filterKeys(settingsHandlers["gpii.windows.spiSettingsHandler"], "com.microsoft.windows.mouseTrailing"); + settingsHandlers["gpii.windows.registrySettingsHandler"] = fluid.filterKeys(settingsHandlers["gpii.windows.registrySettingsHandler"], "com.microsoft.windows.magnifier"); testCaseHolder.settingsHandlers = settingsHandlers; }; @@ -354,7 +379,7 @@ gpii.tests.journal.normalLoginFixtures = [ gpii.tests.journal.fixtures = [ { name: "Journal state and restoration", - expect: 10, + expect: 11, sequenceSegments: [ { func: "gpii.tests.journal.stashJournalId", args: "{testCaseHolder}" @@ -391,6 +416,12 @@ gpii.tests.journal.fixtures = [ }, kettle.test.startServerSequence, { + func: "gpii.test.setSettings", + args: [gpii.tests.journal.settingsAfterCrash, "{nameResolver}", "{testCaseHolder}.events.onInitialSettingsComplete.fire"] + }, { + event: "{tests}.events.onInitialSettingsComplete", + listener: "fluid.identity" + }, { func: "{listJournalsRequest}.send" }, { event: "{listJournalsRequest}.events.onComplete", diff --git a/tests/configs/gpii.tests.multiScreenreader.config.json b/tests/configs/gpii.tests.multiScreenreader.config.json new file mode 100644 index 000000000..0ce917b80 --- /dev/null +++ b/tests/configs/gpii.tests.multiScreenreader.config.json @@ -0,0 +1,18 @@ +{ + "type": "gpii.tests.multiScreenreader.config", + "options": { + "distributeOptions": { + "multiSH.rawPreferencesDataSource": { + "record": "%universal/testData/preferences/acceptanceTests/%userToken.json", + "target": "{that rawPreferencesServer rawPreferencesDataSource}.options.path", + "priority": "after:development.rawPreferencesDataSource" + }, + "multiSH.deviceReporter": { + "record": "%universal/tests/data/multiScreenreaderDeviceReporter.json", + "target": "{that deviceReporter installedSolutionsDataSource}.options.path", + "priority": "after:development.installedSolutionsPath" + } + } + }, + "mergeConfigs": "%universal/gpii/configs/gpii.config.development.all.local.json" +} diff --git a/tests/configs/gpii.tests.multiScreenreader.config.txt b/tests/configs/gpii.tests.multiScreenreader.config.txt new file mode 100644 index 000000000..4e792098a --- /dev/null +++ b/tests/configs/gpii.tests.multiScreenreader.config.txt @@ -0,0 +1,4 @@ +gpii.tests.multiScreenreader.config.json + +Is used for the integration test CloseConflictingAppsTest. It uses the NP sets of the testData's acceptanceTests folder and a device reporter that reports only two screenreaders (Jaws and NVDA) installed. + diff --git a/tests/data/multiSHSolutionRegistry.json b/tests/data/multiSHSolutionRegistry.json index a1d593921..23c7565c7 100644 --- a/tests/data/multiSHSolutionRegistry.json +++ b/tests/data/multiSHSolutionRegistry.json @@ -8,7 +8,7 @@ } ] }, - "settingsHandlers": { + "handlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { diff --git a/tests/data/multiScreenreaderDeviceReporter.json b/tests/data/multiScreenreaderDeviceReporter.json new file mode 100644 index 000000000..5e9147038 --- /dev/null +++ b/tests/data/multiScreenreaderDeviceReporter.json @@ -0,0 +1,9 @@ +[ + { + "id": "com.freedomscientific.jaws" + }, + + { + "id": "org.nvda-project" + } +] diff --git a/tests/platform/linux/linux-builtIn-testSpec.js b/tests/platform/linux/linux-builtIn-testSpec.js index bc97e9cbf..6d00d6ad4 100644 --- a/tests/platform/linux/linux-builtIn-testSpec.js +++ b/tests/platform/linux/linux-builtIn-testSpec.js @@ -15,6 +15,7 @@ Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016. "use strict"; + var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); @@ -28,9 +29,31 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ { name: "Testing os_common using default matchmaker", userToken: "os_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] + } + }, settingsHandlers: { "gpii.gsettings": { - "some.app.id": [{ + "org.gnome.desktop.a11y.magnifier": [{ "settings": { "mag-factor": 1.5, "screen-position": "full-screen", @@ -41,7 +64,8 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ "options": { "schema": "org.gnome.desktop.a11y.magnifier" } - }, { + }], + "org.gnome.desktop.interface": [{ "settings": { "gtk-theme": "HighContrast", "icon-theme": "HighContrast", @@ -52,15 +76,172 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ "schema": "org.gnome.desktop.interface" } }] + }, + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] + } + } + }, { + name: "Testing os_common - magnifier running on startup", + userToken: "os_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] + } + }, + settingsHandlers: { + "gpii.gsettings": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "mag-factor": 1.5, + "screen-position": "full-screen", + "mouse-tracking": "proportional", + "caret-tracking": "proportional", + "focus-tracking": "none" + }, + "options": { + "schema": "org.gnome.desktop.a11y.magnifier" + } + }], + "org.gnome.desktop.interface": [{ + "settings": { + "gtk-theme": "HighContrast", + "icon-theme": "HighContrast", + "text-scaling-factor": 0.75, + "cursor-size": 41 + }, + "options": { + "schema": "org.gnome.desktop.interface" + } + }] + }, + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] + } + } + }, { + name: "Testing os_common - magnifier and keyboard running on startup", + userToken: "os_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] } }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-magnifier-enabled", - "expectConfigured": "true", - "expectRestored": "false" + settingsHandlers: { + "gpii.gsettings": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "mag-factor": 1.5, + "screen-position": "full-screen", + "mouse-tracking": "proportional", + "caret-tracking": "proportional", + "focus-tracking": "none" + }, + "options": { + "schema": "org.gnome.desktop.a11y.magnifier" + } + }], + "org.gnome.desktop.interface": [{ + "settings": { + "gtk-theme": "HighContrast", + "icon-theme": "HighContrast", + "text-scaling-factor": 0.75, + "cursor-size": 41 + }, + "options": { + "schema": "org.gnome.desktop.interface" + } + }] + }, + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }], + "org.gnome.desktop.a11y.applications.onscreen-keyboard": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-keyboard-enabled" + } + }] } - ] + } }, { name: "Testing os_common2 using default matchmaker", @@ -77,15 +258,27 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ } }] } - }, - processes: [] + } }, { name: "Testing os_gnome using default matchmaker", userToken: "os_gnome", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }] + } + }, settingsHandlers: { "gpii.gsettings": { - "some.app.id": [{ + "org.gnome.desktop.a11y.magnifier": [{ "settings": { "mag-factor": 1.5, "screen-position": "full-screen" @@ -93,7 +286,8 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ "options": { "schema": "org.gnome.desktop.a11y.magnifier" } - }, { + }], + "org.gnome.desktop.interface": [{ "settings": { "text-scaling-factor": 0.75, "cursor-size": 90 @@ -104,24 +298,41 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ }] }, "gpii.alsa": { - "some.app.id": [{ + "org.alsa-project": [{ "settings": { "masterVolume": 50 } }] + }, + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }] } - }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-magnifier-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ] + } }, { name: "Testing os_win7 using default matchmaker", userToken: "os_win7", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }] + } + }, settingsHandlers: { "gpii.gsettings": { "some.app.id": [{ @@ -145,15 +356,19 @@ gpii.tests.linux.builtIn.testDefs = fluid.freezeRecursive([ "schema": "org.gnome.desktop.interface" } }] + }, + "gpii.gsettings.launch": { + "org.gnome.desktop.a11y.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-magnifier-enabled" + } + }] } - }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-magnifier-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ] + } } ]); diff --git a/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.js b/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.js index ba98e4079..e69e92668 100644 --- a/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.js +++ b/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.js @@ -29,6 +29,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ name: "Testing screenreader_common using Flat matchmaker", gradeNames: "gpii.test.integration.deviceReporterAware.linux", userToken: "screenreader_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { "data": [ @@ -53,15 +66,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ], deviceReporters: { "gpii.packageKit.find": { "expectInstalled": ["orca"] @@ -72,6 +89,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ name: "Testing screenreader_orca using Flat matchmaker", gradeNames: "gpii.test.integration.deviceReporterAware.linux", userToken: "screenreader_orca", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { "some.app.id": [ @@ -95,15 +125,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ], deviceReporters: { "gpii.packageKit.find": { "expectInstalled": ["orca"] @@ -114,6 +148,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ name: "Testing screenreader_nvda using Flat matchmaker", gradeNames: "gpii.test.integration.deviceReporterAware.linux", userToken: "screenreader_nvda", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { "some.app.id": [ @@ -136,15 +183,19 @@ gpii.tests.deviceReporterAware.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ], deviceReporters: { "gpii.packageKit.find": { "expectInstalled": ["orca"] diff --git a/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.txt b/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.txt index 979e68516..6ea62ad4e 100644 --- a/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.txt +++ b/tests/platform/linux/linux-dynamicDeviceReporter-testSpec.txt @@ -3,4 +3,4 @@ linux-dynamicDeviceReporter-testSpec.js Descriptions: This will run the acceptance tests with dynamic device reporting. -It uses 1 NP set: screenreader_common (but more will be added) +It uses 3 NP sets: screenreader_common, screenreader_orca and screenreader_nvda diff --git a/tests/platform/linux/linux-orca-testSpec.js b/tests/platform/linux/linux-orca-testSpec.js index 1bd68faf6..fecb1fc93 100644 --- a/tests/platform/linux/linux-orca-testSpec.js +++ b/tests/platform/linux/linux-orca-testSpec.js @@ -26,11 +26,24 @@ fluid.registerNamespace("gpii.tests.linux.orca"); gpii.tests.linux.orca.testDefs = [ { - name: "Testing screenreader_common using Flat matchmaker", + name: "Testing screenreader_common", userToken: "screenreader_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { - "some.app.id": [ + "org.gnome.orca": [ { "settings": { "sayAllStyle": 1, @@ -52,22 +65,92 @@ gpii.tests.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + } + }, { + name: "Testing screenreader_common with orca running on login", + userToken: "screenreader_common", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" + settingsHandlers: { + "gpii.orca": { + "org.gnome.orca": [ + { + "settings": { + "sayAllStyle": 1, + "enableSpeech": true, + "enableEchoByWord": true, + "enableEchoByCharacter": false, + "voices.default.rate": 102.27272727272727, + "voices.default.gain": 7.5, + "enableTutorialMessages": false, + "voices.default.family": { + "locale": "en", + "name": "en-westindies" + }, + "verbalizePunctuationStyle": 0, + "voices.default.average-pitch": 1.5 + }, + "options": { + "user": "screenreader_common" + } + } + ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } - ] + } }, { - name: "Testing screenreader_orca using Flat matchmaker", + name: "Testing screenreader_orca", userToken: "screenreader_orca", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { - "some.app.id": [ + "org.gnome.orca": [ { "settings": { "sayAllStyle": 1, @@ -88,22 +171,39 @@ gpii.tests.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } - }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ] + } }, { - name: "Testing screenreader_nvda using Flat matchmaker", + name: "Testing screenreader_nvda", userToken: "screenreader_nvda", + initialState: { + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": false + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] + } + }, settingsHandlers: { "gpii.orca": { - "some.app.id": [ + "org.gnome.orca": [ { "settings": { "sayAllStyle": 1, @@ -123,15 +223,19 @@ gpii.tests.linux.orca.testDefs = [ } } ] + }, + "gpii.gsettings.launch": { + "org.gnome.orca": [{ + "settings": { + "running": true + }, + "options": { + "schema": "org.gnome.desktop.a11y.applications", + "key": "screen-reader-enabled" + } + }] } - }, - processes: [ - { - "command": "gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled", - "expectConfigured": "true", - "expectRestored": "false" - } - ] + } } ]; diff --git a/tests/platform/shared/uioPlusTestDefs.js b/tests/platform/shared/uioPlusTestDefs.js index 1261152cd..966489333 100644 --- a/tests/platform/shared/uioPlusTestDefs.js +++ b/tests/platform/shared/uioPlusTestDefs.js @@ -47,8 +47,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for background color change for UIO+", @@ -76,8 +75,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for font size transformation for UIO+", @@ -105,8 +103,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for line space transformation for UIO+", @@ -134,8 +131,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for highlight color transformation for UIO+", @@ -163,8 +159,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for character space transformation for UIO+", @@ -192,8 +187,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for inputs larger transformation for UIO+", @@ -221,8 +215,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for self voicing transformation for UIO+", @@ -250,8 +243,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for table of contents transformation for UIO+", @@ -279,8 +271,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for dictionary transformation for UIO+", @@ -308,8 +299,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for support tool transformation for UIO+ - multiple values", @@ -337,8 +327,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for support tool transformation for UIO+ - unsupported values", @@ -366,8 +355,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for simplified UI transformation for UIO+", @@ -395,8 +383,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for syllabification UI transformation for UIO+", @@ -424,8 +411,7 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } }, { name: "Acceptance test for multiple transformations for UIO+", @@ -453,7 +439,6 @@ gpii.tests.uioPlus.testDefs = [ } ] } - }, - processes: [] + } } ]; diff --git a/tests/platform/windows/configs/gpii.tests.acceptance.windows.builtIn.config.json b/tests/platform/windows/configs/gpii.tests.acceptance.windows.builtIn.config.json index 064856ecb..c7e30261c 100644 --- a/tests/platform/windows/configs/gpii.tests.acceptance.windows.builtIn.config.json +++ b/tests/platform/windows/configs/gpii.tests.acceptance.windows.builtIn.config.json @@ -8,6 +8,6 @@ "priority": "after:development.installedSolutionsPath" } } - }, + }, "mergeConfigs": "%universal/tests/configs/gpii.tests.acceptance.localInstall.config.json" } diff --git a/tests/platform/windows/windows-builtIn-testSpec.js b/tests/platform/windows/windows-builtIn-testSpec.js index a360d8436..b2549e410 100644 --- a/tests/platform/windows/windows-builtIn-testSpec.js +++ b/tests/platform/windows/windows-builtIn-testSpec.js @@ -28,9 +28,28 @@ gpii.tests.windows.builtIn = [ { name: "Testing os_win7 using default matchmaker", userToken: "os_win7", + initialState: { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }] + } + }, settingsHandlers: { "gpii.windows.spiSettingsHandler": { - "some.app.id": [ + "com.microsoft.windows.mouseTrailing": [ { "settings": { "MouseTrails": { @@ -49,7 +68,10 @@ gpii.tests.windows.builtIn = [ "type": "BOOL" } } - }, { + } + ], + "com.microsoft.windows.mouseKeys": [ + { "settings": { "MouseKeysOn": { "path": "pvParam.dwFlags.MKF_MOUSEKEYSON", @@ -73,7 +95,10 @@ gpii.tests.windows.builtIn = [ "name": "MOUSEKEYS" } } - }, { + } + ], + "com.microsoft.windows.stickyKeys": [ + { "settings": { "StickyKeysOn": { "path": "pvParam.dwFlags.SKF_STICKYKEYSON", @@ -89,7 +114,10 @@ gpii.tests.windows.builtIn = [ "name": "STICKYKEYS" } } - }, { + } + ], + "com.microsoft.windows.filterKeys": [ + { "settings": { "FilterKeysEnable": { "path": "pvParam.dwFlags.FKF_FILTERKEYSON", @@ -109,7 +137,10 @@ gpii.tests.windows.builtIn = [ "name": "FILTERKEYS" } } - }, { // high contrast settings + } + ], + "com.microsoft.windows.highContrast": [ + { // high contrast settings "settings": { "HighContrastOn": { "path": "pvParam.dwFlags.HCF_HIGHCONTRASTON", @@ -129,7 +160,7 @@ gpii.tests.windows.builtIn = [ ] }, "gpii.windows.registrySettingsHandler": { - "some.app.id": [{ // magnifier stuff + "com.microsoft.windows.magnifier": [{ // magnifier stuff "settings": { "Invert": 1, "Magnification": 150, @@ -150,7 +181,8 @@ gpii.tests.windows.builtIn = [ "MagnificationMode": "REG_DWORD" } } - }, { // cursor size stuff + }], + "com.microsoft.windows.cursors": [{ // cursor size stuff "settings": { "No": "%SystemRoot%\\cursors\\aero_unavail_xl.cur", "Hand": "%SystemRoot%\\cursors\\aero_link_xl.cur", @@ -211,7 +243,7 @@ gpii.tests.windows.builtIn = [ }] }, "gpii.windows.displaySettingsHandler": { - "some.app.id": [{ + "com.microsoft.windows.screenResolution": [{ "settings": { "screen-resolution": { "width": 800, @@ -220,21 +252,59 @@ gpii.tests.windows.builtIn = [ "screen-dpi": 1 } }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }] } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq Magnify.exe\" | find /I \"Magnify.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + } }, { name: "Testing os_common using default matchmaker", userToken: "os_common", + initialState: { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": false + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] + } + }, settingsHandlers: { "gpii.windows.spiSettingsHandler": { - "some.app.id": [ + "com.microsoft.windows.mouseTrailing": [ { "settings": { "MouseTrails": { @@ -253,7 +323,10 @@ gpii.tests.windows.builtIn = [ "type": "BOOL" } } - }, { + } + ], + "com.microsoft.windows.mouseKeys": [ + { "settings": { "MouseKeysOn": { "path": "pvParam.dwFlags.MKF_MOUSEKEYSON", @@ -269,7 +342,10 @@ gpii.tests.windows.builtIn = [ "name": "MOUSEKEYS" } } - }, { + } + ], + "com.microsoft.windows.stickyKeys": [ + { "settings": { "StickyKeysOn": { "path": "pvParam.dwFlags.SKF_STICKYKEYSON", @@ -285,15 +361,240 @@ gpii.tests.windows.builtIn = [ "name": "STICKYKEYS" } } - }, { + } + ], + "com.microsoft.windows.filterKeys": [ + { "settings": { "FilterKeysEnable": { "path": "pvParam.dwFlags.FKF_FILTERKEYSON", + "value": false + }, + "BounceKeysInterval": { + "path": "pvParam.iBounceMSec", + "value": 0 + } + }, + "options": { + "getAction": "SPI_GETFILTERKEYS", + "setAction": "SPI_SETFILTERKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "FILTERKEYS" + } + } + } + ], + "com.microsoft.windows.highContrast": [ + { // high contrast settings + "settings": { + "HighContrastOn": { + "path": "pvParam.dwFlags.HCF_HIGHCONTRASTON", "value": true + } + }, + "options": { + "getAction": "SPI_GETHIGHCONTRAST", + "setAction": "SPI_SETHIGHCONTRAST", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "HIGHCONTRAST" + } + } + } + ] + }, + "gpii.windows.registrySettingsHandler": { + "com.microsoft.windows.magnifier": [{ // magnifier stuff + "settings": { + "Invert": 1, + "Magnification": 150, + "MagnificationMode": 3, + "FollowFocus": 0, + "FollowCaret": 1, + "FollowMouse": 1 + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Software\\Microsoft\\ScreenMagnifier", + "dataTypes": { + "Magnification": "REG_DWORD", + "Invert": "REG_DWORD", + "FollowFocus": "REG_DWORD", + "FollowCaret": "REG_DWORD", + "FollowMouse": "REG_DWORD", + "MagnificationMode": "REG_DWORD" + } + } + }], + "com.microsoft.windows.cursors": [{ // cursor size stuff + "settings": { + "No": "%SystemRoot%\\cursors\\aero_unavail_xl.cur", + "Hand": "%SystemRoot%\\cursors\\aero_link_xl.cur", + "Help": "%SystemRoot%\\cursors\\aero_helpsel_xl.cur", + "Wait": "%SystemRoot%\\cursors\\aero_busy_xl.ani", + "Arrow": "%SystemRoot%\\cursors\\aero_arrow_xl.cur", + "NWPen": "%SystemRoot%\\cursors\\aero_pen_xl.cur", + "SizeNS": "%SystemRoot%\\cursors\\aero_ns_xl.cur", + "SizeWE": "%SystemRoot%\\cursors\\aero_ew_xl.cur", + "SizeAll": "%SystemRoot%\\cursors\\aero_move_xl.cur", + "UpArrow": "%SystemRoot%\\cursors\\aero_up_xl.cur", + "SizeNESW": "%SystemRoot%\\cursors\\aero_nesw_xl.cur", + "SizeNWSE": "%SystemRoot%\\cursors\\aero_nwse_xl.cur", + "AppStarting": "%SystemRoot%\\cursors\\aero_working_xl.ani" + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Control Panel\\Cursors", + "dataTypes": { + "Arrow": "REG_SZ", + "Hand": "REG_SZ", + "Help": "REG_SZ", + "AppStarting": "REG_SZ", + "No": "REG_SZ", + "NWPen": "REG_SZ", + "SizeAll": "REG_SZ", + "SizeNESW": "REG_SZ", + "SizeNS": "REG_SZ", + "SizeNWSE": "REG_SZ", + "SizeWE": "REG_SZ", + "UpArrow": "REG_SZ", + "Wait": "REG_SZ" + } + } + }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": true + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] + } + } + }, { + name: "Testing os_common - magnifier running on startup", + userToken: "os_common", + initialState: { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": false + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] + } + }, + settingsHandlers: { + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.mouseTrailing": [ + { + "settings": { + "MouseTrails": { + "path": { + "get": "pvParam", + "set": "uiParam" + }, + "value": 10 + } + }, + "options": { + "getAction": "SPI_GETMOUSETRAILS", + "setAction": "SPI_SETMOUSETRAILS", + "uiParam": 0, + "pvParam": { + "type": "BOOL" + } + } + } + ], + "com.microsoft.windows.mouseKeys": [ + { + "settings": { + "MouseKeysOn": { + "path": "pvParam.dwFlags.MKF_MOUSEKEYSON", + "value": true + } + }, + "options": { + "getAction": "SPI_GETMOUSEKEYS", + "setAction": "SPI_SETMOUSEKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "MOUSEKEYS" + } + } + } + ], + "com.microsoft.windows.stickyKeys": [ + { + "settings": { + "StickyKeysOn": { + "path": "pvParam.dwFlags.SKF_STICKYKEYSON", + "value": true + } + }, + "options": { + "getAction": "SPI_GETSTICKYKEYS", + "setAction": "SPI_SETSTICKYKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "STICKYKEYS" + } + } + } + ], + "com.microsoft.windows.filterKeys": [ + { + "settings": { + "FilterKeysEnable": { + "path": "pvParam.dwFlags.FKF_FILTERKEYSON", + "value": false }, "BounceKeysInterval": { "path": "pvParam.iBounceMSec", - "value": 1000 + "value": 0 } }, "options": { @@ -305,7 +606,10 @@ gpii.tests.windows.builtIn = [ "name": "FILTERKEYS" } } - }, { // high contrast settings + } + ], + "com.microsoft.windows.highContrast": [ + { // high contrast settings "settings": { "HighContrastOn": { "path": "pvParam.dwFlags.HCF_HIGHCONTRASTON", @@ -325,7 +629,7 @@ gpii.tests.windows.builtIn = [ ] }, "gpii.windows.registrySettingsHandler": { - "some.app.id": [{ // magnifier stuff + "com.microsoft.windows.magnifier": [{ // magnifier stuff "settings": { "Invert": 1, "Magnification": 150, @@ -346,7 +650,8 @@ gpii.tests.windows.builtIn = [ "MagnificationMode": "REG_DWORD" } } - }, { // cursor size stuff + }], + "com.microsoft.windows.cursors": [{ // cursor size stuff "settings": { "No": "%SystemRoot%\\cursors\\aero_unavail_xl.cur", "Hand": "%SystemRoot%\\cursors\\aero_link_xl.cur", @@ -382,21 +687,290 @@ gpii.tests.windows.builtIn = [ } } }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": true + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] + } + } + }, { + name: "Testing os_common - magnifier and keyboard both running on startup", + userToken: "os_common", + initialState: { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": true + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] } }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq Magnify.exe\" | find /I \"Magnify.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" + settingsHandlers: { + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.mouseTrailing": [ + { + "settings": { + "MouseTrails": { + "path": { + "get": "pvParam", + "set": "uiParam" + }, + "value": 10 + } + }, + "options": { + "getAction": "SPI_GETMOUSETRAILS", + "setAction": "SPI_SETMOUSETRAILS", + "uiParam": 0, + "pvParam": { + "type": "BOOL" + } + } + } + ], + "com.microsoft.windows.mouseKeys": [ + { + "settings": { + "MouseKeysOn": { + "path": "pvParam.dwFlags.MKF_MOUSEKEYSON", + "value": true + } + }, + "options": { + "getAction": "SPI_GETMOUSEKEYS", + "setAction": "SPI_SETMOUSEKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "MOUSEKEYS" + } + } + } + ], + "com.microsoft.windows.stickyKeys": [ + { + "settings": { + "StickyKeysOn": { + "path": "pvParam.dwFlags.SKF_STICKYKEYSON", + "value": true + } + }, + "options": { + "getAction": "SPI_GETSTICKYKEYS", + "setAction": "SPI_SETSTICKYKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "STICKYKEYS" + } + } + } + ], + "com.microsoft.windows.filterKeys": [ + { + "settings": { + "FilterKeysEnable": { + "path": "pvParam.dwFlags.FKF_FILTERKEYSON", + "value": false + }, + "BounceKeysInterval": { + "path": "pvParam.iBounceMSec", + "value": 0 + } + }, + "options": { + "getAction": "SPI_GETFILTERKEYS", + "setAction": "SPI_SETFILTERKEYS", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "FILTERKEYS" + } + } + } + ], + "com.microsoft.windows.highContrast": [ + { // high contrast settings + "settings": { + "HighContrastOn": { + "path": "pvParam.dwFlags.HCF_HIGHCONTRASTON", + "value": true + } + }, + "options": { + "getAction": "SPI_GETHIGHCONTRAST", + "setAction": "SPI_SETHIGHCONTRAST", + "uiParam": "struct_size", + "pvParam": { + "type": "struct", + "name": "HIGHCONTRAST" + } + } + } + ] + }, + "gpii.windows.registrySettingsHandler": { + "com.microsoft.windows.magnifier": [{ // magnifier stuff + "settings": { + "Invert": 1, + "Magnification": 150, + "MagnificationMode": 3, + "FollowFocus": 0, + "FollowCaret": 1, + "FollowMouse": 1 + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Software\\Microsoft\\ScreenMagnifier", + "dataTypes": { + "Magnification": "REG_DWORD", + "Invert": "REG_DWORD", + "FollowFocus": "REG_DWORD", + "FollowCaret": "REG_DWORD", + "FollowMouse": "REG_DWORD", + "MagnificationMode": "REG_DWORD" + } + } + }], + "com.microsoft.windows.cursors": [{ // cursor size stuff + "settings": { + "No": "%SystemRoot%\\cursors\\aero_unavail_xl.cur", + "Hand": "%SystemRoot%\\cursors\\aero_link_xl.cur", + "Help": "%SystemRoot%\\cursors\\aero_helpsel_xl.cur", + "Wait": "%SystemRoot%\\cursors\\aero_busy_xl.ani", + "Arrow": "%SystemRoot%\\cursors\\aero_arrow_xl.cur", + "NWPen": "%SystemRoot%\\cursors\\aero_pen_xl.cur", + "SizeNS": "%SystemRoot%\\cursors\\aero_ns_xl.cur", + "SizeWE": "%SystemRoot%\\cursors\\aero_ew_xl.cur", + "SizeAll": "%SystemRoot%\\cursors\\aero_move_xl.cur", + "UpArrow": "%SystemRoot%\\cursors\\aero_up_xl.cur", + "SizeNESW": "%SystemRoot%\\cursors\\aero_nesw_xl.cur", + "SizeNWSE": "%SystemRoot%\\cursors\\aero_nwse_xl.cur", + "AppStarting": "%SystemRoot%\\cursors\\aero_working_xl.ani" + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Control Panel\\Cursors", + "dataTypes": { + "Arrow": "REG_SZ", + "Hand": "REG_SZ", + "Help": "REG_SZ", + "AppStarting": "REG_SZ", + "No": "REG_SZ", + "NWPen": "REG_SZ", + "SizeAll": "REG_SZ", + "SizeNESW": "REG_SZ", + "SizeNS": "REG_SZ", + "SizeNWSE": "REG_SZ", + "SizeWE": "REG_SZ", + "UpArrow": "REG_SZ", + "Wait": "REG_SZ" + } + } + }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": true + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] } - ] + } }, { name: "Testing os_gnome using default matchmaker", userToken: "os_gnome", + initialState: { + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": false + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }], + "com.microsoft.windows.onscreenKeyboard": [{ + "settings": { + "running": false + }, + "options": { + "registryName": "osk", + "queryProcess": "osk.exe" + } + }] + } + }, settingsHandlers: { "gpii.windows.registrySettingsHandler": { - "some.app.id": [{ // magnifier stuff + "com.microsoft.windows.magnifier": [{ // magnifier stuff "settings": { "Magnification": 150, "MagnificationMode": 2 @@ -413,7 +987,8 @@ gpii.tests.windows.builtIn = [ "MagnificationMode": "REG_DWORD" } } - }, { // cursor size stuff + }], + "com.microsoft.windows.cursors": [{ // cursor size stuff "settings": { "No": "%SystemRoot%\\cursors\\aero_unavail_xl.cur", "Hand": "%SystemRoot%\\cursors\\aero_link_xl.cur", @@ -449,15 +1024,25 @@ gpii.tests.windows.builtIn = [ } } }] + }, + "gpii.windows.enableRegisteredAT": { + "com.microsoft.windows.magnifier": [{ + "settings": { + "running": true + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "registryName": "magnifierpane", + "queryProcess": "Magnify.exe" + } + }] } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq Magnify.exe\" | find /I \"Magnify.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + } } ]; diff --git a/tests/platform/windows/windows-dynamicDeviceReporter-testSpec.js b/tests/platform/windows/windows-dynamicDeviceReporter-testSpec.js index a2a11bb3c..12f2fd06b 100644 --- a/tests/platform/windows/windows-dynamicDeviceReporter-testSpec.js +++ b/tests/platform/windows/windows-dynamicDeviceReporter-testSpec.js @@ -24,10 +24,90 @@ gpii.loadTestingSupport(); fluid.registerNamespace("gpii.tests.deviceReporterAware.windows"); -gpii.tests.deviceReporterAware.windows = [ +gpii.tests.deviceReporterAware.windows.flexibleHandlerEntries = { + nvda: function (running) { + return { + "org.nvda-project": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "nvda" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "nvda_service.exe" + },{ + "type": "gpii.windows.closeProcessByName", + "filename": "nvda.exe" + } + ] + } + }] + }; + }, + readwrite: function (running) { + return { + "com.texthelp.readWriteGold": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 40, + retryInterval: 1000 + }, + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_CURRENT_USER\\Software\\Texthelp\\Read&Write11\\InstallPath}\\ReadAndWrite.exe\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "ReadAndWrite.exe" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "ReadAndWrite" + } + ] + } + }] + }; + } +}; + + +gpii.tests.deviceReporterAware.windows.testDefs = [ { name: "Testing screenreader_nvda using Flat matchmaker", userToken: "screenreader_nvda", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.deviceReporterAware.windows.flexibleHandlerEntries.nvda(false) + }, gradeNames: "gpii.test.integration.deviceReporterAware.windows", settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { @@ -57,15 +137,9 @@ gpii.tests.deviceReporterAware.windows = [ } } ] - } + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.deviceReporterAware.windows.flexibleHandlerEntries.nvda(true) }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq nvda.exe\" | find /I \"nvda.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ], deviceReporters: { "gpii.deviceReporter.registryKeyExists": { "expectInstalled": [{ @@ -80,14 +154,12 @@ gpii.tests.deviceReporterAware.windows = [ name: "Testing readwritegold_application1 using Flat matchmaker", userToken: "readwritegold_application1", gradeNames: "gpii.test.integration.deviceReporterAware.windows", - settingsHandlers: {}, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq ReadAndWrite.exe\" | find /I \"ReadAndWrite.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ], + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.deviceReporterAware.windows.flexibleHandlerEntries.readwrite(false) + }, + settingsHandlers: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.deviceReporterAware.windows.flexibleHandlerEntries.readwrite(true) + }, deviceReporters: { "gpii.deviceReporter.registryKeyExists": { "expectInstalled": [{ @@ -101,7 +173,7 @@ gpii.tests.deviceReporterAware.windows = [ ]; module.exports = gpii.test.bootstrap({ - testDefs: "gpii.tests.deviceReporterAware.windows", + testDefs: "gpii.tests.deviceReporterAware.windows.testDefs", configName: "windows-dynamicDeviceReporter-config", configPath: "%universal/tests/platform/windows/configs" }, ["gpii.test.integration.testCaseHolder.windows", "gpii.test.integration.deviceReporterAware.windows"], diff --git a/tests/platform/windows/windows-jaws-testSpec.js b/tests/platform/windows/windows-jaws-testSpec.js index 33b4cf4cc..24693d37a 100644 --- a/tests/platform/windows/windows-jaws-testSpec.js +++ b/tests/platform/windows/windows-jaws-testSpec.js @@ -22,15 +22,66 @@ fluid.require("%universal"); gpii.loadTestingSupport(); -fluid.registerNamespace("gpii.tests.windows"); +fluid.registerNamespace("gpii.tests.windows.jaws"); -gpii.tests.windows.jaws = [ +// To avoid duplicating this entire piece in each test. Given a true or false value +// as input, this will return a settingshandler entry, containing all the options from +// the solutions registry entry for NVDAs launchHandler, with a settings block with +// running: X - where X is replaced with the input parameter +gpii.tests.windows.jaws.flexibleHandlerEntry = function (running) { + return { + "com.freedomscientific.jaws": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "jfw" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\JAWS17.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "jfw.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "fsSynth32.exe" + }, + { + "type": "gpii.windows.closeProcessByName", + "filename": "jhookldr.exe" + } + ] + } + }] + }; +}; + +gpii.tests.windows.jaws.testDefs = [ { - name: "Testing NP set \"jaws_application\" using Flat matchmaker", + name: "Testing NP set \"jaws_application\"", userToken: "jaws_application", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "com.freedomscientific.jaws": [ { "settings": { "Voice Profiles.ActiveVoiceProfileName" : "GPII", @@ -84,23 +135,85 @@ gpii.tests.windows.jaws = [ } } ] - } + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) + } + }, + { + name: "Testing NP set \"jaws_application\" - where jaws is running on startup", + userToken: "jaws_application", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq jfw.exe\" | find /I \"jfw.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0", - "maxTimeouts": "40" - } - ] + settingsHandlers: { + "gpii.settingsHandlers.INISettingsHandler": { + "com.freedomscientific.jaws": [ + { + "settings": { + "Voice Profiles.ActiveVoiceProfileName" : "GPII", + "options.SayAllIndicateCaps" : false, + "options.TypingEcho": 3, + "options.SayAllMode": 0, + "Braille.BrailleMode": 0, + "options.SayAllIgnoreShiftKeys": true + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\enu\\DEFAULT.JCF" + } + }, + + { + "settings": { + "Options.PrimarySynthesizer" : "eloq", + "ENU-Global.Rate": 100, + "ENU-JAWSCursor.Rate": 100, + "ENU-Keyboard.Rate": 100, + "ENU-MenuAndDialog.Rate": 100, + "ENU-Message.Rate": 100, + "ENU-PCCursor.Rate": 100, + "ENU-Global.Pitch": 75, + "ENU-JAWSCursor.Pitch": 75, + "ENU-Keyboard.Pitch": 75, + "ENU-MenuAndDialog.Pitch": 75, + "ENU-Message.Pitch": 75, + "ENU-PCCursor.Pitch": 75, + "ENU-Global.Volume": 100, + "ENU-JAWSCursor.Volume": 100, + "ENU-Keyboard.Volume": 100, + "ENU-MenuAndDialog.Volume": 100, + "ENU-Message.Volume": 100, + "ENU-PCCursor.Volume": 100, + "ENU-Global.Punctuation": 2, + "ENU-JAWSCursor.Punctuation": 2, + "ENU-Keyboard.Punctuation": 2, + "ENU-MenuAndDialog.Punctuation": 2, + "ENU-Message.Punctuation": 2, + "ENU-PCCursor.Punctuation": 2, + "ENU-Global.SynthLangString": "Italian", + "ENU-JAWSCursor.SynthLangString": "Italian", + "ENU-Keyboard.SynthLangString": "Italian", + "ENU-MenuAndDialog.SynthLangString": "Italian", + "ENU-Message.SynthLangString": "Italian", + "ENU-PCCursor.SynthLangString": "Italian" + }, + "options": { + "filename": "${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\17.0\\Settings\\VoiceProfiles\\GPII.VPF" + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) + } }, { - name: "Testing NP set \"jaws_common\" using Flat matchmaker", + name: "Testing NP set \"jaws_common\"", userToken: "jaws_common", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "com.freedomscientific.jaws": [ { "settings": { "Options.PrimarySynthesizer": "eloq", @@ -154,23 +267,19 @@ gpii.tests.windows.jaws = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq jfw.exe\" | find /I \"jfw.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0", - "maxTimeouts": "40" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) + } }, { - name: "Testing NP set \"jaws_common2\" using Flat matchmaker", + name: "Testing NP set \"jaws_common2\"", userToken: "jaws_common2", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "com.freedomscientific.jaws": [ { "settings": { "Options.PrimarySynthesizer": "eloq", @@ -223,23 +332,19 @@ gpii.tests.windows.jaws = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq jfw.exe\" | find /I \"jfw.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0", - "maxTimeouts": "40" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) + } }, { - name: "Testing NP set \"jaws_common3\" using Flat matchmaker", + name: "Testing NP set \"jaws_common3\"", userToken: "jaws_common3", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "com.freedomscientific.jaws": [ { "settings": { "Options.PrimarySynthesizer": "eloq", @@ -293,21 +398,14 @@ gpii.tests.windows.jaws = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq jfw.exe\" | find /I \"jfw.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0", - "maxTimeouts": "40" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.jaws.flexibleHandlerEntry(true) + } } ]; module.exports = gpii.test.bootstrap({ - testDefs: "gpii.tests.windows.jaws", + testDefs: "gpii.tests.windows.jaws.testDefs", configName: "gpii.tests.acceptance.windows.jaws.config", configPath: "%universal/tests/platform/windows/configs" }, ["gpii.test.integration.testCaseHolder.windows"], diff --git a/tests/platform/windows/windows-maavis-testSpec.js b/tests/platform/windows/windows-maavis-testSpec.js index 313bd6abf..93ade6a8a 100644 --- a/tests/platform/windows/windows-maavis-testSpec.js +++ b/tests/platform/windows/windows-maavis-testSpec.js @@ -22,15 +22,57 @@ fluid.require("%universal"); gpii.loadTestingSupport(); -fluid.registerNamespace("gpii.tests.windows"); +fluid.registerNamespace("gpii.tests.windows.maavis"); -gpii.tests.windows.maavis = [ +// To avoid duplicating this entire piece in each test. Given a true or false value +// as input, this will return a settingshandler entry, containing all the options from +// the solutions registry entry for NVDAs launchHandler, with a settings block with +// running: X - where X is replaced with the input parameter +gpii.tests.windows.maavis.flexibleHandlerEntry = function (running) { + return { + "net.opendirective.maavis": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + "retryOptions": { + "rewriteEvery": 0, + "numRetries": 20 + }, + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "${{environment}.ComSpec} /c \"cd ${{environment}.MAAVIS_HOME} && MaavisPortable.cmd\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "firefox.exe" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "MaavisPortable" + } + ] + } + }] + }; +}; + +gpii.tests.windows.maavis.testDefs = [ { - name: "Testing maavis_highcontrast using Flat matchmaker", + name: "Testing maavis_highcontrast - when maavis is running on login", userToken: "maavis_highcontrast", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(true) + }, settingsHandlers: { "gpii.settingsHandlers.JSONSettingsHandler": { - "data": [ + "net.opendirective.maavis": [ { "settings": { "theme": "hc", @@ -43,21 +85,42 @@ gpii.tests.windows.maavis = [ } } ] - } + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(true) + } + }, { + name: "Testing maavis_highcontrast", + userToken: "maavis_highcontrast", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(false) }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq MaavisPortable.exe\" | find /I \"MaavisPortable.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + settingsHandlers: { + "gpii.settingsHandlers.JSONSettingsHandler": { + "net.opendirective.maavis": [ + { + "settings": { + "theme": "hc", + "speakTitles": "no", + "speakLabels": "no", + "speakOnActivate": "no" + }, + "options": { + "filename": "${{environment}.MAAVIS_HOME}\\MaavisMedia\\Users\\Default\\userconfig.json" + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(true) + } }, { - name: "Testing maavis_selfvoicing using Flat matchmaker", + name: "Testing maavis_selfvoicing", userToken: "maavis_selfvoicing", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.JSONSettingsHandler": { - "data": [ + "net.opendirective.maavis": [ { "settings": { "theme": "colour", @@ -70,20 +133,14 @@ gpii.tests.windows.maavis = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq MaavisPortable.exe\" | find /I \"MaavisPortable.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.maavis.flexibleHandlerEntry(true) + } } ]; module.exports = gpii.test.bootstrap({ - testDefs: "gpii.tests.windows.maavis", + testDefs: "gpii.tests.windows.maavis.testDefs", configName: "gpii.tests.acceptance.windows.maavis.config", configPath: "%universal/tests/platform/windows/configs" }, ["gpii.test.integration.testCaseHolder.windows"], diff --git a/tests/platform/windows/windows-nvda-testSpec.js b/tests/platform/windows/windows-nvda-testSpec.js index f09388034..fdc6ba26d 100644 --- a/tests/platform/windows/windows-nvda-testSpec.js +++ b/tests/platform/windows/windows-nvda-testSpec.js @@ -22,15 +22,61 @@ fluid.require("%universal"); gpii.loadTestingSupport(); -fluid.registerNamespace("gpii.tests.windows"); +fluid.registerNamespace("gpii.tests.windows.nvda"); -gpii.tests.windows.nvda = [ +// To avoid duplicating this entire piece in each test. Given a true or false value +// as input, this will return a settingshandler entry, containing all the options from +// the solutions registry entry for NVDAs launchHandler, with a settings block with +// running: X - where X is replaced with the input parameter +gpii.tests.windows.nvda.flexibleHandlerEntry = function (running) { + return { + "org.nvda-project": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 20, + retryInterval: 1000 + }, + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "nvda" + } + ], + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe\\}\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "nvda_service.exe" + },{ + "type": "gpii.windows.closeProcessByName", + "filename": "nvda.exe" + } + ] + } + }] + }; +}; + +gpii.tests.windows.nvda.testDef = [ { - name: "Testing screenreader_nvda using Flat matchmaker", + name: "Testing screenreader_nvda - When running on start", userToken: "screenreader_nvda", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(true) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "org.nvda-project": [ { "settings": { "speech.espeak.rate": 17, @@ -56,21 +102,55 @@ gpii.tests.windows.nvda = [ } } ] - } + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(true) + } + }, { + name: "Testing screenreader_nvda", + userToken: "screenreader_nvda", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(false) }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq nvda.exe\" | find /I \"nvda.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + settingsHandlers: { + "gpii.settingsHandlers.INISettingsHandler": { + "org.nvda-project": [ + { + "settings": { + "speech.espeak.rate": 17, + "speech.espeak.volume": 80, + "speech.espeak.pitch": 60, + "speech.espeak.rateBoost": true, + "speech.synth": "espeak", + "speech.outputDevice": "Microsoft Sound Mapper", + "speech.symbolLevel": 300, + "speech.espeak.voice": "en\\en-wi", + "reviewCursor.followFocus": false, + "reviewCursor.followCaret": true, + "reviewCursor.followMouse": true, + "keyboard.speakTypedWords": true, + "keyboard.speakTypedCharacters": false, + "presentation.reportHelpBalloons": false, + "speech.espeak.sayCapForCapitals": true + }, + "options": { + "filename": "${{environment}.APPDATA}\\nvda\\nvda.ini", + "allowNumberSignComments": true, + "allowSubSections": true + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(true) + } }, { - name: "Testing screenreader_common using Flat matchmaker", + name: "Testing screenreader_common", userToken: "screenreader_common", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "org.nvda-project": [ { "settings": { "speech.espeak.rate": 17, @@ -94,21 +174,18 @@ gpii.tests.windows.nvda = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq nvda.exe\" | find /I \"nvda.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(true) + } }, { - name: "Testing screenreader_orca using Flat matchmaker", + name: "Testing screenreader_orca", userToken: "screenreader_orca", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.INISettingsHandler": { - "some.app.id": [ + "org.nvda-project": [ { "settings": { "speech.symbolLevel": 300, @@ -126,20 +203,14 @@ gpii.tests.windows.nvda = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq nvda.exe\" | find /I \"nvda.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.nvda.flexibleHandlerEntry(true) + } } ]; module.exports = gpii.test.bootstrap({ - testDefs: "gpii.tests.windows.nvda", + testDefs: "gpii.tests.windows.nvda.testDef", configName: "gpii.tests.acceptance.windows.nvda.config", configPath: "%universal/tests/platform/windows/configs" }, ["gpii.test.integration.testCaseHolder.windows"], diff --git a/tests/platform/windows/windows-readWrite-testSpec.js b/tests/platform/windows/windows-readWrite-testSpec.js index 6b90bd2b0..7d6878adf 100644 --- a/tests/platform/windows/windows-readWrite-testSpec.js +++ b/tests/platform/windows/windows-readWrite-testSpec.js @@ -19,15 +19,59 @@ fluid.require("%universal"); gpii.loadTestingSupport(); -fluid.registerNamespace("gpii.tests.windows"); +fluid.registerNamespace("gpii.tests.windows.readwrite"); -gpii.tests.windows.readWrite = [ +// To avoid duplicating this entire piece in each test. Given a true or false value +// as input, this will return a settingshandler entry, containing all the options from +// the solutions registry entry for NVDAs launchHandler, with a settings block with +// running: X - where X is replaced with the input parameter +gpii.tests.windows.readwrite.flexibleHandlerEntry = function (running) { + return { + "com.texthelp.readWriteGold": [{ + "settings": { + "running": running + }, + "options": { + "verifySettings": true, + retryOptions: { + rewriteEvery: 0, + numRetries: 40, + retryInterval: 1000 + }, + "setTrue": [ + { + "type": "gpii.launch.exec", + "command": "\"${{registry}.HKEY_CURRENT_USER\\Software\\Texthelp\\Read&Write11\\InstallPath}\\ReadAndWrite.exe\"" + } + ], + "setFalse": [ + { + "type": "gpii.windows.closeProcessByName", + "filename": "ReadAndWrite.exe" + } + ], + "getState": [ + { + "type": "gpii.processReporter.find", + "command": "ReadAndWrite" + } + ] + } + }] + }; +}; + + +gpii.tests.windows.readwrite.testDefs = [ { - name: "Testing rwg1", + name: "Testing rwg1 - running on login", userToken: "rwg1", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(true) + }, settingsHandlers: { "gpii.settingsHandlers.XMLHandler": { - "some.app.id": [ + "com.texthelp.readWriteGold": [ { "settings": { "ApplicationSettings.AppBar.optToolbarIconSet.$t": "Fun", @@ -56,21 +100,58 @@ gpii.tests.windows.readWrite = [ } } ] - } + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(true) + } + }, { + name: "Testing rwg1", + userToken: "rwg1", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(false) }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq ReadAndWrite.exe\" | find /I \"ReadAndWrite.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + settingsHandlers: { + "gpii.settingsHandlers.XMLHandler": { + "com.texthelp.readWriteGold": [ + { + "settings": { + "ApplicationSettings.AppBar.optToolbarIconSet.$t": "Fun", + "ApplicationSettings.AppBar.optToolbarButtonGroupNameCurrent.$t": "Writing Features", + "ApplicationSettings.AppBar.DocType.$t": "1", + "ApplicationSettings.AppBar.ShowText.$t": "true", + "ApplicationSettings.AppBar.optToolbarShowText.$t": "true", + "ApplicationSettings.AppBar.LargeIcons.$t": "true", + "ApplicationSettings.AppBar.optToolbarLargeIcons.$t": "true", + "ApplicationSettings.Speech.optSAPI5Pitch.$t": "36", + "ApplicationSettings.Speech.optSAPI5Speed.$t": "38", + "ApplicationSettings.Speech.optSAPI5Volume.$t": "72", + "ApplicationSettings.Speech.optSAPI5PauseBetweenWords.$t": "0", + "ApplicationSettings.Speech.optSAPI5Voice.$t": "ScanSoft UK English Daniel", + "ApplicationSettings.Speech.WebHighlighting.$t": "false", + "ApplicationSettings.Translation.ToLanguage.$t": "fr", + "ApplicationSettings.Speech.optSAPI5SpeechHighlightContext.$t": "2", + "ApplicationSettings.Scanning.ScanDestination.$t": "PDF", + "ApplicationSettings.Scanning.ScanToFile.$t": "false", + "ApplicationSettings.Spelling.SpellAsIType.$t": "true" + }, + "options": { + "filename": "${{environment}.APPDATA}\\Texthelp\\ReadAndWrite\\11\\RWSettings11.xml", + "encoding": "utf-8", + "xml-tag": "" + } + } + ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(true) + } }, { name: "Testing rwg2", userToken: "rwg2", + initialState: { + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(false) + }, settingsHandlers: { "gpii.settingsHandlers.XMLHandler": { - "some.app.id": [ + "com.texthelp.readWriteGold": [ { "settings": { "ApplicationSettings.AppBar.optToolbarIconSet.$t": "Professional", @@ -101,20 +182,14 @@ gpii.tests.windows.readWrite = [ } } ] - } - }, - processes: [ - { - "command": "tasklist /fi \"STATUS eq RUNNING\" /FI \"IMAGENAME eq ReadAndWrite.exe\" | find /I \"ReadAndWrite.exe\" /C", - "expectConfigured": "1", - "expectRestored": "0" - } - ] + }, + "gpii.launchHandlers.flexibleHandler": gpii.tests.windows.readwrite.flexibleHandlerEntry(true) + } } ]; module.exports = gpii.test.bootstrap({ - testDefs: "gpii.tests.windows.readWrite", + testDefs: "gpii.tests.windows.readwrite.testDefs", configName: "gpii.tests.acceptance.windows.readWrite.config", configPath: "%universal/tests/platform/windows/configs" }, ["gpii.test.integration.testCaseHolder.windows"], diff --git a/tests/shared/ContextIntegrationTestDefs.js b/tests/shared/ContextIntegrationTestDefs.js index 4706f436c..a00e7ea2b 100644 --- a/tests/shared/ContextIntegrationTestDefs.js +++ b/tests/shared/ContextIntegrationTestDefs.js @@ -92,7 +92,7 @@ gpii.tests.contextIntegration.data = { "http://registry.gpii.net/common/environment/illuminance": 200, "http://registry.gpii.net/common/environment/auditory.noise": 10000 }, - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -117,7 +117,7 @@ gpii.tests.contextIntegration.data = { "http://registry.gpii.net/common/environment/illuminance": 500, "http://registry.gpii.net/common/environment/auditory.noise": 10000 }, - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -138,7 +138,7 @@ gpii.tests.contextIntegration.data = { } }, "onlyBright": { // if user logs in when brightness is active from the beginning - only expect mag - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -156,7 +156,7 @@ gpii.tests.contextIntegration.data = { "http://registry.gpii.net/common/environment/illuminance": 200, "http://registry.gpii.net/common/environment/auditory.noise": 30000 }, - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -181,7 +181,7 @@ gpii.tests.contextIntegration.data = { "http://registry.gpii.net/common/environment/illuminance": 500, "http://registry.gpii.net/common/environment/auditory.noise": 30000 }, - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -207,7 +207,7 @@ gpii.tests.contextIntegration.data = { gpii.tests.contextIntegration.fixtures = [ { name: "Simple context change after login", - expect: 9, + expect: 7, sequenceSegments: [ [ { @@ -235,7 +235,6 @@ gpii.tests.contextIntegration.fixtures = [ args: ["{lifecycleManager}", "context1", "gpii-default"] } ], - gpii.test.createProcessChecks(gpii.tests.contextIntegration.data.processes, "expectConfigured"), gpii.tests.contextIntegration.changeEnvironmentAndCheck("bright"), [ { @@ -243,11 +242,7 @@ gpii.tests.contextIntegration.fixtures = [ }, { event: "{logoutRequest}.events.onComplete", listener: "gpii.test.logoutRequestListen" - } - ], - gpii.test.createProcessChecks(gpii.tests.contextIntegration.data.processes, "expectRestored"), - [ - { + }, { func: "gpii.test.checkRestoredConfiguration", args: ["{tests}.contexts.gpii-default.settingsHandlers", "{tests}.settingsStore", "{nameResolver}", "{testCaseHolder}.events.onCheckRestoredConfigurationComplete.fire"] }, { @@ -259,7 +254,7 @@ gpii.tests.contextIntegration.fixtures = [ }, { name: "Context changed before login", - expect: 6, + expect: 5, sequenceSegments: [ [ { @@ -297,11 +292,7 @@ gpii.tests.contextIntegration.fixtures = [ }, { event: "{logoutRequest}.events.onComplete", listener: "gpii.test.logoutRequestListen" - } - ], - gpii.test.createProcessChecks(gpii.tests.contextIntegration.data.processes, "expectRestored"), - [ - { + }, { func: "gpii.test.checkRestoredConfiguration", args: ["{tests}.contexts.gpii-default.settingsHandlers", "{tests}.settingsStore", "{nameResolver}", "{testCaseHolder}.events.onCheckRestoredConfigurationComplete.fire"] }, { @@ -312,7 +303,7 @@ gpii.tests.contextIntegration.fixtures = [ ] }, { name: "Multiple context changes", - expect: 15, + expect: 13, sequenceSegments: [ [ { @@ -340,7 +331,6 @@ gpii.tests.contextIntegration.fixtures = [ args: ["{lifecycleManager}", "context1", "gpii-default"] } ], - gpii.test.createProcessChecks(gpii.tests.contextIntegration.data.processes, "expectConfigured"), gpii.tests.contextIntegration.changeEnvironmentAndCheck("bright"), gpii.tests.contextIntegration.changeEnvironmentAndCheck("gpii-default"), gpii.tests.contextIntegration.changeEnvironmentAndCheck("noise"), @@ -351,11 +341,7 @@ gpii.tests.contextIntegration.fixtures = [ }, { event: "{logoutRequest}.events.onComplete", listener: "gpii.test.logoutRequestListen" - } - ], - gpii.test.createProcessChecks(gpii.tests.contextIntegration.data.processes, "expectRestored"), - [ - { + }, { func: "gpii.test.checkRestoredConfiguration", args: ["{tests}.contexts.gpii-default.settingsHandlers", "{tests}.settingsStore", "{nameResolver}", "{testCaseHolder}.events.onCheckRestoredConfigurationComplete.fire"] }, { diff --git a/tests/shared/PCPIntegrationTestDefs.js b/tests/shared/PCPIntegrationTestDefs.js index 2372313c3..772012464 100644 --- a/tests/shared/PCPIntegrationTestDefs.js +++ b/tests/shared/PCPIntegrationTestDefs.js @@ -66,7 +66,7 @@ gpii.tests.pcpIntegration.connectionSucceeded = function (data) { gpii.tests.pcpIntegration.data = { initial: { - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -87,7 +87,7 @@ gpii.tests.pcpIntegration.data = { } }, afterChange1: { - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -108,7 +108,7 @@ gpii.tests.pcpIntegration.data = { } }, afterChange2: { - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": { @@ -129,7 +129,7 @@ gpii.tests.pcpIntegration.data = { } }, bright: { - "settingsHandlers": { + "handlers": { "gpii.gsettings": { "data": [{ "settings": {