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

Side by Side Diff: chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc

Issue 866713002: Reland: Reenable oobe spoken feedback test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually focus the language select element. Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/accessibility/speech_monitor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 550
555 EXPECT_TRUE( 551 EXPECT_TRUE(
556 MatchPattern(speech_monitor_.GetNextUtterance(), 552 MatchPattern(speech_monitor_.GetNextUtterance(),
557 "about:blank*toolbar Reload Button")); 553 "about:blank*toolbar Reload Button"));
558 } 554 }
559 555
560 // 556 //
561 // Spoken feedback tests of the out-of-box experience. 557 // Spoken feedback tests of the out-of-box experience.
562 // 558 //
563 559
564 class OobeSpokenFeedbackTest : public InProcessBrowserTest { 560 class OobeSpokenFeedbackTest : public LoginManagerTest {
565 protected: 561 protected:
566 OobeSpokenFeedbackTest() {} 562 OobeSpokenFeedbackTest() : LoginManagerTest(false) {}
567 ~OobeSpokenFeedbackTest() override {} 563 ~OobeSpokenFeedbackTest() override {}
568 564
569 void SetUpCommandLine(base::CommandLine* command_line) override { 565 void SetUpCommandLine(base::CommandLine* command_line) override {
570 command_line->AppendSwitch(chromeos::switches::kLoginManager); 566 LoginManagerTest::SetUpCommandLine(command_line);
571 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); 567 // Many bots don't have keyboard/mice which triggers the HID detection
572 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 568 // dialog in the OOBE. Avoid confusing the tests with that.
573 } 569 command_line->AppendSwitch(chromeos::switches::kDisableHIDDetectionOnOOBE);
574
575 void SetUpOnMainThread() override {
576 AccessibilityManager::Get()->
577 SetProfileForTest(ProfileHelper::GetSigninProfile());
578 } 570 }
579 571
580 SpeechMonitor speech_monitor_; 572 SpeechMonitor speech_monitor_;
581 573
582 private: 574 private:
583 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); 575 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
584 }; 576 };
585 577
586 // Test is flaky: http://crbug.com/346797 578 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, SpokenFeedbackInOobe) {
587 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
588 ui_controls::EnableUIControls(); 579 ui_controls::EnableUIControls();
589 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 580 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
590 581
591 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); 582 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host();
592 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); 583 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView();
593 views::Widget* widget = web_ui_login_view->GetWidget(); 584 views::Widget* widget = web_ui_login_view->GetWidget();
594 gfx::NativeWindow window = widget->GetNativeWindow(); 585 gfx::NativeWindow window = widget->GetNativeWindow();
595 586
587 // We expect to be in the language select dropdown for this test to work,
588 // so make sure that's the case.
589 js_checker().Execute("$('language-select').focus()");
596 AccessibilityManager::Get()->EnableSpokenFeedback( 590 AccessibilityManager::Get()->EnableSpokenFeedback(
597 true, ui::A11Y_NOTIFICATION_NONE); 591 true, ui::A11Y_NOTIFICATION_NONE);
598 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 592 ASSERT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
593 // There's no guarantee that ChromeVox speaks anything when injected after
594 // the page loads, which is by design. Tab forward and then backward
595 // to make sure we get the right feedback from the language and keyboard
596 // selection fields.
597 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
598 window, ui::VKEY_TAB, false, false, false, false));
599 599
600 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance()); 600 while (speech_monitor_.GetNextUtterance() != "Select your keyboard:") {
601 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); 601 }
602 EXPECT_EQ("U S", speech_monitor_.GetNextUtterance());
602 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), 603 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
603 "Combo box * of *")); 604 "Combo box * of *"));
604 ASSERT_TRUE( 605 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
605 ui_test_utils::SendKeyPressToWindowSync( 606 window, ui::VKEY_TAB, false, true /*shift*/, false, false));
606 window, ui::VKEY_TAB, false, false, false, false)); 607 while (speech_monitor_.GetNextUtterance() != "Select your language:") {
607 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance()); 608 }
609 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance());
610 EXPECT_TRUE(
611 MatchPattern(speech_monitor_.GetNextUtterance(), "Combo box * of *"));
608 } 612 }
609 613
610 } // namespace chromeos 614 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility/speech_monitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698