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
...@@ -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