Commit 2d6e9bc3 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

Use RectUtil in a11y extension tests

This is a pure refactor.

AX-Relnotes: n/a.
Bug: None.
Change-Id: I6fab3b1663a7f4f8e2b2bcfe8d9b373f9c820ed8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382398Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#812475}
parent ffc8bf94
......@@ -62,6 +62,7 @@ js2gtest("accessibility_common_extjs_tests") {
"autoclick/autoclick_test.js",
]
gen_include_files = [
"../common/rect_util.js",
"../common/testing/callback_helper.js",
"../common/testing/e2e_test_base.js",
"../common/testing/mock_accessibility_private.js",
......
......@@ -4,6 +4,7 @@
GEN_INCLUDE(['../../common/testing/e2e_test_base.js']);
GEN_INCLUDE(['../../common/testing/mock_accessibility_private.js']);
GEN_INCLUDE(['../../common/rect_util.js']);
/**
* Automatic clicks feature using accessibility common extension browser tests.
......@@ -54,10 +55,7 @@ AutoclickE2ETest = class extends E2ETestBase {
* @param {!chrome.accessibilityPrivate.ScreenRect} second
*/
assertSameRect(first, second) {
assertEquals(first.left, second.left);
assertEquals(first.top, second.top);
assertEquals(first.width, second.width);
assertEquals(first.height, second.height);
assertTrue(RectUtil.equal(first, second));
}
};
......
......@@ -5,7 +5,8 @@
// Include test fixture.
GEN_INCLUDE([
'../chromevox/testing/chromevox_next_e2e_test_base.js',
'testing/assert_additions.js', '../chromevox/testing/snippets.js'
'testing/assert_additions.js', '../chromevox/testing/snippets.js',
'rect_util.js'
]);
/**
......@@ -186,22 +187,21 @@ TEST_F(
TEST_F('AccessibilityExtensionAutomationUtilE2ETest', 'HitTest', function() {
this.runWithLoadedTree(headingDoc, function(r) {
// Gets the center point of a rect.
function getCP(node) {
const loc = node.location;
return {x: loc.left + loc.width / 2, y: loc.top + loc.height / 2};
}
const [h1, h2, a] = r.findAll({role: 'inlineTextBox'});
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1)));
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent)));
assertEquals(h1, AutomationUtil.hitTest(r, RectUtil.center(h1.location)));
assertEquals(
h1, AutomationUtil.hitTest(r, RectUtil.center(h1.parent.location)));
assertEquals(
h1.parent.parent, AutomationUtil.hitTest(r, getCP(h1.parent.parent)));
h1.parent.parent,
AutomationUtil.hitTest(r, RectUtil.center(h1.parent.parent.location)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent)));
assertEquals(a, AutomationUtil.hitTest(r, RectUtil.center(a.location)));
assertEquals(
a, AutomationUtil.hitTest(r, RectUtil.center(a.parent.location)));
assertEquals(
a.parent.parent, AutomationUtil.hitTest(r, getCP(a.parent.parent)));
a.parent.parent,
AutomationUtil.hitTest(r, RectUtil.center(a.parent.parent.location)));
});
});
......
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