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

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

Issue 541903002: Add test for ChromeVox sticky mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sticky_key
Patch Set: Rebase Created 6 years, 2 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 | « no previous file | 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/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"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 true, ash::A11Y_NOTIFICATION_NONE); 128 true, ash::A11Y_NOTIFICATION_NONE);
129 129
130 // Block until we get "ready". 130 // Block until we get "ready".
131 while (speech_monitor_.GetNextUtterance() != "ready") { 131 while (speech_monitor_.GetNextUtterance() != "ready") {
132 } 132 }
133 133
134 // Now load the requested url. 134 // Now load the requested url.
135 ui_test_utils::NavigateToURL(browser(), url); 135 ui_test_utils::NavigateToURL(browser(), url);
136 } 136 }
137 137
138 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key,
139 const std::string& expected_utterance) {
140 // This helper function is needed when you want to poll for something
141 // that happens asynchronously. Keep pressing |key|, until
142 // the speech feedback that follows is |expected_utterance|.
143 // Note that this doesn't work if pressing that key doesn't speak anything
144 // at all before the asynchronous event occurred.
145 while (true) {
146 SendKeyPress(key);
147 const std::string& utterance = speech_monitor_.GetNextUtterance();
148 if (utterance == expected_utterance)
149 break;
150 }
151 }
152
138 SpeechMonitor speech_monitor_; 153 SpeechMonitor speech_monitor_;
139 154
140 private: 155 private:
141 StubBrailleController braille_controller_; 156 StubBrailleController braille_controller_;
142 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); 157 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest);
143 }; 158 };
144 159
145 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) { 160 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) {
146 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 161 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
147 162
148 AccessibilityManager::Get()->EnableSpokenFeedback( 163 AccessibilityManager::Get()->EnableSpokenFeedback(
149 true, ash::A11Y_NOTIFICATION_NONE); 164 true, ash::A11Y_NOTIFICATION_NONE);
150 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 165 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
151 DisableEarcons(); 166 DisableEarcons();
152 167
153 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 168 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
154 169
155 // Create a bookmark with title "foo". 170 // Create a bookmark with title "foo".
156 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE); 171 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 235 }
221 }; 236 };
222 237
223 INSTANTIATE_TEST_CASE_P( 238 INSTANTIATE_TEST_CASE_P(
224 TestAsNormalAndGuestUser, 239 TestAsNormalAndGuestUser,
225 SpokenFeedbackTest, 240 SpokenFeedbackTest,
226 ::testing::Values(kTestAsNormalUser, 241 ::testing::Values(kTestAsNormalUser,
227 kTestAsGuestUser)); 242 kTestAsGuestUser));
228 243
229 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { 244 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
230 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 245 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
231 246
232 AccessibilityManager::Get()->EnableSpokenFeedback( 247 AccessibilityManager::Get()->EnableSpokenFeedback(
233 true, ash::A11Y_NOTIFICATION_NONE); 248 true, ash::A11Y_NOTIFICATION_NONE);
234 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 249 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
235 } 250 }
236 251
237 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { 252 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
238 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 253 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
239 254
240 AccessibilityManager::Get()->EnableSpokenFeedback( 255 AccessibilityManager::Get()->EnableSpokenFeedback(
241 true, ash::A11Y_NOTIFICATION_NONE); 256 true, ash::A11Y_NOTIFICATION_NONE);
242 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 257 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
243 DisableEarcons(); 258 DisableEarcons();
244 259
245 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 260 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
246 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 261 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
247 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*")); 262 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
248 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance()); 263 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
249 EXPECT_EQ("button", speech_monitor_.GetNextUtterance()); 264 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
250 } 265 }
251 266
252 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { 267 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
253 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 268 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
254 269
255 AccessibilityManager::Get()->EnableSpokenFeedback( 270 AccessibilityManager::Get()->EnableSpokenFeedback(
256 true, ash::A11Y_NOTIFICATION_NONE); 271 true, ash::A11Y_NOTIFICATION_NONE);
257 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 272 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
258 DisableEarcons(); 273 DisableEarcons();
259 274
260 // Wait for ChromeVox to finish speaking. 275 // Wait for ChromeVox to finish speaking.
261 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); 276 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
262 while (true) { 277 while (true) {
263 std::string utterance = speech_monitor_.GetNextUtterance(); 278 std::string utterance = speech_monitor_.GetNextUtterance();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance()); 350 EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance());
336 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); 351 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
337 EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance()); 352 EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance());
338 353
339 // Press again to end the selection. 354 // Press again to end the selection.
340 SendKeyPressWithSearchAndShift(ui::VKEY_S); 355 SendKeyPressWithSearchAndShift(ui::VKEY_S);
341 EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance()); 356 EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance());
342 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); 357 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
343 } 358 }
344 359
360 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxStickyMode) {
361 LoadChromeVoxAndThenNavigateToURL(
362 GURL("data:text/html;charset=utf-8,"
363 "<label>Enter your name <input autofocus></label>"
364 "<p>One</p>"
365 "<h2>Two</h2>"));
366 while (speech_monitor_.GetNextUtterance() != "Enter your name") {
367 }
368 EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
369
370 // Press the sticky-key sequence: Search Search.
371 SendKeyPress(ui::VKEY_LWIN);
372 SendKeyPress(ui::VKEY_LWIN);
373 EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance());
374
375 // Even once we hear "sticky mode enabled" from the ChromeVox background
376 // page, there's a short window of time when the content script still
377 // hasn't switched to sticky mode. That's why we're focused on a text box.
378 // Keep pressing the '/' key. If sticky mode is off, it will echo the word
379 // "slash". If sticky mode is on, it will open "Find in page". Keep pressing
380 // '/' until we get "Find in page.".
381 PressRepeatedlyUntilUtterance(ui::VKEY_OEM_2, "Find in page.");
382 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
383
384 // Press Esc to exit Find in Page mode.
385 SendKeyPress(ui::VKEY_ESCAPE);
386 EXPECT_EQ("Exited", speech_monitor_.GetNextUtterance());
387 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
388
389 // Press N H to jump to the next heading. Skip over speech in-between
390 // but make sure we end up at the heading.
391 SendKeyPress(ui::VKEY_N);
392 SendKeyPress(ui::VKEY_H);
393 while (speech_monitor_.GetNextUtterance() != "Two") {
394 }
395 EXPECT_EQ("Heading 2", speech_monitor_.GetNextUtterance());
396
397 // Press the up arrow to go to the previous element.
398 SendKeyPress(ui::VKEY_UP);
399 EXPECT_EQ("One", speech_monitor_.GetNextUtterance());
400 }
401
345 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { 402 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
346 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 403 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
347 404
348 AccessibilityManager::Get()->EnableSpokenFeedback( 405 AccessibilityManager::Get()->EnableSpokenFeedback(
349 true, ash::A11Y_NOTIFICATION_NONE); 406 true, ash::A11Y_NOTIFICATION_NONE);
350 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 407 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
351 DisableEarcons(); 408 DisableEarcons();
352 409
353 SimulateTouchScreenInChromeVox(); 410 SimulateTouchScreenInChromeVox();
354 411
355 // Send an accessibility hover event on the system tray, which is 412 // Send an accessibility hover event on the system tray, which is
356 // what we get when you tap it on a touch screen when ChromeVox is on. 413 // what we get when you tap it on a touch screen when ChromeVox is on.
(...skipping 21 matching lines...) Expand all
378 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 435 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
379 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, 436 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
380 chromeos::login::kGuestUserName); 437 chromeos::login::kGuestUserName);
381 } 438 }
382 439
383 private: 440 private:
384 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest); 441 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest);
385 }; 442 };
386 443
387 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { 444 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
388 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 445 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
389 446
390 AccessibilityManager::Get()->EnableSpokenFeedback( 447 AccessibilityManager::Get()->EnableSpokenFeedback(
391 true, ash::A11Y_NOTIFICATION_NONE); 448 true, ash::A11Y_NOTIFICATION_NONE);
392 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 449 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
393 DisableEarcons(); 450 DisableEarcons();
394 451
395 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 452 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
396 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 453 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
397 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*")); 454 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
398 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance()); 455 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
(...skipping 22 matching lines...) Expand all
421 478
422 SpeechMonitor speech_monitor_; 479 SpeechMonitor speech_monitor_;
423 480
424 private: 481 private:
425 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); 482 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
426 }; 483 };
427 484
428 // Test is flaky: http://crbug.com/346797 485 // Test is flaky: http://crbug.com/346797
429 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) { 486 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
430 ui_controls::EnableUIControls(); 487 ui_controls::EnableUIControls();
431 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 488 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
432 489
433 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); 490 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host();
434 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); 491 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView();
435 views::Widget* widget = web_ui_login_view->GetWidget(); 492 views::Widget* widget = web_ui_login_view->GetWidget();
436 gfx::NativeWindow window = widget->GetNativeWindow(); 493 gfx::NativeWindow window = widget->GetNativeWindow();
437 494
438 AccessibilityManager::Get()->EnableSpokenFeedback( 495 AccessibilityManager::Get()->EnableSpokenFeedback(
439 true, ash::A11Y_NOTIFICATION_NONE); 496 true, ash::A11Y_NOTIFICATION_NONE);
440 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); 497 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
441 498
442 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance()); 499 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance());
443 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); 500 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance());
444 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), 501 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
445 "Combo box * of *")); 502 "Combo box * of *"));
446 ASSERT_TRUE( 503 ASSERT_TRUE(
447 ui_test_utils::SendKeyPressToWindowSync( 504 ui_test_utils::SendKeyPressToWindowSync(
448 window, ui::VKEY_TAB, false, false, false, false)); 505 window, ui::VKEY_TAB, false, false, false, false));
449 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance()); 506 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance());
450 } 507 }
451 508
452 } // namespace chromeos 509 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698