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") { ...@@ -62,6 +62,7 @@ js2gtest("accessibility_common_extjs_tests") {
"autoclick/autoclick_test.js", "autoclick/autoclick_test.js",
] ]
gen_include_files = [ gen_include_files = [
"../common/rect_util.js",
"../common/testing/callback_helper.js", "../common/testing/callback_helper.js",
"../common/testing/e2e_test_base.js", "../common/testing/e2e_test_base.js",
"../common/testing/mock_accessibility_private.js", "../common/testing/mock_accessibility_private.js",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
GEN_INCLUDE(['../../common/testing/e2e_test_base.js']); GEN_INCLUDE(['../../common/testing/e2e_test_base.js']);
GEN_INCLUDE(['../../common/testing/mock_accessibility_private.js']); GEN_INCLUDE(['../../common/testing/mock_accessibility_private.js']);
GEN_INCLUDE(['../../common/rect_util.js']);
/** /**
* Automatic clicks feature using accessibility common extension browser tests. * Automatic clicks feature using accessibility common extension browser tests.
...@@ -54,10 +55,7 @@ AutoclickE2ETest = class extends E2ETestBase { ...@@ -54,10 +55,7 @@ AutoclickE2ETest = class extends E2ETestBase {
* @param {!chrome.accessibilityPrivate.ScreenRect} second * @param {!chrome.accessibilityPrivate.ScreenRect} second
*/ */
assertSameRect(first, second) { assertSameRect(first, second) {
assertEquals(first.left, second.left); assertTrue(RectUtil.equal(first, second));
assertEquals(first.top, second.top);
assertEquals(first.width, second.width);
assertEquals(first.height, second.height);
} }
}; };
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
// Include test fixture. // Include test fixture.
GEN_INCLUDE([ GEN_INCLUDE([
'../chromevox/testing/chromevox_next_e2e_test_base.js', '../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( ...@@ -186,22 +187,21 @@ TEST_F(
TEST_F('AccessibilityExtensionAutomationUtilE2ETest', 'HitTest', function() { TEST_F('AccessibilityExtensionAutomationUtilE2ETest', 'HitTest', function() {
this.runWithLoadedTree(headingDoc, function(r) { 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'}); const [h1, h2, a] = r.findAll({role: 'inlineTextBox'});
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1))); assertEquals(h1, AutomationUtil.hitTest(r, RectUtil.center(h1.location)));
assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); assertEquals(
h1, AutomationUtil.hitTest(r, RectUtil.center(h1.parent.location)));
assertEquals( 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, RectUtil.center(a.location)));
assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); assertEquals(
a, AutomationUtil.hitTest(r, RectUtil.center(a.parent.location)));
assertEquals( 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