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

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

Issue 490443002: Add test for ChromeVox keyboard commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No changes to ui_controls_factory_aurax11 needed. Created 6 years, 3 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 | Annotate | Revision Log
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
13 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" 13 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 14 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 16 #include "chrome/browser/chromeos/login/ui/webui_login_view.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/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
26 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/interactive_test_utils.h" 28 #include "chrome/test/base/interactive_test_utils.h"
28 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
29 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
30 #include "chromeos/chromeos_switches.h" 31 #include "chromeos/chromeos_switches.h"
31 #include "chromeos/login/user_names.h" 32 #include "chromeos/login/user_names.h"
32 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
33 #include "content/public/test/browser_test_utils.h" 34 #include "content/public/test/browser_test_utils.h"
(...skipping 19 matching lines...) Expand all
53 54
54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 55 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
55 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); 56 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
56 } 57 }
57 58
58 virtual void TearDownOnMainThread() OVERRIDE { 59 virtual void TearDownOnMainThread() OVERRIDE {
59 AccessibilityManager::SetBrailleControllerForTest(NULL); 60 AccessibilityManager::SetBrailleControllerForTest(NULL);
60 } 61 }
61 62
62 void SendKeyPress(ui::KeyboardCode key) { 63 void SendKeyPress(ui::KeyboardCode key) {
63 gfx::NativeWindow root_window = 64 ASSERT_NO_FATAL_FAILURE(
64 ash::Shell::GetInstance()->GetPrimaryRootWindow(); 65 ASSERT_TRUE(
65 ASSERT_TRUE( 66 ui_test_utils::SendKeyPressToWindowSync(
66 ui_test_utils::SendKeyPressToWindowSync( 67 NULL, key, false, false, false, false)));
67 root_window, key, false, false, false, false)); 68 }
69
70 void SendKeyPressWithControl(ui::KeyboardCode key) {
71 ASSERT_NO_FATAL_FAILURE(
72 ASSERT_TRUE(
73 ui_test_utils::SendKeyPressToWindowSync(
74 NULL, key, true, false, false, false)));
75 }
76
77 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) {
78 ASSERT_NO_FATAL_FAILURE(
79 ASSERT_TRUE(
80 ui_test_utils::SendKeyPressToWindowSync(
81 NULL, key, false, true, false, true)));
68 } 82 }
69 83
70 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { 84 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
71 extensions::ExtensionHost* host = 85 extensions::ExtensionHost* host =
72 extensions::ExtensionSystem::Get(browser()->profile())-> 86 extensions::ExtensionSystem::Get(browser()->profile())->
73 process_manager()->GetBackgroundHostForExtension( 87 process_manager()->GetBackgroundHostForExtension(
74 extension_misc::kChromeVoxExtensionId); 88 extension_misc::kChromeVoxExtensionId);
75 CHECK(content::ExecuteScript(host->host_contents(), script)); 89 CHECK(content::ExecuteScript(host->host_contents(), script));
76 } 90 }
77 91
78 void SimulateTouchScreenInChromeVox() { 92 void SimulateTouchScreenInChromeVox() {
79 // ChromeVox looks at whether 'ontouchstart' exists to know whether 93 // ChromeVox looks at whether 'ontouchstart' exists to know whether
80 // or not it should respond to hover events. Fake it so that touch 94 // or not it should respond to hover events. Fake it so that touch
81 // exploration events get spoken. 95 // exploration events get spoken.
82 RunJavaScriptInChromeVoxBackgroundPage( 96 RunJavaScriptInChromeVoxBackgroundPage(
83 "window.ontouchstart = function() {};"); 97 "window.ontouchstart = function() {};");
84 } 98 }
85 99
86 void DisableEarcons() { 100 void DisableEarcons() {
87 // Playing earcons from within a test is not only annoying if you're 101 // Playing earcons from within a test is not only annoying if you're
88 // running the test locally, but seems to cause crashes 102 // running the test locally, but seems to cause crashes
89 // (http://crbug.com/396507). Work around this by just telling 103 // (http://crbug.com/396507). Work around this by just telling
90 // ChromeVox to not ever play earcons (prerecorded sound effects). 104 // ChromeVox to not ever play earcons (prerecorded sound effects).
91 RunJavaScriptInChromeVoxBackgroundPage( 105 RunJavaScriptInChromeVoxBackgroundPage(
92 "cvox.ChromeVox.earcons.playEarcon = function() {};"); 106 "cvox.ChromeVox.earcons.playEarcon = function() {};");
93 } 107 }
94 108
109 void LoadChromeVoxAndThenNavigateToURL(const GURL& url) {
110 // The goal of this helper function is to avoid race conditions between
111 // the page loading and the ChromeVox extension loading and fully
David Tseng 2014/09/22 21:52:21 Mention something about the content script being f
112 // initializing. To do this, we first load a test url that repeatedly
113 // asks ChromeVox to speak 'ready', then we load ChromeVox and block
114 // until we get that 'ready' speech.
115
116 ui_test_utils::NavigateToURL(
117 browser(),
118 GURL("data:text/html;charset=utf-8,"
119 "<script>"
120 "window.setInterval(function() {"
121 " try {"
122 " cvox.Api.speak('ready');"
123 " } catch (e) {}"
124 "}, 100);"
125 "</script>"));
126 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
127 AccessibilityManager::Get()->EnableSpokenFeedback(
128 true, ash::A11Y_NOTIFICATION_NONE);
129
130 // Block until we get "ready".
131 while (speech_monitor_.GetNextUtterance() != "ready") {
David Tseng 2014/09/22 21:52:21 Should we sleep here inside the loop to avoid pote
132 }
133
134 // Now load the requested url.
135 ui_test_utils::NavigateToURL(browser(), url);
136 }
137
138 SpeechMonitor speech_monitor_;
139
95 private: 140 private:
96 StubBrailleController braille_controller_; 141 StubBrailleController braille_controller_;
97 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); 142 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest);
98 }; 143 };
99 144
100 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) { 145 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) {
101 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 146 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
102 147
103 SpeechMonitor monitor;
104 AccessibilityManager::Get()->EnableSpokenFeedback( 148 AccessibilityManager::Get()->EnableSpokenFeedback(
105 true, ash::A11Y_NOTIFICATION_NONE); 149 true, ash::A11Y_NOTIFICATION_NONE);
106 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 150 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
107 DisableEarcons(); 151 DisableEarcons();
108 152
109 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 153 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
110 154
111 // Create a bookmark with title "foo". 155 // Create a bookmark with title "foo".
112 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE); 156 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE);
113 EXPECT_EQ("Bookmark added!,", monitor.GetNextUtterance()); 157 EXPECT_EQ("Bookmark added!,", speech_monitor_.GetNextUtterance());
114 EXPECT_EQ("about blank,", monitor.GetNextUtterance()); 158 EXPECT_EQ("about blank,", speech_monitor_.GetNextUtterance());
115 EXPECT_EQ("Bookmark name,", monitor.GetNextUtterance()); 159 EXPECT_EQ("Bookmark name,", speech_monitor_.GetNextUtterance());
116 EXPECT_EQ("text box", monitor.GetNextUtterance()); 160 EXPECT_EQ("text box", speech_monitor_.GetNextUtterance());
117 161
118 SendKeyPress(ui::VKEY_F); 162 SendKeyPress(ui::VKEY_F);
119 EXPECT_EQ("f", monitor.GetNextUtterance()); 163 EXPECT_EQ("f", speech_monitor_.GetNextUtterance());
120 SendKeyPress(ui::VKEY_O); 164 SendKeyPress(ui::VKEY_O);
121 EXPECT_EQ("o", monitor.GetNextUtterance()); 165 EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
122 SendKeyPress(ui::VKEY_O); 166 SendKeyPress(ui::VKEY_O);
123 EXPECT_EQ("o", monitor.GetNextUtterance()); 167 EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
124 168
125 SendKeyPress(ui::VKEY_TAB); 169 SendKeyPress(ui::VKEY_TAB);
126 EXPECT_EQ("Bookmarks bar,", monitor.GetNextUtterance()); 170 EXPECT_EQ("Bookmarks bar,", speech_monitor_.GetNextUtterance());
127 EXPECT_EQ("Bookmark folder,", monitor.GetNextUtterance()); 171 EXPECT_EQ("Bookmark folder,", speech_monitor_.GetNextUtterance());
128 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "combo box*")); 172 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "combo box*"));
129 173
130 SendKeyPress(ui::VKEY_RETURN); 174 SendKeyPress(ui::VKEY_RETURN);
131 175
132 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 176 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
133 // Wait for active window change to be announced to avoid interference from 177 // Wait for active window change to be announced to avoid interference from
134 // that below. 178 // that below.
135 while (monitor.GetNextUtterance() != "window about blank tab") { 179 while (speech_monitor_.GetNextUtterance() != "window about blank tab") {
136 // Do nothing. 180 // Do nothing.
137 } 181 }
138 182
139 // Focus bookmarks bar and listen for "foo". 183 // Focus bookmarks bar and listen for "foo".
140 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS); 184 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS);
141 while (true) { 185 while (true) {
142 std::string utterance = monitor.GetNextUtterance(); 186 std::string utterance = speech_monitor_.GetNextUtterance();
143 VLOG(0) << "Got utterance: " << utterance; 187 VLOG(0) << "Got utterance: " << utterance;
144 if (utterance == "Bookmarks,") 188 if (utterance == "Bookmarks,")
145 break; 189 break;
146 } 190 }
147 EXPECT_EQ("foo,", monitor.GetNextUtterance()); 191 EXPECT_EQ("foo,", speech_monitor_.GetNextUtterance());
148 EXPECT_EQ("button", monitor.GetNextUtterance()); 192 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
149 } 193 }
150 194
151 // 195 //
152 // Spoken feedback tests in both a logged in browser window and guest mode. 196 // Spoken feedback tests in both a logged in browser window and guest mode.
153 // 197 //
154 198
155 enum SpokenFeedbackTestVariant { 199 enum SpokenFeedbackTestVariant {
156 kTestAsNormalUser, 200 kTestAsNormalUser,
157 kTestAsGuestUser 201 kTestAsGuestUser
158 }; 202 };
(...skipping 19 matching lines...) Expand all
178 222
179 INSTANTIATE_TEST_CASE_P( 223 INSTANTIATE_TEST_CASE_P(
180 TestAsNormalAndGuestUser, 224 TestAsNormalAndGuestUser,
181 SpokenFeedbackTest, 225 SpokenFeedbackTest,
182 ::testing::Values(kTestAsNormalUser, 226 ::testing::Values(kTestAsNormalUser,
183 kTestAsGuestUser)); 227 kTestAsGuestUser));
184 228
185 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { 229 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
186 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 230 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
187 231
188 SpeechMonitor monitor;
189 AccessibilityManager::Get()->EnableSpokenFeedback( 232 AccessibilityManager::Get()->EnableSpokenFeedback(
190 true, ash::A11Y_NOTIFICATION_NONE); 233 true, ash::A11Y_NOTIFICATION_NONE);
191 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 234 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
192 } 235 }
193 236
194 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { 237 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
195 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 238 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
196 239
197 SpeechMonitor monitor;
198 AccessibilityManager::Get()->EnableSpokenFeedback( 240 AccessibilityManager::Get()->EnableSpokenFeedback(
199 true, ash::A11Y_NOTIFICATION_NONE); 241 true, ash::A11Y_NOTIFICATION_NONE);
200 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 242 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
201 DisableEarcons(); 243 DisableEarcons();
202 244
203 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 245 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
204 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 246 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
205 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 247 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
206 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); 248 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
207 EXPECT_EQ("button", monitor.GetNextUtterance()); 249 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
208 } 250 }
209 251
210 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { 252 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
211 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 253 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
212 254
213 SpeechMonitor monitor;
214 AccessibilityManager::Get()->EnableSpokenFeedback( 255 AccessibilityManager::Get()->EnableSpokenFeedback(
215 true, ash::A11Y_NOTIFICATION_NONE); 256 true, ash::A11Y_NOTIFICATION_NONE);
216 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 257 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
217 DisableEarcons(); 258 DisableEarcons();
218 259
219 // Wait for ChromeVox to finish speaking. 260 // Wait for ChromeVox to finish speaking.
220 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); 261 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
221 while (true) { 262 while (true) {
222 std::string utterance = monitor.GetNextUtterance(); 263 std::string utterance = speech_monitor_.GetNextUtterance();
223 VLOG(0) << "Got utterance: " << utterance; 264 VLOG(0) << "Got utterance: " << utterance;
224 if (utterance == "text box") 265 if (utterance == "text box")
225 break; 266 break;
226 } 267 }
227 268
228 SendKeyPress(ui::VKEY_X); 269 SendKeyPress(ui::VKEY_X);
229 EXPECT_EQ("x", monitor.GetNextUtterance()); 270 EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
230 271
231 SendKeyPress(ui::VKEY_Y); 272 SendKeyPress(ui::VKEY_Y);
232 EXPECT_EQ("y", monitor.GetNextUtterance()); 273 EXPECT_EQ("y", speech_monitor_.GetNextUtterance());
233 274
234 SendKeyPress(ui::VKEY_Z); 275 SendKeyPress(ui::VKEY_Z);
235 EXPECT_EQ("z", monitor.GetNextUtterance()); 276 EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
236 277
237 SendKeyPress(ui::VKEY_BACK); 278 SendKeyPress(ui::VKEY_BACK);
238 EXPECT_EQ("z", monitor.GetNextUtterance()); 279 EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
280 }
281
282 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxShiftSearch) {
283 LoadChromeVoxAndThenNavigateToURL(
284 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
285 while (true) {
286 std::string utterance = speech_monitor_.GetNextUtterance();
287 if (utterance == "Click me")
David Tseng 2014/09/22 21:52:21 Would be helpful to state why we're expecting this
288 break;
289 }
David Tseng 2014/09/22 21:52:21 Ditto.
290 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
291
292 // Press Search+Shift+/ to enter ChromeVox's "find in page".
293 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
294 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
295 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
296 }
297
298 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxPrefixKey) {
299 LoadChromeVoxAndThenNavigateToURL(
300 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
301 while (true) {
302 std::string utterance = speech_monitor_.GetNextUtterance();
303 if (utterance == "Click me")
304 break;
305 }
306 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
307
308 // Press the prefix key Ctrl+';' followed by '/'
309 // to enter ChromeVox's "find in page".
310 SendKeyPressWithControl(ui::VKEY_OEM_1);
311 SendKeyPress(ui::VKEY_OEM_2);
312 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
313 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
239 } 314 }
240 315
241 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { 316 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
242 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 317 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
243 318
244 SpeechMonitor monitor;
245 AccessibilityManager::Get()->EnableSpokenFeedback( 319 AccessibilityManager::Get()->EnableSpokenFeedback(
246 true, ash::A11Y_NOTIFICATION_NONE); 320 true, ash::A11Y_NOTIFICATION_NONE);
247 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 321 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
248 DisableEarcons(); 322 DisableEarcons();
249 323
250 SimulateTouchScreenInChromeVox(); 324 SimulateTouchScreenInChromeVox();
251 325
252 // Send an accessibility hover event on the system tray, which is 326 // Send an accessibility hover event on the system tray, which is
253 // what we get when you tap it on a touch screen when ChromeVox is on. 327 // what we get when you tap it on a touch screen when ChromeVox is on.
254 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); 328 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray();
255 tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); 329 tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true);
256 330
257 EXPECT_EQ("Status tray,", monitor.GetNextUtterance()); 331 EXPECT_EQ("Status tray,", speech_monitor_.GetNextUtterance());
258 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "time*,")); 332 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "time*,"));
259 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Battery*,")); 333 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "Battery*,"));
260 EXPECT_EQ("button", monitor.GetNextUtterance()); 334 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
261 } 335 }
262 336
263 // 337 //
264 // Spoken feedback tests that run only in guest mode. 338 // Spoken feedback tests that run only in guest mode.
265 // 339 //
266 340
267 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest { 341 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest {
268 protected: 342 protected:
269 GuestSpokenFeedbackTest() {} 343 GuestSpokenFeedbackTest() {}
270 virtual ~GuestSpokenFeedbackTest() {} 344 virtual ~GuestSpokenFeedbackTest() {}
271 345
272 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 346 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
273 command_line->AppendSwitch(chromeos::switches::kGuestSession); 347 command_line->AppendSwitch(chromeos::switches::kGuestSession);
274 command_line->AppendSwitch(::switches::kIncognito); 348 command_line->AppendSwitch(::switches::kIncognito);
275 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 349 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
276 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, 350 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
277 chromeos::login::kGuestUserName); 351 chromeos::login::kGuestUserName);
278 } 352 }
279 353
280 private: 354 private:
281 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest); 355 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest);
282 }; 356 };
283 357
284 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { 358 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
285 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 359 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
286 360
287 SpeechMonitor monitor;
288 AccessibilityManager::Get()->EnableSpokenFeedback( 361 AccessibilityManager::Get()->EnableSpokenFeedback(
289 true, ash::A11Y_NOTIFICATION_NONE); 362 true, ash::A11Y_NOTIFICATION_NONE);
290 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 363 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
291 DisableEarcons(); 364 DisableEarcons();
292 365
293 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 366 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
294 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 367 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
295 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 368 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
296 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); 369 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
297 EXPECT_EQ("button", monitor.GetNextUtterance()); 370 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
298 } 371 }
299 372
300 // 373 //
301 // Spoken feedback tests of the out-of-box experience. 374 // Spoken feedback tests of the out-of-box experience.
302 // 375 //
303 376
304 class OobeSpokenFeedbackTest : public InProcessBrowserTest { 377 class OobeSpokenFeedbackTest : public InProcessBrowserTest {
305 protected: 378 protected:
306 OobeSpokenFeedbackTest() {} 379 OobeSpokenFeedbackTest() {}
307 virtual ~OobeSpokenFeedbackTest() {} 380 virtual ~OobeSpokenFeedbackTest() {}
308 381
309 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 382 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
310 command_line->AppendSwitch(chromeos::switches::kLoginManager); 383 command_line->AppendSwitch(chromeos::switches::kLoginManager);
311 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); 384 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
312 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 385 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
313 } 386 }
314 387
315 virtual void SetUpOnMainThread() OVERRIDE { 388 virtual void SetUpOnMainThread() OVERRIDE {
316 AccessibilityManager::Get()-> 389 AccessibilityManager::Get()->
317 SetProfileForTest(ProfileHelper::GetSigninProfile()); 390 SetProfileForTest(ProfileHelper::GetSigninProfile());
318 } 391 }
319 392
393 SpeechMonitor speech_monitor_;
394
320 private: 395 private:
321 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); 396 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
322 }; 397 };
323 398
324 // Test is flaky: http://crbug.com/346797 399 // Test is flaky: http://crbug.com/346797
325 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) { 400 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
326 ui_controls::EnableUIControls(); 401 ui_controls::EnableUIControls();
327 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 402 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
328 403
329 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); 404 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host();
330 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); 405 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView();
331 views::Widget* widget = web_ui_login_view->GetWidget(); 406 views::Widget* widget = web_ui_login_view->GetWidget();
332 gfx::NativeWindow window = widget->GetNativeWindow(); 407 gfx::NativeWindow window = widget->GetNativeWindow();
333 408
334 SpeechMonitor monitor;
335 AccessibilityManager::Get()->EnableSpokenFeedback( 409 AccessibilityManager::Get()->EnableSpokenFeedback(
336 true, ash::A11Y_NOTIFICATION_NONE); 410 true, ash::A11Y_NOTIFICATION_NONE);
337 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 411 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
338 412
339 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); 413 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance());
340 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); 414 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance());
341 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); 415 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
416 "Combo box * of *"));
342 ASSERT_TRUE( 417 ASSERT_TRUE(
343 ui_test_utils::SendKeyPressToWindowSync( 418 ui_test_utils::SendKeyPressToWindowSync(
344 window, ui::VKEY_TAB, false, false, false, false)); 419 window, ui::VKEY_TAB, false, false, false, false));
345 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); 420 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance());
346 } 421 }
347 422
348 } // namespace chromeos 423 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/ui_controls_factory_ozone.cc » ('j') | ui/aura/test/ui_controls_factory_ozone.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698