UNPKG

gpii-universal

Version:

Cross platform, core components of the GPII personalization infrastructure.

1,174 lines (1,137 loc) 49.2 kB
/*! GPII MatchMaker Utilities Tests Copyright 2014 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, JSON5 */ var fluid = fluid || require("infusion"), gpii = fluid.registerNamespace("gpii"), $ = fluid.registerNamespace("jQuery"); (function () { "use strict"; fluid.registerNamespace("gpii.tests.matchMakerUtilities"); var transformSpec = JSON5.parse($.ajax({ type: "GET", url: "../../../../../testData/ontologies/mappings/ISO24751-flat.json5", async: false }).responseText); var apptologyTransformSpec = JSON5.parse($.ajax({ type: "GET", url: "../../../../../testData/ontologies/mappings/flat-apptology.json5", async: false }).responseText); var computeLeavesFixtures = [ { name: "Nested structure including empty objects", model: { "display": { "screenEnhancement": { "fontSize": 24, "foregroundColor": "white", "backgroundColor": "black", "fontFace": { "genericFontFace": "sans serif" }, "screenMagnification": { } } }, "control": { "structuralNavigation": { "tableOfContents": false } } }, expected: [ "display.screenEnhancement.fontSize", "display.screenEnhancement.foregroundColor", "display.screenEnhancement.backgroundColor", "display.screenEnhancement.fontFace.genericFontFace", "control.structuralNavigation.tableOfContents" ] }, { name: "Array parsing disabled", model: { "com.microsoft.windows.narrator": { "http://registry.gpii.net/common/speechRate": 180, "http://registry.gpii.net/common/pitch": 0.2 }, "http://registry.gpii.net/common/trackingTTS": ["focus","mouse"], "http://registry.gpii.net/applications/com.microsoft.windows.magnifier": { "invertColours": true } }, expected: [ "com\\.microsoft\\.windows\\.narrator.http://registry\\.gpii\\.net/common/speechRate", "com\\.microsoft\\.windows\\.narrator.http://registry\\.gpii\\.net/common/pitch", "http://registry\\.gpii\\.net/common/trackingTTS.0", "http://registry\\.gpii\\.net/common/trackingTTS.1", "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.magnifier.invertColours" ] } ]; gpii.tests.matchMakerUtilities.computeLeaves = function () { fluid.each(computeLeavesFixtures, function (fixture) { var result = gpii.matchMakerFramework.utils.computeLeaves(fixture.model); jqUnit.assertDeepEq(fixture.name, fixture.expected, result); }); }; var pathsToSkeletonFixtures = [ { description: "Object with various levels of nesting", expected: { "display": { "screenEnhancement": { "fontSize": {}, "foregroundColor": {}, "backgroundColor": {}, "fontFace": { "genericFontFace": {} } }, "hello": {} }, "control": { "structuralNavigation": { "tableOfContents": {} } }, "cat": {} }, model: [ "display.screenEnhancement.fontSize", "display.screenEnhancement.foregroundColor", "display.screenEnhancement.backgroundColor", "display.screenEnhancement.fontFace.genericFontFace", "display.hello", "control.structuralNavigation.tableOfContents", "cat" ] }, { description: "Object with various levels of nesting", expected: { "display": { "screenEnhancement": { "fontSize": true, "foregroundColor": true, "backgroundColor": true, "fontFace": { "genericFontFace": true } }, "hello": true }, "control": { "structuralNavigation": { "tableOfContents": true } }, "cat": true }, model: [ "display.screenEnhancement.fontSize", "display.screenEnhancement.foregroundColor", "display.screenEnhancement.backgroundColor", "display.screenEnhancement.fontFace.genericFontFace", "display.hello", "control.structuralNavigation.tableOfContents", "cat" ], value: true } ]; gpii.tests.matchMakerUtilities.pathsToSkeleton = function () { fluid.each(pathsToSkeletonFixtures, function (fixture) { var result = gpii.matchMakerFramework.utils.pathsToSkeleton(fixture.model, fixture.value); jqUnit.assertDeepEq(fixture.name, fixture.expected, result); }); }; var computeAndOntologizeCapabilitiesFromSolutionFixture = { description: "solution incl capabilities and transformations", solution: { "name": "GNOME Shell Magnifier", "contexts": {}, "capabilities": [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], "settingsHandlers": { "configuration": { "type": "gpii.gsettings", "options": { "schema": "org.gnome.desktop.a11y.magnifier" }, "capabilitiesTransformations": { "mag-factor": "http://registry\\.gpii\\.net/common/magnification", "show-cross-hairs": "http://registry\\.gpii\\.net/common/showCrosshairs", "transform": { "type": "fluid.transforms.arrayToSetMembership", "inputPath": "http://registry\\.gpii\\.net/common/tracking", "presentValue": "proportional", "missingValue": "none", "options": { "focus": "focus-tracking", "caret": "caret-tracking", "mouse": "mouse-tracking" } }, "screen-position": { "transform": { "type": "fluid.transforms.valueMapper", "defaultInputPath": "http://registry\\.gpii\\.net/common/magnifierPosition", "match": { "FullScreen": "full-screen" } } }, "someSetting": "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled" } } }, "isInstalled": [ { "type": "gpii.packageKit.find", "name": "gnome-shell" } ] }, expectedCapabilities: [ "http://registry\\.gpii\\.net/common/tracking", "http://registry\\.gpii\\.net/common/magnification", "http://registry\\.gpii\\.net/common/showCrosshairs", "http://registry\\.gpii\\.net/common/magnifierPosition", "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled", "http://registry\\.gpii\\.net/common/magnification/enabled" ], expectedSpecialCapabilities: [ "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled", "http://registry\\.gpii\\.net/common/magnification/enabled" ], expectedISO: [ "display.screenEnhancement.tracking", "display.screenEnhancement.magnification", "display.screenEnhancement.-provisional-magnifierPosition", "display.screenEnhancement.-provisional-magnification/enabled", "display.screenReader.-provisional-screenReaderTTS/enabled" ], expectedApptology: [ "http://registry\\.gpii\\.net/common/magnifierApplication", "http://registry\\.gpii\\.net/common/screenReaderApplication" ] }; gpii.tests.matchMakerUtilities.computeAndOntologizeCapabilitiesFromSolution = function () { var fixture = computeAndOntologizeCapabilitiesFromSolutionFixture; var capabilities = gpii.matchMakerFramework.utils.computeCapabilitiesFromSolution(fixture.solution); jqUnit.assertDeepEq("Capabilities computed by gpii.matchMakerFramework.utils.computeCapabilitiesFromSolution", fixture.expectedCapabilities, capabilities); var specialCapabilities = gpii.matchMakerFramework.utils.extractSpecialCapabilities(capabilities); jqUnit.assertDeepEq("Special capabilities computed by gpii.matchMakerFramework.utils.extractSpecialCapabilities", fixture.expectedSpecialCapabilities, specialCapabilities); var flatToISOSpec = fluid.model.transform.invertConfiguration(transformSpec); var resultISO = gpii.matchMakerFramework.utils.transformCapabilitiesToOntologizedLeaves(capabilities, flatToISOSpec); jqUnit.assertDeepEq("Capabilities to ISO leaves (gpii.matchMakerFramework.utils.transformCapabilitiesToOntologizedLeaves)", fixture.expectedISO, resultISO); var resultApptology = gpii.matchMakerFramework.utils.transformCapabilitiesToOntologizedLeaves(capabilities, apptologyTransformSpec); jqUnit.assertDeepEq("Capabilities to apptology (gpii.matchMakerFramework.utils.transformCapabilitiesToOntologizedLeaves)", fixture.expectedApptology, resultApptology); }; var buildReturnPayloadFixtures = [ { description: "Basic payloads", disposed: { "gpii-default": { "mac.dummy": true } }, fullModel: { "gpiiKey": "mac", "preferences": { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } }, "deviceReporter": { "solutions": [ { "id": "mac.dummy" }, { "id": "mac.dummy_empty" } ], "OS": { "id": "darwin", "version": "12.5.0" } }, "solutionsRegistryEntries": { "mac.dummy": { "name": "Mac dummy", "contexts": { "OS": [ { "id": "darwin" } ] }, "settingsHandlers": { "myconf": { "type": "gpii.settingsHandlers.JSONSettingsHandler.set", "options": { "path": "/path/to/some/file.json" }, "capabilitiesTransformations": { "setting1": "http://registry\\.gpii\\.net/common/fontSize", "setting2.path1": "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled", "setting2.path2": "http://registry\\.gpii\\.net/common/magnification/enabled", "setting2.path3.hello": "http://registry\\.gpii\\.net/common/magnification" } } }, "configure": [ "settings.myconf" ], "restore": [ "settings.myconf" ] }, "mac.dummy_empty": { "name": "Mac dummy empty", "contexts": { "OS": [ { "id": "darwin" } ] }, "settingsHandlers": { "otherconf": { "type": "gpii.settingsHandlers.noSettings" } }, "start": [], "stop": [] } }, "hierarchicalPrefs": { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "display": { "screenEnhancement": { "fontSize": 16, "magnification": 1, "-provisional-magnification/enabled": false }, "screenReader": { "-provisional-screenReaderTTS/enabled": false } } } } } } }, expected: { "inferredConfiguration": { "gpii-default": { "applications": { "mac.dummy": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } } } ]; gpii.tests.matchMakerUtilities.buildReturnPayload = function () { fluid.each(buildReturnPayloadFixtures, function (fixture) { var result = gpii.matchMakerFramework.utils.buildReturnPayload(fixture.fullModel, fixture.disposed); jqUnit.assertDeepEq(fixture.description, fixture.expected, result); }); }; var addSolutionTypeInformationFixtures = [{ name: "Three solutions, two of same type", payload: { solutionCapabilities: { "fakemag1": [ "http://registry\\.gpii\\.net/common/magnification/enabled", "http://registry\\.gpii\\.net/common/magnification" ], "fakemag2": [ "http://registry\\.gpii\\.net/common/magnification/enabled", "http://registry\\.gpii\\.net/common/magnification", "http://registry\\.gpii\\.net/common/invertColours" ], "fakescreenreader1": [ "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled", "http://registry\\.gpii\\.net/common/pitch", "http://registry\\.gpii\\.net/common/volumeTTS", "http://registry\\.gpii\\.net/common/speechRate" ] } }, expectedSolutionTypes: { "fakemag1": [ "http://registry\\.gpii\\.net/common/magnifierApplication" ], "fakemag2": [ "http://registry\\.gpii\\.net/common/magnifierApplication" ], "fakescreenreader1": [ "http://registry\\.gpii\\.net/common/screenReaderApplication" ] }, expectedSolutionTypeMapping: { "http://registry\\.gpii\\.net/common/magnifierApplication": { "fakemag1": true, "fakemag2": true }, "http://registry\\.gpii\\.net/common/screenReaderApplication": { "fakescreenreader1": true } } }]; gpii.tests.matchMakerUtilities.testAddSolutionTypeInformation = function () { jqUnit.module("AddSolutionTypeInformation tests"); fluid.each(addSolutionTypeInformationFixtures, function (fixture) { var payload = fluid.copy(fixture.payload); gpii.matchMakerFramework.utils.addSolutionTypeInformation(payload, apptologyTransformSpec); jqUnit.assertDeepEq(fixture.name + ". Checking solutions types are properly added", fixture.expectedSolutionTypes, payload.solutionTypes); jqUnit.assertDeepEq(fixture.name + ". Checking solutions Mapping is properly added", fixture.expectedSolutionTypeMapping, payload.solutionTypeMapping); }); }; gpii.tests.matchMakerUtilities.updateInferredConfigurationSolutionRegistryEntries = { "fake.magnifier1": { "capabilities": [] }, "fake.magnifier2": { "capabilities": [] }, "fake.magnifier3": { "capabilities": [ "http://registry\\.gpii\\.net/common/magnification/enabled" ] }, "fontSizer": { "capabilities": [] } }; gpii.tests.matchMakerUtilities.updateInferredConfigurationTestDefs = [{ name: "single top-level common term, single application", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/fontSize": 20 } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 20, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "multiple top-level common terms in preferences, single application", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/fontSize": 20, "http://registry.gpii.net/common/magnification": 2 } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 20, "http://registry.gpii.net/common/screenReaderTTS/enabled": false, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 2 } } } } } }, { name: "common terms in preferences not matching applications in inferred", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/fontSize": 20 } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "multiple top-level common terms in preferences, multiple application", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/fontSize": 20, "http://registry.gpii.net/common/magnification": 2 } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } }, "fontSizer": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 12, "http://registry.gpii.net/common/screenReaderTTS/enabled": false } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 2 } }, "fontSizer": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 20, "http://registry.gpii.net/common/screenReaderTTS/enabled": false } } } } } }, { name: "Common terms in preferences scoped to an application", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/fake.magnifier1": { "http://registry.gpii.net/common/magnification": 2 } } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } }, "fake.magnifier2": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 2 } }, "fake.magnifier2": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "Common terms in preferences, both scoped and not scoped to an application", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/fake.magnifier1": { "http://registry.gpii.net/common/magnification": 2 }, "http://registry.gpii.net/common/magnification/enabled": true } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } }, "fake.magnifier2": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier1": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 2 } }, "fake.magnifier2": { "active": true, "settings": { "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "'enabled' term in updated preferences, resulting in 'active' change", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/common/magnification/enabled": false } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier3": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier3": { "active": false, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "application scoped 'enabled' term in updated preferences, resulting in 'active' change", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/fake.magnifier3": { "http://registry.gpii.net/common/magnification/enabled": false } } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier3": { "active": true, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier3": { "active": false, "settings": { "http://registry.gpii.net/common/fontSize": 16, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "application scoped 'enabled' term in updated preferences, but for other application (i.e. no 'active' change)", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/fake.magnifier2": { "http://registry.gpii.net/common/magnification/enabled": true } } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier2": { "active": false, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } }, "fake.magnifier3": { "active": false, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier2": { "active": false, "settings": { "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } }, "fake.magnifier3": { "active": false, "settings": { "http://registry.gpii.net/common/magnification/enabled": false, "http://registry.gpii.net/common/magnification": 1 } } } } } }, { name: "GPII-3995: application terms can have non-common terms nested in it", preferences: { "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/fake.magnifier3": { fontSize: 18 } } } } }, inferredConfiguration: { "gpii-default": { "applications": { "fake.magnifier3": { "active": true, "settings": { "http://registry.gpii.net/applications/fake.magnifier3": { fontSize: 16 }, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } } } } }, expected: { "gpii-default": { "applications": { "fake.magnifier3": { "active": true, "settings": { "http://registry.gpii.net/applications/fake.magnifier3": { fontSize: 18 }, "http://registry.gpii.net/common/screenReaderTTS/enabled": true, "http://registry.gpii.net/common/magnification/enabled": true, "http://registry.gpii.net/common/magnification": 1 } } } } } }]; gpii.tests.matchMakerUtilities.updateInferredConfiguration = function () { jqUnit.module("Tests for updateInferredConfiguration"); fluid.each(gpii.tests.matchMakerUtilities.updateInferredConfigurationTestDefs, function (testDef) { var result = gpii.matchMakerFramework.utils.updateInferredConfiguration(testDef.preferences, testDef.inferredConfiguration, gpii.tests.matchMakerUtilities.updateInferredConfigurationSolutionRegistryEntries); jqUnit.assertDeepEq(testDef.name, testDef.expected, result); }); }; fluid.registerNamespace("gpii.tests.matchMakerUtilities.getLeastLiveness"); gpii.tests.matchMakerUtilities.getLeastLiveness.solutions = { "fakemag1": { "capabilities": [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], "settingsHandlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { "filename": "/tmp/fakemag1.settings.json" }, "capabilitiesTransformations": { "magnification": "http://registry\\.gpii\\.net/common/magnification" }, "liveness": "live" } } }, "fakemag2": { "capabilities": [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], "settingsHandlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { "filename": "/tmp/fakemag2.settings.json" }, "capabilitiesTransformations": { "magnification": "http://registry\\.gpii\\.net/common/magnification", "invert": "http://registry\\.gpii\\.net/common/invertColours" }, "liveness": "liveRestart" } } }, "fakescreenreader1": { "capabilities": [ "http://registry\\.gpii\\.net/common/screenReaderTTS/enabled" ], "settingsHandlers": { "configuration": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { "filename": "/tmp/fakescreenreader1.json" }, "capabilitiesTransformations": { "rate": "http://registry\\.gpii\\.net/common/speechRate" }, "liveness": "OSRestart" }, "configuration2": { "type": "gpii.settingsHandlers.JSONSettingsHandler", "options": { "filename": "/tmp/fakescreenreader1.json" }, "capabilitiesTransformations": { "pitch": "http://registry\\.gpii\\.net/common/pitch", "volumeTTS": "http://registry\\.gpii\\.net/common/volumeTTS", "rate": "http://registry\\.gpii\\.net/common/speechRate" }, "liveness": "manualRestart" } } } }; gpii.tests.matchMakerUtilities.getLeastLiveness.testData = [ { name: "Basic with single solution", term: "http://registry.gpii.net/common/magnification", solutions: fluid.filterKeys(gpii.tests.matchMakerUtilities.getLeastLiveness.solutions, ["fakemag1"]), expected: "live" }, { name: "Term present in multiple solutions, least lively wins", term: "http://registry.gpii.net/common/magnification", solutions: fluid.filterKeys(gpii.tests.matchMakerUtilities.getLeastLiveness.solutions, ["fakemag1", "fakemag2"]), expected: "liveRestart" }, { name: "Term inferred from capability transformations", term: "http://registry.gpii.net/common/invertColours", solutions: fluid.filterKeys(gpii.tests.matchMakerUtilities.getLeastLiveness.solutions, [ "fakemag2"]), expected: "liveRestart" }, { name: "Term in a secondary settingshandler block", term: "http://registry.gpii.net/common/pitch", solutions: fluid.filterKeys(gpii.tests.matchMakerUtilities.getLeastLiveness.solutions, [ "fakescreenreader1"]), expected: "manualRestart" }, { name: "No terms provided", term: undefined, solutions: fluid.filterKeys(gpii.tests.matchMakerUtilities.getLeastLiveness.solutions, [ "fakescreenreader1"]), expected: "OSRestart" } ]; gpii.tests.matchMakerUtilities.getLeastLiveness.tests = function () { jqUnit.module("Tests for getLeastLiveness"); fluid.each(gpii.tests.matchMakerUtilities.getLeastLiveness.testData, function (testDef) { var liveness = gpii.matchMakerFramework.utils.getLeastLiveness(testDef.solutions, testDef.term); jqUnit.assertDeepEq(testDef.name, testDef.expected, liveness); }); }; gpii.tests.matchMakerUtilities.getActiveValueFromEnabledTermsData = [ { name: "no enabled terms in the user's preference set", args: { specialPreferences: {}, specialCapabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], solution: { capabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ] }, solutionId: "my.solution" }, expected: undefined }, { name: "no enabled term in solutions capability", args: { specialPreferences: { "http://registry.gpii.net/common/magnification/enabled": true }, specialCapabilities: [ ], solution: {}, solutionId: "my.solution" }, expected: undefined }, { name: "enabled term in outer level of prefs - 'true' value", args: { specialPreferences: { "http://registry.gpii.net/common/magnification/enabled": true }, specialCapabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], solution: { capabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ] }, solutionId: "my.solution" }, expected: true }, { name: "enabled term in outer level of prefs - 'false' value", args: { specialPreferences: { "http://registry.gpii.net/common/magnification/enabled": false }, specialCapabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], solution: { capabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ] }, solutionId: "my.solution" }, expected: false }, { name: "enabled term in application specific block of prefs", args: { specialPreferences: { "http://registry.gpii.net/applications/my.solution": { "http://registry.gpii.net/common/magnification/enabled": true } }, specialCapabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], solution: { capabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ] }, solutionId: "my.solution" }, expected: true }, { name: "enabled capability is from capabilities transformations (not from solution's capabilities block)", args: { specialPreferences: { "http://registry.gpii.net/common/magnification/enabled": true }, specialCapabilities: [ "http://registry\\.gpii\\.net/common/magnification/enabled" ], solution: { capabilities: [] }, solutionId: "my.solution" }, expected: undefined } ]; gpii.tests.matchMakerUtilities.getActiveValueFromEnabledTerms = function () { jqUnit.module("Tests for getActiveValueFromEnabledTerms"); fluid.each(gpii.tests.matchMakerUtilities.getActiveValueFromEnabledTermsData, function (def) { var result = gpii.matchMakerFramework.utils.getActiveValueFromEnabledTerms(def.args.specialPreferences, def.args.specialCapabilities, def.args.solution, def.args.solutionId); jqUnit.assertDeepEq(def.name, def.expected, result); }); }; gpii.tests.matchMakerUtilities.runTests = function () { jqUnit.module("MatchMakerUtilities"); jqUnit.test("Compute Leaves", gpii.tests.matchMakerUtilities.computeLeaves); jqUnit.test("Paths to Skeleton", gpii.tests.matchMakerUtilities.pathsToSkeleton); jqUnit.test("Compute Capabilities From Solution", gpii.tests.matchMakerUtilities.computeAndOntologizeCapabilitiesFromSolution); jqUnit.test("Build Return Payload", gpii.tests.matchMakerUtilities.buildReturnPayload); jqUnit.test("Adding solution type information to payload", gpii.tests.matchMakerUtilities.testAddSolutionTypeInformation); jqUnit.test("Updated Inferred Configuration with preferences", gpii.tests.matchMakerUtilities.updateInferredConfiguration); jqUnit.test("Test getLeastLiveness functionality", gpii.tests.matchMakerUtilities.getLeastLiveness.tests); jqUnit.test("Test getActiveValueFromEnabledTerms", gpii.tests.matchMakerUtilities.getActiveValueFromEnabledTerms); }; })();