| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 12 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 12 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
| 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 16 #include "chrome/browser/chromeos/login/users/user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" | 18 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" |
| 19 #include "chrome/browser/speech/tts_controller.h" | 19 #include "chrome/browser/speech/tts_controller.h" |
| 20 #include "chrome/browser/speech/tts_platform.h" | 20 #include "chrome/browser/speech/tts_platform.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "chrome/test/base/interactive_test_utils.h" |
| 26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
| 29 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
| 30 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/base/test/ui_controls.h" | 33 #include "ui/base/test/ui_controls.h" |
| 33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 34 | 35 |
| 35 using extensions::api::braille_display_private::StubBrailleController; | 36 using extensions::api::braille_display_private::StubBrailleController; |
| 36 | 37 |
| 37 namespace chromeos { | 38 namespace chromeos { |
| 38 | 39 |
| 39 // | 40 // |
| 40 // Spoken feedback tests in a normal browser window. | 41 // Spoken feedback tests only in a logged in user's window. |
| 42 // |
| 43 |
| 44 class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { |
| 45 protected: |
| 46 LoggedInSpokenFeedbackTest() {} |
| 47 virtual ~LoggedInSpokenFeedbackTest() {} |
| 48 |
| 49 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 50 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); |
| 51 } |
| 52 |
| 53 virtual void CleanUpOnMainThread() OVERRIDE { |
| 54 AccessibilityManager::SetBrailleControllerForTest(NULL); |
| 55 } |
| 56 |
| 57 void SendKeyPress(ui::KeyboardCode key) { |
| 58 gfx::NativeWindow root_window = |
| 59 ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
| 60 ASSERT_TRUE( |
| 61 ui_test_utils::SendKeyPressToWindowSync( |
| 62 root_window, key, false, false, false, false)); |
| 63 } |
| 64 |
| 65 private: |
| 66 StubBrailleController braille_controller_; |
| 67 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); |
| 68 }; |
| 69 |
| 70 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) { |
| 71 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 72 |
| 73 SpeechMonitor monitor; |
| 74 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 75 true, ash::A11Y_NOTIFICATION_NONE); |
| 76 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
| 77 |
| 78 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); |
| 79 |
| 80 // Create a bookmark with title "foo". |
| 81 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE); |
| 82 EXPECT_EQ("Bookmark added!,", monitor.GetNextUtterance()); |
| 83 EXPECT_EQ("about blank,", monitor.GetNextUtterance()); |
| 84 EXPECT_EQ("Bookmark name,", monitor.GetNextUtterance()); |
| 85 EXPECT_EQ("text box", monitor.GetNextUtterance()); |
| 86 |
| 87 SendKeyPress(ui::VKEY_F); |
| 88 EXPECT_EQ("f", monitor.GetNextUtterance()); |
| 89 SendKeyPress(ui::VKEY_O); |
| 90 EXPECT_EQ("o", monitor.GetNextUtterance()); |
| 91 SendKeyPress(ui::VKEY_O); |
| 92 EXPECT_EQ("o", monitor.GetNextUtterance()); |
| 93 |
| 94 SendKeyPress(ui::VKEY_TAB); |
| 95 EXPECT_EQ("Bookmarks bar,", monitor.GetNextUtterance()); |
| 96 EXPECT_EQ("Bookmark folder,", monitor.GetNextUtterance()); |
| 97 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "combo box*")); |
| 98 |
| 99 SendKeyPress(ui::VKEY_RETURN); |
| 100 |
| 101 // Focus bookmarks bar and listen for "foo". |
| 102 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS); |
| 103 while (true) { |
| 104 std::string utterance = monitor.GetNextUtterance(); |
| 105 VLOG(0) << "Got utterance: " << utterance; |
| 106 if (utterance == "Bookmarks,") |
| 107 break; |
| 108 } |
| 109 EXPECT_EQ("foo,", monitor.GetNextUtterance()); |
| 110 EXPECT_EQ("button", monitor.GetNextUtterance()); |
| 111 } |
| 112 |
| 113 // |
| 114 // Spoken feedback tests in both a logged in browser window and guest mode. |
| 41 // | 115 // |
| 42 | 116 |
| 43 enum SpokenFeedbackTestVariant { | 117 enum SpokenFeedbackTestVariant { |
| 44 kTestAsNormalUser, | 118 kTestAsNormalUser, |
| 45 kTestAsGuestUser | 119 kTestAsGuestUser |
| 46 }; | 120 }; |
| 47 | 121 |
| 48 class SpokenFeedbackTest | 122 class SpokenFeedbackTest |
| 49 : public InProcessBrowserTest, | 123 : public LoggedInSpokenFeedbackTest, |
| 50 public ::testing::WithParamInterface<SpokenFeedbackTestVariant> { | 124 public ::testing::WithParamInterface<SpokenFeedbackTestVariant> { |
| 51 protected: | 125 protected: |
| 52 SpokenFeedbackTest() {} | 126 SpokenFeedbackTest() {} |
| 53 virtual ~SpokenFeedbackTest() {} | 127 virtual ~SpokenFeedbackTest() {} |
| 54 | 128 |
| 55 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
| 56 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); | |
| 57 } | |
| 58 | |
| 59 virtual void CleanUpOnMainThread() OVERRIDE { | |
| 60 AccessibilityManager::SetBrailleControllerForTest(NULL); | |
| 61 } | |
| 62 | |
| 63 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 129 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 64 if (GetParam() == kTestAsGuestUser) { | 130 if (GetParam() == kTestAsGuestUser) { |
| 65 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 131 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 66 command_line->AppendSwitch(::switches::kIncognito); | 132 command_line->AppendSwitch(::switches::kIncognito); |
| 67 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, | 133 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, |
| 68 "user"); | 134 "user"); |
| 69 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | 135 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
| 70 chromeos::UserManager::kGuestUserName); | 136 chromeos::UserManager::kGuestUserName); |
| 71 } | 137 } |
| 72 } | 138 } |
| 73 | |
| 74 private: | |
| 75 StubBrailleController braille_controller_; | |
| 76 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackTest); | |
| 77 }; | 139 }; |
| 78 | 140 |
| 79 INSTANTIATE_TEST_CASE_P( | 141 INSTANTIATE_TEST_CASE_P( |
| 80 TestAsNormalAndGuestUser, | 142 TestAsNormalAndGuestUser, |
| 81 SpokenFeedbackTest, | 143 SpokenFeedbackTest, |
| 82 ::testing::Values(kTestAsNormalUser, | 144 ::testing::Values(kTestAsNormalUser, |
| 83 kTestAsGuestUser)); | 145 kTestAsGuestUser)); |
| 84 | 146 |
| 85 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { | 147 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { |
| 86 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 148 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 true, ash::A11Y_NOTIFICATION_NONE); | 161 true, ash::A11Y_NOTIFICATION_NONE); |
| 100 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 162 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
| 101 | 163 |
| 102 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); | 164 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); |
| 103 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". | 165 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". |
| 104 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); | 166 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); |
| 105 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); | 167 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); |
| 106 EXPECT_EQ("button", monitor.GetNextUtterance()); | 168 EXPECT_EQ("button", monitor.GetNextUtterance()); |
| 107 } | 169 } |
| 108 | 170 |
| 109 // Disabled for flakiness: http://crbug.com/359204 | 171 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { |
| 110 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) { | |
| 111 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 172 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 112 | 173 |
| 113 SpeechMonitor monitor; | 174 SpeechMonitor monitor; |
| 114 AccessibilityManager::Get()->EnableSpokenFeedback( | 175 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 115 true, ash::A11Y_NOTIFICATION_NONE); | 176 true, ash::A11Y_NOTIFICATION_NONE); |
| 116 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 177 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
| 117 | 178 |
| 179 // Wait for ChromeVox to finish speaking. |
| 118 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); | 180 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); |
| 119 | |
| 120 gfx::NativeWindow window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | |
| 121 ui_controls::SendKeyPress(window, ui::VKEY_X, false, false, false, false); | |
| 122 while (true) { | 181 while (true) { |
| 123 std::string utterance = monitor.GetNextUtterance(); | 182 std::string utterance = monitor.GetNextUtterance(); |
| 124 VLOG(0) << "Got utterance: " << utterance; | 183 VLOG(0) << "Got utterance: " << utterance; |
| 125 if (utterance == "x") | 184 if (utterance == "text box") |
| 126 break; | 185 break; |
| 127 } | 186 } |
| 128 | 187 |
| 129 ui_controls::SendKeyPress(window, ui::VKEY_Y, false, false, false, false); | 188 SendKeyPress(ui::VKEY_X); |
| 189 EXPECT_EQ("x", monitor.GetNextUtterance()); |
| 190 |
| 191 SendKeyPress(ui::VKEY_Y); |
| 130 EXPECT_EQ("y", monitor.GetNextUtterance()); | 192 EXPECT_EQ("y", monitor.GetNextUtterance()); |
| 131 | 193 |
| 132 ui_controls::SendKeyPress(window, ui::VKEY_Z, false, false, false, false); | 194 SendKeyPress(ui::VKEY_Z); |
| 133 EXPECT_EQ("z", monitor.GetNextUtterance()); | 195 EXPECT_EQ("z", monitor.GetNextUtterance()); |
| 134 | 196 |
| 135 ui_controls::SendKeyPress(window, ui::VKEY_BACK, false, false, false, false); | 197 SendKeyPress(ui::VKEY_BACK); |
| 136 EXPECT_EQ("z", monitor.GetNextUtterance()); | 198 EXPECT_EQ("z", monitor.GetNextUtterance()); |
| 137 } | 199 } |
| 138 | 200 |
| 139 // | 201 // |
| 140 // Spoken feedback tests that run in guest mode. | 202 // Spoken feedback tests that run only in guest mode. |
| 141 // | 203 // |
| 142 | 204 |
| 143 class GuestSpokenFeedbackTest : public SpokenFeedbackTest { | 205 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest { |
| 144 protected: | 206 protected: |
| 145 GuestSpokenFeedbackTest() {} | 207 GuestSpokenFeedbackTest() {} |
| 146 virtual ~GuestSpokenFeedbackTest() {} | 208 virtual ~GuestSpokenFeedbackTest() {} |
| 147 | 209 |
| 148 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 210 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 149 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 211 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 150 command_line->AppendSwitch(::switches::kIncognito); | 212 command_line->AppendSwitch(::switches::kIncognito); |
| 151 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 213 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 152 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | 214 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
| 153 chromeos::UserManager::kGuestUserName); | 215 chromeos::UserManager::kGuestUserName); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 gfx::NativeWindow window = widget->GetNativeWindow(); | 269 gfx::NativeWindow window = widget->GetNativeWindow(); |
| 208 | 270 |
| 209 SpeechMonitor monitor; | 271 SpeechMonitor monitor; |
| 210 AccessibilityManager::Get()->EnableSpokenFeedback( | 272 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 211 true, ash::A11Y_NOTIFICATION_NONE); | 273 true, ash::A11Y_NOTIFICATION_NONE); |
| 212 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 274 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
| 213 | 275 |
| 214 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); | 276 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); |
| 215 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); | 277 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); |
| 216 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); | 278 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); |
| 217 ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); | 279 ASSERT_TRUE( |
| 280 ui_test_utils::SendKeyPressToWindowSync( |
| 281 window, ui::VKEY_TAB, false, false, false, false)); |
| 218 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); | 282 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); |
| 219 } | 283 } |
| 220 | 284 |
| 221 } // namespace chromeos | 285 } // namespace chromeos |
| OLD | NEW |