diff --git a/gpii/node_modules/solutionsRegistry/src/js/SolutionsUtils.js b/gpii/node_modules/solutionsRegistry/src/js/SolutionsUtils.js new file mode 100644 index 000000000..070c6c02a --- /dev/null +++ b/gpii/node_modules/solutionsRegistry/src/js/SolutionsUtils.js @@ -0,0 +1,107 @@ +/* + * GPII Solutions Utils - Independent helper functions and utilities for working with + * solutions and their schemas. + * + * Copyright 2019 Raising the Floor - US + * + * 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 + */ +"use strict"; +var fluid = require("infusion"); +var gpii = fluid.registerNamespace("gpii"); + +fluid.registerNamespace("gpii.universal.solutionsRegistry"); + +/** + * This function will take a schema from a supported setting in the solutions + * registry and return metadata on it's default value, including the type of + * the default value. The function will always return a block of json in order + * to avoid any ambiguities for a situation where the default value is perhaps + * `null`. A key `hasDefault` will be `true` or `false` to communicate this. + * If the schema does have a default value, then the properties `type` and + * `default` can also be included. Note that there may not always be a `type` + * that can be included, the inclusion of this in the return if optional and + * will be included if a `type` is declared. + * + * This is NOT meant to be an exhaustive coverage of all the possible ways + * default values can be set for any JSON Schema. We merely want to cover the + * cases in use in the solutions registry, focussing on single primitive values, + * and situations where we next one level deep due to a requirement of having a + * `properties` entry in the schema. + * + * @param {Object} schema - Schema to search for a default value. This is what + * would be in the solutions registry under `supportedSettings` and a + * configuration. An example from the Windows Mouse Keys MaxSpeed setting is: + * ```json + * { + * "title": "Mouse keys speed", + * "description": "Speed of mouse keys", + * "type": "number", + * "multipleOf": 10, + * "default": 80 + * } + * ``` + * @return {Object} Always returns a json block. For the example above the + * return value would be: + * ```json + * { + * "hasDefault": true, + * "type": "number", + * "default": 80 + * } + * ``` + * If a default value cannot be detected the return payload will be: + * ```json + * { + * "hasDefault": false + * } + * ``` + */ +gpii.universal.solutionsRegistry.findDefaultValue = function (schema) { + var togo; + + // 1. The most simple, and hopefull case is that there is a top level + // default value. + if (schema["default"] !== undefined) { + togo = { + hasDefault: true, + default: schema["default"] + }; + if (schema.type) { + togo.type = schema.type; + } + } + // 2. Sometimes we have a properties structure that can be interogated, example: + // "properties": { + // "path": { "type": "string"}, + // "value": { + // "type": "string", + // "default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" + // } + // } + else if (fluid.get(schema, "properties.value.default") !== undefined) { + togo = { + hasDefault: true, + default: schema.properties.value["default"] + }; + if (schema.properties.value.type) { + togo.type = schema.properties.value.type; + } + } + // We cannot find a default value for our simplified usage of json schema... + else { + togo = { + hasDefault: false + }; + } + + return togo; +}; diff --git a/gpii/node_modules/solutionsRegistry/test/SolutionsUtilsTests.js b/gpii/node_modules/solutionsRegistry/test/SolutionsUtilsTests.js new file mode 100644 index 000000000..195c0793c --- /dev/null +++ b/gpii/node_modules/solutionsRegistry/test/SolutionsUtilsTests.js @@ -0,0 +1,153 @@ +/* + * Tests for GPII Solutions Utils + * + * Copyright 2019 Raising the Floor - US + * + * 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 + */ + +"use strict"; +var fluid = require("infusion"); +var gpii = fluid.registerNamespace("gpii"); +var jqUnit = require("node-jqunit"); + +require("../src/js/SolutionsUtils"); + +jqUnit.module("Tests for Solutions Registry Utility functions."); + +fluid.registerNamespace("gpii.tests.universal.solutionsRegistry.solutionsUtils"); + +gpii.tests.universal.solutionsRegistry.solutionsUtils.defaultValueTests = [ + { + schema: { + "title": "Attribute Rotation Delay", + "description": "When in Attribute...", + "type": "integer", + "default": 1000 + }, + result: { + hasDefault: true, + type: "integer", + default: 1000 + } + }, + { + schema: { + "title": "Attribute Rotation Delay", + "description": "When in Attribute...", + "default": 1000 + }, + result: { + hasDefault: true, + default: 1000 + } + }, + { + schema: { + "title": "Attribute Rotation Delay With No Default...", + "description": "When in Attribute...", + "type": "integer" + }, + result: { + hasDefault: false + } + }, + { + schema: { + "title": "Desktop background wallpaper", + "description": "The path to the image to be set as the new desktop wallpaper.", + "properties": { + "path": { "type": "string"}, + "value": { + "type": "string", + "default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" + } + } + }, + result: { + hasDefault: true, + type: "string", + default: "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" + } + }, + { + schema: { + "title": "Desktop background wallpaper", + "description": "The path to the image to be set as the new desktop wallpaper.", + "properties": { + "path": { "type": "string"}, + "value": { + "default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" + } + } + }, + result: { + hasDefault: true, + default: "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" + } + }, + { + schema: { + "title": "Desktop background wallpaper", + "description": "The path to the image to be set as the new desktop wallpaper.", + "properties": { + "path": { "type": "string", "required": true}, + "value": { + "type": "string", + "required": true, + "default": "" + } + } + }, + result: { + hasDefault: true, + type: "string", + default: "" + } + }, + { + schema: { + "title": "Screen mirroring", + "description": "Mirrors the primary screen into a secondary screen.", + "type": "boolean", + "default": false + }, + result: { + hasDefault: true, + type: "boolean", + default: false + } + } +]; + +gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTest = function (schema, expectedResult) { + var result = gpii.universal.solutionsRegistry.findDefaultValue(schema); + jqUnit.assertDeepEq("Checking default value for: " + schema.title, expectedResult, result); +}; + +gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTests = function () { + jqUnit.test("Testing my empty stubs...", function () { + fluid.each(gpii.tests.universal.solutionsRegistry.solutionsUtils.defaultValueTests, function (item) { + gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTest(item.schema, item.result); + }); + }); +}; + +fluid.defaults("gpii.tests.universal.solutionsRegistry.solutionsUtils", { + gradeNames: ["fluid.component"], + listeners: { + "onCreate.findDefaultValueTest": { + funcName: "gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTests" + } + } +}); + +gpii.tests.universal.solutionsRegistry.solutionsUtils(); diff --git a/gpii/node_modules/solutionsRegistry/test/all-tests.js b/gpii/node_modules/solutionsRegistry/test/all-tests.js index 96e6da5b1..da5d62907 100644 --- a/gpii/node_modules/solutionsRegistry/test/all-tests.js +++ b/gpii/node_modules/solutionsRegistry/test/all-tests.js @@ -5,3 +5,4 @@ require("./ValidationMiddlewareTests.js"); require("./GenericTermsTests.js"); require("./SettingsPayloadTests.js"); require("./SolutionsRegistryFileTests.js"); +require("./SolutionsUtilsTests.js"); diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 0cfba1702..3004df224 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -917,6 +917,15 @@ "default": 0 } }, + "Options.AutomaticNotificationOfUpdates": { + "schema": { + "title": "Automatic Notification of Updates", + "description": "Whether to show automatic notifications for updates.", + "enum": [0, 1], + "enumLabels": ["off", "on"], + "default": 0 + } + }, // This does not seem safe to update, as we have no idea which displays are available on a given machine. // "Options.BrailleDisplay": { // "schema": { @@ -926,6 +935,15 @@ // "default": "Braille1" // } // }, + "Options.bVirtViewer": { + "schema": { + "title": "Show Virtual Viewer on screen", + "description": "Whether to show the virtual viewer on screen.", + "enum": [0, 1], + "enumLabels": ["off", "on"], + "default": 0 + } + }, "Options.CapIndicator": { "schema": { "title": "Cap Indicator", @@ -1283,14 +1301,24 @@ } }, // No documentation, disabled for now. - // "Options.KeyboardType": { - // "schema": { - // "title": "Keyboard Type", - // "description": "Can be one of the types defined in the default.jkm settings file.", - // "type": "string", - // "default": "Laptop" - // } - // }, + "Options.KeyboardType": { + "schema": { + "title": "Keyboard Type", + "description": "Can be one of the types defined in the default.jkm settings file.", + "type": "string", + "default": "Desktop", + "enum": [ + "Desktop", + "Laptop", + "Kinesis" + ], + "enumLabels": [ + "Desktop", + "Laptop", + "Kinesis" + ] + } + }, "Options.KeyRepeat": { "schema": { "title": "Key Repeat", @@ -2311,6 +2339,21 @@ ] } }, + "Options.ViewMode": { + "schema": { + "title": "Run JAWS from System Tray", + "description": "Whether to run JAWS from the System Tray", + "default": 0, + "enum": [ + 0, + 1 + ], + "enumLabels": [ + "off", + "on" + ] + } + }, "Options.VirtualDocumentLinkActivationMethod": { "schema": { "title": "Virtual Document Link Activation Method", @@ -2617,6 +2660,44 @@ "default": 0 } }, + "OutputModes.ACCESS_KEY": { + "schema": { + "title": "Access Key", + "description": "Which items to speak with the access key???", + "type": "string", + "default": "1|1|1|Access Key", + "enum": [ + "0|0|0|Access Key", + "1|1|1|Access Key", + "2|2|2|Access Key", + "3|3|3|Access Key" + ], + "enumLabels": [ + "Off", + "Speak all", + "Speak menus only", + "Speak dialogs only" + ] + } + }, + "OutputModes.TUTOR": { + "schema": { + "title": "Tutor Messages", + "description": "Which items to speak with the access key???", + "type": "string", + "default": "1|1|1|Tutor", + "enum": [ + "0|0|0|Tutor", + "1|1|1|Tutor", + "2|2|2|Tutor" + ], + "enumLabels": [ + "Turn off menu and control help", + "Announce menu and control help", + "Announce custom messages only" + ] + } + }, // TODO: Document default. "Touch.FlickVelocityMin": { "schema": { @@ -4803,7 +4884,7 @@ ] }, "com.microsoft.windows.desktopBackground": { - "name": "Windows desktop background personalization", + "name": "Windows desktop background wallpaper", "contexts": { "OS": [ { @@ -5007,7 +5088,7 @@ ] }, "com.microsoft.windows.desktopBackgroundColor": { - "name": "Windows desktop background personalization", + "name": "Windows desktop background color", "contexts": { "OS": [ { @@ -6325,13 +6406,26 @@ "properties": { "path": { "type": "string", "required": true}, "value": { + // In the current Windows 10 UI this goes from 0.0 seconds + // to 20.0 seconds in somewhat random steps in a combo box: + // 0.0, 0.3, 0.5, 0.7, 1.0, 1.4, 2.0, 5.0, 10.0, 20.0 + // TODO try manually setting a differnet value under the covers, + // not sure if this should really be an enum... "required": true, "type": "integer", - "default": 0 // 0 means no interval time + "minimum": 0, + "maximum": 20000, + "default": 1000 // 0 means no interval time } } } }, + // GPII-4207 This default looks correct... it probably isn't getting casted to + // a number during the default check... + // + // Currently in the control panel it goes from 0.3 to 20 seconds in a drop down + // + // Having issues capturing changes to this... am I looking at the correct setting "BounceKeysInterval": { "schema": { "title": "Bounce keys interval", @@ -7077,6 +7171,7 @@ "title": "Enable/Disable underlaying menu shortcuts", "description": "Displays a underline showing which is the shortcut to active a menu item", "type": "boolean", + // GPII-4207 This is coming out of the capture as 0 rather than false... TODO "default": false } } @@ -7117,6 +7212,7 @@ "title": "Keyboard as preferred input method", "description": "Set the keyboard as the preferred input method", "type": "boolean", + // GPII-4207 This is coming out of the capture as 0 rather than false... TODO "default": false } } @@ -7618,6 +7714,15 @@ "name": "MOUSEKEYS" } }, + /* + * Some interesting notes from testing on GPII-4207 + * the `MouseKeysOn` isn't getting defaulted because we still need to add + * support for checkingin the `properties` block. + * + * The MaxSpeed and Acceleration both have slightly different values + * + * Defaults are from observing 2 different peoples windows captures (Gregg and sgithens) + */ "supportedSettings": { "MouseKeysOn": { "schema": { @@ -7634,22 +7739,40 @@ } } }, + // GPII-4207 sgithens speed + // Having tested this in conjuction with the control panel it seems the + // max and min values are: (what is shown when you hover over the slider) + // + // Control Panel UI GPII Capture + // low: 10 10 + // high: 358 358 + // default: 80 80 "MaxSpeed": { "schema": { "title": "Mouse keys speed", "description": "Speed of mouse keys", "type": "number", - "multipleOf": 10 + "multipleOf": 10, + "default": 80 } }, + // GPII-4207 sgithens acceleration + // Having tested this in conjuction with the control panel it seems the + // max and min values are: (what is shown when you hover over the slider) + // + // Control Panel UI GPII Capture + // low: 100 5000 + // high: 500 1000 (yes it's inverse) + // default: 300 3000 "Acceleration": { "schema": { "title": "Mouse keys acceleration", "description": "Acceleration of mouse keys", - "type": "number", - "minimum": -1000, + "type": "integer", + "minimum": 1000, // TODO: Not clear how to describe this setting - "maximum": 1000 + "maximum": 5000, + "default": 3000 } } }, @@ -8521,7 +8644,8 @@ "required": true, "type": "integer", "minimum": 0, - "maximum": 10 + "maximum": 10, + "default": 0 } } } @@ -9644,7 +9768,11 @@ "description": "Whether or not sticky keys should be turned on.", "properties": { "path": { "type": "string", "required": true}, - "value": { "type": "boolean", "required": true} + "value": { + "type": "boolean", + "required": true, + "default": false + } } } } @@ -14749,7 +14877,7 @@ // TODO: Figure out a way to more cleanly reuse material between language-supporting features. Common term? "enum": [ "af", "sq", "am", "ar", "an", "hy-arevela", "hyw", "as", "az", "eu", "bn", "bpy", "bs", - "bg", "ca", "zh-yue", "zh-cmn", "hr", "cs", "da", "nl", "en-us", "en-029", "en-gb", + "bg", "ca", "zh-yue", "zh-cmn", "hr", "cs", "da", "nl", "en", "en-us", "en-029", "en-gb", "en-gb-x-gbclan", "en-gb-x-rp", "en-gb-scotland", "en-gb-x-gbcwmd", "eo", "et", "fi", "fr-be", "fr-fr", "fr-ch", "ga", "gd", "ka", "de", "grc", "el", "kl", "gn", "gu", "ht", "hak", "hi", "hu", "is", "id", "ia", "it", "ja", "quc", "kn", "kk", "kok", "ko", "ku", "ky", @@ -14762,7 +14890,7 @@ "Afrikaans", "Albanian", "Amharic", "Arabic", "Aragonese", "Armenian (East Armenia)", "Armenian (West Armenia)", "Assamese", "Azerbaijani", "Basque", "Bengali", "Bishnupriya Manipuri", "Bosnian", "Bulgarian", "Catalan", "Chinese (Cantonese)", - "Chinese (Mandarin)", "Croatian", "Czech", "Danish", "Dutch", "English (America)", + "Chinese (Mandarin)", "Croatian", "Czech", "Danish", "Dutch", "English", "English (America)", "English (Caribbean)", "English (Great Britain)", "English (Lancaster)", "English (Received Pronunciation)", "English (Scotland)", "English (West Midlands)", "Esperanto", "Estonian", "Finnish", "French (Belgium)", "French (France)", @@ -14778,7 +14906,8 @@ "Shan (Tai Yai)", "Sindhi", "Sinhala", "Slovak", "Slovenian", "Spanish (Latin America)", "Spanish (Spain)", "Swahili", "Swedish", "Tamil", "Tatar", "Telugu", "Turkish", "Urdu", "Vietnamese (Central)", "Vietnamese (Northern)", "Vietnamese (Southern)", "Welsh" - ] + ], + "default": "en" } }, "speech.espeak.volume": { @@ -16096,6 +16225,8 @@ "supportedSettings": { "OverrideTabletMode": { "schema": { + // GPII-4207 OverrideTabletMode and Enable Tablet Mode before look to have cut and paste issues + // with their title and description... TODO "title": "Enable Tablet Mode", "description": "Display larger ribbon buttons that are easier to touch", "type": "number",