Commit 9c10cec9 authored by Josiah K's avatar Josiah K Committed by Commit Bot

Fix AutoclickE2ETest.RemovesAndAddAutoclick test

Just noticed test was missing this.newCallback(), so added it, to make sure test runs and waits for callback before finishing.

AX-Relnotes: n/a
Change-Id: I72baf27159706853672d18af00410c07cfef91b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450794
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814243}
parent bc115884
...@@ -15,6 +15,8 @@ AutoclickE2ETest = class extends E2ETestBase { ...@@ -15,6 +15,8 @@ AutoclickE2ETest = class extends E2ETestBase {
this.mockAccessibilityPrivate = MockAccessibilityPrivate; this.mockAccessibilityPrivate = MockAccessibilityPrivate;
chrome.accessibilityPrivate = this.mockAccessibilityPrivate; chrome.accessibilityPrivate = this.mockAccessibilityPrivate;
window.RoleType = chrome.automation.RoleType;
// Re-initialize AccessibilityCommon with mock AccessibilityPrivate API. // Re-initialize AccessibilityCommon with mock AccessibilityPrivate API.
accessibilityCommon = new AccessibilityCommon(); accessibilityCommon = new AccessibilityCommon();
...@@ -60,21 +62,21 @@ AutoclickE2ETest = class extends E2ETestBase { ...@@ -60,21 +62,21 @@ AutoclickE2ETest = class extends E2ETestBase {
TEST_F('AutoclickE2ETest', 'HighlightsRootWebAreaIfNotScrollable', function() { TEST_F('AutoclickE2ETest', 'HighlightsRootWebAreaIfNotScrollable', function() {
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,<p>Cats rock!</p>', function(desktop) { 'data:text/html;charset=utf-8,<p>Cats rock!</p>',
async function(desktop) {
const node = desktop.find( const node = desktop.find(
{role: 'staticText', attributes: {name: 'Cats rock!'}}); {role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}});
this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested( await new Promise(resolve => {
// Offset slightly into the node to ensure the hittest this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested(
// happens within the node. // Offset slightly into the node to ensure the hittest
node.location.left + 1, node.location.top + 1, // happens within the node.
this.newCallback(() => { node.location.left + 1, node.location.top + 1, resolve);
const expected = node.root.location; });
this.assertSameRect( const expected = node.root.location;
this.mockAccessibilityPrivate.getScrollableBounds(), this.assertSameRect(
expected); this.mockAccessibilityPrivate.getScrollableBounds(), expected);
this.assertSameRect( this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0], expected); this.mockAccessibilityPrivate.getFocusRings()[0], expected);
}));
}); });
}); });
...@@ -84,53 +86,52 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() { ...@@ -84,53 +86,52 @@ TEST_F('AutoclickE2ETest', 'HighlightsScrollableDiv', function() {
'<div style="width:100px;height:100px;overflow:scroll">' + '<div style="width:100px;height:100px;overflow:scroll">' +
'<div style="margin:50px">cats rock! this text wraps and overflows!' + '<div style="margin:50px">cats rock! this text wraps and overflows!' +
'</div></div>', '</div></div>',
function(desktop) { async function(desktop) {
const node = desktop.find({ const node = desktop.find({
role: 'staticText', role: RoleType.STATIC_TEXT,
attributes: {name: 'cats rock! this text wraps and overflows!'} attributes: {name: 'cats rock! this text wraps and overflows!'}
}); });
this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested( await new Promise(resolve => {
// Offset slightly into the node to ensure the hittest happens this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested(
// within the node. // Offset slightly into the node to ensure the hittest happens
node.location.left + 1, node.location.top + 1, // within the node.
this.newCallback(() => { node.location.left + 1, node.location.top + 1, resolve);
// The outer div, which is the parent of the parent of the });
// text, is scrollable. // The outer div, which is the parent of the parent of the
assertTrue(node.parent.parent.scrollable); // text, is scrollable.
const expected = node.parent.parent.location; assertTrue(node.parent.parent.scrollable);
this.assertSameRect( const expected = node.parent.parent.location;
this.mockAccessibilityPrivate.getScrollableBounds(), this.assertSameRect(
expected); this.mockAccessibilityPrivate.getScrollableBounds(), expected);
this.assertSameRect( this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0], expected); this.mockAccessibilityPrivate.getFocusRings()[0], expected);
}));
}); });
}); });
TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() { TEST_F('AutoclickE2ETest', 'RemovesAndAddsAutoclick', function() {
this.runWithLoadedTree( this.runWithLoadedTree(
'data:text/html;charset=utf-8,<p>Cats rock!</p>', function(desktop) { 'data:text/html;charset=utf-8,<p>Cats rock!</p>',
async function(desktop) {
// Toggle autoclick off and on, ensure it still works and no crashes. // Toggle autoclick off and on, ensure it still works and no crashes.
chrome.accessibilityFeatures.autoclick.set({value: false}, () => { await new Promise(resolve => {
chrome.accessibilityFeatures.autoclick.set({value: true}, () => { chrome.accessibilityFeatures.autoclick.set({value: false}, resolve);
const node = desktop.find( });
{role: 'staticText', attributes: {name: 'Cats rock!'}}); await new Promise(resolve => {
this.mockAccessibilityPrivate chrome.accessibilityFeatures.autoclick.set({value: true}, resolve);
.callOnScrollableBoundsForPointRequested( });
// Offset slightly into the node to ensure the hittest const node = desktop.find(
// happens within the node. {role: RoleType.STATIC_TEXT, attributes: {name: 'Cats rock!'}});
node.location.left + 1, node.location.top + 1, await new Promise(resolve => {
this.newCallback(() => { this.mockAccessibilityPrivate.callOnScrollableBoundsForPointRequested(
const expected = node.root.location; // Offset slightly into the node to ensure the hittest happens
this.assertSameRect( // within the node.
this.mockAccessibilityPrivate.getScrollableBounds(), node.location.left + 1, node.location.top + 1, resolve);
expected);
this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0],
expected);
}));
});
}); });
const expected = node.root.location;
this.assertSameRect(
this.mockAccessibilityPrivate.getScrollableBounds(), expected);
this.assertSameRect(
this.mockAccessibilityPrivate.getFocusRings()[0], expected);
}); });
}); });
......
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