Commit a3c46feb authored by David Tseng's avatar David Tseng Committed by Commit Bot

Re-enable some SpokenFeedbackTests

General strategy:
- perform all actions (sm_.Call)
- gather pending utterances
- mix in Expect* calls between all Call actions (incrementally from the top)
- keep the tests mostly simple (limit UI interactions) to prevent flakes
- do use the async SpeechMonitor api which should be less flakey
- deleted one test who's behavior is still in flux (empty panel menu behavior)

Some tests were still failing but due to external factors. Comments left.

Change-Id: I7689880dbeeac3b31fe22a8029fae5078d975f0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119382
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753470}
parent 071013fb
...@@ -230,6 +230,10 @@ void SpeechMonitor::Replay() { ...@@ -230,6 +230,10 @@ void SpeechMonitor::Replay() {
} }
void SpeechMonitor::MaybeContinueReplay() { void SpeechMonitor::MaybeContinueReplay() {
// This method can be called prior to Replay() being called.
if (!replay_called_)
return;
auto it = replay_queue_.begin(); auto it = replay_queue_.begin();
while (it != replay_queue_.end()) { while (it != replay_queue_.end()) {
if (it->first()) { if (it->first()) {
......
...@@ -140,34 +140,32 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, ...@@ -140,34 +140,32 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
while (sm_.GetNextUtterance() != "Press Search plus Space to activate") { sm_.ExpectSpeech("Shelf");
}
// Press space on the launcher button in shelf, this opens peeking launcher. // Press space on the launcher button in shelf, this opens peeking launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
while (sm_.GetNextUtterance() != "Launcher, partial view") { sm_.ExpectSpeech("Launcher, partial view");
}
// Send a key press to enable keyboard traversal // Send a key press to enable keyboard traversal
SendKeyPressWithSearchAndShift(ui::VKEY_TAB); sm_.Call([this]() { SendKeyPressWithSearchAndShift(ui::VKEY_TAB); });
// Move focus to expand all apps button. // Move focus to expand all apps button.
SendKeyPressWithSearchAndShift(ui::VKEY_TAB); sm_.Call([this]() { SendKeyPressWithSearchAndShift(ui::VKEY_TAB); });
while (sm_.GetNextUtterance() != "Press Search plus Space to activate") { sm_.ExpectSpeech("Expand to all apps");
}
// Press space on expand arrow to go to fullscreen launcher. // Press space on expand arrow to go to fullscreen launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
while (sm_.GetNextUtterance() != "Launcher, all apps") { sm_.ExpectSpeech("Launcher, all apps");
}
// Make sure the first traversal left is not the expand arrow button. // Make sure the first traversal left is not the expand arrow button.
SendKeyPressWithSearch(ui::VKEY_LEFT); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_LEFT); });
EXPECT_NE("Expand to all apps", sm_.GetNextUtterance()); sm_.ExpectNextSpeechIsNot("Expand to all apps");
// Make sure the second traversal left is not the expand arrow button. // Make sure the second traversal left is not the expand arrow button.
SendKeyPressWithSearch(ui::VKEY_LEFT); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_LEFT); });
EXPECT_NE("Expand to all apps", sm_.GetNextUtterance()); sm_.ExpectNextSpeechIsNot("Expand to all apps");
sm_.Replay();
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
...@@ -256,61 +254,49 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, ...@@ -256,61 +254,49 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
sm_.Replay(); sm_.Replay();
} }
// TODO(newcomer): reimplement this test once the AppListFocus changes are IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, NavigateAppLauncher) {
// complete (http://crbug.com/784942).
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
DISABLED_NavigateAppLauncher) {
EnableChromeVox(); EnableChromeVox();
// Add one app to the applist.
PopulateApps(1);
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
// Wait for it to say "Launcher", "Button", "Shelf", "Tool bar". // Wait for it to say "Launcher", "Button", "Shelf", "Tool bar".
while (true) { sm_.ExpectSpeechPattern("Launcher");
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeech("Button");
if (base::MatchPattern(utterance, "Launcher")) sm_.ExpectSpeech("Shelf");
break; sm_.ExpectSpeech("Tool bar");
}
EXPECT_EQ("Button", sm_.GetNextUtterance());
EXPECT_EQ("Shelf", sm_.GetNextUtterance());
EXPECT_EQ("Tool bar", sm_.GetNextUtterance());
// Click on the launcher, it brings up the app list UI. // Click on the launcher, it brings up the app list UI.
SendKeyPress(ui::VKEY_SPACE); sm_.Call([this]() { SendKeyPress(ui::VKEY_SPACE); });
while ("Search or type URL" != sm_.GetNextUtterance()) { sm_.ExpectSpeech(
} "Search your device, apps, and web. Use the arrow keys to navigate your "
while ("Edit text" != sm_.GetNextUtterance()) { "apps.");
} sm_.ExpectSpeech("Edit text");
// Close it and open it again. // Close it and open it again.
SendKeyPress(ui::VKEY_ESCAPE); sm_.Call([this]() { SendKeyPress(ui::VKEY_ESCAPE); });
while (true) { sm_.ExpectSpeechPattern("*window*");
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "*window*"))
break;
}
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); sm_.Call(
while (true) { [this]() { EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); });
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeechPattern("Launcher");
if (base::MatchPattern(utterance, "Button")) sm_.ExpectSpeech("Button");
break;
} sm_.Call([this]() { SendKeyPress(ui::VKEY_SPACE); });
SendKeyPress(ui::VKEY_SPACE); sm_.ExpectSpeech(
"Search your device, apps, and web. Use the arrow keys to navigate your "
// Now type a space into the text field and wait until we hear "space". "apps.");
// This makes the test more robust as it allows us to skip over other
// speech along the way.
SendKeyPress(ui::VKEY_SPACE);
while (true) {
if ("space" == sm_.GetNextUtterance())
break;
}
// Now press the down arrow and we should be focused on an app button // Now press the right arrow and we should be focused on an app button
// in a dialog. // in a dialog.
SendKeyPress(ui::VKEY_DOWN); // THis doesn't work though (to be done below).
while ("Button" != sm_.GetNextUtterance()) {
} // TODO(newcomer): reimplement this test once the AppListFocus changes are
// complete (http://crbug.com/784942).
sm_.Replay();
} }
} // namespace chromeos } // namespace chromeos
...@@ -89,6 +89,11 @@ void LoggedInSpokenFeedbackTest::SendKeyPressWithControl(ui::KeyboardCode key) { ...@@ -89,6 +89,11 @@ void LoggedInSpokenFeedbackTest::SendKeyPressWithControl(ui::KeyboardCode key) {
nullptr, key, true, false, false, false))); nullptr, key, true, false, false, false)));
} }
void LoggedInSpokenFeedbackTest::SendKeyPressWithShift(ui::KeyboardCode key) {
ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
nullptr, key, false, true, false, false)));
}
void LoggedInSpokenFeedbackTest::SendKeyPressWithSearchAndShift( void LoggedInSpokenFeedbackTest::SendKeyPressWithSearchAndShift(
ui::KeyboardCode key) { ui::KeyboardCode key) {
ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
...@@ -174,85 +179,75 @@ void LoggedInSpokenFeedbackTest::PressRepeatedlyUntilUtterance( ...@@ -174,85 +179,75 @@ void LoggedInSpokenFeedbackTest::PressRepeatedlyUntilUtterance(
} }
} }
// This test is very flakey with ChromeVox Next since we generate a lot more IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) {
// utterances for text fields.
// TODO(dtseng): Fix properly.
IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, DISABLED_AddBookmark) {
EnableChromeVox(); EnableChromeVox();
chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
// Create a bookmark with title "foo". // Create a bookmark with title "foo".
chrome::ExecuteCommand(browser(), IDC_BOOKMARK_THIS_TAB); chrome::ExecuteCommand(browser(), IDC_BOOKMARK_THIS_TAB);
EXPECT_EQ("Bookmark added! dialog Bookmark name about:blank Edit text",
sm_.GetNextUtterance());
EXPECT_EQ("about:blank", sm_.GetNextUtterance());
SendKeyPress(ui::VKEY_F); sm_.ExpectSpeech("Bookmark name");
EXPECT_EQ("f", sm_.GetNextUtterance()); sm_.ExpectSpeech("about:blank");
SendKeyPress(ui::VKEY_O); sm_.ExpectSpeech("selected");
EXPECT_EQ("o", sm_.GetNextUtterance()); sm_.ExpectSpeech("Edit text");
SendKeyPress(ui::VKEY_O); sm_.ExpectSpeech("Bookmark added");
EXPECT_EQ("o", sm_.GetNextUtterance()); sm_.ExpectSpeech("Dialog");
sm_.ExpectSpeech("Bookmark added, window");
SendKeyPress(ui::VKEY_TAB); sm_.Call([this]() {
EXPECT_EQ("Bookmark folder combo Box Bookmarks bar", sm_.GetNextUtterance()); SendKeyPress(ui::VKEY_F);
SendKeyPress(ui::VKEY_O);
SendKeyPress(ui::VKEY_O);
});
sm_.ExpectSpeech("F");
sm_.ExpectSpeech("O");
sm_.ExpectSpeech("O");
SendKeyPress(ui::VKEY_RETURN); sm_.Call([this]() { SendKeyPress(ui::VKEY_TAB); });
sm_.ExpectSpeech("Bookmark folder");
sm_.ExpectSpeech("Bookmarks bar");
sm_.ExpectSpeech("Button");
sm_.ExpectSpeech("has pop up");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*oolbar*")); sm_.Call([this]() { SendKeyPress(ui::VKEY_TAB); });
// Wait for active window change to be announced to avoid interference from sm_.ExpectSpeech("More…");
// that below.
while (sm_.GetNextUtterance() != "window about blank tab") { sm_.Call([this]() { SendKeyPress(ui::VKEY_TAB); });
// Do nothing. sm_.ExpectSpeech("Remove");
}
sm_.Call([this]() { SendKeyPress(ui::VKEY_TAB); });
sm_.ExpectSpeech("Done");
sm_.Call([this]() { SendKeyPress(ui::VKEY_RETURN); });
// Focus goes back to window.
sm_.ExpectSpeechPattern("about:blank*");
// Focus bookmarks bar and listen for "foo". // Focus bookmarks bar and listen for "foo".
chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS); sm_.Call(
while (true) { [this]() { chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS); });
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeech("foo");
VLOG(0) << "Got utterance: " << utterance; sm_.ExpectSpeech("Button");
if (utterance == "Bookmarks,") sm_.ExpectSpeech("Bookmarks");
break; sm_.ExpectSpeech("Tool bar");
} sm_.Replay();
EXPECT_EQ("foo,", sm_.GetNextUtterance());
EXPECT_EQ("button", sm_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, NavigateNotificationCenter) {
DISABLED_NavigateNotificationCenter) {
EnableChromeVox(); EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_MESSAGE_CENTER_BUBBLE)); EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_MESSAGE_CENTER_BUBBLE));
sm_.ExpectSpeech(
"Quick Settings, Press search plus left to access the notification "
"center., window");
// Tab to request the initial focus. sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_LEFT); });
SendKeyPress(ui::VKEY_TAB); // If you are hitting this in the course of changing the UI, please fix. This
// item needs a label.
// Wait for it to say "Notification Center, window". sm_.ExpectSpeech("List item");
while ("Notification Center, window" != sm_.GetNextUtterance()) {
}
// Tab until we get to the Do Not Disturb button. // Furthermore, navigation is generally broken using Search+Left.
SendKeyPress(ui::VKEY_TAB);
do {
std::string ut = sm_.GetNextUtterance();
if (ut == "Do not disturb") sm_.Replay();
break;
else if (ut == "Button")
SendKeyPress(ui::VKEY_TAB);
} while (true);
EXPECT_EQ("Button", sm_.GetNextUtterance());
EXPECT_EQ("Not pressed", sm_.GetNextUtterance());
SendKeyPress(ui::VKEY_SPACE);
EXPECT_EQ("Do not disturb", sm_.GetNextUtterance());
EXPECT_EQ("Button", sm_.GetNextUtterance());
EXPECT_EQ("Pressed", sm_.GetNextUtterance());
SendKeyPress(ui::VKEY_SPACE);
EXPECT_EQ("Do not disturb", sm_.GetNextUtterance());
EXPECT_EQ("Button", sm_.GetNextUtterance());
EXPECT_EQ("Not pressed", sm_.GetNextUtterance());
} }
// //
...@@ -285,9 +280,7 @@ INSTANTIATE_TEST_SUITE_P(TestAsNormalAndGuestUser, ...@@ -285,9 +280,7 @@ INSTANTIATE_TEST_SUITE_P(TestAsNormalAndGuestUser,
::testing::Values(kTestAsNormalUser, ::testing::Values(kTestAsNormalUser,
kTestAsGuestUser)); kTestAsGuestUser));
// TODO(tommi): Flakily hitting HasOneRef DCHECK in IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
// AudioOutputResampler::Shutdown, see crbug.com/630031.
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_EnableSpokenFeedback) {
EnableChromeVox(); EnableChromeVox();
} }
...@@ -299,21 +292,37 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { ...@@ -299,21 +292,37 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
EXPECT_EQ("Button", sm_.GetNextUtterance()); EXPECT_EQ("Button", sm_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EnableChromeVox(); EnableChromeVox();
// Location bar has focus by default so just start typing. ui_test_utils::NavigateToURL(
SendKeyPress(ui::VKEY_X); browser(), GURL("data:text/html;charset=utf-8,<p>unused</p>"));
EXPECT_EQ("x", sm_.GetNextUtterance());
sm_.Call([this]() { SendKeyPressWithControl(ui::VKEY_L); });
sm_.ExpectSpeech("Address and search bar");
sm_.Call([this]() {
// Select all the text.
SendKeyPressWithControl(ui::VKEY_A);
// Type x, y, and z.
SendKeyPress(ui::VKEY_X);
SendKeyPress(ui::VKEY_Y);
SendKeyPress(ui::VKEY_Z);
});
sm_.ExpectSpeech("X");
sm_.ExpectSpeech("Y");
sm_.ExpectSpeech("Z");
SendKeyPress(ui::VKEY_Y); sm_.Call([this]() { SendKeyPress(ui::VKEY_BACK); });
EXPECT_EQ("y", sm_.GetNextUtterance()); sm_.ExpectSpeech("Z");
SendKeyPress(ui::VKEY_Z); // Auto completions.
EXPECT_EQ("z", sm_.GetNextUtterance()); sm_.ExpectSpeech("xy search");
sm_.ExpectSpeech("List item");
sm_.ExpectSpeech("1 of 1");
SendKeyPress(ui::VKEY_BACK); sm_.Replay();
EXPECT_EQ("z", sm_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) {
...@@ -339,9 +348,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) { ...@@ -339,9 +348,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) {
// Verifies that pressing right arrow button with search button should move // Verifies that pressing right arrow button with search button should move
// focus to the next ShelfItem instead of the last one // focus to the next ShelfItem instead of the last one
// (see https://crbug.com/947683). IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ShelfIconFocusForward) {
// This test is flaky, see http://crbug.com/997628
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ShelfIconFocusForward) {
const std::string title("MockApp"); const std::string title("MockApp");
ChromeLauncherController* controller = ChromeLauncherController::instance(); ChromeLauncherController* controller = ChromeLauncherController::instance();
...@@ -353,41 +360,31 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ShelfIconFocusForward) { ...@@ -353,41 +360,31 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ShelfIconFocusForward) {
ash::ShelfID("FakeApp"), controller->shelf_model()->item_count(), ash::ShelfID("FakeApp"), controller->shelf_model()->item_count(),
base::ASCIIToUTF16(title)); base::ASCIIToUTF16(title));
// Wait for the change on ShelfModel to reach ash.
base::RunLoop().RunUntilIdle();
// Focus on the shelf. // Focus on the shelf.
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); sm_.Call([this]() { PerformAcceleratorAction(ash::FOCUS_SHELF); });
while (true) { sm_.ExpectSpeech("Launcher");
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeech("Button");
if (base::MatchPattern(utterance, "Launcher")) sm_.ExpectSpeech("Shelf");
break; sm_.ExpectSpeech("Tool bar");
}
ASSERT_EQ("Button", sm_.GetNextUtterance());
ASSERT_EQ("Shelf", sm_.GetNextUtterance());
ASSERT_EQ("Tool bar", sm_.GetNextUtterance());
ASSERT_EQ(", window", sm_.GetNextUtterance());
ASSERT_EQ("Press Search plus Space to activate", sm_.GetNextUtterance());
// Verifies that pressing right key with search key should move the focus of // Verifies that pressing right key with search key should move the focus of
// ShelfItem correctly. // ShelfItem correctly.
SendKeyPressWithSearch(ui::VKEY_RIGHT); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*")); // Chromium or Google Chrome button here (not being tested).
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button")); sm_.ExpectSpeech("Button");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*")); sm_.ExpectSpeech("Shelf");
SendKeyPressWithSearch(ui::VKEY_RIGHT); sm_.ExpectSpeech("Tool bar");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), title));
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button")); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*")); sm_.ExpectSpeech("MockApp");
sm_.ExpectSpeech("Button");
sm_.Replay();
} }
// Verifies that speaking text under mouse works for Shelf button and voice // Verifies that speaking text under mouse works for Shelf button and voice
// announcements should not be stacked when mouse goes over many Shelf buttons // announcements should not be stacked when mouse goes over many Shelf buttons
// (see https://crbug.com/958120 and https://crbug.com/921182). IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, SpeakingTextUnderMouseForShelfItem) {
// TODO(crbug.com/921182): Fix test correctness/reliability and re-enable.
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest,
DISABLED_SpeakingTextUnderMouseForShelfItem) {
// Add the ShelfItem to the ShelfModel after enabling the ChromeVox. Because // Add the ShelfItem to the ShelfModel after enabling the ChromeVox. Because
// when an extension is enabled, the ShelfItems which are not recorded as // when an extension is enabled, the ShelfItems which are not recorded as
// pinned apps in user preference will be removed. // pinned apps in user preference will be removed.
...@@ -405,7 +402,6 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ...@@ -405,7 +402,6 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest,
controller->CreateAppShortcutLauncherItem( controller->CreateAppShortcutLauncherItem(
ash::ShelfID(app_id), base_index + i, base::ASCIIToUTF16(app_title)); ash::ShelfID(app_id), base_index + i, base::ASCIIToUTF16(app_title));
} }
base::RunLoop().RunUntilIdle();
// Enable the function of speaking text under mouse. // Enable the function of speaking text under mouse.
ash::EventRewriterController::Get()->SetSendMouseEventsToDelegate(true); ash::EventRewriterController::Get()->SetSendMouseEventsToDelegate(true);
...@@ -413,45 +409,26 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ...@@ -413,45 +409,26 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest,
// Focus on the Shelf because voice text for focusing on Shelf is fixed. Wait // Focus on the Shelf because voice text for focusing on Shelf is fixed. Wait
// until voice announcements are finished. // until voice announcements are finished.
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
while (true) { sm_.ExpectSpeechPattern("Launcher");
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "Launcher"))
break;
}
ASSERT_EQ("Button", sm_.GetNextUtterance());
ASSERT_EQ("Shelf", sm_.GetNextUtterance());
ASSERT_EQ("Tool bar", sm_.GetNextUtterance());
ASSERT_EQ(", window", sm_.GetNextUtterance());
ASSERT_EQ("Press Search plus Space to activate", sm_.GetNextUtterance());
// Hover mouse on the Shelf button. Verifies that text under mouse is spoken. // Hover mouse on the Shelf button. Verifies that text under mouse is spoken.
ash::ShelfView* shelf_view = sm_.Call([this]() {
ash::Shelf::ForWindow(ash::Shell::Get()->GetPrimaryRootWindow()) ash::ShelfView* shelf_view =
->shelf_widget() ash::Shelf::ForWindow(ash::Shell::Get()->GetPrimaryRootWindow())
->shelf_view_for_testing(); ->shelf_widget()
const int first_app_index = ->shelf_view_for_testing();
shelf_view->model()->GetItemIndexForType(ash::TYPE_PINNED_APP); const int first_app_index =
SendMouseMoveTo(shelf_view->view_model() shelf_view->model()->GetItemIndexForType(ash::TYPE_PINNED_APP);
->view_at(first_app_index) SendMouseMoveTo(shelf_view->view_model()
->GetBoundsInScreen() ->view_at(first_app_index)
.CenterPoint()); ->GetBoundsInScreen()
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "MockApp0")); .CenterPoint());
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button")); });
// Move mouse to the third Shelf button through the second one. Verifies that sm_.ExpectSpeechPattern("MockApp*");
// only the last Shelf button is announced by ChromeVox. sm_.ExpectSpeech("Button");
const int second_app_index = first_app_index + 1;
SendMouseMoveTo(shelf_view->view_model() sm_.Replay();
->view_at(second_app_index)
->GetBoundsInScreen()
.CenterPoint());
const int third_app_index = first_app_index + 2;
SendMouseMoveTo(shelf_view->view_model()
->view_at(third_app_index)
->GetBoundsInScreen()
.CenterPoint());
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "MockApp2"));
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button"));
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) {
...@@ -470,88 +447,54 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) { ...@@ -470,88 +447,54 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OpenStatusTray) {
// Fails on ASAN. See http://crbug.com/776308 . (Note MAYBE_ doesn't work well // Fails on ASAN. See http://crbug.com/776308 . (Note MAYBE_ doesn't work well
// with parameterized tests). // with parameterized tests).
#if !defined(ADDRESS_SANITIZER) && !defined(OS_CHROMEOS) #if !defined(ADDRESS_SANITIZER)
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) {
EnableChromeVox(); EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_SYSTEM_TRAY_BUBBLE)); sm_.Call(
while (true) { [this]() { (PerformAcceleratorAction(ash::TOGGLE_SYSTEM_TRAY_BUBBLE)); });
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeechPattern(
if (base::MatchPattern(utterance, "Status tray,")) "Quick Settings, Press search plus left to access the notification "
break; "center., window");
}
while (true) {
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "*window"))
break;
}
SendKeyPress(ui::VKEY_TAB);
while (true) {
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "Button"))
break;
}
// Next element. sm_.Call([this]() { SendKeyPress(ui::VKEY_TAB); });
SendKeyPressWithSearch(ui::VKEY_RIGHT); sm_.ExpectSpeech(GetParam() == kTestAsGuestUser ? "Exit guest" : "Sign out");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*")); sm_.ExpectSpeech("Button");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button"));
// Next button. // Next button.
SendKeyPressWithSearch(ui::VKEY_B); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_B); });
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "*")); sm_.ExpectSpeech("Shut down");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Button")); sm_.ExpectSpeech("Button");
// Navigate to Bluetooth sub-menu and open it.
while (true) {
SendKeyPress(ui::VKEY_TAB);
std::string content = sm_.GetNextUtterance();
std::string role = sm_.GetNextUtterance();
if (base::MatchPattern(content, "*Bluetooth*") &&
base::MatchPattern(role, "Button"))
break;
}
SendKeyPress(ui::VKEY_RETURN);
// Navigate to return to previous menu button and press it.
while (true) {
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "Previous menu"))
break;
SendKeyPress(ui::VKEY_TAB);
}
SendKeyPress(ui::VKEY_RETURN);
while (true) { sm_.Replay();
std::string utterance = sm_.GetNextUtterance();
if (base::MatchPattern(utterance, "Bluetooth*"))
break;
}
} }
#endif // !defined(ADDRESS_SANITIZER) && !defined(OS_CHROMEOS) #endif // !defined(ADDRESS_SANITIZER)
// See http://crbug.com/443608 // TODO: these brightness announcements are actually not made.
// https://crbug.com/1064788
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ScreenBrightness) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ScreenBrightness) {
EnableChromeVox(); EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::BRIGHTNESS_UP)); sm_.Call([this]() { (PerformAcceleratorAction(ash::BRIGHTNESS_UP)); });
EXPECT_TRUE( sm_.ExpectSpeechPattern("Brightness * percent");
base::MatchPattern(sm_.GetNextUtterance(), "Brightness * percent"));
sm_.Call([this]() { (PerformAcceleratorAction(ash::BRIGHTNESS_DOWN)); });
sm_.ExpectSpeechPattern("Brightness * percent");
EXPECT_TRUE(PerformAcceleratorAction(ash::BRIGHTNESS_DOWN)); sm_.Replay();
EXPECT_TRUE(
base::MatchPattern(sm_.GetNextUtterance(), "Brightness * percent"));
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_VolumeSlider) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, VolumeSlider) {
EnableChromeVox(); EnableChromeVox();
// Volume slider does not fire valueChanged event on first key press because sm_.Call([this]() {
// it has no widget. // Volume slider does not fire valueChanged event on first key press because
EXPECT_TRUE(PerformAcceleratorAction(ash::VOLUME_UP)); // it has no widget.
EXPECT_TRUE(PerformAcceleratorAction(ash::VOLUME_UP)); PerformAcceleratorAction(ash::VOLUME_UP);
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "* percent*")); PerformAcceleratorAction(ash::VOLUME_UP);
});
sm_.ExpectSpeechPattern("* percent*");
sm_.Replay();
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) {
...@@ -576,129 +519,108 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) { ...@@ -576,129 +519,108 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) {
} }
} }
#if defined(MEMORY_SANITIZER) || defined(OS_CHROMEOS) IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxFindInPage) {
// Fails under MemorySanitizer: http://crbug.com/472125
// Test is flaky under ChromeOS: http://crbug.com/897249
#define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch
#else
#define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) {
EnableChromeVox(); EnableChromeVox();
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(
browser(), browser(),
GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
while (true) {
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeech("Click me");
if (utterance == "Click me")
break;
}
// Press Search+/ to enter ChromeVox's "find in page". // Press Search+/ to enter ChromeVox's "find in page".
SendKeyPressWithSearch(ui::VKEY_OEM_2); SendKeyPressWithSearch(ui::VKEY_OEM_2);
sm_.ExpectSpeech("Find in page");
while (true) { sm_.Replay();
std::string utterance = sm_.GetNextUtterance();
if (utterance == "Find in page")
break;
}
} }
#if defined(MEMORY_SANITIZER) || defined(OS_CHROMEOS) IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNavigateAndSelect) {
// Fails under MemorySanitizer: http://crbug.com/472125
// TODO(crbug.com/721475): Flaky on CrOS.
#define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect
#else
#define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) {
EnableChromeVox(); EnableChromeVox();
ui_test_utils::NavigateToURL(browser(), ui_test_utils::NavigateToURL(browser(),
GURL("data:text/html;charset=utf-8," GURL("data:text/html;charset=utf-8,"
"<h1>Title</h1>" "<h1>Title</h1>"
"<button autofocus>Click me</button>")); "<button autofocus>Click me</button>"));
while (true) {
std::string utterance = sm_.GetNextUtterance(); sm_.ExpectSpeech("Click me");
if (utterance == "Click me")
break;
}
EXPECT_EQ("Button", sm_.GetNextUtterance());
// Press Search+Left to navigate to the previous item. // Press Search+Left to navigate to the previous item.
SendKeyPressWithSearch(ui::VKEY_LEFT); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_LEFT); });
EXPECT_EQ("Title", sm_.GetNextUtterance()); sm_.ExpectSpeech("Title");
EXPECT_EQ("Heading 1", sm_.GetNextUtterance()); sm_.ExpectSpeech("Heading 1");
// Press Search+S to select the text. // Press Search+S to select the text.
SendKeyPressWithSearch(ui::VKEY_S); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_S); });
EXPECT_EQ("Title", sm_.GetNextUtterance()); sm_.ExpectSpeech("Title");
EXPECT_EQ("selected", sm_.GetNextUtterance()); sm_.ExpectSpeech("selected");
// Press again to end the selection. // Press again to end the selection.
SendKeyPressWithSearch(ui::VKEY_S); sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_S); });
EXPECT_EQ("End selection", sm_.GetNextUtterance()); sm_.ExpectSpeech("End selection");
EXPECT_EQ("Title", sm_.GetNextUtterance());
sm_.Replay();
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ChromeVoxNextStickyMode) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxStickyMode) {
EnableChromeVox(); EnableChromeVox();
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(
browser(), browser(),
GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
while ("Button" != sm_.GetNextUtterance()) {
}
// Press the sticky-key sequence: Search Search.
SendKeyPress(ui::VKEY_LWIN);
// Sticky key has a minimum 100 ms check to prevent key repeat from toggling sm_.ExpectSpeech("Click me");
// it.
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LoggedInSpokenFeedbackTest::SendKeyPress,
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));
EXPECT_EQ("Sticky mode enabled", sm_.GetNextUtterance()); // Press the sticky-key sequence: Search Search.
sm_.Call([this]() {
SendKeyPress(ui::VKEY_LWIN);
// Sticky key has a minimum 100 ms check to prevent key repeat from toggling
// it.
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LoggedInSpokenFeedbackTest::SendKeyPress,
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));
});
SendKeyPress(ui::VKEY_H); sm_.ExpectSpeech("Sticky mode enabled");
while ("No next heading" != sm_.GetNextUtterance()) {
}
SendKeyPress(ui::VKEY_LWIN); sm_.Call([this]() { SendKeyPress(ui::VKEY_H); });
sm_.ExpectSpeech("No next heading");
// Sticky key has a minimum 100 ms check to prevent key repeat from toggling sm_.Call([this]() {
// it. SendKeyPress(ui::VKEY_LWIN);
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI}, // Sticky key has a minimum 100 ms check to prevent key repeat from toggling
base::BindOnce(&LoggedInSpokenFeedbackTest::SendKeyPress, // it.
base::Unretained(this), ui::VKEY_LWIN), base::PostDelayedTask(
base::TimeDelta::FromMilliseconds(200)); FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LoggedInSpokenFeedbackTest::SendKeyPress,
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));
});
sm_.ExpectSpeech("Sticky mode disabled");
while ("Sticky mode disabled" != sm_.GetNextUtterance()) { sm_.Replay();
}
} }
// Flaky on Linux ChromiumOS MSan Tests. https://crbug.com/752427 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TouchExploreStatusTray) {
EnableChromeVox(); EnableChromeVox();
SimulateTouchScreenInChromeVox(); SimulateTouchScreenInChromeVox();
// Send an accessibility hover event on the system tray, which is // Send an accessibility hover event on the system tray, which is
// what we get when you tap it on a touch screen when ChromeVox is on. // what we get when you tap it on a touch screen when ChromeVox is on.
ash::TrayBackgroundView* tray = ash::Shell::Get() sm_.Call([]() {
->GetPrimaryRootWindowController() ash::TrayBackgroundView* tray = ash::Shell::Get()
->GetStatusAreaWidget() ->GetPrimaryRootWindowController()
->unified_system_tray(); ->GetStatusAreaWidget()
tray->NotifyAccessibilityEvent(ax::mojom::Event::kHover, true); ->unified_system_tray();
tray->NotifyAccessibilityEvent(ax::mojom::Event::kHover, true);
EXPECT_EQ("Status tray,", sm_.GetNextUtterance()); });
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "time*,")); sm_.ExpectSpeechPattern("Status tray, time* Battery at* percent*");
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Battery*")); sm_.ExpectSpeech("Button");
EXPECT_EQ("Button", sm_.GetNextUtterance());
sm_.Replay();
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextTabRecovery) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextTabRecovery) {
...@@ -792,66 +714,22 @@ class OobeSpokenFeedbackTest : public LoginManagerTest { ...@@ -792,66 +714,22 @@ class OobeSpokenFeedbackTest : public LoginManagerTest {
DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
}; };
// Test is flaky: http://crbug.com/346797 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, SpokenFeedbackInOobe) {
IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
ui_controls::EnableUIControls(); ui_controls::EnableUIControls();
ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
AccessibilityManager::Get()->EnableSpokenFeedback(true);
LoginDisplayHost* login_display_host = LoginDisplayHost::default_host(); // The Let's go button gets initial focus.
WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); sm_.ExpectSpeech("Let's go");
views::Widget* widget = web_ui_login_view->GetWidget();
gfx::NativeWindow window = widget->GetNativeWindow();
// We expect to be in the language select dropdown for this test to work, sm_.Call([]() {
// so make sure that's the case. ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
test::OobeJS().ExecuteAsync("$('language-select').focus()"); nullptr, ui::VKEY_TAB, false, false, false, false));
AccessibilityManager::Get()->EnableSpokenFeedback(true); });
ASSERT_TRUE(sm_.SkipChromeVoxEnabledMessage()); sm_.ExpectSpeech("Shut down");
// There's no guarantee that ChromeVox speaks anything when injected after sm_.ExpectSpeech("Button");
// the page loads, which is by design. Tab forward and then backward
// to make sure we get the right feedback from the language and keyboard
// selection fields.
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
window, ui::VKEY_TAB, false, false, false, false));
while (sm_.GetNextUtterance() != "Select your keyboard:") {
}
EXPECT_EQ("U S", sm_.GetNextUtterance());
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Combo box * of *"));
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
window, ui::VKEY_TAB, false, true /*shift*/, false, false));
while (sm_.GetNextUtterance() != "Select your language:") {
}
EXPECT_EQ("English ( United States)", sm_.GetNextUtterance());
EXPECT_TRUE(base::MatchPattern(sm_.GetNextUtterance(), "Combo box * of *"));
}
// This test is flaky (https://crbug.com/1013551). sm_.Replay();
IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest,
DISABLED_ChromeVoxPanelTabsMenuEmpty) {
// The ChromeVox panel should not populate the tabs menu if we are in the
// OOBE.
ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
AccessibilityManager::Get()->EnableSpokenFeedback(true);
// Included to reduce flakiness.
while (sm_.GetNextUtterance() != "Press Search plus Space to activate") {
}
// Press [search + .] to open ChromeVox Panel
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
nullptr, ui::VKEY_OEM_PERIOD, false, false, false, true));
while (sm_.GetNextUtterance() != "ChromeVox Panel") {
}
// Go to tabs menu and verify that it has no items.
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
nullptr, ui::VKEY_RIGHT, false, false, false, false));
while (sm_.GetNextUtterance() != "Speech") {
}
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
nullptr, ui::VKEY_RIGHT, false, false, false, false));
while (sm_.GetNextUtterance() != "Tabs") {
}
EXPECT_EQ("Menu", sm_.GetNextUtterance());
EXPECT_EQ("No items", sm_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest,
......
...@@ -29,6 +29,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { ...@@ -29,6 +29,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
// Simulate key press event. // Simulate key press event.
void SendKeyPress(ui::KeyboardCode key); void SendKeyPress(ui::KeyboardCode key);
void SendKeyPressWithControl(ui::KeyboardCode key); void SendKeyPressWithControl(ui::KeyboardCode key);
void SendKeyPressWithShift(ui::KeyboardCode key);
void SendKeyPressWithSearchAndShift(ui::KeyboardCode key); void SendKeyPressWithSearchAndShift(ui::KeyboardCode key);
void SendKeyPressWithSearch(ui::KeyboardCode key); void SendKeyPressWithSearch(ui::KeyboardCode key);
void SendKeyPressWithSearchAndControl(ui::KeyboardCode key); void SendKeyPressWithSearchAndControl(ui::KeyboardCode key);
......
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