Commit a92eb9b7 authored by Pavol Marko's avatar Pavol Marko Committed by Commit Bot

Speculative fix for MagnifierE2ETest.MovesDockedMagnifierToActiveDescendant

The test was failing/flaky on some MSAN bots, presumably because the
listener was registered after the event was fired.

Introduce a helper class that allows us to easily register the listener,
perform the event, then wait for the listener to have fired.

TBR=josiahk@chromium.org, dtseng@chromium.org

Bug: 1145612
Test: Runs locally but real test will be whether this fixes failures on
the 'Linux ChromiumOS MSan Tests bot'

Change-Id: I16303d96b101113e80ab4f484b4e604faeab4c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560622Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830991}
parent 0b9512f8
...@@ -14,18 +14,33 @@ DockedMagnifierE2ETest = class extends E2ETestBase { ...@@ -14,18 +14,33 @@ DockedMagnifierE2ETest = class extends E2ETestBase {
constructor() { constructor() {
super(); super();
window.RoleType = chrome.automation.RoleType; window.RoleType = chrome.automation.RoleType;
}
async getNextMagnifierBounds() { /**
return new Promise(resolve => { * Registers a listener for
const listener = (magnifierBounds) => { * chrome.accessibilityPrivate.onMagnifierBoundsChanged in the ctor. After
chrome.accessibilityPrivate.onMagnifierBoundsChanged.removeListener( * that, the test code can perform the action, and then use
listener); * waitForNextMagnifierBounds() to be wait for the previously-registered
resolve(magnifierBounds); * listener to be called.
}; *
chrome.accessibilityPrivate.onMagnifierBoundsChanged.addListener( * @private
listener); */
}); this.nextMagnifierBoundsWaiter_ = class {
constructor() {
this.promise_ = new Promise(resolve => {
const listener = (magnifierBounds) => {
chrome.accessibilityPrivate.onMagnifierBoundsChanged.removeListener(
listener);
resolve(magnifierBounds);
};
chrome.accessibilityPrivate.onMagnifierBoundsChanged.addListener(
listener);
});
}
async waitForNextMagnifierBounds() {
return this.promise_;
}
};
} }
/** @override */ /** @override */
...@@ -60,18 +75,18 @@ TEST_F( ...@@ -60,18 +75,18 @@ TEST_F(
const group = root.find({role: RoleType.GROUP}); const group = root.find({role: RoleType.GROUP});
// Focus and move magnifier to top. // Focus and move magnifier to top.
// Then verify magnifier contain top and not banana.
const boundsWaiter1 = new this.nextMagnifierBoundsWaiter_();
top.focus(); top.focus();
let bounds = await boundsWaiter1.waitForNextMagnifierBounds();
// Verify magnifier contain top and not banana.
let bounds = await this.getNextMagnifierBounds();
assertTrue(RectUtil.contains(bounds, top.location)); assertTrue(RectUtil.contains(bounds, top.location));
assertFalse(RectUtil.contains(bounds, banana.location)); assertFalse(RectUtil.contains(bounds, banana.location));
// Click group to change active descendant to banana. // Click group to change active descendant to banana.
// Then verify magnifier bounds contain banana.
const boundsWaiter2 = new this.nextMagnifierBoundsWaiter_();
group.doDefault(); group.doDefault();
bounds = await boundsWaiter2.waitForNextMagnifierBounds();
// Verify magnifier bounds contain banana.
bounds = await this.getNextMagnifierBounds();
assertFalse(RectUtil.contains(bounds, top.location)); assertFalse(RectUtil.contains(bounds, top.location));
assertTrue(RectUtil.contains(bounds, banana.location)); assertTrue(RectUtil.contains(bounds, banana.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