| 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 9ed18565e30864b72dca4e02dffd957641312ac9..a3aaf04e4eb82fd6022c221f0c989e74c698d549 100644
|
| --- a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
|
| +++ b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
|
| @@ -87,6 +87,11 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
|
| 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())
|
| @@ -120,42 +125,19 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
|
|
|
| void EnableChromeVox() {
|
| // Test setup.
|
| - // Enable ChromeVox, skip welcome message, and disable earcons.
|
| + // Enable ChromeVox, skip welcome message/notification, 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);
|
| + // Ensure we skip all other startup messages by sending an additional speak
|
| + // call.
|
| + RunJavaScriptInChromeVoxBackgroundPage(
|
| + "cvox.ChromeVox.tts.speak('ready to test');");
|
| + EXPECT_TRUE(speech_monitor_.SkipChromeVoxMessage("ready to test"));
|
| }
|
|
|
| void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
|
| @@ -309,24 +291,12 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
|
| 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();
|
|
|
| - 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*"));
|
| -
|
| + // Location bar has focus by default so just start typing.
|
| SendKeyPress(ui::VKEY_X);
|
| EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
|
|
|
| @@ -451,22 +421,15 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, NavigateSystemTray) {
|
| break;
|
| }
|
|
|
| - // Compat next element.
|
| - SendKeyPressWithSearchAndShift(ui::VKEY_RIGHT);
|
| - while (true) {
|
| - std::string utterance = speech_monitor_.GetNextUtterance();
|
| - if (base::MatchPattern(utterance, "Button"))
|
| - break;
|
| - }
|
| + // Next element.
|
| + SendKeyPressWithSearch(ui::VKEY_RIGHT);
|
| + EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
|
| + EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
|
|
|
| - // Compat next button.
|
| - SendKeyPressWithSearchAndShift(ui::VKEY_N);
|
| - SendKeyPress(ui::VKEY_B);
|
| - while (true) {
|
| - std::string utterance = speech_monitor_.GetNextUtterance();
|
| - if (base::MatchPattern(utterance, "Button"))
|
| - break;
|
| - }
|
| + // Next button.
|
| + SendKeyPressWithSearch(ui::VKEY_B);
|
| + EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*"));
|
| + EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button"));
|
|
|
| // Navigate to Bluetooth sub-menu and open it.
|
| while (true) {
|
| @@ -553,30 +516,10 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, OverviewMode) {
|
| #define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch
|
| #endif
|
| IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) {
|
| - 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 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());
|
| -}
|
| + EnableChromeVox();
|
|
|
| -#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(
|
| + ui_test_utils::NavigateToURL(
|
| + browser(),
|
| GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
|
| while (true) {
|
| std::string utterance = speech_monitor_.GetNextUtterance();
|
| @@ -585,13 +528,11 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) {
|
| }
|
| 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);
|
| + // Press Search+/ to enter ChromeVox's "find in page".
|
| + SendKeyPressWithSearch(ui::VKEY_OEM_2);
|
| + EXPECT_EQ(", window", speech_monitor_.GetNextUtterance());
|
| + EXPECT_EQ("webView", speech_monitor_.GetNextUtterance());
|
| 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)
|
| @@ -601,10 +542,12 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) {
|
| #define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect
|
| #endif
|
| IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) {
|
| - LoadChromeVoxAndThenNavigateToURL(
|
| - GURL("data:text/html;charset=utf-8,"
|
| - "<h1>Title</h1>"
|
| - "<button autofocus>Click me</button>"));
|
| + EnableChromeVox();
|
| +
|
| + ui_test_utils::NavigateToURL(browser(),
|
| + 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")
|
| @@ -612,68 +555,28 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) {
|
| }
|
| EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
|
|
|
| - // Press Search+Shift+Up to navigate to the previous item.
|
| - SendKeyPressWithSearchAndShift(ui::VKEY_UP);
|
| + // Press Search+Left to navigate to the previous item.
|
| + SendKeyPressWithSearch(ui::VKEY_LEFT);
|
| EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
|
| EXPECT_EQ("Heading 1", speech_monitor_.GetNextUtterance());
|
|
|
| - // Press Search+Shift+S to select the text.
|
| - SendKeyPressWithSearchAndShift(ui::VKEY_S);
|
| - EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance());
|
| + // Press Search+S to select the text.
|
| + SendKeyPressWithSearch(ui::VKEY_S);
|
| EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
|
| - EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance());
|
| + EXPECT_EQ("selected", speech_monitor_.GetNextUtterance());
|
|
|
| // Press again to end the selection.
|
| - SendKeyPressWithSearchAndShift(ui::VKEY_S);
|
| + SendKeyPressWithSearch(ui::VKEY_S);
|
| EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance());
|
| EXPECT_EQ("Title", 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);
|
| -
|
| - // 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));
|
| -
|
| - EXPECT_EQ("Sticky mode enabled", 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 -->"));
|
| + EnableChromeVox();
|
| +
|
| + ui_test_utils::NavigateToURL(
|
| + browser(),
|
| + GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
|
| while ("Button" != speech_monitor_.GetNextUtterance()) {
|
| }
|
|
|
| @@ -752,10 +655,6 @@ IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
|
|
|
| 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*"));
|
| }
|
|
|
| //
|
|
|