Commit 39daef1d authored by David Tseng's avatar David Tseng Committed by Commit Bot

Format all test files under c/b/r/c/accessibility

Change-Id: Iff73bb8018053690ec88a6152a5c0740ef462e27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937131
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722718}
parent 65a674b7
......@@ -102,7 +102,7 @@ source_set("browser_tests") {
js2gtest("autoclick_extjs_tests") {
test_type = "extension"
sources = [
"autoclick_test.extjs",
"autoclick_test.js",
]
gen_include_files = [
"../chromevox/testing/callback_helper.js",
......
......@@ -120,36 +120,39 @@ AutoclickE2ETest.prototype = {
};
TEST_F('AutoclickE2ETest', 'HighlightsRootWebAreaIfNotScrollable', function() {
this.runWithLoadedTree('data:text/html;charset=utf-8,<p>Cats rock!</p>',
function(desktop) {
let node = desktop.find({role: 'staticText',
attributes: {name: 'Cats rock!'}});
this.runWithLoadedTree(
'data:text/html;charset=utf-8,<p>Cats rock!</p>', function(desktop) {
let node = desktop.find(
{role: 'staticText', attributes: {name: 'Cats rock!'}});
this.mockAccessibilityPrivate.callFindScrollableBoundsForPoint(
// Offset slightly into the node to ensure the hittest happens within
// the node.
// Offset slightly into the node to ensure the hittest happens
// within the node.
node.location.left + 1, node.location.top + 1,
this.newCallback(() => {
let expected = node.root.location;
this.assertSameRect(
this.mockAccessibilityPrivate.getScrollableBounds(),
expected);
this.assertSameRect(this.mockAccessibilityPrivate.getFocusRings()[0],
expected);
this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0], expected);
}));
});
});
TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() {
this.runWithLoadedTree('data:text/html;charset=utf-8,' +
this.runWithLoadedTree(
'data:text/html;charset=utf-8,' +
'<div style="width:100px;height:100px;overflow:scroll">' +
'<div style="margin:50px">cats rock! this text wraps and overflows!' +
'</div></div>',
function(desktop) {
let node = desktop.find({role: 'staticText',
attributes: {name: 'cats rock! this text wraps and overflows!'}});
let node = desktop.find({
role: 'staticText',
attributes: {name: 'cats rock! this text wraps and overflows!'}
});
this.mockAccessibilityPrivate.callFindScrollableBoundsForPoint(
// Offset slightly into the node to ensure the hittest happens within
// the node.
// Offset slightly into the node to ensure the hittest happens
// within the node.
node.location.left + 1, node.location.top + 1,
this.newCallback(() => {
// The outer div, which is the parent of the parent of the
......@@ -159,8 +162,8 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() {
this.assertSameRect(
this.mockAccessibilityPrivate.getScrollableBounds(),
expected);
this.assertSameRect(this.mockAccessibilityPrivate.getFocusRings()[0],
expected);
this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0], expected);
}));
});
});
......
......@@ -80,9 +80,7 @@ BrailleImeUnitTest.prototype = {
__proto__: testing.Test.prototype,
/** @Override */
extraLibraries: [
'braille_ime.js'
],
extraLibraries: ['braille_ime.js'],
/** @Override */
setUp: function() {
......@@ -102,12 +100,12 @@ BrailleImeUnitTest.prototype = {
},
createIme: function() {
var IME_EVENTS = [ 'onActivate', 'onDeactivated', 'onFocus', 'onBlur',
'onInputContextUpdate', 'onKeyEvent', 'onReset',
'onMenuItemActivated' ];
var IME_EVENTS = [
'onActivate', 'onDeactivated', 'onFocus', 'onBlur',
'onInputContextUpdate', 'onKeyEvent', 'onReset', 'onMenuItemActivated'
];
for (var i = 0, name; name = IME_EVENTS[i]; ++i) {
this[name] = chrome.input.ime[name] = new MockEvent();
}
chrome.input.ime.setMenuItems = function(parameters) {
this.menuItems = parameters.items;
......@@ -124,15 +122,17 @@ BrailleImeUnitTest.prototype = {
activateIme: function() {
this.onActivate.dispatch(ENGINE_ID);
assertThat(this.port.messages,
eqJSON([{type: 'activeState', active: true}]));
assertThat(
this.port.messages, eqJSON([{type: 'activeState', active: true}]));
this.port.messages.length = 0;
},
sendKeyEvent_: function(type, code, extra) {
var event = {type: type,
var event = {
type: type,
code: code,
requestId: (++this.lastSentKeyRequestId_) + ''};
requestId: (++this.lastSentKeyRequestId_) + ''
};
for (var key in extra) {
event[key] = extra[key];
}
......@@ -190,7 +190,7 @@ TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeysEnabled', function() {
expectFalse(this.sendKeyDown('ControlLeft', ctrlFlag));
expectFalse(this.sendKeyDown('KeyL', ctrlFlag));
expectFalse(this.sendKeyUp('KeyL', ctrlFlag));
expectFalse(this.sendKeyUp('ControlLeft', ctrlFlag))
expectFalse(this.sendKeyUp('ControlLeft', ctrlFlag));
// Space key by itself should send a blank cell.
expectTrue(this.sendKeyDown('Space'));
......@@ -207,10 +207,10 @@ TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeysEnabled', function() {
expectTrue(this.sendKeyUp('Space'));
expectTrue(this.sendKeyUp('KeyF'));
assertThat(this.port.messages,
eqJSON([{type: 'brailleDots', dots: 0x03},
{type: 'brailleDots', dots: 0x09},
{type: 'brailleDots', dots: 0}]));
assertThat(this.port.messages, eqJSON([
{type: 'brailleDots', dots: 0x03},
{type: 'brailleDots', dots: 0x09}, {type: 'brailleDots', dots: 0}
]));
});
TEST_F('BrailleImeUnitTest', 'TestBackspaceKey', function() {
......@@ -221,13 +221,14 @@ TEST_F('BrailleImeUnitTest', 'TestBackspaceKey', function() {
assertTrue(this.menuItems[0].checked);
expectEquals(undefined, this.sendKeyDown('Backspace'));
assertThat(this.port.messages,
eqJSON([{type: 'backspace',
requestId: this.lastSentKeyRequestId_ + ''}]));
this.port.onMessage.dispatch(
{type: 'keyEventHandled',
assertThat(this.port.messages, eqJSON([
{type: 'backspace', requestId: this.lastSentKeyRequestId_ + ''}
]));
this.port.onMessage.dispatch({
type: 'keyEventHandled',
requestId: this.lastSentKeyRequestId_ + '',
result: true});
result: true
});
expectEquals(this.lastSentKeyRequestId_, this.lastHandledKeyRequestId_);
expectTrue(this.lastHandledKeyResult_);
});
......@@ -264,9 +265,12 @@ TEST_F('BrailleImeUnitTest', 'ReplaceText', function() {
callback();
};
var sendReplaceText = function(deleteBefore, newText) {
this.port.onMessage.dispatch(
{type: 'replaceText', contextID: CONTEXT_ID,
deleteBefore: deleteBefore, newText: newText});
this.port.onMessage.dispatch({
type: 'replaceText',
contextID: CONTEXT_ID,
deleteBefore: deleteBefore,
newText: newText
});
}.bind(this);
this.activateIme();
sendReplaceText(0, 'hello!');
......
......@@ -26,6 +26,9 @@ def CheckBrailleIme():
os.path.join(_SCRIPT_DIR, 'braille_ime.js'),
os.path.join(_SCRIPT_DIR, 'main.js')]
externs = [
os.path.join(
_CHROME_SOURCE_DIR,
'third_party/closure_compiler/externs/chrome.js'),
os.path.join(
_CHROME_SOURCE_DIR,
'third_party/closure_compiler/externs/chrome_extensions.js'),
......
......@@ -129,9 +129,9 @@ source_set("browser_tests") {
js2gtest("select_to_speak_extjs_tests") {
test_type = "extension"
sources = [
"select_to_speak_keystroke_selection_test.extjs",
"select_to_speak_mouse_selection_test.extjs",
"select_to_speak_prefs_test.extjs",
"select_to_speak_keystroke_selection_test.js",
"select_to_speak_mouse_selection_test.js",
"select_to_speak_prefs_test.js",
]
gen_include_files = [
"../chromevox/testing/callback_helper.js",
......
......@@ -7,7 +7,7 @@
* @constructor
* @extends {testing.Test}
*/
function SelectToSpeakRectUtilsUnitTest () {
function SelectToSpeakRectUtilsUnitTest() {
testing.Test.call(this);
}
......
......@@ -5,7 +5,8 @@
GEN_INCLUDE(['select_to_speak_e2e_test_base.js']);
GEN_INCLUDE(['../../../../../../ui/webui/resources/js/cr.js']);
GEN_INCLUDE(['../../../../../test/data/webui/fake_chrome_event.js']);
GEN_INCLUDE(['../../../../../test/data/webui/settings/fake_settings_private.js']);
GEN_INCLUDE(
['../../../../../test/data/webui/settings/fake_settings_private.js']);
GEN_INCLUDE(['mock_storage.js']);
/**
......@@ -34,7 +35,7 @@ function SelectToSpeakPrefsTest() {
};
this.resetStorage();
};
}
SelectToSpeakPrefsTest.prototype = {
__proto__: SelectToSpeakE2ETest.prototype,
......@@ -48,10 +49,10 @@ SelectToSpeakPrefsTest.prototype = {
// properly.
setGlobalRateAndPitch: function(rate, pitch) {
let unused = () => {};
this.mockSettingsPrivate_.setPref('settings.tts.speech_rate', rate, '',
unused);
this.mockSettingsPrivate_.setPref('settings.tts.speech_pitch', pitch, '',
unused);
this.mockSettingsPrivate_.setPref(
'settings.tts.speech_rate', rate, '', unused);
this.mockSettingsPrivate_.setPref(
'settings.tts.speech_pitch', pitch, '', unused);
},
setStsRateAndPitch: function(rate, pitch) {
......@@ -63,12 +64,12 @@ SelectToSpeakPrefsTest.prototype = {
let onPrefsRemovedFromStorage = this.newCallback(() => {
// Once prefs are removed from storage, make sure the global prefs are
// updated to the appropriate values.
this.mockSettingsPrivate_.getPref('settings.tts.speech_rate',
this.newCallback((pref) => {
this.mockSettingsPrivate_.getPref(
'settings.tts.speech_rate', this.newCallback((pref) => {
assertEquals(rate, pref.value);
}));
this.mockSettingsPrivate_.getPref('settings.tts.speech_pitch',
this.newCallback((pref) => {
this.mockSettingsPrivate_.getPref(
'settings.tts.speech_pitch', this.newCallback((pref) => {
assertEquals(pitch, pref.value);
}));
});
......@@ -82,27 +83,27 @@ SelectToSpeakPrefsTest.prototype = {
};
// TODO(katie): Test no alert -- this is hard because it happens last.
TEST_F('SelectToSpeakPrefsTest', 'RemovesPrefsWithNoAlertIfAllDefault',
TEST_F(
'SelectToSpeakPrefsTest', 'RemovesPrefsWithNoAlertIfAllDefault',
function() {
this.setGlobalRateAndPitch(1.0, 1.0);
this.setStsRateAndPitch(1.0, 1.0);
this.mockStorage_.updatePrefs();
this.ensurePrefsRemovedAndGlobalSetTo(1.0, 1.0);
});
});
// TODO(katie): Test no alert -- this is hard because it happens last.
TEST_F('SelectToSpeakPrefsTest', 'RemovesPrefsWithNoAlertIfAllEqual',
function() {
TEST_F(
'SelectToSpeakPrefsTest', 'RemovesPrefsWithNoAlertIfAllEqual', function() {
this.setGlobalRateAndPitch(1.5, 1.8);
this.setStsRateAndPitch(1.5, 1.8);
this.mockStorage_.updatePrefs();
this.ensurePrefsRemovedAndGlobalSetTo(1.5, 1.8);
});
});
TEST_F('SelectToSpeakPrefsTest', 'SavesNonDefaultStsPrefsToGlobal',
function() {
TEST_F('SelectToSpeakPrefsTest', 'SavesNonDefaultStsPrefsToGlobal', function() {
this.setGlobalRateAndPitch(1.0, 1.0);
this.setStsRateAndPitch(2.0, 2.5);
this.mockStorage_.updatePrefs();
......@@ -110,20 +111,22 @@ TEST_F('SelectToSpeakPrefsTest', 'SavesNonDefaultStsPrefsToGlobal',
this.ensurePrefsRemovedAndGlobalSetTo(2.0, 2.5);
});
TEST_F('SelectToSpeakPrefsTest',
TEST_F(
'SelectToSpeakPrefsTest',
'DoesNotSaveNonDefaultStsPrefsToGlobalIfGlobalChanged', function() {
this.setGlobalRateAndPitch(1.0, 1.5);
this.setStsRateAndPitch(1.0, 2.5);
this.mockStorage_.updatePrefs();
this.ensurePrefsRemovedAndGlobalSetTo(1.0, 1.5);
});
});
TEST_F('SelectToSpeakPrefsTest', 'DoesNotSaveStsPrefsToGlobalIfGlobalChanged',
TEST_F(
'SelectToSpeakPrefsTest', 'DoesNotSaveStsPrefsToGlobalIfGlobalChanged',
function() {
this.setGlobalRateAndPitch(2.0, 1.0);
this.setStsRateAndPitch(1.0, 1.0);
this.mockStorage_.updatePrefs();
this.ensurePrefsRemovedAndGlobalSetTo(2.0, 1.0);
});
});
......@@ -7,7 +7,7 @@
* @constructor
* @extends {testing.Test}
*/
function SelectToSpeakUnitTest () {
function SelectToSpeakUnitTest() {
testing.Test.call(this);
}
......@@ -15,10 +15,7 @@ SelectToSpeakUnitTest.prototype = {
__proto__: testing.Test.prototype,
/** @override */
extraLibraries: [
'test_support.js',
'select_to_speak.js'
]
extraLibraries: ['test_support.js', 'select_to_speak.js']
};
TEST_F('SelectToSpeakUnitTest', 'getGSuiteAppRoot', function() {
......@@ -43,7 +40,7 @@ TEST_F('SelectToSpeakUnitTest', 'getGSuiteAppRoot', function() {
assertEquals(getGSuiteAppRoot(div2), root);
// Not in GSuite app
root.url = 'https://www.not_a_doc.com'
root.url = 'https://www.not_a_doc.com';
assertEquals(getGSuiteAppRoot(focus), null);
assertEquals(getGSuiteAppRoot(div2), null);
});
......@@ -7,7 +7,7 @@
* @constructor
* @extends {testing.Test}
*/
function SelectToSpeakWordUtilsUnitTest () {
function SelectToSpeakWordUtilsUnitTest() {
testing.Test.call(this);
}
......@@ -22,7 +22,8 @@ SelectToSpeakWordUtilsUnitTest.prototype = {
]
};
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordStartWithoutWordStarts',
TEST_F(
'SelectToSpeakWordUtilsUnitTest', 'getNextWordStartWithoutWordStarts',
function() {
let node = {node: {}};
assertEquals(0, WordUtils.getNextWordStart('kitty cat', 0, node));
......@@ -30,16 +31,17 @@ TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordStartWithoutWordStarts',
assertEquals(6, WordUtils.getNextWordStart('kitty cat', 5, node));
assertEquals(6, WordUtils.getNextWordStart('kitty cat', 6, node));
assertEquals(7, WordUtils.getNextWordStart('kitty "cat"', 5, node));
});
});
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordEndWithoutWordEnds',
TEST_F(
'SelectToSpeakWordUtilsUnitTest', 'getNextWordEndWithoutWordEnds',
function() {
let node = {node: {}};
assertEquals(5, WordUtils.getNextWordEnd('kitty cat', 0, node));
assertEquals(6, WordUtils.getNextWordEnd(' kitty cat', 0, node));
assertEquals(9, WordUtils.getNextWordEnd('kitty cat', 6, node));
assertEquals(9, WordUtils.getNextWordEnd('kitty cat', 7, node));
});
});
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordStart', function() {
let inlineText = {wordStarts: [0, 6], name: 'kitty cat'};
......@@ -55,21 +57,31 @@ TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordStart', function() {
// Should return the default if the inlineText children are missing.
staticText.children = [];
assertEquals(10, WordUtils.getNextWordStart('once upon a kitty cat', 10, node));
assertEquals(
10, WordUtils.getNextWordStart('once upon a kitty cat', 10, node));
});
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordStartMultipleChildren',
TEST_F(
'SelectToSpeakWordUtilsUnitTest', 'getNextWordStartMultipleChildren',
function() {
let inlineText1 = {wordStarts: [0, 6], name: 'kitty cat ', indexInParent: 0};
let inlineText1 = {
wordStarts: [0, 6],
name: 'kitty cat ',
indexInParent: 0
};
let inlineText2 = {wordStarts: [0, 3], name: 'is cute', indexInParent: 1};
let staticText = {children: [inlineText1, inlineText2],
name: 'kitty cat is cute'};
let staticText = {
children: [inlineText1, inlineText2],
name: 'kitty cat is cute'
};
inlineText1.parent = staticText;
inlineText2.parent = staticText;
let node = {node: staticText, startChar: 0, hasInlineText: true};
assertEquals(10, WordUtils.getNextWordStart('kitty cat is cute', 7, node));
assertEquals(13, WordUtils.getNextWordStart('kitty cat is cute', 11, node));
});
assertEquals(
10, WordUtils.getNextWordStart('kitty cat is cute', 7, node));
assertEquals(
13, WordUtils.getNextWordStart('kitty cat is cute', 11, node));
});
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordEnd', function() {
let inlineText = {wordEnds: [5, 9], name: 'kitty cat'};
......@@ -89,15 +101,22 @@ TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordEnd', function() {
assertEquals(5, WordUtils.getNextWordEnd('kitty cat', 4, node));
});
TEST_F('SelectToSpeakWordUtilsUnitTest', 'getNextWordEndMultipleChildren',
TEST_F(
'SelectToSpeakWordUtilsUnitTest', 'getNextWordEndMultipleChildren',
function() {
let inlineText1 = {wordEnds: [5, 9], name: 'kitty cat ', indexInParent: 0};
let inlineText1 = {
wordEnds: [5, 9],
name: 'kitty cat ',
indexInParent: 0
};
let inlineText2 = {wordEnds: [2, 7], name: 'is cute', indexInParent: 1};
let staticText = {children: [inlineText1, inlineText2],
name: 'kitty cat is cute'};
let staticText = {
children: [inlineText1, inlineText2],
name: 'kitty cat is cute'
};
inlineText1.parent = staticText;
inlineText2.parent = staticText;
let node = {node: staticText, startChar: 0, hasInlineText: true};
assertEquals(12, WordUtils.getNextWordEnd('kitty cat is cute', 10, node));
assertEquals(17, WordUtils.getNextWordEnd('kitty cat is cute', 13, node));
});
\ No newline at end of file
});
\ No newline at end of file
......@@ -112,11 +112,11 @@ source_set("browser_tests") {
js2gtest("switch_access_extjs_tests") {
test_type = "extension"
sources = [
"auto_scan_manager_test.extjs",
"navigation_manager_test.extjs",
"nodes/node_wrapper_test.extjs",
"switch_access_predicate_test.extjs",
"text_navigation_manager_test.extjs",
"auto_scan_manager_test.js",
"navigation_manager_test.js",
"nodes/node_wrapper_test.js",
"switch_access_predicate_test.js",
"text_navigation_manager_test.js",
]
gen_include_files = [
"../chromevox/testing/callback_helper.js",
......
......@@ -56,32 +56,36 @@ SwitchAccessAutoScanManagerTest.prototype = {
TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabled', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running prematurely');
assertEquals(0, switchAccess.moveForwardCount,
assertEquals(
0, switchAccess.moveForwardCount,
'Incorrect initialization of moveForwardCount');
assertEquals(0, intervalCount, 'Incorrect initialization of intervalCount');
switchAccess.onMoveForwardForTesting_ =
this.newCallback(() => {
assertTrue(this.autoScanManager.isRunning(),
switchAccess.onMoveForwardForTesting_ = this.newCallback(() => {
assertTrue(
this.autoScanManager.isRunning(),
'Auto scan manager has stopped running');
assertGT(switchAccess.moveForwardCount, 0,
assertGT(
switchAccess.moveForwardCount, 0,
'Switch Access has not moved forward');
assertEquals(1, intervalCount,
'The number of intervals is no longer exactly 1');
assertEquals(
1, intervalCount, 'The number of intervals is no longer exactly 1');
});
this.autoScanManager.setEnabled(true);
assertTrue(this.autoScanManager.isRunning(),
'Auto scan manager is not running');
assertTrue(
this.autoScanManager.isRunning(), 'Auto scan manager is not running');
assertEquals(1, intervalCount, 'There is not exactly 1 interval');
});
});
TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running prematurely');
assertEquals(0, intervalCount, 'Incorrect initialization of intervalCount');
......@@ -89,86 +93,101 @@ TEST_F('SwitchAccessAutoScanManagerTest', 'SetEnabledMultiple', function() {
this.autoScanManager.setEnabled(true);
this.autoScanManager.setEnabled(true);
assertTrue(this.autoScanManager.isRunning(),
'Auto scan manager is not running');
assertTrue(
this.autoScanManager.isRunning(), 'Auto scan manager is not running');
assertEquals(1, intervalCount, 'There is not exactly 1 interval');
});
});
TEST_F('SwitchAccessAutoScanManagerTest', 'EnableAndDisable', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running prematurely');
assertEquals(0, intervalCount, 'Incorrect initialization of intervalCount');
this.autoScanManager.setEnabled(true);
assertTrue(this.autoScanManager.isRunning(),
'Auto scan manager is not running');
assertTrue(
this.autoScanManager.isRunning(), 'Auto scan manager is not running');
assertEquals(1, intervalCount, 'There is not exactly 1 interval');
this.autoScanManager.setEnabled(false);
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager did not stop running');
assertEquals(0, intervalCount, 'Interval was not removed');
});
});
TEST_F('SwitchAccessAutoScanManagerTest', 'RestartIfRunningMultiple', function() {
TEST_F(
'SwitchAccessAutoScanManagerTest', 'RestartIfRunningMultiple', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running prematurely');
assertEquals(0, switchAccess.moveForwardCount,
assertEquals(
0, switchAccess.moveForwardCount,
'Incorrect initialization of moveForwardCount');
assertEquals(0, intervalCount, 'Incorrect initialization of intervalCount');
assertEquals(
0, intervalCount, 'Incorrect initialization of intervalCount');
this.autoScanManager.setEnabled(true);
this.autoScanManager.restartIfRunning();
this.autoScanManager.restartIfRunning();
this.autoScanManager.restartIfRunning();
assertTrue(this.autoScanManager.isRunning(),
assertTrue(
this.autoScanManager.isRunning(),
'Auto scan manager is not running');
assertEquals(1, intervalCount, 'There is not exactly 1 interval');
});
});
});
TEST_F('SwitchAccessAutoScanManagerTest', 'RestartIfRunningWhenOff', function()
{
TEST_F(
'SwitchAccessAutoScanManagerTest', 'RestartIfRunningWhenOff', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running at start.');
this.autoScanManager.restartIfRunning();
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager enabled by restartIfRunning');
});
});
});
TEST_F('SwitchAccessAutoScanManagerTest', 'SetDefaultScanTime', function() {
this.runWithLoadedTree('', (desktop) => {
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Auto scan manager is running prematurely');
assertEquals(UNDEFINED_INTERVAL_DELAY, intervalDelay,
assertEquals(
UNDEFINED_INTERVAL_DELAY, intervalDelay,
'Interval delay improperly initialized');
this.autoScanManager.setDefaultScanTime(2);
assertFalse(this.autoScanManager.isRunning(),
assertFalse(
this.autoScanManager.isRunning(),
'Setting default scan time started auto-scanning');
assertEquals(2, this.autoScanManager.defaultScanTime_,
assertEquals(
2, this.autoScanManager.defaultScanTime_,
'Default scan time set improperly');
assertEquals(UNDEFINED_INTERVAL_DELAY, intervalDelay,
assertEquals(
UNDEFINED_INTERVAL_DELAY, intervalDelay,
'Interval delay set prematurely');
this.autoScanManager.setEnabled(true);
assertTrue(this.autoScanManager.isRunning(), 'Auto scan did not start');
assertEquals(2, this.autoScanManager.defaultScanTime_,
assertEquals(
2, this.autoScanManager.defaultScanTime_,
'Default scan time has changed');
assertEquals(2, intervalDelay, 'Interval delay not set');
this.autoScanManager.setDefaultScanTime(5);
assertTrue(this.autoScanManager.isRunning(), 'Auto scan stopped');
assertEquals(5, this.autoScanManager.defaultScanTime_,
assertEquals(
5, this.autoScanManager.defaultScanTime_,
'Default scan time did not change when set a second time');
assertEquals(5, intervalDelay, 'Interval delay did not update');
});
});
......@@ -27,12 +27,13 @@ TEST_F('SwitchAccessNodeWrapperTest', 'BuildDesktopTree', function() {
assertFalse(child instanceof BackButtonNode);
// Check that the children form a loop.
const next = children[(i+1) % children.length];
assertEquals(next, child.next,
'next not properly initialized on child ' + i);
const next = children[(i + 1) % children.length];
assertEquals(
next, child.next, 'next not properly initialized on child ' + i);
// We add children.length to ensure the value is greater than zero.
const previous = children[(i-1 + children.length) % children.length];
assertEquals(previous, child.previous,
const previous = children[(i - 1 + children.length) % children.length];
assertEquals(
previous, child.previous,
'previous not properly initialized on child ' + i);
}
});
......@@ -47,7 +48,7 @@ TEST_F('SwitchAccessNodeWrapperTest', 'AsRootNode', function() {
<button></button>
</div>`;
this.runWithLoadedTree(website, (desktop) => {
const slider = desktop.find({role: chrome.automation.RoleType.SLIDER})
const slider = desktop.find({role: chrome.automation.RoleType.SLIDER});
const inner = slider.parent;
assertNotEquals(undefined, inner, 'Could not find inner group');
const outer = inner.parent;
......@@ -60,11 +61,14 @@ TEST_F('SwitchAccessNodeWrapperTest', 'AsRootNode', function() {
const innerRootNode = innerNode.asRootNode();
assertEquals(3, innerRootNode.children.length, 'Expected 3 children');
const sliderNode = innerRootNode.firstChild;
assertEquals(chrome.automation.RoleType.SLIDER, sliderNode.role,
assertEquals(
chrome.automation.RoleType.SLIDER, sliderNode.role,
'First child should be a slider');
assertEquals(chrome.automation.RoleType.BUTTON, sliderNode.next.role,
assertEquals(
chrome.automation.RoleType.BUTTON, sliderNode.next.role,
'Second child should be a button');
assertTrue(innerRootNode.lastChild instanceof BackButtonNode,
assertTrue(
innerRootNode.lastChild instanceof BackButtonNode,
'Final child should be the back button');
});
});
......@@ -82,46 +86,60 @@ TEST_F('SwitchAccessNodeWrapperTest', 'Equals', function() {
childGroup = childGroup.asRootNode();
assertFalse(desktopRootNode.equals(), 'Root node equals nothing');
assertFalse(desktopRootNode.equals(new SARootNode()),
assertFalse(
desktopRootNode.equals(new SARootNode()),
'Different type root nodes are equal');
assertFalse(new SARootNode().equals(desktopRootNode),
assertFalse(
new SARootNode().equals(desktopRootNode),
'Equals is not symmetric? Different types of root are equal');
assertFalse(desktopRootNode.equals(childGroup),
assertFalse(
desktopRootNode.equals(childGroup),
'Groups with different children are equal');
assertFalse(childGroup.equals(desktopRootNode),
assertFalse(
childGroup.equals(desktopRootNode),
'Equals is not symmetric? Groups with different children are equal');
assertTrue(desktopRootNode.equals(desktopRootNode),
assertTrue(
desktopRootNode.equals(desktopRootNode),
'Equals is not reflexive? (root node)');
const desktopCopy = RootNodeWrapper.buildDesktopTree(desktop);
assertTrue(desktopRootNode.equals(desktopCopy),
'Two desktop roots are not equal');
assertTrue(desktopCopy.equals(desktopRootNode),
assertTrue(
desktopRootNode.equals(desktopCopy), 'Two desktop roots are not equal');
assertTrue(
desktopCopy.equals(desktopRootNode),
'Equals is not symmetric? Two desktop roots aren\'t equal');
const wrappedNode = desktopRootNode.firstChild;
assertTrue(wrappedNode instanceof NodeWrapper,
assertTrue(
wrappedNode instanceof NodeWrapper,
'Child node is not of type NodeWrapper');
assertGT(desktopRootNode.children.length, 1,
'Desktop root has only 1 child');
assertGT(
desktopRootNode.children.length, 1, 'Desktop root has only 1 child');
assertFalse(wrappedNode.equals(), 'Child NodeWrapper equals nothing');
assertFalse(wrappedNode.equals(new BackButtonNode()),
assertFalse(
wrappedNode.equals(new BackButtonNode()),
'Child NodeWrapper equals a BackButtonNode');
assertFalse(new BackButtonNode().equals(wrappedNode),
assertFalse(
new BackButtonNode().equals(wrappedNode),
'Equals is not symmetric? NodeWrapper equals a BackButtonNode');
assertFalse(wrappedNode.equals(desktopRootNode.lastChild),
assertFalse(
wrappedNode.equals(desktopRootNode.lastChild),
'Children with different base nodes are equal');
assertFalse(desktopRootNode.lastChild.equals(wrappedNode),
assertFalse(
desktopRootNode.lastChild.equals(wrappedNode),
'Equals is not symmetric? Nodes with different base nodes are equal');
const equivalentWrappedNode = new NodeWrapper(wrappedNode.baseNode_,
desktopRootNode);
assertTrue(wrappedNode.equals(wrappedNode),
const equivalentWrappedNode =
new NodeWrapper(wrappedNode.baseNode_, desktopRootNode);
assertTrue(
wrappedNode.equals(wrappedNode),
'Equals is not reflexive? (child node)');
assertTrue(wrappedNode.equals(equivalentWrappedNode),
assertTrue(
wrappedNode.equals(equivalentWrappedNode),
'Two nodes with the same base node are not equal');
assertTrue(equivalentWrappedNode.equals(wrappedNode),
assertTrue(
equivalentWrappedNode.equals(wrappedNode),
'Equals is not symmetric? Nodes with the same base node aren\'t equal');
});
});
......@@ -135,37 +153,48 @@ TEST_F('SwitchAccessNodeWrapperTest', 'Actions', function() {
desktop.find({role: chrome.automation.RoleType.TEXT_FIELD}),
new SARootNode());
assertEquals(chrome.automation.RoleType.TEXT_FIELD, textField.role,
assertEquals(
chrome.automation.RoleType.TEXT_FIELD, textField.role,
'Text field node is not a text field');
assertTrue(textField.hasAction(SAConstants.MenuAction.OPEN_KEYBOARD),
assertTrue(
textField.hasAction(SAConstants.MenuAction.OPEN_KEYBOARD),
'Text field does not have action OPEN_KEYBOARD');
assertTrue(textField.hasAction(SAConstants.MenuAction.DICTATION),
assertTrue(
textField.hasAction(SAConstants.MenuAction.DICTATION),
'Text field does not have action DICTATION');
assertFalse(textField.hasAction(SAConstants.MenuAction.SELECT),
assertFalse(
textField.hasAction(SAConstants.MenuAction.SELECT),
'Text field has action SELECT');
const button = new NodeWrapper(
desktop.find({role: chrome.automation.RoleType.BUTTON}),
new SARootNode());
assertEquals(chrome.automation.RoleType.BUTTON, button.role,
assertEquals(
chrome.automation.RoleType.BUTTON, button.role,
'Button node is not a button');
assertTrue(button.hasAction(SAConstants.MenuAction.SELECT),
assertTrue(
button.hasAction(SAConstants.MenuAction.SELECT),
'Button does not have action SELECT');
assertFalse(button.hasAction(SAConstants.MenuAction.OPEN_KEYBOARD),
assertFalse(
button.hasAction(SAConstants.MenuAction.OPEN_KEYBOARD),
'Button has action OPEN_KEYBOARD');
assertFalse(button.hasAction(SAConstants.MenuAction.DICTATION),
assertFalse(
button.hasAction(SAConstants.MenuAction.DICTATION),
'Button has action DICTATION');
const slider = new NodeWrapper(
desktop.find({role: chrome.automation.RoleType.SLIDER}),
new SARootNode());
assertEquals(chrome.automation.RoleType.SLIDER, slider.role,
assertEquals(
chrome.automation.RoleType.SLIDER, slider.role,
'Slider node is not a slider');
assertTrue(slider.hasAction(SAConstants.MenuAction.INCREMENT),
assertTrue(
slider.hasAction(SAConstants.MenuAction.INCREMENT),
'Slider does not have action INCREMENT');
assertTrue(slider.hasAction(SAConstants.MenuAction.DECREMENT),
assertTrue(
slider.hasAction(SAConstants.MenuAction.DECREMENT),
'Slider does not have action DECREMENT');
});
});
......@@ -12,18 +12,16 @@ function SwitchAccessTextNavigationManagerTest() {
SwitchAccessE2ETest.call(this);
}
SwitchAccessTextNavigationManagerTest.prototype =
{
SwitchAccessTextNavigationManagerTest.prototype = {
__proto__: SwitchAccessE2ETest.prototype,
/** @override */
setUp: function() {
this.textNavigationManager =
switchAccess.navigationManager_.menuManager_.textNavigationManager_;
this.navigationManager =
switchAccess.navigationManager_;
}
this.navigationManager = switchAccess.navigationManager_;
}
};
/**
......@@ -85,10 +83,10 @@ function runTextNavigationTest(testHelper, textParams) {
* -initialIndex: index of the text caret before the navigation action.
* -targetStartIndex: start index of the selection after the selection action.
* -targetEndIndex: end index of the selection after the navigation action.
* -navigationAction: function executing a text navigation action or selection action.
* -id: id of the text area element (optional).
* -cols: number of columns in the text area (optional).
* -wrap: the wrap attribute ("hard" or "soft") of the text area (optional).
* -navigationAction: function executing a text navigation action or selection
* action. -id: id of the text area element (optional). -cols: number of columns
* in the text area (optional). -wrap: the wrap attribute ("hard" or "soft") of
* the text area (optional).
*
* @param {!SwitchAccessE2ETest} testHelper
* @param {selectionTextParams} textParams,
......@@ -111,7 +109,7 @@ function runTextSelectionTest(testHelper, textParams) {
textId, textContent, initialTextIndex, textCols, textWrap);
let navigationTargetIndex = targetTextEndIndex;
if(selectionIsBackward){
if (selectionIsBackward) {
navigationTargetIndex = targetTextStartIndex;
}
......@@ -120,8 +118,9 @@ function runTextSelectionTest(testHelper, textParams) {
assertNotEquals(inputNode, null);
checkNodeIsFocused(inputNode);
let callback = testHelper.newCallback(function() {
setUpCursorChangeListener(testHelper, inputNode, targetTextEndIndex,
targetTextStartIndex, targetTextEndIndex);
setUpCursorChangeListener(
testHelper, inputNode, targetTextEndIndex, targetTextStartIndex,
targetTextEndIndex);
testHelper.textNavigationManager.saveSelectEnd();
});
......@@ -205,14 +204,15 @@ function checkNodeIsFocused(inputNode) {
* @param {number} targetTextEndIndex
* @param {function() || undefined} callback
*/
function setUpCursorChangeListener( testHelper, inputNode, initialTextIndex,
targetTextStartIndex, targetTextEndIndex, callback) {
function setUpCursorChangeListener(
testHelper, inputNode, initialTextIndex, targetTextStartIndex,
targetTextEndIndex, callback) {
// Ensures that the text index has changed before checking the new index.
const checkActionFinished = function(tab) {
if (inputNode.textSelStart != initialTextIndex ||
inputNode.textSelEnd != initialTextIndex) {
checkTextIndex();
if(callback) {
if (callback) {
callback();
}
}
......@@ -222,11 +222,13 @@ function setUpCursorChangeListener( testHelper, inputNode, initialTextIndex,
const checkTextIndex = testHelper.newCallback(function() {
assertEquals(inputNode.textSelStart, targetTextStartIndex);
assertEquals(inputNode.textSelEnd, targetTextEndIndex);
// If there's a callback then this is the navigation listener for a selection
// test, thus remove it when fired to make way for the selection listener.
if (callback){
// If there's a callback then this is the navigation listener for a
// selection test, thus remove it when fired to make way for the selection
// listener.
if (callback) {
inputNode.removeEventListener(
chrome.automation.EventType.TEXT_SELECTION_CHANGED, checkActionFinished);
chrome.automation.EventType.TEXT_SELECTION_CHANGED,
checkActionFinished);
}
});
......@@ -240,7 +242,7 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'JumpToBeginning', function() {
initialIndex: 6,
targetIndex: 0,
navigationAction: () => {
this.textNavigationManager.jumpToBeginning()
this.textNavigationManager.jumpToBeginning();
}
});
});
......@@ -251,7 +253,7 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'JumpToEnd', function() {
initialIndex: 3,
targetIndex: 8,
navigationAction: () => {
this.textNavigationManager.jumpToEnd()
this.textNavigationManager.jumpToEnd();
}
});
});
......@@ -263,7 +265,7 @@ TEST_F(
initialIndex: 7,
targetIndex: 6,
navigationAction: () => {
this.textNavigationManager.moveBackwardOneChar()
this.textNavigationManager.moveBackwardOneChar();
}
});
});
......@@ -275,7 +277,7 @@ TEST_F(
initialIndex: 5,
targetIndex: 0,
navigationAction: () => {
this.textNavigationManager.moveBackwardOneWord()
this.textNavigationManager.moveBackwardOneWord();
}
});
});
......@@ -287,7 +289,7 @@ TEST_F(
initialIndex: 0,
targetIndex: 1,
navigationAction: () => {
this.textNavigationManager.moveForwardOneChar()
this.textNavigationManager.moveForwardOneChar();
}
});
});
......@@ -299,7 +301,7 @@ TEST_F(
initialIndex: 4,
targetIndex: 12,
navigationAction: () => {
this.textNavigationManager.moveForwardOneWord()
this.textNavigationManager.moveForwardOneWord();
}
});
});
......@@ -325,19 +327,21 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'MoveDownOneLine', function() {
cols: 8,
wrap: 'hard',
navigationAction: () => {
this.textNavigationManager.moveDownOneLine()
this.textNavigationManager.moveDownOneLine();
}
});
});
/**
* Test the setSelectStart function by checking correct index is stored as the
* selection start index.
*/
TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectStart', function(){
const website = generateWebsiteWithTextArea(
'test', 'test123', 3, 20, 'hard');
* Test the setSelectStart function by checking correct index is stored as the
* selection start index.
*/
TEST_F(
'SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectStart',
function() {
const website =
generateWebsiteWithTextArea('test', 'test123', 3, 20, 'hard');
this.runWithLoadedTree(website, function(desktop) {
const inputNode = findNodeById(desktop, 'test', this);
......@@ -346,39 +350,42 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectStart', function
this.textNavigationManager.saveSelectStart();
let startIndex = this.textNavigationManager.getSelStartIndex();
assertEquals(startIndex, 3)
assertEquals(startIndex, 3);
});
});
});
/**
* Test the setSelectEnd function by manually setting the selection start index
* and node then calling setSelectEnd and checking for the correct selection
* bounds
*/
TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectEnd', function(){
const website = generateWebsiteWithTextArea(
'test', 'test 123', 6, 20, 'hard');
* Test the setSelectEnd function by manually setting the selection start index
* and node then calling setSelectEnd and checking for the correct selection
* bounds
*/
TEST_F(
'SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectEnd', function() {
const website =
generateWebsiteWithTextArea('test', 'test 123', 6, 20, 'hard');
this.runWithLoadedTree(website, function(desktop) {
const inputNode = findNodeById(desktop, 'test', this);
assertNotEquals(inputNode, null);
checkNodeIsFocused(inputNode)
checkNodeIsFocused(inputNode);
let startIndex = 3;
this.textNavigationManager.setSelStartIndexAndNode(startIndex, inputNode);
this.textNavigationManager.setSelStartIndexAndNode(
startIndex, inputNode);
this.textNavigationManager.saveSelectEnd();
let endIndex = inputNode.textSelEnd;
assertEquals(6, endIndex);
});
});
});
/**
* Test use of setSelectStart and setSelectEnd with the moveForwardOneChar function.
*/
TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectCharacter', function() {
* Test use of setSelectStart and setSelectEnd with the moveForwardOneChar
* function.
*/
TEST_F(
'SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectCharacter',
function() {
runTextSelectionTest(this, {
content: 'hello world!',
initialIndex: 0,
......@@ -390,13 +397,15 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectCharacter', func
this.textNavigationManager.moveForwardOneChar();
}
});
});
});
/**
* Test use of setSelectStart and setSelectEnd with a backward selection using
* the moveBackwardOneWord function.
*/
TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectWordBackward', function() {
* Test use of setSelectStart and setSelectEnd with a backward selection using
* the moveBackwardOneWord function.
*/
TEST_F(
'SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectWordBackward',
function() {
runTextSelectionTest(this, {
content: 'hello world!',
initialIndex: 5,
......@@ -409,7 +418,7 @@ TEST_F('SwitchAccessTextNavigationManagerTest', 'DISABLED_SelectWordBackward', f
},
backward: true
});
});
});
/**
* selectionTextParams should specify parameters
......
......@@ -10,28 +10,29 @@ var MachineLearningInternalsUnitTests = class extends testing.Test {
'machine_learning_internals_utils.js',
];
}
}
};
TEST_F('MachineLearningInternalsUnitTests', 'enumToString', function() {
const TestEnum = {
OK: 1,
FAIL: 2,
};
assertEquals("OK", machine_learning_internals.utils.enumToString(1, TestEnum));
assertEquals("FAIL", machine_learning_internals.utils.enumToString(2, TestEnum));
assertThrows(
() => {machine_learning_internals.utils.enumToString(3, TestEnum)},
"Unknown enumValue: 3");
assertEquals(
'OK', machine_learning_internals.utils.enumToString(1, TestEnum));
assertEquals(
'FAIL', machine_learning_internals.utils.enumToString(2, TestEnum));
assertThrows(() => {
machine_learning_internals.utils.enumToString(3, TestEnum);
}, 'Unknown enumValue: 3');
});
TEST_F('MachineLearningInternalsUnitTests', 'makeTensor', function() {
const myArray = [1.0, 2.0, 3.0];
const myTensor = machine_learning_internals.utils.makeTensor(
myArray, [myArray.length]);
const myTensor =
machine_learning_internals.utils.makeTensor(myArray, [myArray.length]);
assertEquals(myArray, myTensor.data.floatList.value);
assertEquals(myArray.length, myTensor.shape.value[0]);
assertThrows(
() => {machine_learning_internals.utils.makeTensor(myArray, [2,3])},
`valueList.length ${myArray.length} != expectedLength 6`);
assertThrows(() => {
machine_learning_internals.utils.makeTensor(myArray, [2, 3]);
}, `valueList.length ${myArray.length} != expectedLength 6`);
});
......@@ -258,14 +258,14 @@ js2gtest("unit_tests_js") {
]
if (is_chromeos) {
sources += [
"../../../browser/resources/chromeos/accessibility/braille_ime/braille_ime_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/select_to_speak/node_utils_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/select_to_speak/paragraph_utils_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/select_to_speak/rect_utils_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/select_to_speak/select_to_speak_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/select_to_speak/word_utils_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/switch_access/rect_helper_unittest.gtestjs",
"../../../browser/resources/chromeos/machine_learning/machine_learning_internals_utils_unittest.gtestjs",
"../../../browser/resources/chromeos/accessibility/braille_ime/braille_ime_unittest.js",
"../../../browser/resources/chromeos/accessibility/select_to_speak/node_utils_unittest.js",
"../../../browser/resources/chromeos/accessibility/select_to_speak/paragraph_utils_unittest.js",
"../../../browser/resources/chromeos/accessibility/select_to_speak/rect_utils_unittest.js",
"../../../browser/resources/chromeos/accessibility/select_to_speak/select_to_speak_unittest.js",
"../../../browser/resources/chromeos/accessibility/select_to_speak/word_utils_unittest.js",
"../../../browser/resources/chromeos/accessibility/switch_access/rect_helper_unittest.js",
"../../../browser/resources/chromeos/machine_learning/machine_learning_internals_utils_unittest.js",
]
extra_js_files += [
"../../../browser/resources/chromeos/accessibility/braille_ime/braille_ime.js",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment