Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc

Issue 2438893004: Revert of Make ChromeVox Next the default ChromeVox experience (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
index abd11d05c94971a12d9b93f5e9f9e96ae729fcab..bd2b3a9ef73df9b0705776342697d481c6e83b53 100644
--- a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
+++ b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
@@ -87,11 +87,6 @@
nullptr, key, false, true, false, true)));
}
- void SendKeyPressWithSearch(ui::KeyboardCode key) {
- ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
- nullptr, key, false, false, false, true)));
- }
-
void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
extensions::ExtensionHost* host =
extensions::ProcessManager::Get(browser()->profile())
@@ -125,13 +120,42 @@
void EnableChromeVox() {
// Test setup.
- // Enable ChromeVox, skip welcome message/notification, and disable earcons.
+ // Enable ChromeVox, skip welcome message, and disable earcons.
ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
+ }
+
+ void LoadChromeVoxAndThenNavigateToURL(const GURL& url) {
+ // The goal of this helper function is to avoid race conditions between
+ // the page loading and the ChromeVox extension loading and fully
+ // initializing. To do this, we first load a test url that repeatedly
+ // asks ChromeVox to speak 'ready', then we load ChromeVox and block
+ // until we get that 'ready' speech.
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("data:text/html;charset=utf-8,"
+ "<script>"
+ "window.setInterval(function() {"
+ " try {"
+ " cvox.Api.speak('ready');"
+ " } catch (e) {}"
+ "}, 100);"
+ "</script>"));
+ EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
+ AccessibilityManager::Get()->EnableSpokenFeedback(
+ true, ash::A11Y_NOTIFICATION_NONE);
+
+ // Block until we get "ready".
+ while (speech_monitor_.GetNextUtterance() != "ready") {
+ }
+
+ // Now load the requested url.
+ ui_test_utils::NavigateToURL(browser(), url);
}
void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
@@ -285,12 +309,24 @@
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(
+ base::MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*"));
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EnableChromeVox();
- // Location bar has focus by default so just start typing.
+ chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
+ EXPECT_EQ("Address and search bar", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("about:blank", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(
+ base::MatchPattern(speech_monitor_.GetNextUtterance(), "*about:blank*"));
+
SendKeyPress(ui::VKEY_X);
EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
@@ -402,13 +438,14 @@
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
- // Next element.
- SendKeyPressWithSearch(ui::VKEY_RIGHT);
+ // Compat next element.
+ SendKeyPressWithSearchAndShift(ui::VKEY_RIGHT);
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
- // Next button.
- SendKeyPressWithSearch(ui::VKEY_B);
+ // Compat next button.
+ SendKeyPressWithSearchAndShift(ui::VKEY_N);
+ SendKeyPress(ui::VKEY_B);
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
@@ -490,10 +527,7 @@
#define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) {
- EnableChromeVox();
-
- ui_test_utils::NavigateToURL(
- browser(),
+ LoadChromeVoxAndThenNavigateToURL(
GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
while (true) {
std::string utterance = speech_monitor_.GetNextUtterance();
@@ -502,11 +536,36 @@
}
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
- // Press Search+/ to enter ChromeVox's "find in page".
- SendKeyPressWithSearch(ui::VKEY_OEM_2);
- EXPECT_EQ("webView", speech_monitor_.GetNextUtterance());
- EXPECT_EQ(", window", speech_monitor_.GetNextUtterance());
+ // Press Search+Shift+/ to enter ChromeVox's "find in page".
+ SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ(",", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
+}
+
+#if defined(MEMORY_SANITIZER)
+// Fails under MemorySanitizer: http://crbug.com/472125
+#define MAYBE_ChromeVoxPrefixKey DISABLED_ChromeVoxPrefixKey
+#else
+#define MAYBE_ChromeVoxPrefixKey ChromeVoxPrefixKey
+#endif
+IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) {
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
+ while (true) {
+ std::string utterance = speech_monitor_.GetNextUtterance();
+ if (utterance == "Click me")
+ break;
+ }
+ EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
+
+ // Press the prefix key Ctrl+';' followed by '/'
+ // to enter ChromeVox's "find in page".
+ SendKeyPressWithControl(ui::VKEY_OEM_1);
+ SendKeyPress(ui::VKEY_OEM_2);
+ EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ(",", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
}
#if defined(MEMORY_SANITIZER)
@@ -516,12 +575,10 @@
#define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) {
- EnableChromeVox();
-
- ui_test_utils::NavigateToURL(browser(),
- GURL("data:text/html;charset=utf-8,"
- "<h1>Title</h1>"
- "<button autofocus>Click me</button>"));
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,"
+ "<h1>Title</h1>"
+ "<button autofocus>Click me</button>"));
while (true) {
std::string utterance = speech_monitor_.GetNextUtterance();
if (utterance == "Click me")
@@ -529,30 +586,33 @@
}
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
- // Press Search+Left to navigate to the previous item.
- SendKeyPressWithSearch(ui::VKEY_LEFT);
+ // Press Search+Shift+Up to navigate to the previous item.
+ SendKeyPressWithSearchAndShift(ui::VKEY_UP);
EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Heading 1", speech_monitor_.GetNextUtterance());
- // Press Search+S to select the text.
- SendKeyPressWithSearch(ui::VKEY_S);
+ // Press Search+Shift+S to select the text.
+ SendKeyPressWithSearchAndShift(ui::VKEY_S);
+ EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
- EXPECT_EQ("selected", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance());
// Press again to end the selection.
- SendKeyPressWithSearch(ui::VKEY_S);
+ SendKeyPressWithSearchAndShift(ui::VKEY_S);
EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
}
-IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextStickyMode) {
- EnableChromeVox();
-
- ui_test_utils::NavigateToURL(
- browser(),
- GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
- while ("Button" != speech_monitor_.GetNextUtterance()) {
- }
+// http://crbug.com/628060
+IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ChromeVoxStickyMode) {
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,"
+ "<label>Enter your name <input autofocus></label>"
+ "<p>One</p>"
+ "<h2>Two</h2>"));
+ while (speech_monitor_.GetNextUtterance() != "Enter your name") {
+ }
+ EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
// Press the sticky-key sequence: Search Search.
SendKeyPress(ui::VKEY_LWIN);
@@ -567,10 +627,31 @@
EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance());
- SendKeyPress(ui::VKEY_H);
- while ("No next heading." != speech_monitor_.GetNextUtterance()) {
- }
-
+ // Even once we hear "sticky mode enabled" from the ChromeVox background
+ // page, there's a short window of time when the content script still
+ // hasn't switched to sticky mode. That's why we're focused on a text box.
+ // Keep pressing the '/' key. If sticky mode is off, it will echo the word
+ // "slash". If sticky mode is on, it will open "Find in page". Keep pressing
+ // '/' until we get "Find in page.".
+ PressRepeatedlyUntilUtterance(ui::VKEY_OEM_2, "Find in page.");
+ while (speech_monitor_.GetNextUtterance() != "Enter a search query.") {
+ }
+
+ // Press Esc to exit Find in Page mode.
+ SendKeyPress(ui::VKEY_ESCAPE);
+ EXPECT_EQ("Exited", speech_monitor_.GetNextUtterance());
+ while (speech_monitor_.GetNextUtterance() != "Find in page.") {
+ }
+}
+
+IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextStickyMode) {
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"
+ "<!-- chromevox_next_test -->"));
+ while ("Button" != speech_monitor_.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
@@ -581,6 +662,22 @@
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));
+ EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance());
+
+ SendKeyPress(ui::VKEY_H);
+ while ("No next heading." != speech_monitor_.GetNextUtterance()) {
+ }
+
+ SendKeyPress(ui::VKEY_LWIN);
+
+ // Sticky key has a minimum 100 ms check to prevent key repeat from toggling
+ // it.
+ content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress,
+ base::Unretained(this), ui::VKEY_LWIN),
+ base::TimeDelta::FromMilliseconds(200));
+
while ("Sticky mode disabled" != speech_monitor_.GetNextUtterance()) {
}
}
@@ -629,6 +726,10 @@
EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("main", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(
+ base::MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*"));
}
//
« no previous file with comments | « chrome/browser/chromeos/accessibility/speech_monitor.cc ('k') | chrome/browser/chromeos/login/session/user_session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698