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") {
js2gtest("chromevox_unitjs_tests") {
test_type = "webui"
sources = [
"braille/bluetooth_braille_display_manager_test.unitjs",
"braille/bluetooth_braille_display_ui_test.unitjs",
"braille/braille_display_manager_test.unitjs",
"braille/braille_input_handler_test.unitjs",
"braille/expanding_braille_translator_test.unitjs",
"braille/pan_strategy_test.unitjs",
"common/key_sequence_test.unitjs",
"common/spannable_test.unitjs",
"testing/mock_feedback_test.unitjs",
"braille/bluetooth_braille_display_manager_test.js",
"braille/bluetooth_braille_display_ui_test.js",
"braille/braille_display_manager_test.js",
"braille/braille_input_handler_test.js",
"braille/expanding_braille_translator_test.js",
"braille/pan_strategy_test.js",
"common/key_sequence_test.js",
"common/spannable_test.js",
"testing/mock_feedback_test.js",
]
gen_include_files = [
"testing/assert_additions.js",
......@@ -459,26 +459,26 @@ if (is_chromeos) {
js2gtest("chromevox_extjs_tests") {
test_type = "extension"
sources = [
"background/automation_util_test.extjs",
"background/background_test.extjs",
"background/braille_command_data_test.extjs",
"background/color_test.extjs",
"background/cursors_test.extjs",
"background/download_handler_test.extjs",
"background/editing_test.extjs",
"background/keyboard_handler_test.extjs",
"background/language_switching_test.extjs",
"background/live_regions_test.extjs",
"background/logging/log_store_test.extjs",
"background/output_test.extjs",
"background/panel/i_search_test.extjs",
"background/panel/panel_test.extjs",
"background/recovery_strategy_test.extjs",
"background/tree_walker_test.extjs",
"braille/braille_table_test.extjs",
"braille/braille_translator_manager_test.extjs",
"braille/liblouis_test.extjs",
"common/tts_background_test.extjs",
"background/automation_util_test.js",
"background/background_test.js",
"background/braille_command_data_test.js",
"background/color_test.js",
"background/cursors_test.js",
"background/download_handler_test.js",
"background/editing_test.js",
"background/keyboard_handler_test.js",
"background/language_switching_test.js",
"background/live_regions_test.js",
"background/logging/log_store_test.js",
"background/output_test.js",
"background/panel/i_search_test.js",
"background/panel/panel_test.js",
"background/recovery_strategy_test.js",
"background/tree_walker_test.js",
"braille/braille_table_test.js",
"braille/braille_translator_manager_test.js",
"braille/liblouis_test.js",
"common/tts_background_test.js",
]
gen_include_files = [
"testing/assert_additions.js",
......
......@@ -3,10 +3,9 @@
// found in the LICENSE file.
// 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/assert_additions.js']);
GEN_INCLUDE(['//chrome/browser/resources/chromeos/accessibility/chromevox/testing/snippets.js']);
GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
GEN_INCLUDE(['../testing/assert_additions.js']);
GEN_INCLUDE(['../testing/snippets.js']);
/**
* Test fixture for automation_util.js.
......@@ -31,36 +30,38 @@ ChromeVoxAutomationUtilE2ETest.prototype = {
}
window.getNonDesktopAncestors = function(node) {
return AutomationUtil.getAncestors(node)
.filter(filterNonDesktopRoot);
}
return AutomationUtil.getAncestors(node).filter(filterNonDesktopRoot);
};
window.getNonDesktopUniqueAncestors = function(node1, node2) {
return AutomationUtil.getUniqueAncestors(node1, node2)
.filter(filterNonDesktopRoot);
}
};
},
basicDoc: function() {/*!
<p><a href='#'></a>hello</p>
<h1><ul><li>a</ul><div role="group"><button></button></div></h1>
*/},
secondDoc: function() {/*!
<html>
<head><title>Second doc</title></head>
<body><div>Second</div></body>
</html>
*/},
iframeDoc: function() {/*!
<html>
<head><title>Second doc</title></head>
<body>
<iframe src="data:text/html,<p>Inside</p>"></iframe>
</body>
</html>
*/}
basicDoc:
function() { /*!
<p><a href='#'></a>hello</p>
<h1><ul><li>a</ul><div role="group"><button></button></div></h1>
*/ },
secondDoc:
function() { /*!
<html>
<head><title>Second doc</title></head>
<body><div>Second</div></body>
</html>
*/ },
iframeDoc:
function() { /*!
<html>
<head><title>Second doc</title></head>
<body>
<iframe src="data:text/html,<p>Inside</p>"></iframe>
</body>
</html>
*/ }
};
TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetAncestors', function() {
......@@ -92,28 +93,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetUniqueAncestors', function() {
assertEquals(
-1, AutomationUtil.getDivergence(leftAncestors, leftAncestors));
var uniqueAncestorsLeft =
getNonDesktopUniqueAncestors(rightmost, leftmost);
var uniqueAncestorsLeft = getNonDesktopUniqueAncestors(rightmost, leftmost);
var uniqueAncestorsRight =
getNonDesktopUniqueAncestors(leftmost, rightmost);
assertEquals(2, uniqueAncestorsLeft.length);
assertEquals(RoleType.PARAGRAPH,
uniqueAncestorsLeft[0].role);
assertEquals(RoleType.LINK,
uniqueAncestorsLeft[1].role);
assertEquals(RoleType.PARAGRAPH, uniqueAncestorsLeft[0].role);
assertEquals(RoleType.LINK, uniqueAncestorsLeft[1].role);
assertEquals(3, uniqueAncestorsRight.length);
assertEquals(RoleType.HEADING,
uniqueAncestorsRight[0].role);
assertEquals(RoleType.GROUP,
uniqueAncestorsRight[1].role);
assertEquals(RoleType.BUTTON,
uniqueAncestorsRight[2].role);
assertEquals(
1, getNonDesktopUniqueAncestors(leftmost, leftmost).length);
assertEquals(RoleType.HEADING, uniqueAncestorsRight[0].role);
assertEquals(RoleType.GROUP, uniqueAncestorsRight[1].role);
assertEquals(RoleType.BUTTON, uniqueAncestorsRight[2].role);
assertEquals(1, getNonDesktopUniqueAncestors(leftmost, leftmost).length);
}.bind(this));
});
......@@ -140,20 +133,20 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'GetDirection', function() {
TEST_F('ChromeVoxAutomationUtilE2ETest', 'VisitContainer', function() {
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);
assertEquals('toolbar', toolbar.role);
var back = AutomationUtil.findNextNode(toolbar, 'forward', pred);
assertEquals('Back', back.name);
assertEquals(toolbar,
AutomationUtil.findNextNode(back, 'backward', pred));
assertEquals(toolbar, AutomationUtil.findNextNode(back, 'backward', pred));
var forward = AutomationUtil.findNextNode(back, 'forward', pred);
assertEquals('Forward', forward.name);
assertEquals(back,
AutomationUtil.findNextNode(forward, 'backward', pred));
assertEquals(back, AutomationUtil.findNextNode(forward, 'backward', pred));
});
});
......@@ -162,57 +155,78 @@ TEST_F('ChromeVoxAutomationUtilE2ETest', 'HitTest', function() {
// Gets the center point of a rect.
function getCP(node) {
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;
[h1, h2, a] = r.findAll({role: 'inlineTextBox'});
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1)));
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent)));
assertEquals(h1.parent.parent,
AutomationUtil.hitTest(r, getCP(h1.parent.parent)));
assertEquals(
h1.parent.parent, AutomationUtil.hitTest(r, getCP(h1.parent.parent)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent)));
assertEquals(a.parent.parent,
AutomationUtil.hitTest(r, getCP(a.parent.parent)));
assertEquals(
a.parent.parent, AutomationUtil.hitTest(r, getCP(a.parent.parent)));
});
});
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeSimple', function() {
this.runWithLoadedTree(function() {/*!
<p aria-label=" "><div aria-label="x"></div></p>
*/}, function(r) {
assertEquals('x',
AutomationUtil.findLastNode(r, function(n) {
return n.role == RoleType.GENERIC_CONTAINER;
}).name);
});
this.runWithLoadedTree(
function() { /*!
<p aria-label=" "><div aria-label="x"></div></p>
*/ },
function(r) {
assertEquals(
'x',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.GENERIC_CONTAINER;
})
.name);
});
});
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeNonLeaf', function() {
this.runWithLoadedTree(function() {/*!
<div role="button" aria-label="outer">
<div role="button" aria-label="inner">
</div>
</div>
*/}, function(r) {
assertEquals('outer',
AutomationUtil.findLastNode(r, function(n) {
return n.role == RoleType.BUTTON;
}).name);
});
this.runWithLoadedTree(
function() { /*!
<div role="button" aria-label="outer">
<div role="button" aria-label="inner">
</div>
</div>
*/ },
function(r) {
assertEquals(
'outer',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.BUTTON;
})
.name);
});
});
TEST_F('ChromeVoxAutomationUtilE2ETest', 'FindLastNodeLeaf', function() {
this.runWithLoadedTree(function() {/*!
<p>start</p>
<div aria-label="outer"><div aria-label="inner"></div></div>
<p>end</p>
*/}, function(r) {
assertEquals('inner',
AutomationUtil.findLastNode(r, function(n) {
return n.role == RoleType.GENERIC_CONTAINER;
}).name);
});
this.runWithLoadedTree(
function() { /*!
<p>start</p>
<div aria-label="outer"><div aria-label="inner"></div></div>
<p>end</p>
*/ },
function(r) {
assertEquals(
'inner',
AutomationUtil
.findLastNode(
r,
function(n) {
return n.role == RoleType.GENERIC_CONTAINER;
})
.name);
});
});
......@@ -3,9 +3,9 @@
// found in the LICENSE file.
// 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.
......@@ -24,7 +24,7 @@ SYNC_TEST_F('ChromeVoxBrailleCommandDataTest', 'Duplicates', function() {
try {
BrailleCommandData.DOT_PATTERN_TO_COMMAND = [];
BrailleCommandData.init_();
} catch(e) {
} catch (e) {
assertNotReached(e.toString());
}
});
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// 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.
......@@ -26,9 +26,11 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindDistanceTest', function() {
var opaqueRed = 0xffff0000;
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.
assertEquals(Color.findDistance(red,lime), Color.findDistance(opaqueRed, transparentLime));
assertEquals(
Color.findDistance(red, lime),
Color.findDistance(opaqueRed, transparentLime));
});
SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() {
......@@ -55,7 +57,8 @@ SYNC_TEST_F('ChromeVoxColorTest', 'FindClosestMatchingColorTest', function() {
assertEquals('Black', Color.findClosestMatchingColor(gmailDefaultTextColor));
assertEquals('Pink', Color.findClosestMatchingColor(looksLikePink));
assertEquals('Forest Green', Color.findClosestMatchingColor(looksLikeGreen));
assertEquals('Dark Slate Grey', Color.findClosestMatchingColor(looksLikeDarkGrey));
assertEquals(
'Dark Slate Grey', Color.findClosestMatchingColor(looksLikeDarkGrey));
// No match.
assertEquals('', Color.findClosestMatchingColor(unknownColor));
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// 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.
......@@ -23,22 +23,23 @@ ChromeVoxBackgroundKeyboardHandlerTest.prototype = {
}
};
TEST_F('ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough',
function() {
this.runWithLoadedTree('<p>test</p>', function() {
// A Search keydown gets eaten.
var searchDown = {};
searchDown.preventDefault = this.newCallback();
searchDown.stopPropagation = this.newCallback();
searchDown.metaKey = true;
keyboardHandler.onKeyDown(searchDown);
assertEquals(1, keyboardHandler.eatenKeyDowns_.size);
TEST_F(
'ChromeVoxBackgroundKeyboardHandlerTest', 'SearchGetsPassedThrough',
function() {
this.runWithLoadedTree('<p>test</p>', function() {
// A Search keydown gets eaten.
var searchDown = {};
searchDown.preventDefault = this.newCallback();
searchDown.stopPropagation = this.newCallback();
searchDown.metaKey = true;
keyboardHandler.onKeyDown(searchDown);
assertEquals(1, keyboardHandler.eatenKeyDowns_.size);
// A Search keydown does not get eaten when there's no range.
ChromeVoxState.instance.setCurrentRange(null);
var searchDown2 = {};
searchDown2.metaKey = true;
keyboardHandler.onKeyDown(searchDown2);
assertEquals(1, keyboardHandler.eatenKeyDowns_.size);
// A Search keydown does not get eaten when there's no range.
ChromeVoxState.instance.setCurrentRange(null);
var searchDown2 = {};
searchDown2.metaKey = true;
keyboardHandler.onKeyDown(searchDown2);
assertEquals(1, keyboardHandler.eatenKeyDowns_.size);
});
});
});
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// 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.
......
......@@ -3,7 +3,9 @@
// found in the LICENSE file.
// 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.
......@@ -20,7 +22,7 @@ ChromeVoxISearchTest.prototype = {
/** @override */
runtimeDeps: ['ISearch', 'ISearchHandler'],
linksAndHeadingsDoc: function() {/*!
linksAndHeadingsDoc: `
<p>start</p>
<a href='#a'>Home</a>
<a href='#b'>About US</a>
......@@ -31,7 +33,7 @@ ChromeVoxISearchTest.prototype = {
<a href='#bar'>Questions?</a>
<h2>Privacy Policy</h2>
<p>end<span>of test</span></p>
*/}
`
};
/**
......@@ -51,9 +53,7 @@ FakeISearchHandler.prototype = {
/** @override */
onSearchResultChanged: function(node, start, end) {
this.expect_.shift()({node: node,
start: start,
end: end});
this.expect_.shift()({node: node, start: start, end: end});
},
expect: function(str, opt_callback) {
......@@ -80,28 +80,34 @@ TEST_F('ChromeVoxISearchTest', 'Simple', function() {
// Simple forward search.
search.search('US', 'forward');
handler.expect('start=6 end=8 text=About US',
search.search.bind(search, 'start', 'backward'));
handler.expect(
'start=6 end=8 text=About US',
search.search.bind(search, 'start', 'backward'));
handler.expect('start',
// Boundary (beginning).
search.search.bind(search, 'foo', 'backward'));
handler.expect(
'start',
// Boundary (beginning).
search.search.bind(search, 'foo', 'backward'));
handler.expect('boundary=start',
// Boundary (end).
search.search.bind(search, 'foo', 'forward'));
handler.expect(
'boundary=start',
// Boundary (end).
search.search.bind(search, 'foo', 'forward'));
// Search "focus" doesn't move.
handler.expect('boundary=start',
// Mixed case substring.
search.search.bind(search, 'bReak', 'forward'));
handler.expect(
'boundary=start',
// Mixed case substring.
search.search.bind(search, 'bReak', 'forward'));
handler.expect('start=7 end=12 text=Latest Breaking News',
search.search.bind(search, 'bReaki', 'forward'));
handler.expect(
'start=7 end=12 text=Latest Breaking News',
search.search.bind(search, 'bReaki', 'forward'));
// Incremental search stays on the current node.
handler.expect('start=7 end=13 text=Latest Breaking News',
search.search.bind(search, 'bReakio', 'forward'));
handler.expect(
'start=7 end=13 text=Latest Breaking News',
search.search.bind(search, 'bReakio', 'forward'));
// No results for the search.
handler.expect('boundary=Latest Breaking News');
......
......@@ -3,9 +3,7 @@
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE([
'//chrome/browser/resources/chromeos/accessibility/chromevox/testing/chromevox_e2e_test_base.js'
]);
GEN_INCLUDE(['chromevox_e2e_test_base.js']);
/**
* 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