Commit fe988f69 authored by Joel Riley's avatar Joel Riley Committed by Chromium LUCI CQ

Fix bug where Select-to-speak was not going back into inactive state.

When navigation controls are not present, STS was not going into inactive state after TTS completed. This CL fixes this issue, as calling updatePauseStatusFromTtsEvent_ was setting STS back into SPEAKING state.

Also, if STS is activated without nodes, do not show panel.

AX-Relnotes: Bug fix when activating STS without navigation controls, STS did not go back into inactive state.

Bug: 1165847
Change-Id: I88b44e84de525d2dbc190b97fa02b691394cb294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625268
Commit-Queue: Joel Riley <joelriley@google.com>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843301}
parent 107a4008
...@@ -1322,16 +1322,16 @@ export class SelectToSpeak { ...@@ -1322,16 +1322,16 @@ export class SelectToSpeak {
startSpeech_(text) { startSpeech_(text) {
this.prepareForSpeech_(true /* clearFocusRing */); this.prepareForSpeech_(true /* clearFocusRing */);
const options = this.prefsManager_.speechOptions(); const options = this.prefsManager_.speechOptions();
// Without nodes to anchor on, navigate is not supported.
this.supportsNavigationPanel_ = false;
options.onEvent = (event) => { options.onEvent = (event) => {
if (event.type === 'start') { if (event.type === 'start') {
this.onStateChanged_(SelectToSpeakState.SPEAKING); this.onStateChanged_(SelectToSpeakState.SPEAKING);
this.testCurrentNode_(); this.testCurrentNode_();
} else if ( } else if (
(event.type === 'end' || event.type === 'interrupted' || event.type === 'end' || event.type === 'interrupted' ||
event.type === 'cancelled') && event.type === 'cancelled') {
!this.shouldShowNavigationControls_()) { // Automatically dismiss when we're at the end.
// Automatically dismiss when we're at the end, unless navigation
// controled is enabled, in which case we persist STS.
this.onStateChanged_(SelectToSpeakState.INACTIVE); this.onStateChanged_(SelectToSpeakState.INACTIVE);
} }
}; };
...@@ -1569,10 +1569,11 @@ export class SelectToSpeak { ...@@ -1569,10 +1569,11 @@ export class SelectToSpeak {
if (isLastNodeGroup) { if (isLastNodeGroup) {
if (!this.shouldShowNavigationControls_()) { if (!this.shouldShowNavigationControls_()) {
this.onStateChanged_(SelectToSpeakState.INACTIVE); this.onStateChanged_(SelectToSpeakState.INACTIVE);
} else {
// If navigation features are enabled, we should turn the pause status
// to true so that the user can hit resume to continue.
this.updatePauseStatusFromTtsEvent_(true /* shouldPause */);
} }
// If navigation features are enabled, we should turn the pause status to
// true so that the user can hit resume to continue.
this.updatePauseStatusFromTtsEvent_(true /* shouldPause */);
return; return;
} }
......
...@@ -684,3 +684,35 @@ TEST_F('SelectToSpeakNavigationControlTest', 'ResizeWhilePlaying', function() { ...@@ -684,3 +684,35 @@ TEST_F('SelectToSpeakNavigationControlTest', 'ResizeWhilePlaying', function() {
resizeButton.doDefault(); resizeButton.doDefault();
}); });
}); });
TEST_F(
'SelectToSpeakNavigationControlTest',
'RemainsActiveAfterCompletingUtterance', function() {
const bodyHtml = '<p id="p1">Paragraph 1</p>';
this.runWithLoadedTree(
this.generateHtmlWithSelectedElement('p1', bodyHtml), () => {
// Simulate starting and completing TTS.
this.triggerReadSelectedText();
this.mockTts.finishPendingUtterance();
// Should remain in speaking state.
assertEquals(selectToSpeak.state_, SelectToSpeakState.SPEAKING);
});
});
TEST_F(
'SelectToSpeakNavigationControlTest',
'AutoDismissesIfNavigationControlsDisabled', function() {
// Disable navigation controls via settings.
chrome.storage.sync.set({'navigationControls': false});
const bodyHtml = '<p id="p1">Paragraph 1</p>';
this.runWithLoadedTree(
this.generateHtmlWithSelectedElement('p1', bodyHtml), () => {
// Simulate starting and completing TTS.
this.triggerReadSelectedText();
this.mockTts.finishPendingUtterance();
// Should auto-dismiss.
assertEquals(selectToSpeak.state_, SelectToSpeakState.INACTIVE);
});
});
\ No newline at end of file
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