Commit 3044b97c authored by Josiah K's avatar Josiah K Committed by Commit Bot

Add earcons for when smart sticky mode turns on/off

Fixed: 1129617
AX-Relnotes: Add earcons for when smart sticky mode turns on/off
Change-Id: I586e14c17acd614212c34d852c9f69aba976ede5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419751
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812527}
parent 9790b44e
...@@ -2806,46 +2806,6 @@ TEST_F('ChromeVoxBackgroundTest', 'PointerOnOffOnRepeatsNode', function() { ...@@ -2806,46 +2806,6 @@ TEST_F('ChromeVoxBackgroundTest', 'PointerOnOffOnRepeatsNode', function() {
}); });
}); });
TEST_F('ChromeVoxBackgroundTest', 'SmartStickyModeJumpCommands', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p>start</p>
<input type="text"></input>
<button>end</button>
`,
function(root) {
mockFeedback.call(doCmd('toggleStickyMode'))
.expectSpeech('Sticky mode enabled')
.call(doCmd('nextFormField'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextFormField'))
.expectSpeech('Button')
.call(doCmd('previousFormField'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('previousObject'))
.expectSpeech('start')
.call(doCmd('nextEditText'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextObject'))
.expectSpeech('Button')
.call(doCmd('previousEditText'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextObject'))
.expectSpeech('Button')
.call(doCmd('previousObject'))
.expectSpeech('Sticky mode disabled')
.expectSpeech('Edit text')
.call(() => assertFalse(ChromeVox.isStickyModeOn()))
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'PopupButtonCollapsed', function() { TEST_F('ChromeVoxBackgroundTest', 'PopupButtonCollapsed', function() {
const mockFeedback = this.createMockFeedback(); const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree( this.runWithLoadedTree(
......
...@@ -335,6 +335,22 @@ EarconEngine = class { ...@@ -335,6 +335,22 @@ EarconEngine = class {
this.play(this.controlSound, {pitch: -5, time: this.baseDelay * 2}); this.play(this.controlSound, {pitch: -5, time: this.baseDelay * 2});
} }
/**
* Play the smart sticky mode on sound.
*/
onSmartStickyModeOn() {
this.play('static', {gain: this.clickVolume * 0.5});
this.play(this.controlSound, {pitch: 7});
}
/**
* Play the smart sticky mode off sound.
*/
onSmartStickyModeOff() {
this.play('static', {gain: this.clickVolume * 0.5});
this.play(this.controlSound, {pitch: -5});
}
/** /**
* Play the select control sound. * Play the select control sound.
*/ */
......
...@@ -140,6 +140,12 @@ NextEarcons = class extends AbstractEarcons { ...@@ -140,6 +140,12 @@ NextEarcons = class extends AbstractEarcons {
case Earcon.SLIDER: case Earcon.SLIDER:
this.engine_.onSlider(); this.engine_.onSlider();
break; break;
case Earcon.SMART_STICKY_MODE_OFF:
this.engine_.onSmartStickyModeOff();
break;
case Earcon.SMART_STICKY_MODE_ON:
this.engine_.onSmartStickyModeOn();
break;
case Earcon.NO_POINTER_ANCHOR: case Earcon.NO_POINTER_ANCHOR:
this.engine_.onNoPointerAnchor(); this.engine_.onNoPointerAnchor();
break; break;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
goog.provide('SmartStickyMode'); goog.provide('SmartStickyMode');
goog.require('AutomationUtil'); goog.require('AutomationUtil');
goog.require('ChromeVox');
goog.require('ChromeVoxState'); goog.require('ChromeVoxState');
/** @implements {ChromeVoxStateObserver} */ /** @implements {ChromeVoxStateObserver} */
...@@ -79,10 +80,12 @@ SmartStickyMode = class { ...@@ -79,10 +80,12 @@ SmartStickyMode = class {
// Save the sticky state for restoration later. // Save the sticky state for restoration later.
this.didTurnOffStickyMode_ = true; this.didTurnOffStickyMode_ = true;
ChromeVox.earcons.playEarcon(Earcon.SMART_STICKY_MODE_OFF);
ChromeVoxBackground.setPref( ChromeVoxBackground.setPref(
'sticky', false /* value */, true /* announce */); 'sticky', false /* value */, true /* announce */);
} else if (this.didTurnOffStickyMode_) { } else if (this.didTurnOffStickyMode_) {
// Restore the previous sticky mode state. // Restore the previous sticky mode state.
ChromeVox.earcons.playEarcon(Earcon.SMART_STICKY_MODE_ON);
ChromeVoxBackground.setPref( ChromeVoxBackground.setPref(
'sticky', true /* value */, true /* announce */); 'sticky', true /* value */, true /* announce */);
this.didTurnOffStickyMode_ = false; this.didTurnOffStickyMode_ = false;
......
...@@ -11,6 +11,7 @@ GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']); ...@@ -11,6 +11,7 @@ GEN_INCLUDE(['../testing/chromevox_next_e2e_test_base.js']);
ChromeVoxSmartStickyModeTest = class extends ChromeVoxNextE2ETest { ChromeVoxSmartStickyModeTest = class extends ChromeVoxNextE2ETest {
/** @override */ /** @override */
setUp() { setUp() {
window.doCmd = this.doCmd;
this.ssm_ = new SmartStickyMode(); this.ssm_ = new SmartStickyMode();
// Deregister from actual range changes. // Deregister from actual range changes.
ChromeVoxState.removeObserver(this.ssm_); ChromeVoxState.removeObserver(this.ssm_);
...@@ -108,3 +109,68 @@ TEST_F( ...@@ -108,3 +109,68 @@ TEST_F(
this.assertDidNotTurnOffForNode(p); this.assertDidNotTurnOffForNode(p);
}); });
}); });
TEST_F(
'ChromeVoxSmartStickyModeTest', 'SmartStickyModeJumpCommands', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p>start</p>
<input type="text"></input>
<button>end</button>
`,
function(root) {
mockFeedback.call(doCmd('toggleStickyMode'))
.expectSpeech('Sticky mode enabled')
.call(doCmd('nextFormField'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextFormField'))
.expectSpeech('Button')
.call(doCmd('previousFormField'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('previousObject'))
.expectSpeech('start')
.call(doCmd('nextEditText'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextObject'))
.expectSpeech('Button')
.call(doCmd('previousEditText'))
.expectSpeech('Edit text')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.call(doCmd('nextObject'))
.expectSpeech('Button')
.call(doCmd('previousObject'))
.expectSpeech('Sticky mode disabled')
.expectSpeech('Edit text')
.call(() => assertFalse(ChromeVox.isStickyModeOn()))
.replay();
});
});
TEST_F('ChromeVoxSmartStickyModeTest', 'SmartStickyModeEarcons', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p>start</p>
<input type="text"></input>
<button>end</button>
`,
function(root) {
mockFeedback.call(doCmd('toggleStickyMode'))
.expectSpeech('Sticky mode enabled')
.call(doCmd('nextObject'))
.expectEarcon(Earcon.SMART_STICKY_MODE_OFF)
.expectSpeech('Sticky mode disabled')
.expectSpeech('Edit text')
.call(() => assertFalse(ChromeVox.isStickyModeOn()))
.call(doCmd('nextObject'))
.expectEarcon(Earcon.SMART_STICKY_MODE_ON)
.expectSpeech('Sticky mode enabled')
.expectSpeech('Button')
.call(() => assertTrue(ChromeVox.isStickyModeOn()))
.replay();
});
});
...@@ -46,6 +46,8 @@ Earcon = { ...@@ -46,6 +46,8 @@ Earcon = {
SELECTION_REVERSE: 'selection_reverse', SELECTION_REVERSE: 'selection_reverse',
SKIP: 'skip', SKIP: 'skip',
SLIDER: 'slider', SLIDER: 'slider',
SMART_STICKY_MODE_OFF: 'smart_sticky_mode_off',
SMART_STICKY_MODE_ON: 'smart_sticky_mode_on',
NO_POINTER_ANCHOR: 'no_pointer_anchor', NO_POINTER_ANCHOR: 'no_pointer_anchor',
WRAP: 'wrap', WRAP: 'wrap',
WRAP_EDGE: 'wrap_edge', WRAP_EDGE: 'wrap_edge',
......
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