Commit 94ef2a90 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Do not move ChromeVox focus ring on value changes

R=akihiroota@chromium.org

Fixed: 1098914
AX-Relnotes: ChromeVox will not move its focus indicator when adjusting the volume using hardware keys.
Change-Id: I6d64fb39dd63bab76630b667ba37ea5d96a02c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416751
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808112}
parent 9c6dc328
......@@ -3094,3 +3094,19 @@ TEST_F('ChromeVoxBackgroundTest', 'ImageAnnotations', function() {
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'VolumeChanges', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(``, function() {
const bounds = ChromeVoxState.instance.getFocusBounds();
mockFeedback.call(press(KeyCode.VOLUME_UP))
.expectSpeech('Volume', 'Slider', /\d+%/)
.call(() => {
// The bounds should not have changed.
assertEquals(
JSON.stringify(bounds),
JSON.stringify(ChromeVoxState.instance.getFocusBounds()));
})
.replay();
});
});
......@@ -428,6 +428,7 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
this.lastValueChanged_ = new Date();
const output = new Output();
output.withoutFocusRing();
if (fromDesktop &&
(!this.lastValueTarget_ || this.lastValueTarget_ !== t)) {
......
......@@ -117,6 +117,9 @@ Output = class {
/** @private {!Object} */
this.initialSpeechProps_ = {};
/** @private {boolean} */
this.drawFocusRing_ = true;
}
/**
......@@ -364,6 +367,15 @@ Output = class {
return this;
}
/**
* Don't draw a focus ring based on this output.
* @return {!Output}
*/
withoutFocusRing() {
this.drawFocusRing_ = false;
return this;
}
/**
* Supply initial speech properties that will be applied to all output.
* @param {!Object} speechProps
......@@ -561,7 +573,7 @@ Output = class {
}
// Display.
if (this.speechCategory_ != TtsCategory.LIVE) {
if (this.speechCategory_ != TtsCategory.LIVE && this.drawFocusRing_) {
ChromeVoxState.instance.setFocusBounds(this.locations_);
}
}
......
......@@ -1335,3 +1335,27 @@ TEST_F('ChromeVoxOutputE2ETest', 'DelayHintVariants', function() {
o.speechOutputForTest);
});
});
TEST_F('ChromeVoxOutputE2ETest', 'WithoutFocusRing', function() {
const site = `<button></button>`;
this.runWithLoadedTree(site, function(root) {
let called = false;
ChromeVoxState.instance.setFocusBounds = this.newCallback(() => {
called = true;
});
const button = root.find({role: RoleType.BUTTON});
// Triggers drawing of the focus ring.
new Output().withSpeech(cursors.Range.fromNode(button)).go();
assertTrue(called);
called = false;
// Does not trigger drawing of the focus ring.
new Output()
.withSpeech(cursors.Range.fromNode(button))
.withoutFocusRing()
.go();
assertFalse(called);
});
});
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