Commit 81a9300a authored by dtseng's avatar dtseng Committed by Commit bot

Reland: Split spoken feedback up on a per format rule basis.

Original cl
https://codereview.chromium.org/1035983003/

In order for ChromeVox to queue up utterances, we can separate each attribute or rule into its own spannable. Each spannable is then sent to tts (queueing as needed).

BUG=477492
TBR=dtseng@chromium.org

Review URL: https://codereview.chromium.org/1094463003

Cr-Commit-Position: refs/heads/master@{#325542}
parent 0ee13e37
...@@ -263,15 +263,24 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { ...@@ -263,15 +263,24 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
EnableChromeVox(); EnableChromeVox();
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*"));
"about:blank*Tool bar Reload Button")); EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EnableChromeVox(); EnableChromeVox();
chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*Edit text*")); EXPECT_TRUE(
MatchPattern(speech_monitor_.GetNextUtterance(), "*about:blank*"));
EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Address and search bar", speech_monitor_.GetNextUtterance());
EXPECT_EQ("about:blank", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_X); SendKeyPress(ui::VKEY_X);
EXPECT_EQ("x", speech_monitor_.GetNextUtterance()); EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
...@@ -290,13 +299,17 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) { ...@@ -290,13 +299,17 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) {
EnableChromeVox(); EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
const char* expected = app_list::switches::IsExperimentalAppListEnabled() EXPECT_EQ("Shelf", speech_monitor_.GetNextUtterance());
? "Shelf Tool bar Launcher Button" EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
: "Shelf Tool bar Apps Button"; if (app_list::switches::IsExperimentalAppListEnabled())
EXPECT_EQ(expected, speech_monitor_.GetNextUtterance()); EXPECT_EQ("Launcher", speech_monitor_.GetNextUtterance());
else
EXPECT_EQ("Apps", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_TAB); SendKeyPress(ui::VKEY_TAB);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "* Button")); EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateAppLauncher) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateAppLauncher) {
...@@ -305,17 +318,19 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateAppLauncher) { ...@@ -305,17 +318,19 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateAppLauncher) {
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
while (true) { while (true) {
std::string utterance = speech_monitor_.GetNextUtterance(); std::string utterance = speech_monitor_.GetNextUtterance();
if (MatchPattern(utterance, "*Button")) if (MatchPattern(utterance, "Button"))
break; break;
} }
SendKeyPress(ui::VKEY_RETURN); SendKeyPress(ui::VKEY_RETURN);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), EXPECT_EQ("Search or type U R L", speech_monitor_.GetNextUtterance());
"Search or type U R L Edit text")); EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_DOWN); SendKeyPress(ui::VKEY_DOWN);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "* Button")); EXPECT_EQ("Dialog", speech_monitor_.GetNextUtterance());
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) {
...@@ -326,7 +341,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) { ...@@ -326,7 +341,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) {
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "time *")); EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "time *"));
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
"Battery is*full.")); "Battery is*full."));
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*Button")); EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) {
...@@ -335,15 +351,16 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) { ...@@ -335,15 +351,16 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) {
EXPECT_TRUE(PerformAcceleratorAction(ash::SHOW_SYSTEM_TRAY_BUBBLE)); EXPECT_TRUE(PerformAcceleratorAction(ash::SHOW_SYSTEM_TRAY_BUBBLE));
while (true) { while (true) {
std::string utterance = speech_monitor_.GetNextUtterance(); std::string utterance = speech_monitor_.GetNextUtterance();
if (MatchPattern(utterance, "* Button")) if (MatchPattern(utterance, "Button"))
break; break;
} }
// Navigate to Bluetooth sub-menu and open it. // Navigate to Bluetooth sub-menu and open it.
while (true) { while (true) {
SendKeyPress(ui::VKEY_TAB); SendKeyPress(ui::VKEY_TAB);
std::string utterance = speech_monitor_.GetNextUtterance(); std::string content = speech_monitor_.GetNextUtterance();
if (MatchPattern(utterance, "*Bluetooth* Button")) std::string role = speech_monitor_.GetNextUtterance();
if (MatchPattern(content, "*Bluetooth*") && MatchPattern(role, "Button"))
break; break;
} }
SendKeyPress(ui::VKEY_RETURN); SendKeyPress(ui::VKEY_RETURN);
...@@ -352,12 +369,16 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) { ...@@ -352,12 +369,16 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) {
while (true) { while (true) {
SendKeyPress(ui::VKEY_TAB); SendKeyPress(ui::VKEY_TAB);
std::string utterance = speech_monitor_.GetNextUtterance(); std::string utterance = speech_monitor_.GetNextUtterance();
if (MatchPattern(utterance, "Previous menu Button")) if (MatchPattern(utterance, "Previous menu"))
break; break;
} }
SendKeyPress(ui::VKEY_RETURN); SendKeyPress(ui::VKEY_RETURN);
EXPECT_TRUE(
MatchPattern(speech_monitor_.GetNextUtterance(), "*Bluetooth* Button")); while (true) {
std::string utterance = speech_monitor_.GetNextUtterance();
if (MatchPattern(speech_monitor_.GetNextUtterance(), "*Bluetooth"))
break;
}
} }
// See http://crbug.com/443608 // See http://crbug.com/443608
...@@ -387,11 +408,12 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) { ...@@ -387,11 +408,12 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) {
EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_OVERVIEW)); EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_OVERVIEW));
EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance()); EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Alert Entered window overview mode", EXPECT_EQ("Alert", speech_monitor_.GetNextUtterance());
speech_monitor_.GetNextUtterance()); EXPECT_EQ("Entered window overview mode", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_TAB); SendKeyPress(ui::VKEY_TAB);
EXPECT_EQ("about:blank Button", speech_monitor_.GetNextUtterance()); EXPECT_EQ("about:blank", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
} }
#if defined(MEMORY_SANITIZER) #if defined(MEMORY_SANITIZER)
...@@ -559,8 +581,11 @@ IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { ...@@ -559,8 +581,11 @@ IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*"));
"about:blank*Tool bar Reload Button")); EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
} }
// //
......
...@@ -23,17 +23,63 @@ OutputE2ETest.prototype = { ...@@ -23,17 +23,63 @@ OutputE2ETest.prototype = {
} }
}; };
TEST_F('OutputE2ETest', 'RenderBasic', function() { TEST_F('OutputE2ETest', 'Links', function() {
this.runWithLoadedTree('<a href="#">Click here</a>', this.runWithLoadedTree('<a href="#">Click here</a>',
function(root) { function(root) {
var link = root.firstChild.firstChild; var el = root.firstChild.firstChild;
var range = cursors.Range.fromNode(link); var range = cursors.Range.fromNode(el);
var o = new Output().withSpeechAndBraille(range, null, 'navigate'); var o = new Output().withSpeechAndBraille(range, null, 'navigate');
assertEqualsJSON({string_: 'Click here Link', 'spans_': [ assertEqualsJSON({string_: 'Click hereLink', 'spans_': [
{value: 'name', start: 0, end: 10}, // Attributes.
// Link earcon. {value: 'name', start: 0, end: 10},
{value: {}, start: 11, end: 15} {value: 'role', start: 10, end: 14},
]},
o.getBuffer()); // Link earcon (based on the role).
{value: {}, start: 10, end: 14}
]}, o.toSpannable());
});
});
TEST_F('OutputE2ETest', 'Checkbox', function() {
this.runWithLoadedTree('<input type="checkbox">',
function(root) {
var el = root.firstChild.firstChild;
var range = cursors.Range.fromNode(el);
var o = new Output().withSpeechAndBraille(range, null, 'navigate');
assertEqualsJSON({string_: 'Check boxnot checked', 'spans_': [
// Attributes.
{value: 'name', start: 0, end: 0},
{value: 'role', start: 0, end: 9},
{value: 'state', start: 9, end: 20},
// Link earcon (based on the state).
{value: {}, start: 9, end: 20}
]}, o.toSpannable());
});
});
TEST_F('OutputE2ETest', 'InLineTextBoxValueGetsIgnored', function() {
this.runWithLoadedTree('<p>OK',
function(root) {
var el = root.firstChild.firstChild.firstChild;
assertEquals('inlineTextBox', el.role);
var range = cursors.Range.fromNode(el);
var o = new Output().withSpeechAndBraille(range, null, 'navigate');
assertEqualsJSON({string_: 'OK', 'spans_': [
// Attributes.
{value: 'name', start: 0, end: 2}
]}, o.toSpannable());
el = root.firstChild.firstChild;
assertEquals('staticText', el.role);
range = cursors.Range.fromNode(el);
o = new Output().withSpeechAndBraille(range, null, 'navigate');
assertEqualsJSON({string_: 'OK', 'spans_': [
// Attributes.
{value: 'value', start: 0, end: 2},
// The name is an empty string.
{value: 'name', start: 2, end: 2}
]}, o.toSpannable());
}); });
}); });
...@@ -533,6 +533,9 @@ ...@@ -533,6 +533,9 @@
<message desc="Spoken when the user opens a Chrome menu named 'title'." name="IDS_CHROMEVOX_CHROME_MENU_OPENED"> <message desc="Spoken when the user opens a Chrome menu named 'title'." name="IDS_CHROMEVOX_CHROME_MENU_OPENED">
<ph name="title">$1</ph> menu opened <ph name="title">$1</ph> menu opened
</message> </message>
<message desc="Spoken when the user closes any Chrome menu." name="IDS_CHROMEVOX_CHROME_MENU_CLOSED">
menu closed
</message>
<message desc="Describes a HTML checkbox named 'name' in the checked state." name="IDS_CHROMEVOX_DESCRIBE_CHECKBOX_CHECKED"> <message desc="Describes a HTML checkbox named 'name' in the checked state." name="IDS_CHROMEVOX_DESCRIBE_CHECKBOX_CHECKED">
<ph name="name">$1</ph> checkbox checked <ph name="name">$1</ph> checkbox checked
</message> </message>
...@@ -647,6 +650,12 @@ ...@@ -647,6 +650,12 @@
<message desc="Spoken when the user enters a dialog with the text 'text'." name="IDS_CHROMEVOX_ENTERING_DIALOG"> <message desc="Spoken when the user enters a dialog with the text 'text'." name="IDS_CHROMEVOX_ENTERING_DIALOG">
Entered dialog Entered dialog
</message> </message>
<message desc="Spoken for an element with role dialog." name="IDS_CHROMEVOX_DIALOG">
Dialog
</message>
<message desc="Brailled for an element with role dialog." name="IDS_CHROMEVOX_DIALOG_BRL">
dlg
</message>
<message desc="Spoken before the list of elements when a live region of a page is removed." name="IDS_CHROMEVOX_LIVE_REGIONS_REMOVED"> <message desc="Spoken before the list of elements when a live region of a page is removed." name="IDS_CHROMEVOX_LIVE_REGIONS_REMOVED">
removed: removed:
</message> </message>
......
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