1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h"
10 #include "ash/system/tray/system_tray.h"
11 #include "base/command_line.h"
12 #include "base/strings/string_util.h"
13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
16 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
17 #include "chrome/browser/chromeos/login/login_manager_test.h"
18 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
20 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
22 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h"
23 #include "chrome/browser/speech/tts_controller.h"
24 #include "chrome/browser/speech/tts_platform.h"
25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/extensions/extension_constants.h"
31 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/interactive_test_utils.h"
33 #include "chrome/test/base/testing_profile.h"
34 #include "chrome/test/base/ui_test_utils.h"
35 #include "chromeos/chromeos_switches.h"
36 #include "chromeos/login/user_names.h"
37 #include "content/public/common/url_constants.h"
38 #include "content/public/test/browser_test_utils.h"
39 #include "content/public/test/test_utils.h"
40 #include "extensions/browser/extension_host.h"
41 #include "extensions/browser/process_manager.h"
42 #include "testing/gtest/include/gtest/gtest.h"
43 #include "ui/app_list/app_list_switches.h"
44 #include "ui/base/test/ui_controls.h"
45 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
46 #include "ui/views/widget/widget.h"
48 using extensions::api::braille_display_private::StubBrailleController
;
53 // Spoken feedback tests only in a logged in user's window.
56 class LoggedInSpokenFeedbackTest
: public InProcessBrowserTest
{
58 LoggedInSpokenFeedbackTest()
59 : animation_mode_(ui::ScopedAnimationDurationScaleMode::ZERO_DURATION
) {}
60 ~LoggedInSpokenFeedbackTest() override
{}
62 void SetUpInProcessBrowserTestFixture() override
{
63 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_
);
66 void TearDownOnMainThread() override
{
67 AccessibilityManager::SetBrailleControllerForTest(nullptr);
70 void SendKeyPress(ui::KeyboardCode key
) {
71 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
72 nullptr, key
, false, false, false, false)));
75 void SendKeyPressWithControl(ui::KeyboardCode key
) {
76 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
77 nullptr, key
, true, false, false, false)));
80 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key
) {
81 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
82 nullptr, key
, false, true, false, true)));
85 void RunJavaScriptInChromeVoxBackgroundPage(const std::string
& script
) {
86 extensions::ExtensionHost
* host
=
87 extensions::ProcessManager::Get(browser()->profile())
88 ->GetBackgroundHostForExtension(
89 extension_misc::kChromeVoxExtensionId
);
90 CHECK(content::ExecuteScript(host
->host_contents(), script
));
93 void SimulateTouchScreenInChromeVox() {
94 // ChromeVox looks at whether 'ontouchstart' exists to know whether
95 // or not it should respond to hover events. Fake it so that touch
96 // exploration events get spoken.
97 RunJavaScriptInChromeVoxBackgroundPage(
98 "window.ontouchstart = function() {};");
101 bool PerformAcceleratorAction(ash::AcceleratorAction action
) {
102 ash::AcceleratorController
* controller
=
103 ash::Shell::GetInstance()->accelerator_controller();
104 return controller
->PerformActionIfEnabled(action
);
107 void DisableEarcons() {
108 // Playing earcons from within a test is not only annoying if you're
109 // running the test locally, but seems to cause crashes
110 // (http://crbug.com/396507). Work around this by just telling
111 // ChromeVox to not ever play earcons (prerecorded sound effects).
112 RunJavaScriptInChromeVoxBackgroundPage(
113 "cvox.ChromeVox.earcons.playEarcon = function() {};");
116 void EnableChromeVox() {
118 // Enable ChromeVox, skip welcome message, and disable earcons.
119 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
121 AccessibilityManager::Get()->EnableSpokenFeedback(
122 true, ui::A11Y_NOTIFICATION_NONE
);
123 EXPECT_TRUE(speech_monitor_
.SkipChromeVoxEnabledMessage());
127 void LoadChromeVoxAndThenNavigateToURL(const GURL
& url
) {
128 // The goal of this helper function is to avoid race conditions between
129 // the page loading and the ChromeVox extension loading and fully
130 // initializing. To do this, we first load a test url that repeatedly
131 // asks ChromeVox to speak 'ready', then we load ChromeVox and block
132 // until we get that 'ready' speech.
134 ui_test_utils::NavigateToURL(
136 GURL("data:text/html;charset=utf-8,"
138 "window.setInterval(function() {"
140 " cvox.Api.speak('ready');"
144 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
145 AccessibilityManager::Get()->EnableSpokenFeedback(
146 true, ui::A11Y_NOTIFICATION_NONE
);
148 // Block until we get "ready".
149 while (speech_monitor_
.GetNextUtterance() != "ready") {
152 // Now load the requested url.
153 ui_test_utils::NavigateToURL(browser(), url
);
156 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key
,
157 const std::string
& expected_utterance
) {
158 // This helper function is needed when you want to poll for something
159 // that happens asynchronously. Keep pressing |key|, until
160 // the speech feedback that follows is |expected_utterance|.
161 // Note that this doesn't work if pressing that key doesn't speak anything
162 // at all before the asynchronous event occurred.
165 const std::string
& utterance
= speech_monitor_
.GetNextUtterance();
166 if (utterance
== expected_utterance
)
171 SpeechMonitor speech_monitor_
;
174 StubBrailleController braille_controller_
;
175 ui::ScopedAnimationDurationScaleMode animation_mode_
;
177 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest
);
180 // This test is very flakey with ChromeVox Next since we generate a lot more
181 // utterances for text fields.
182 // TODO(dtseng): Fix properly.
183 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest
, DISABLED_AddBookmark
) {
185 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR
);
187 // Create a bookmark with title "foo".
188 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE
);
189 EXPECT_EQ("Bookmark added! dialog Bookmark name about:blank Edit text",
190 speech_monitor_
.GetNextUtterance());
191 EXPECT_EQ("about:blank", speech_monitor_
.GetNextUtterance());
193 SendKeyPress(ui::VKEY_F
);
194 EXPECT_EQ("f", speech_monitor_
.GetNextUtterance());
195 SendKeyPress(ui::VKEY_O
);
196 EXPECT_EQ("o", speech_monitor_
.GetNextUtterance());
197 SendKeyPress(ui::VKEY_O
);
198 EXPECT_EQ("o", speech_monitor_
.GetNextUtterance());
200 SendKeyPress(ui::VKEY_TAB
);
201 EXPECT_EQ("Bookmark folder combo Box Bookmarks bar",
202 speech_monitor_
.GetNextUtterance());
204 SendKeyPress(ui::VKEY_RETURN
);
206 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "*oolbar*"));
207 // Wait for active window change to be announced to avoid interference from
209 while (speech_monitor_
.GetNextUtterance() != "window about blank tab") {
213 // Focus bookmarks bar and listen for "foo".
214 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS
);
216 std::string utterance
= speech_monitor_
.GetNextUtterance();
217 VLOG(0) << "Got utterance: " << utterance
;
218 if (utterance
== "Bookmarks,")
221 EXPECT_EQ("foo,", speech_monitor_
.GetNextUtterance());
222 EXPECT_EQ("button", speech_monitor_
.GetNextUtterance());
226 // Spoken feedback tests in both a logged in browser window and guest mode.
229 enum SpokenFeedbackTestVariant
{
234 class SpokenFeedbackTest
235 : public LoggedInSpokenFeedbackTest
,
236 public ::testing::WithParamInterface
<SpokenFeedbackTestVariant
> {
238 SpokenFeedbackTest() {}
239 virtual ~SpokenFeedbackTest() {}
241 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
242 if (GetParam() == kTestAsGuestUser
) {
243 command_line
->AppendSwitch(chromeos::switches::kGuestSession
);
244 command_line
->AppendSwitch(::switches::kIncognito
);
245 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
,
247 command_line
->AppendSwitchASCII(chromeos::switches::kLoginUser
,
248 chromeos::login::kGuestUserName
);
253 INSTANTIATE_TEST_CASE_P(
254 TestAsNormalAndGuestUser
,
256 ::testing::Values(kTestAsNormalUser
,
259 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, EnableSpokenFeedback
) {
263 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, FocusToolbar
) {
265 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR
);
266 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
267 "about:blank*Tool bar Reload Button"));
270 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, TypeInOmnibox
) {
273 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION
);
274 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "*Edit text*"));
276 SendKeyPress(ui::VKEY_X
);
277 EXPECT_EQ("x", speech_monitor_
.GetNextUtterance());
279 SendKeyPress(ui::VKEY_Y
);
280 EXPECT_EQ("y", speech_monitor_
.GetNextUtterance());
282 SendKeyPress(ui::VKEY_Z
);
283 EXPECT_EQ("z", speech_monitor_
.GetNextUtterance());
285 SendKeyPress(ui::VKEY_BACK
);
286 EXPECT_EQ("z", speech_monitor_
.GetNextUtterance());
289 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, FocusShelf
) {
292 EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF
));
293 const char* expected
= app_list::switches::IsExperimentalAppListEnabled()
294 ? "Shelf Tool bar Launcher Button"
295 : "Shelf Tool bar Apps Button";
296 EXPECT_EQ(expected
, speech_monitor_
.GetNextUtterance());
298 SendKeyPress(ui::VKEY_TAB
);
299 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "* Button"));
302 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, NavigateAppLauncher
) {
305 EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF
));
307 std::string utterance
= speech_monitor_
.GetNextUtterance();
308 if (MatchPattern(utterance
, "*Button"))
312 SendKeyPress(ui::VKEY_RETURN
);
314 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
315 "Search or type U R L Edit text"));
317 SendKeyPress(ui::VKEY_DOWN
);
318 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "* Button"));
321 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, OpenStatusTray
) {
324 EXPECT_TRUE(PerformAcceleratorAction(ash::SHOW_SYSTEM_TRAY_BUBBLE
));
325 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "Status tray*"));
326 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "time *"));
327 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
328 "Battery is*full."));
329 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "*Button"));
332 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, NavigateSystemTray
) {
335 EXPECT_TRUE(PerformAcceleratorAction(ash::SHOW_SYSTEM_TRAY_BUBBLE
));
337 std::string utterance
= speech_monitor_
.GetNextUtterance();
338 if (MatchPattern(utterance
, "* Button"))
342 // Navigate to Bluetooth sub-menu and open it.
344 SendKeyPress(ui::VKEY_TAB
);
345 std::string utterance
= speech_monitor_
.GetNextUtterance();
346 if (MatchPattern(utterance
, "*Bluetooth* Button"))
349 SendKeyPress(ui::VKEY_RETURN
);
351 // Navigate to return to previous menu button and press it.
353 SendKeyPress(ui::VKEY_TAB
);
354 std::string utterance
= speech_monitor_
.GetNextUtterance();
355 if (MatchPattern(utterance
, "Previous menu Button"))
358 SendKeyPress(ui::VKEY_RETURN
);
360 MatchPattern(speech_monitor_
.GetNextUtterance(), "*Bluetooth* Button"));
363 // See http://crbug.com/443608
364 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, DISABLED_ScreenBrightness
) {
367 EXPECT_TRUE(PerformAcceleratorAction(ash::BRIGHTNESS_UP
));
368 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
369 "Brightness * percent"));
371 EXPECT_TRUE(PerformAcceleratorAction(ash::BRIGHTNESS_DOWN
));
372 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
373 "Brightness * percent"));
376 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, VolumeSlider
) {
379 EXPECT_TRUE(PerformAcceleratorAction(ash::VOLUME_UP
));
380 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "* percent*"));
381 EXPECT_EQ("Volume,", speech_monitor_
.GetNextUtterance());
382 EXPECT_EQ("slider", speech_monitor_
.GetNextUtterance());
385 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, OverviewMode
) {
388 EXPECT_TRUE(PerformAcceleratorAction(ash::TOGGLE_OVERVIEW
));
389 EXPECT_EQ("Edit text", speech_monitor_
.GetNextUtterance());
390 EXPECT_EQ("Alert Entered window overview mode",
391 speech_monitor_
.GetNextUtterance());
393 SendKeyPress(ui::VKEY_TAB
);
394 EXPECT_EQ("about:blank Button", speech_monitor_
.GetNextUtterance());
397 #if defined(MEMORY_SANITIZER)
398 // Fails under MemorySanitizer: http://crbug.com/472125
399 #define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch
401 #define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch
403 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, MAYBE_ChromeVoxShiftSearch
) {
404 LoadChromeVoxAndThenNavigateToURL(
405 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
407 std::string utterance
= speech_monitor_
.GetNextUtterance();
408 if (utterance
== "Click me")
411 EXPECT_EQ("Button", speech_monitor_
.GetNextUtterance());
413 // Press Search+Shift+/ to enter ChromeVox's "find in page".
414 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2
);
415 EXPECT_EQ("Find in page.", speech_monitor_
.GetNextUtterance());
416 EXPECT_EQ("Enter a search query.", speech_monitor_
.GetNextUtterance());
419 #if defined(MEMORY_SANITIZER)
420 // Fails under MemorySanitizer: http://crbug.com/472125
421 #define MAYBE_ChromeVoxPrefixKey DISABLED_ChromeVoxPrefixKey
423 #define MAYBE_ChromeVoxPrefixKey ChromeVoxPrefixKey
425 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, MAYBE_ChromeVoxPrefixKey
) {
426 LoadChromeVoxAndThenNavigateToURL(
427 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
429 std::string utterance
= speech_monitor_
.GetNextUtterance();
430 if (utterance
== "Click me")
433 EXPECT_EQ("Button", speech_monitor_
.GetNextUtterance());
435 // Press the prefix key Ctrl+';' followed by '/'
436 // to enter ChromeVox's "find in page".
437 SendKeyPressWithControl(ui::VKEY_OEM_1
);
438 SendKeyPress(ui::VKEY_OEM_2
);
439 EXPECT_EQ("Find in page.", speech_monitor_
.GetNextUtterance());
440 EXPECT_EQ("Enter a search query.", speech_monitor_
.GetNextUtterance());
443 #if defined(MEMORY_SANITIZER)
444 // Fails under MemorySanitizer: http://crbug.com/472125
445 #define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect
447 #define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect
449 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, MAYBE_ChromeVoxNavigateAndSelect
) {
450 LoadChromeVoxAndThenNavigateToURL(
451 GURL("data:text/html;charset=utf-8,"
453 "<button autofocus>Click me</button>"));
455 std::string utterance
= speech_monitor_
.GetNextUtterance();
456 if (utterance
== "Click me")
459 EXPECT_EQ("Button", speech_monitor_
.GetNextUtterance());
461 // Press Search+Shift+Up to navigate to the previous item.
462 SendKeyPressWithSearchAndShift(ui::VKEY_UP
);
463 EXPECT_EQ("Title", speech_monitor_
.GetNextUtterance());
464 EXPECT_EQ("Heading 1", speech_monitor_
.GetNextUtterance());
466 // Press Search+Shift+S to select the text.
467 SendKeyPressWithSearchAndShift(ui::VKEY_S
);
468 EXPECT_EQ("Start selection", speech_monitor_
.GetNextUtterance());
469 EXPECT_EQ("Title", speech_monitor_
.GetNextUtterance());
470 EXPECT_EQ(", selected", speech_monitor_
.GetNextUtterance());
472 // Press again to end the selection.
473 SendKeyPressWithSearchAndShift(ui::VKEY_S
);
474 EXPECT_EQ("End selection", speech_monitor_
.GetNextUtterance());
475 EXPECT_EQ("Title", speech_monitor_
.GetNextUtterance());
478 // flaky: http://crbug.com/418572
479 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, DISABLED_ChromeVoxStickyMode
) {
480 LoadChromeVoxAndThenNavigateToURL(
481 GURL("data:text/html;charset=utf-8,"
482 "<label>Enter your name <input autofocus></label>"
485 while (speech_monitor_
.GetNextUtterance() != "Enter your name") {
487 EXPECT_EQ("Edit text", speech_monitor_
.GetNextUtterance());
489 // Press the sticky-key sequence: Search Search.
490 SendKeyPress(ui::VKEY_LWIN
);
491 SendKeyPress(ui::VKEY_LWIN
);
492 EXPECT_EQ("Sticky mode enabled", speech_monitor_
.GetNextUtterance());
494 // Even once we hear "sticky mode enabled" from the ChromeVox background
495 // page, there's a short window of time when the content script still
496 // hasn't switched to sticky mode. That's why we're focused on a text box.
497 // Keep pressing the '/' key. If sticky mode is off, it will echo the word
498 // "slash". If sticky mode is on, it will open "Find in page". Keep pressing
499 // '/' until we get "Find in page.".
500 PressRepeatedlyUntilUtterance(ui::VKEY_OEM_2
, "Find in page.");
501 EXPECT_EQ("Enter a search query.", speech_monitor_
.GetNextUtterance());
503 // Press Esc to exit Find in Page mode.
504 SendKeyPress(ui::VKEY_ESCAPE
);
505 EXPECT_EQ("Exited", speech_monitor_
.GetNextUtterance());
506 EXPECT_EQ("Find in page.", speech_monitor_
.GetNextUtterance());
508 // Press N H to jump to the next heading. Skip over speech in-between
509 // but make sure we end up at the heading.
510 SendKeyPress(ui::VKEY_N
);
511 SendKeyPress(ui::VKEY_H
);
512 while (speech_monitor_
.GetNextUtterance() != "Two") {
514 EXPECT_EQ("Heading 2", speech_monitor_
.GetNextUtterance());
516 // Press the up arrow to go to the previous element.
517 SendKeyPress(ui::VKEY_UP
);
518 EXPECT_EQ("One", speech_monitor_
.GetNextUtterance());
521 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest
, TouchExploreStatusTray
) {
523 SimulateTouchScreenInChromeVox();
525 // Send an accessibility hover event on the system tray, which is
526 // what we get when you tap it on a touch screen when ChromeVox is on.
527 ash::SystemTray
* tray
= ash::Shell::GetInstance()->GetPrimarySystemTray();
528 tray
->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER
, true);
530 EXPECT_EQ("Status tray,", speech_monitor_
.GetNextUtterance());
531 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "time*,"));
532 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(), "Battery*"));
533 EXPECT_EQ("Button", speech_monitor_
.GetNextUtterance());
537 // Spoken feedback tests that run only in guest mode.
540 class GuestSpokenFeedbackTest
: public LoggedInSpokenFeedbackTest
{
542 GuestSpokenFeedbackTest() {}
543 ~GuestSpokenFeedbackTest() override
{}
545 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
546 command_line
->AppendSwitch(chromeos::switches::kGuestSession
);
547 command_line
->AppendSwitch(::switches::kIncognito
);
548 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
, "user");
549 command_line
->AppendSwitchASCII(chromeos::switches::kLoginUser
,
550 chromeos::login::kGuestUserName
);
554 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest
);
557 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest
, FocusToolbar
) {
560 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR
);
562 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
563 "about:blank*Tool bar Reload Button"));
567 // Spoken feedback tests of the out-of-box experience.
570 class OobeSpokenFeedbackTest
: public LoginManagerTest
{
572 OobeSpokenFeedbackTest() : LoginManagerTest(false) {}
573 ~OobeSpokenFeedbackTest() override
{}
575 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
576 LoginManagerTest::SetUpCommandLine(command_line
);
577 // Many bots don't have keyboard/mice which triggers the HID detection
578 // dialog in the OOBE. Avoid confusing the tests with that.
579 command_line
->AppendSwitch(chromeos::switches::kDisableHIDDetectionOnOOBE
);
582 SpeechMonitor speech_monitor_
;
585 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest
);
588 // Test is flaky: http://crbug.com/346797
589 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest
, DISABLED_SpokenFeedbackInOobe
) {
590 ui_controls::EnableUIControls();
591 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
593 LoginDisplayHost
* login_display_host
= LoginDisplayHostImpl::default_host();
594 WebUILoginView
* web_ui_login_view
= login_display_host
->GetWebUILoginView();
595 views::Widget
* widget
= web_ui_login_view
->GetWidget();
596 gfx::NativeWindow window
= widget
->GetNativeWindow();
598 // We expect to be in the language select dropdown for this test to work,
599 // so make sure that's the case.
600 js_checker().Execute("$('language-select').focus()");
601 AccessibilityManager::Get()->EnableSpokenFeedback(
602 true, ui::A11Y_NOTIFICATION_NONE
);
603 ASSERT_TRUE(speech_monitor_
.SkipChromeVoxEnabledMessage());
604 // There's no guarantee that ChromeVox speaks anything when injected after
605 // the page loads, which is by design. Tab forward and then backward
606 // to make sure we get the right feedback from the language and keyboard
608 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
609 window
, ui::VKEY_TAB
, false, false, false, false));
611 while (speech_monitor_
.GetNextUtterance() != "Select your keyboard:") {
613 EXPECT_EQ("U S", speech_monitor_
.GetNextUtterance());
614 EXPECT_TRUE(MatchPattern(speech_monitor_
.GetNextUtterance(),
615 "Combo box * of *"));
616 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
617 window
, ui::VKEY_TAB
, false, true /*shift*/, false, false));
618 while (speech_monitor_
.GetNextUtterance() != "Select your language:") {
620 EXPECT_EQ("English ( United States)", speech_monitor_
.GetNextUtterance());
622 MatchPattern(speech_monitor_
.GetNextUtterance(), "Combo box * of *"));
625 } // namespace chromeos