Commit 63d14bf0 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Format ChromeVox test files

- rename all *.extjs and *.unitjs files to *.js
- fix all linter errors
- run clang-format on all files (which are now enforced as .js files).

Change-Id: Ia2064db1caed23e3cf85bee3f46ad716fac4e5dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925339
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#718435}
parent 6a982bbb
...@@ -431,15 +431,15 @@ generate_deps_js("chromevox_test_deps_js") { ...@@ -431,15 +431,15 @@ generate_deps_js("chromevox_test_deps_js") {
js2gtest("chromevox_unitjs_tests") { js2gtest("chromevox_unitjs_tests") {
test_type = "webui" test_type = "webui"
sources = [ sources = [
"braille/bluetooth_braille_display_manager_test.unitjs", "braille/bluetooth_braille_display_manager_test.js",
"braille/bluetooth_braille_display_ui_test.unitjs", "braille/bluetooth_braille_display_ui_test.js",
"braille/braille_display_manager_test.unitjs", "braille/braille_display_manager_test.js",
"braille/braille_input_handler_test.unitjs", "braille/braille_input_handler_test.js",
"braille/expanding_braille_translator_test.unitjs", "braille/expanding_braille_translator_test.js",
"braille/pan_strategy_test.unitjs", "braille/pan_strategy_test.js",
"common/key_sequence_test.unitjs", "common/key_sequence_test.js",
"common/spannable_test.unitjs", "common/spannable_test.js",
"testing/mock_feedback_test.unitjs", "testing/mock_feedback_test.js",
] ]
gen_include_files = [ gen_include_files = [
"testing/assert_additions.js", "testing/assert_additions.js",
...@@ -459,26 +459,26 @@ if (is_chromeos) { ...@@ -459,26 +459,26 @@ if (is_chromeos) {
js2gtest("chromevox_extjs_tests") { js2gtest("chromevox_extjs_tests") {
test_type = "extension" test_type = "extension"
sources = [ sources = [
"background/automation_util_test.extjs", "background/automation_util_test.js",
"background/background_test.extjs", "background/background_test.js",
"background/braille_command_data_test.extjs", "background/braille_command_data_test.js",
"background/color_test.extjs", "background/color_test.js",
"background/cursors_test.extjs", "background/cursors_test.js",
"background/download_handler_test.extjs", "background/download_handler_test.js",
"background/editing_test.extjs", "background/editing_test.js",
"background/keyboard_handler_test.extjs", "background/keyboard_handler_test.js",
"background/language_switching_test.extjs", "background/language_switching_test.js",
"background/live_regions_test.extjs", "background/live_regions_test.js",
"background/logging/log_store_test.extjs", "background/logging/log_store_test.js",
"background/output_test.extjs", "background/output_test.js",
"background/panel/i_search_test.extjs", "background/panel/i_search_test.js",
"background/panel/panel_test.extjs", "background/panel/panel_test.js",
"background/recovery_strategy_test.extjs", "background/recovery_strategy_test.js",
"background/tree_walker_test.extjs", "background/tree_walker_test.js",
"braille/braille_table_test.extjs", "braille/braille_table_test.js",
"braille/braille_translator_manager_test.extjs", "braille/braille_translator_manager_test.js",
"braille/liblouis_test.extjs", "braille/liblouis_test.js",
"common/tts_background_test.extjs", "common/tts_background_test.js",
] ]
gen_include_files = [ gen_include_files = [
"testing/assert_additions.js", "testing/assert_additions.js",
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
GEN_INCLUDE(['../testing/assert_additions.js']);
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/assert_additions.js']); GEN_INCLUDE(['../testing/snippets.js']);
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/snippets.js']);
/** /**
* Test fixture for automation_util.js. * Test fixture for automation_util.js.
...@@ -31,36 +30,38 @@ ChromeVoxAutomationUtilE2ETest.prototype = { ...@@ -31,36 +30,38 @@ ChromeVoxAutomationUtilE2ETest.prototype = {
} }
window.getNonDesktopAncestors = function(node) { window.getNonDesktopAncestors = function(node) {
return AutomationUtil.getAncestors(node) return AutomationUtil.getAncestors(node).filter(filterNonDesktopRoot);
.filter(filterNonDesktopRoot); };
}
window.getNonDesktopUniqueAncestors = function(node1, node2) { window.getNonDesktopUniqueAncestors = function(node1, node2) {
return AutomationUtil.getUniqueAncestors(node1, node2) return AutomationUtil.getUniqueAncestors(node1, node2)
.filter(filterNonDesktopRoot); .filter(filterNonDesktopRoot);
} };
}, },
basicDoc: function() {/*! basicDoc:
<p><a href='#'></a>hello</p> function() { /*!
<h1><ul><li>a</ul><div role="group"><button></button></div></h1> <p><a href='#'></a>hello</p>
*/}, <h1><ul><li>a</ul><div role="group"><button></button></div></h1>
*/ },
secondDoc: function() {/*!
<html> secondDoc:
<head><title>Second doc</title></head> function() { /*!
<body><div>Second</div></body> <html>
</html> <head><title>Second doc</title></head>
*/}, <body><div>Second</div></body>
</html>
iframeDoc: function() {/*! */ },
<html>
<head><title>Second doc</title></head> iframeDoc:
<body> function() { /*!
<html>
<head><title>Second doc</title></head>
<body>
<iframe src="data:text/html,<p>Inside</p>"></iframe> <iframe src="data:text/html,<p>Inside</p>"></iframe>
</body> </body>
</html> </html>
*/} */ }
}; };
TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetAncestors', function() { TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetAncestors', function() {
...@@ -92,28 +93,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetUniqueAncestors', function() { ...@@ -92,28 +93,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetUniqueAncestors', function() {
assertEquals( assertEquals(
-1, AutomationUtil.getDivergence(leftAncestors, leftAncestors)); -1, AutomationUtil.getDivergence(leftAncestors, leftAncestors));
var uniqueAncestorsLeft = var uniqueAncestorsLeft = getNonDesktopUniqueAncestors(rightmost, leftmost);
getNonDesktopUniqueAncestors(rightmost, leftmost);
var uniqueAncestorsRight = var uniqueAncestorsRight =
getNonDesktopUniqueAncestors(leftmost, rightmost); getNonDesktopUniqueAncestors(leftmost, rightmost);
assertEquals(2, uniqueAncestorsLeft.length); assertEquals(2, uniqueAncestorsLeft.length);
assertEquals(RoleType.PARAGRAPH, assertEquals(RoleType.PARAGRAPH, uniqueAncestorsLeft[0].role);
uniqueAncestorsLeft[0].role); assertEquals(RoleType.LINK, uniqueAncestorsLeft[1].role);
assertEquals(RoleType.LINK,
uniqueAncestorsLeft[1].role);
assertEquals(3, uniqueAncestorsRight.length); assertEquals(3, uniqueAncestorsRight.length);
assertEquals(RoleType.HEADING, assertEquals(RoleType.HEADING, uniqueAncestorsRight[0].role);
uniqueAncestorsRight[0].role); assertEquals(RoleType.GROUP, uniqueAncestorsRight[1].role);
assertEquals(RoleType.GROUP, assertEquals(RoleType.BUTTON, uniqueAncestorsRight[2].role);
uniqueAncestorsRight[1].role);
assertEquals(RoleType.BUTTON,
uniqueAncestorsRight[2].role);
assertEquals(
1, getNonDesktopUniqueAncestors(leftmost, leftmost).length);
assertEquals(1, getNonDesktopUniqueAncestors(leftmost, leftmost).length);
}.bind(this)); }.bind(this));
}); });
...@@ -140,20 +133,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetDirection', function() { ...@@ -140,20 +133,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetDirection', function() {
TEST_F('ChromeVoxAutomationUtilE2ETest', 'VisitContainer', function() { TEST_F('ChromeVoxAutomationUtilE2ETest', 'VisitContainer', function() {
this.runWithLoadedTree(toolbarDoc, function(r) { this.runWithLoadedTree(toolbarDoc, function(r) {
var pred = function(n) { return n.role != 'rootWebArea'; }; var pred = function(n) {
return n.role != 'rootWebArea';
};
var toolbar = AutomationUtil.findNextNode(r, 'forward', pred); var toolbar = AutomationUtil.findNextNode(r, 'forward', pred);
assertEquals('toolbar', toolbar.role); assertEquals('toolbar', toolbar.role);
var back = AutomationUtil.findNextNode(toolbar, 'forward', pred); var back = AutomationUtil.findNextNode(toolbar, 'forward', pred);
assertEquals('Back', back.name); assertEquals('Back', back.name);
assertEquals(toolbar, assertEquals(toolbar, AutomationUtil.findNextNode(back, 'backward', pred));
AutomationUtil.findNextNode(back, 'backward', pred));
var forward = AutomationUtil.findNextNode(back, 'forward', pred); var forward = AutomationUtil.findNextNode(back, 'forward', pred);
assertEquals('Forward', forward.name); assertEquals('Forward', forward.name);
assertEquals(back, assertEquals(back, AutomationUtil.findNextNode(forward, 'backward', pred));
AutomationUtil.findNextNode(forward, 'backward', pred));
}); });
}); });
...@@ -162,57 +155,78 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'HitTest', function() { ...@@ -162,57 +155,78 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'HitTest', function() {
// Gets the center point of a rect. // Gets the center point of a rect.
function getCP(node) { function getCP(node) {
var loc = node.location; var loc = node.location;
return {x: loc.left + loc.width/2, y: loc.top + loc.height/2}; return {x: loc.left + loc.width / 2, y: loc.top + loc.height / 2};
} }
var h1, h2, a; var h1, h2, a;
[h1, h2, a] = r.findAll({role: 'inlineTextBox'}); [h1, h2, a] = r.findAll({role: 'inlineTextBox'});
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1))); assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1)));
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent)));
assertEquals(h1.parent.parent, assertEquals(
AutomationUtil.hitTest(r, getCP(h1.parent.parent))); h1.parent.parent, AutomationUtil.hitTest(r, getCP(h1.parent.parent)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a))); assertEquals(a, AutomationUtil.hitTest(r, getCP(a)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent)));
assertEquals(a.parent.parent, assertEquals(
AutomationUtil.hitTest(r, getCP(a.parent.parent))); a.parent.parent, AutomationUtil.hitTest(r, getCP(a.parent.parent)));
}); });
}); });
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeSimple', function() { TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeSimple', function() {
this.runWithLoadedTree(function() {/*! this.runWithLoadedTree(
<p aria-label=" "><div aria-label="x"></div></p> function() { /*!
*/}, function(r) { <p aria-label=" "><div aria-label="x"></div></p>
assertEquals('x', */ },
AutomationUtil.findLastNode(r, function(n) { function(r) {
assertEquals(
'x',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.GENERIC_CONTAINER; return n.role == RoleType.GENERIC_CONTAINER;
}).name); })
.name);
}); });
}); });
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeNonLeaf', function() { TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeNonLeaf', function() {
this.runWithLoadedTree(function() {/*! this.runWithLoadedTree(
<div role="button" aria-label="outer"> function() { /*!
<div role="button" aria-label="inner"> <div role="button" aria-label="outer">
</div> <div role="button" aria-label="inner">
</div> </div>
*/}, function(r) { </div>
assertEquals('outer', */ },
AutomationUtil.findLastNode(r, function(n) { function(r) {
assertEquals(
'outer',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.BUTTON; return n.role == RoleType.BUTTON;
}).name); })
.name);
}); });
}); });
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeLeaf', function() { TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeLeaf', function() {
this.runWithLoadedTree(function() {/*! this.runWithLoadedTree(
<p>start</p> function() { /*!
<div aria-label="outer"><div aria-label="inner"></div></div> <p>start</p>
<p>end</p> <div aria-label="outer"><div aria-label="inner"></div></div>
*/}, function(r) { <p>end</p>
assertEquals('inner', */ },
AutomationUtil.findLastNode(r, function(n) { function(r) {
assertEquals(
'inner',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.GENERIC_CONTAINER; return n.role == RoleType.GENERIC_CONTAINER;
}).name); })
.name);
}); });
}); });
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/assert_additions.js']); GEN_INCLUDE(['../testing/assert_additions.js']);
/** /**
* Test fixture for braille_command_data.js. * Test fixture for braille_command_data.js.
...@@ -24,7 +24,7 @@ SYNC_TEST_F('ChromeVoxBrailleCommandDataTest', 'Duplicates', function() { ...@@ -24,7 +24,7 @@ SYNC_TEST_F('ChromeVoxBrailleCommandDataTest', 'Duplicates', function() {
try { try {
BrailleCommandData.DOT_PATTERN_TO_COMMAND = []; BrailleCommandData.DOT_PATTERN_TO_COMMAND = [];
BrailleCommandData.init_(); BrailleCommandData.init_();
} catch(e) { } catch (e) {
assertNotReached(e.toString()); assertNotReached(e.toString());
} }
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
/** /**
* Test fixture for Color. * Test fixture for Color.
...@@ -26,9 +26,11 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindDistanceTest', function() { ...@@ -26,9 +26,11 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindDistanceTest', function() {
var opaqueRed = 0xffff0000; var opaqueRed = 0xffff0000;
var transparentLime = 0x0000ff00; var transparentLime = 0x0000ff00;
assertEquals(Color.findDistance(red,lime), Color.findDistance(lime, blue)); assertEquals(Color.findDistance(red, lime), Color.findDistance(lime, blue));
// Opacity should not factor into this calculation. // Opacity should not factor into this calculation.
assertEquals(Color.findDistance(red,lime), Color.findDistance(opaqueRed, transparentLime)); assertEquals(
Color.findDistance(red, lime),
Color.findDistance(opaqueRed, transparentLime));
}); });
SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() { SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() {
...@@ -55,7 +57,8 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() { ...@@ -55,7 +57,8 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() {
assertEquals('Black', Color.findClosestMatchingColor(gmailDefaultTextColor)); assertEquals('Black', Color.findClosestMatchingColor(gmailDefaultTextColor));
assertEquals('Pink', Color.findClosestMatchingColor(looksLikePink)); assertEquals('Pink', Color.findClosestMatchingColor(looksLikePink));
assertEquals('Forest Green', Color.findClosestMatchingColor(looksLikeGreen)); assertEquals('Forest Green', Color.findClosestMatchingColor(looksLikeGreen));
assertEquals('Dark Slate Grey', Color.findClosestMatchingColor(looksLikeDarkGrey)); assertEquals(
'Dark Slate Grey', Color.findClosestMatchingColor(looksLikeDarkGrey));
// No match. // No match.
assertEquals('', Color.findClosestMatchingColor(unknownColor)); assertEquals('', Color.findClosestMatchingColor(unknownColor));
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
/** /**
* Test fixture for ChromeVox KeyboardHandler. * Test fixture for ChromeVox KeyboardHandler.
...@@ -23,7 +23,8 @@ ChromeVoxBackgroundKeyboardHandlerTest.prototype = { ...@@ -23,7 +23,8 @@ ChromeVoxBackgroundKeyboardHandlerTest.prototype = {
} }
}; };
TEST_F('ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough', TEST_F(
'ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough',
function() { function() {
this.runWithLoadedTree('<p>test</p>', function() { this.runWithLoadedTree('<p>test</p>', function() {
// A Search keydown gets eaten. // A Search keydown gets eaten.
...@@ -41,4 +42,4 @@ TEST_F('ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough', ...@@ -41,4 +42,4 @@ TEST_F('ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough',
keyboardHandler.onKeyDown(searchDown2); keyboardHandler.onKeyDown(searchDown2);
assertEquals(1, keyboardHandler.eatenKeyDowns_.size); assertEquals(1, keyboardHandler.eatenKeyDowns_.size);
}); });
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']);
/** /**
* Test fixture for automation_util.js. * Test fixture for automation_util.js.
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE([
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js'
]);
/** /**
* Test fixture for ISearch. * Test fixture for ISearch.
...@@ -20,7 +22,7 @@ ChromeVoxISearchTest.prototype = { ...@@ -20,7 +22,7 @@ ChromeVoxISearchTest.prototype = {
/** @override */ /** @override */
runtimeDeps: ['ISearch', 'ISearchHandler'], runtimeDeps: ['ISearch', 'ISearchHandler'],
linksAndHeadingsDoc: function() {/*! linksAndHeadingsDoc: `
<p>start</p> <p>start</p>
<a href='#a'>Home</a> <a href='#a'>Home</a>
<a href='#b'>About US</a> <a href='#b'>About US</a>
...@@ -31,7 +33,7 @@ ChromeVoxISearchTest.prototype = { ...@@ -31,7 +33,7 @@ ChromeVoxISearchTest.prototype = {
<a href='#bar'>Questions?</a> <a href='#bar'>Questions?</a>
<h2>Privacy Policy</h2> <h2>Privacy Policy</h2>
<p>end<span>of test</span></p> <p>end<span>of test</span></p>
*/} `
}; };
/** /**
...@@ -51,9 +53,7 @@ FakeISearchHandler.prototype = { ...@@ -51,9 +53,7 @@ FakeISearchHandler.prototype = {
/** @override */ /** @override */
onSearchResultChanged: function(node, start, end) { onSearchResultChanged: function(node, start, end) {
this.expect_.shift()({node: node, this.expect_.shift()({node: node, start: start, end: end});
start: start,
end: end});
}, },
expect: function(str, opt_callback) { expect: function(str, opt_callback) {
...@@ -80,27 +80,33 @@ TEST_F('ChromeVoxISearchTest', 'Simple', function() { ...@@ -80,27 +80,33 @@ TEST_F('ChromeVoxISearchTest', 'Simple', function() {
// Simple forward search. // Simple forward search.
search.search('US', 'forward'); search.search('US', 'forward');
handler.expect('start=6 end=8 text=About US', handler.expect(
'start=6 end=8 text=About US',
search.search.bind(search, 'start', 'backward')); search.search.bind(search, 'start', 'backward'));
handler.expect('start', handler.expect(
'start',
// Boundary (beginning). // Boundary (beginning).
search.search.bind(search, 'foo', 'backward')); search.search.bind(search, 'foo', 'backward'));
handler.expect('boundary=start', handler.expect(
'boundary=start',
// Boundary (end). // Boundary (end).
search.search.bind(search, 'foo', 'forward')); search.search.bind(search, 'foo', 'forward'));
// Search "focus" doesn't move. // Search "focus" doesn't move.
handler.expect('boundary=start', handler.expect(
'boundary=start',
// Mixed case substring. // Mixed case substring.
search.search.bind(search, 'bReak', 'forward')); search.search.bind(search, 'bReak', 'forward'));
handler.expect('start=7 end=12 text=Latest Breaking News', handler.expect(
'start=7 end=12 text=Latest Breaking News',
search.search.bind(search, 'bReaki', 'forward')); search.search.bind(search, 'bReaki', 'forward'));
// Incremental search stays on the current node. // Incremental search stays on the current node.
handler.expect('start=7 end=13 text=Latest Breaking News', handler.expect(
'start=7 end=13 text=Latest Breaking News',
search.search.bind(search, 'bReakio', 'forward')); search.search.bind(search, 'bReakio', 'forward'));
// No results for the search. // No results for the search.
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js']); GEN_INCLUDE([
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js'
]);
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/mock_feedback.js']); GEN_INCLUDE([
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/mock_feedback.js'
]);
/** /**
* Test fixture for Panel. * Test fixture for Panel.
...@@ -21,15 +25,15 @@ ChromeVoxPanelTest.prototype = { ...@@ -21,15 +25,15 @@ ChromeVoxPanelTest.prototype = {
/** @override */ /** @override */
testGenCppIncludes: function() { testGenCppIncludes: function() {
ChromeVoxE2ETest.prototype. testGenCppIncludes.call(this); ChromeVoxE2ETest.prototype.testGenCppIncludes.call(this);
}, },
/** /**
* @return {!MockFeedback} * @return {!MockFeedback}
*/ */
createMockFeedback: function() { createMockFeedback: function() {
var mockFeedback = new MockFeedback(this.newCallback(), var mockFeedback =
this.newCallback.bind(this)); new MockFeedback(this.newCallback(), this.newCallback.bind(this));
mockFeedback.install(); mockFeedback.install();
return mockFeedback; return mockFeedback;
}, },
...@@ -63,12 +67,12 @@ ChromeVoxPanelTest.prototype = { ...@@ -63,12 +67,12 @@ ChromeVoxPanelTest.prototype = {
}.bind(this); }.bind(this);
}, },
linksDoc: function() {/*! linksDoc: `
<p>start</p> <p>start</p>
<a href="#">apple</a> <a href="#">apple</a>
<a href="#">grape</a> <a href="#">grape</a>
<a href="#">banana</a> <a href="#">banana</a>
*/} `
}; };
// TODO: Flaky timeouts. https://crbug.com/795840 and https://crbug.com/990229 // TODO: Flaky timeouts. https://crbug.com/795840 and https://crbug.com/990229
...@@ -78,14 +82,14 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_ActivateMenu', function() { ...@@ -78,14 +82,14 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_ActivateMenu', function() {
var openMenus = new PanelCommand(PanelCommandType.OPEN_MENUS); var openMenus = new PanelCommand(PanelCommandType.OPEN_MENUS);
mockFeedback.call(openMenus.send.bind(openMenus)) mockFeedback.call(openMenus.send.bind(openMenus))
.expectSpeech( .expectSpeech(
'Jump', 'Jump', 'Menu',
'Menu',
'Go To Beginning Of Table ChromeVox+Alt+Shift+Left arrow', 'Go To Beginning Of Table ChromeVox+Alt+Shift+Left arrow',
/ 1 of [0-9]{2} /) / 1 of [0-9]{2} /)
.call(this.fireMockEvent('ArrowRight')) .call(this.fireMockEvent('ArrowRight'))
.expectSpeech('Speech', 'Menu', .expectSpeech(
'Announce The Title Of The Current Page ChromeVox+A>W', 'Speech', 'Menu',
'Menu item', / 1 of [0-9]{2} /) 'Announce The Title Of The Current Page ChromeVox+A>W', 'Menu item',
/ 1 of [0-9]{2} /)
.replay(); .replay();
}); });
}); });
...@@ -96,13 +100,19 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_LinkMenu', function() { ...@@ -96,13 +100,19 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_LinkMenu', function() {
this.runWithLoadedTree(this.linksDoc, function(root) { this.runWithLoadedTree(this.linksDoc, function(root) {
var openMenus = new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_link'); var openMenus = new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_link');
mockFeedback.call(openMenus.send.bind(openMenus)) mockFeedback.call(openMenus.send.bind(openMenus))
.expectSpeech('Link', 'Menu', 'apple Link', 'Menu item', ' 1 of 3 ',) .expectSpeech(
'Link',
'Menu',
'apple Link',
'Menu item',
' 1 of 3 ',
)
.call(this.fireMockEvent('ArrowLeft')) .call(this.fireMockEvent('ArrowLeft'))
.expectSpeech('Landmark', 'Menu', 'No items.', 'Menu item', ' 1 of 1 ') .expectSpeech('Landmark', 'Menu', 'No items.', 'Menu item', ' 1 of 1 ')
.call(this.fireMockEvent('ArrowRight')) .call(this.fireMockEvent('ArrowRight'))
.expectSpeech('Link', 'Menu', 'apple Link', 'Menu item', ' 1 of 3 ') .expectSpeech('Link', 'Menu', 'apple Link', 'Menu item', ' 1 of 3 ')
.call(this.fireMockEvent('ArrowUp')) .call(this.fireMockEvent('ArrowUp'))
.expectSpeech( 'banana Link', 'Menu item', ' 3 of 3 ') .expectSpeech('banana Link', 'Menu item', ' 3 of 3 ')
.clearPendingOutput() .clearPendingOutput()
.call(this.fireMockEvent('Enter')) .call(this.fireMockEvent('Enter'))
.expectSpeech('banana', 'Link') .expectSpeech('banana', 'Link')
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_next_e2e_test_base.js',
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/assert_additions.js']);
/**
* Test fixture for recovery strategy tests.
* @constructor
* @extends {ChromeVoxNextE2ETest}
*/
function ChromeVoxRecoveryStrategyTest() {
ChromeVoxNextE2ETest.call(this);
window.RoleType = chrome.automation.RoleType;
}
ChromeVoxRecoveryStrategyTest.prototype = {
__proto__: ChromeVoxNextE2ETest.prototype,
};
TEST_F('ChromeVoxRecoveryStrategyTest', 'ReparentedRecovery', function() {
this.runWithLoadedTree(function() {/*!
<input type="text"></input>
<p id="p">hi</p>
<button id="go"</button>
<script>
document.getElementById('go').addEventListener('click', function() {
var p = document.getElementById('p');
p.remove();
document.body.appendChild(p);
});
</script>
*/}, function(root) {
var p = root.find({role: RoleType.PARAGRAPH});
var s = root.find({role: RoleType.STATIC_TEXT});
var b = root.find({role: RoleType.BUTTON});
var bAncestryRecovery = new AncestryRecoveryStrategy(b);
var pAncestryRecovery = new AncestryRecoveryStrategy(p);
var sAncestryRecovery = new AncestryRecoveryStrategy(s);
var bTreePathRecovery = new TreePathRecoveryStrategy(b);
var pTreePathRecovery = new TreePathRecoveryStrategy(p);
var sTreePathRecovery = new TreePathRecoveryStrategy(s);
this.listenOnce(b, 'clicked', function() {
assertFalse(bAncestryRecovery.requiresRecovery(),
"bAncestryRecovery.requiresRecovery");
assertTrue(pAncestryRecovery.requiresRecovery(),
"pAncestryRecovery.requiresRecovery()");
assertTrue(sAncestryRecovery.requiresRecovery(),
"sAncestryRecovery.requiresRecovery()");
assertFalse(bTreePathRecovery.requiresRecovery(),
"bTreePathRecovery.requiresRecovery()");
assertTrue(pTreePathRecovery.requiresRecovery(),
"pTreePathRecovery.requiresRecovery()");
assertTrue(sTreePathRecovery.requiresRecovery(),
"sTreePathRecovery.requiresRecovery()");
assertEquals(RoleType.BUTTON, bAncestryRecovery.node.role);
assertEquals(root, pAncestryRecovery.node);
assertEquals(root, sAncestryRecovery.node);
assertEquals(b, bTreePathRecovery.node);
assertEquals(b, pTreePathRecovery.node);
assertEquals(b, sTreePathRecovery.node);
assertFalse(bAncestryRecovery.requiresRecovery(),
"bAncestryRecovery.requiresRecovery()");
assertFalse(pAncestryRecovery.requiresRecovery(),
"pAncestryRecovery.requiresRecovery()");
assertFalse(sAncestryRecovery.requiresRecovery(),
"sAncestryRecovery.requiresRecovery()");
assertFalse(bTreePathRecovery.requiresRecovery(),
"bTreePathRecovery.requiresRecovery()");
assertFalse(pTreePathRecovery.requiresRecovery(),
"pTreePathRecovery.requiresRecovery()");
assertFalse(sTreePathRecovery.requiresRecovery(),
"sTreePathRecovery.requiresRecovery()");
});
// Trigger the change.
b.doDefault();
});
});
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Include test fixture. // Include test fixture.
GEN_INCLUDE([ GEN_INCLUDE(['chromevox_e2e_test_base.js']);
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_e2e_test_base.js'
]);
/** /**
* Base test fixture for ChromeVox Next end to end tests. * Base test fixture for ChromeVox Next end to end tests.
......
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