Commit 182eef43 authored by Lei Shi's avatar Lei Shi Committed by Chromium LUCI CQ

Change Backward Sentence Navigation in Select to Speak

Currently, the backward sentence navigation takes the user to the
closest sentence start before the current position. If the user wants to
go to the previous sentence, they have to click the backward button at
the beginning of the current sentence before TTS speaking any word. This
poses interaction challenges as the user has to compete with the TTS
engine.

After consolidating with our UXD, we plan to change the behavior of
backward sentence navigation. Clicking the backward button will always
go to the previous sentence, regardless of the user's position at the
current sentence. However, we need to keep the behavior of the pause and
resume feature, which brings the user back to the start of the current
sentence.

This CL modifies navigateToNextSentenceWithinNodeGroup_ and
navigateToNextSentence_ to allow callers to set whether we will skip the
current sentence when navigating backward.

AX-Relnotes: N/A.
Bug: 1143823
Change-Id: I71d05f62f38cb3dbba31b6375f11b537b611b4a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597178
Commit-Queue: Lei Shi <leileilei@google.com>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838981}
parent 1515997b
...@@ -346,7 +346,7 @@ TEST_F('SelectToSpeakNavigationControlTest', 'PrevSentence', function() { ...@@ -346,7 +346,7 @@ TEST_F('SelectToSpeakNavigationControlTest', 'PrevSentence', function() {
this.generateHtmlWithSelectedElement('p1', bodyHtml), async function() { this.generateHtmlWithSelectedElement('p1', bodyHtml), async function() {
this.triggerReadSelectedText(); this.triggerReadSelectedText();
// Speaks till the end of the second sentence. // Speaks util the start of the second sentence.
this.mockTts.speakUntilCharIndex(33); this.mockTts.speakUntilCharIndex(33);
assertTrue(this.mockTts.currentlySpeaking()); assertTrue(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 1); assertEquals(this.mockTts.pendingUtterances().length, 1);
...@@ -366,6 +366,37 @@ TEST_F('SelectToSpeakNavigationControlTest', 'PrevSentence', function() { ...@@ -366,6 +366,37 @@ TEST_F('SelectToSpeakNavigationControlTest', 'PrevSentence', function() {
}); });
}); });
TEST_F(
'SelectToSpeakNavigationControlTest', 'PrevSentenceFromMiddleOfSentence',
function() {
const bodyHtml = `
<p id="p1">First sentence. Second sentence. Third sentence.</p>'
`;
this.runWithLoadedTree(
this.generateHtmlWithSelectedElement('p1', bodyHtml),
async function() {
this.triggerReadSelectedText();
// Speaks util the start of "sentence" in "Second sentence".
this.mockTts.speakUntilCharIndex(23);
assertTrue(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 1);
this.assertEqualsCollapseWhitespace(
this.mockTts.pendingUtterances()[0],
'First sentence. Second sentence. Third sentence.');
// Hitting prev sentence will start another TTS.
await selectToSpeak.onSelectToSpeakPanelAction_(
chrome.accessibilityPrivate.SelectToSpeakPanelAction
.PREVIOUS_SENTENCE);
assertTrue(this.mockTts.currentlySpeaking());
assertEquals(this.mockTts.pendingUtterances().length, 1);
this.assertEqualsCollapseWhitespace(
this.mockTts.pendingUtterances()[0],
'First sentence. Second sentence. Third sentence.');
});
});
TEST_F( TEST_F(
'SelectToSpeakNavigationControlTest', 'PrevSentenceWithinParagraph', 'SelectToSpeakNavigationControlTest', 'PrevSentenceWithinParagraph',
function() { function() {
......
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