Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <queue> | 5 #include <queue> |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | |
| 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 15 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 15 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 16 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
| 17 #include "chrome/browser/chromeos/login/login_manager_test.h" | |
| 16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 18 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 20 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con troller.h" | 22 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con troller.h" |
| 21 #include "chrome/browser/speech/tts_controller.h" | 23 #include "chrome/browser/speech/tts_controller.h" |
| 22 #include "chrome/browser/speech/tts_platform.h" | 24 #include "chrome/browser/speech/tts_platform.h" |
| 23 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_commands.h" | 26 #include "chrome/browser/ui/browser_commands.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 55 protected: | 57 protected: |
| 56 LoggedInSpokenFeedbackTest() | 58 LoggedInSpokenFeedbackTest() |
| 57 : animation_mode_(ui::ScopedAnimationDurationScaleMode::ZERO_DURATION) {} | 59 : animation_mode_(ui::ScopedAnimationDurationScaleMode::ZERO_DURATION) {} |
| 58 ~LoggedInSpokenFeedbackTest() override {} | 60 ~LoggedInSpokenFeedbackTest() override {} |
| 59 | 61 |
| 60 void SetUpInProcessBrowserTestFixture() override { | 62 void SetUpInProcessBrowserTestFixture() override { |
| 61 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); | 63 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void TearDownOnMainThread() override { | 66 void TearDownOnMainThread() override { |
| 65 AccessibilityManager::SetBrailleControllerForTest(NULL); | 67 AccessibilityManager::SetBrailleControllerForTest(nullptr); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void SendKeyPress(ui::KeyboardCode key) { | 70 void SendKeyPress(ui::KeyboardCode key) { |
| 69 ASSERT_NO_FATAL_FAILURE( | 71 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 70 ASSERT_TRUE( | 72 nullptr, key, false, false, false, false))); |
| 71 ui_test_utils::SendKeyPressToWindowSync( | |
| 72 NULL, key, false, false, false, false))); | |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SendKeyPressWithControl(ui::KeyboardCode key) { | 75 void SendKeyPressWithControl(ui::KeyboardCode key) { |
| 76 ASSERT_NO_FATAL_FAILURE( | 76 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 77 ASSERT_TRUE( | 77 nullptr, key, true, false, false, false))); |
| 78 ui_test_utils::SendKeyPressToWindowSync( | |
| 79 NULL, key, true, false, false, false))); | |
| 80 } | 78 } |
| 81 | 79 |
| 82 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) { | 80 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) { |
| 83 ASSERT_NO_FATAL_FAILURE( | 81 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 84 ASSERT_TRUE( | 82 nullptr, key, false, true, false, true))); |
| 85 ui_test_utils::SendKeyPressToWindowSync( | |
| 86 NULL, key, false, true, false, true))); | |
| 87 } | 83 } |
| 88 | 84 |
| 89 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { | 85 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { |
| 90 extensions::ExtensionHost* host = | 86 extensions::ExtensionHost* host = |
| 91 extensions::ProcessManager::Get(browser()->profile()) | 87 extensions::ProcessManager::Get(browser()->profile()) |
| 92 ->GetBackgroundHostForExtension( | 88 ->GetBackgroundHostForExtension( |
| 93 extension_misc::kChromeVoxExtensionId); | 89 extension_misc::kChromeVoxExtensionId); |
| 94 CHECK(content::ExecuteScript(host->host_contents(), script)); | 90 CHECK(content::ExecuteScript(host->host_contents(), script)); |
| 95 } | 91 } |
| 96 | 92 |
| 97 void SimulateTouchScreenInChromeVox() { | 93 void SimulateTouchScreenInChromeVox() { |
| 98 // ChromeVox looks at whether 'ontouchstart' exists to know whether | 94 // ChromeVox looks at whether 'ontouchstart' exists to know whether |
| 99 // or not it should respond to hover events. Fake it so that touch | 95 // or not it should respond to hover events. Fake it so that touch |
| 100 // exploration events get spoken. | 96 // exploration events get spoken. |
| 101 RunJavaScriptInChromeVoxBackgroundPage( | 97 RunJavaScriptInChromeVoxBackgroundPage( |
| 102 "window.ontouchstart = function() {};"); | 98 "window.ontouchstart = function() {};"); |
| 103 } | 99 } |
| 104 | 100 |
| 105 bool PerformAcceleratorAction(ash::AcceleratorAction action) { | 101 bool PerformAcceleratorAction(ash::AcceleratorAction action) { |
| 106 ash::AcceleratorController* controller = | 102 ash::AcceleratorController* controller = |
| 107 ash::Shell::GetInstance()->accelerator_controller(); | 103 ash::Shell::GetInstance()->accelerator_controller(); |
| 108 return controller->PerformActionIfEnabled(action); | 104 return controller->PerformActionIfEnabled(action); |
| 109 } | 105 } |
| 110 | 106 |
| 111 void DisableEarcons() { | 107 void DisableEarcons() { |
| 112 // Playing earcons from within a test is not only annoying if you're | 108 // Playing earcons from within a test is not only annoying if you're |
| 113 // running the test locally, but seems to cause crashes | 109 // running the test locally, but seems to cause crashes |
| 114 // (http://crbug.com/396507). Work around this by just telling | 110 // (http://crbug.com/396507). Work around this by just telling |
| 115 // ChromeVox to not ever play earcons (prerecorded sound effects). | 111 // ChromeVox to not ever play earcons (prerecorded sound effects). |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 | 547 |
| 552 EXPECT_TRUE( | 548 EXPECT_TRUE( |
| 553 MatchPattern(speech_monitor_.GetNextUtterance(), | 549 MatchPattern(speech_monitor_.GetNextUtterance(), |
| 554 "about:blank*toolbar Reload Button")); | 550 "about:blank*toolbar Reload Button")); |
| 555 } | 551 } |
| 556 | 552 |
| 557 // | 553 // |
| 558 // Spoken feedback tests of the out-of-box experience. | 554 // Spoken feedback tests of the out-of-box experience. |
| 559 // | 555 // |
| 560 | 556 |
| 561 class OobeSpokenFeedbackTest : public InProcessBrowserTest { | 557 class OobeSpokenFeedbackTest : public LoginManagerTest { |
| 562 protected: | 558 protected: |
| 563 OobeSpokenFeedbackTest() {} | 559 OobeSpokenFeedbackTest() : LoginManagerTest(false) {} |
| 564 ~OobeSpokenFeedbackTest() override {} | 560 ~OobeSpokenFeedbackTest() override {} |
| 565 | 561 |
| 566 void SetUpCommandLine(base::CommandLine* command_line) override { | 562 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 567 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 563 LoginManagerTest::SetUpCommandLine(command_line); |
| 568 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 564 // Many bots don't have keyboard/mice which triggers the HID detection |
| 569 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 565 // dialog in the OOBE. Avoid confusing the tests with that. |
| 566 command_line->AppendSwitch(chromeos::switches::kDisableHIDDetectionOnOOBE); | |
| 570 } | 567 } |
| 571 | 568 |
| 572 void SetUpOnMainThread() override { | 569 // Waits until the OOBE screen signals it is ready. |
| 573 AccessibilityManager::Get()-> | 570 void WaitUntilJSIsReady() { |
| 574 SetProfileForTest(ProfileHelper::GetSigninProfile()); | 571 LoginDisplayHostImpl* host = static_cast<LoginDisplayHostImpl*>( |
| 572 LoginDisplayHostImpl::default_host()); | |
| 573 ASSERT_NE(nullptr, host); | |
| 574 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | |
| 575 ASSERT_NE(nullptr, oobe_ui); | |
| 576 base::RunLoop run_loop; | |
| 577 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | |
| 578 if (!oobe_ui_ready) | |
| 579 run_loop.Run(); | |
| 575 } | 580 } |
| 576 | 581 |
| 577 SpeechMonitor speech_monitor_; | 582 SpeechMonitor speech_monitor_; |
| 578 | 583 |
| 579 private: | 584 private: |
| 580 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); | 585 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); |
| 581 }; | 586 }; |
| 582 | 587 |
| 583 // Test is flaky: http://crbug.com/346797 | 588 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, SpokenFeedbackInOobe) { |
| 584 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) { | |
| 585 ui_controls::EnableUIControls(); | 589 ui_controls::EnableUIControls(); |
| 586 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 590 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 587 | 591 |
| 588 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); | 592 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); |
| 589 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); | 593 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); |
| 590 views::Widget* widget = web_ui_login_view->GetWidget(); | 594 views::Widget* widget = web_ui_login_view->GetWidget(); |
| 591 gfx::NativeWindow window = widget->GetNativeWindow(); | 595 gfx::NativeWindow window = widget->GetNativeWindow(); |
| 592 | 596 |
| 597 WaitUntilJSIsReady(); | |
| 598 // We expect to be in the language select dropdown for this test to wwork, | |
|
David Tseng
2015/01/27 18:16:45
nit: new line above
dmazzoni
2015/01/27 18:38:44
Also wwork -> work
| |
| 599 // so fail early if that's not the case. | |
| 600 ASSERT_TRUE( | |
| 601 js_checker().GetBool("document.activeElement.id == 'language-select'")); | |
| 593 AccessibilityManager::Get()->EnableSpokenFeedback( | 602 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 594 true, ui::A11Y_NOTIFICATION_NONE); | 603 true, ui::A11Y_NOTIFICATION_NONE); |
| 595 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); | 604 ASSERT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); |
| 605 // There's no guarantee that ChromeVox speaks anything when injected after | |
| 606 // the page loads, which is by design. Tab forward and then backward | |
| 607 // to make sure we get the right feedback from the language and keyboard | |
| 608 // selection fields. | |
| 609 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
| 610 window, ui::VKEY_TAB, false, false, false, false)); | |
| 596 | 611 |
| 597 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance()); | 612 while (speech_monitor_.GetNextUtterance() != "Select your keyboard:") { |
| 598 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); | 613 } |
| 614 LOG(ERROR) << "Got select your keyboard"; | |
|
David Tseng
2015/01/27 18:16:45
nit: remove
| |
| 615 EXPECT_EQ("U S", speech_monitor_.GetNextUtterance()); | |
| 599 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), | 616 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), |
| 600 "Combo box * of *")); | 617 "Combo box * of *")); |
| 601 ASSERT_TRUE( | 618 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 602 ui_test_utils::SendKeyPressToWindowSync( | 619 window, ui::VKEY_TAB, false, true /*shift*/, false, false)); |
| 603 window, ui::VKEY_TAB, false, false, false, false)); | 620 while (speech_monitor_.GetNextUtterance() != "Select your language:") { |
| 604 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance()); | 621 } |
| 622 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); | |
| 623 EXPECT_TRUE( | |
| 624 MatchPattern(speech_monitor_.GetNextUtterance(), "Combo box * of *")); | |
| 605 } | 625 } |
| 606 | 626 |
| 607 } // namespace chromeos | 627 } // namespace chromeos |
| OLD | NEW |