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/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
8 #include "ash/common/accelerators/accelerator_table.h" | 8 #include "ash/common/accelerators/accelerator_table.h" |
9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void SendKeyPressWithControl(ui::KeyboardCode key) { | 80 void SendKeyPressWithControl(ui::KeyboardCode key) { |
81 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 81 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
82 nullptr, key, true, false, false, false))); | 82 nullptr, key, true, false, false, false))); |
83 } | 83 } |
84 | 84 |
85 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) { | 85 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) { |
86 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 86 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
87 nullptr, key, false, true, false, true))); | 87 nullptr, key, false, true, false, true))); |
88 } | 88 } |
89 | 89 |
90 void SendKeyPressWithSearch(ui::KeyboardCode key) { | |
91 ASSERT_NO_FATAL_FAILURE(ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
92 nullptr, key, false, false, false, true))); | |
93 } | |
94 | |
95 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { | 90 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { |
96 extensions::ExtensionHost* host = | 91 extensions::ExtensionHost* host = |
97 extensions::ProcessManager::Get(browser()->profile()) | 92 extensions::ProcessManager::Get(browser()->profile()) |
98 ->GetBackgroundHostForExtension( | 93 ->GetBackgroundHostForExtension( |
99 extension_misc::kChromeVoxExtensionId); | 94 extension_misc::kChromeVoxExtensionId); |
100 CHECK(content::ExecuteScript(host->host_contents(), script)); | 95 CHECK(content::ExecuteScript(host->host_contents(), script)); |
101 } | 96 } |
102 | 97 |
103 void SimulateTouchScreenInChromeVox() { | 98 void SimulateTouchScreenInChromeVox() { |
104 // ChromeVox looks at whether 'ontouchstart' exists to know whether | 99 // ChromeVox looks at whether 'ontouchstart' exists to know whether |
(...skipping 13 matching lines...) Expand all Loading... |
118 // Playing earcons from within a test is not only annoying if you're | 113 // Playing earcons from within a test is not only annoying if you're |
119 // running the test locally, but seems to cause crashes | 114 // running the test locally, but seems to cause crashes |
120 // (http://crbug.com/396507). Work around this by just telling | 115 // (http://crbug.com/396507). Work around this by just telling |
121 // ChromeVox to not ever play earcons (prerecorded sound effects). | 116 // ChromeVox to not ever play earcons (prerecorded sound effects). |
122 RunJavaScriptInChromeVoxBackgroundPage( | 117 RunJavaScriptInChromeVoxBackgroundPage( |
123 "cvox.ChromeVox.earcons.playEarcon = function() {};"); | 118 "cvox.ChromeVox.earcons.playEarcon = function() {};"); |
124 } | 119 } |
125 | 120 |
126 void EnableChromeVox() { | 121 void EnableChromeVox() { |
127 // Test setup. | 122 // Test setup. |
128 // Enable ChromeVox, skip welcome message/notification, and disable earcons. | 123 // Enable ChromeVox, skip welcome message, and disable earcons. |
129 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 124 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
130 | 125 |
131 AccessibilityManager::Get()->EnableSpokenFeedback( | 126 AccessibilityManager::Get()->EnableSpokenFeedback( |
132 true, ash::A11Y_NOTIFICATION_NONE); | 127 true, ash::A11Y_NOTIFICATION_NONE); |
133 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); | 128 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); |
134 DisableEarcons(); | 129 DisableEarcons(); |
135 } | 130 } |
136 | 131 |
| 132 void LoadChromeVoxAndThenNavigateToURL(const GURL& url) { |
| 133 // The goal of this helper function is to avoid race conditions between |
| 134 // the page loading and the ChromeVox extension loading and fully |
| 135 // initializing. To do this, we first load a test url that repeatedly |
| 136 // asks ChromeVox to speak 'ready', then we load ChromeVox and block |
| 137 // until we get that 'ready' speech. |
| 138 |
| 139 ui_test_utils::NavigateToURL( |
| 140 browser(), |
| 141 GURL("data:text/html;charset=utf-8," |
| 142 "<script>" |
| 143 "window.setInterval(function() {" |
| 144 " try {" |
| 145 " cvox.Api.speak('ready');" |
| 146 " } catch (e) {}" |
| 147 "}, 100);" |
| 148 "</script>")); |
| 149 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 150 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 151 true, ash::A11Y_NOTIFICATION_NONE); |
| 152 |
| 153 // Block until we get "ready". |
| 154 while (speech_monitor_.GetNextUtterance() != "ready") { |
| 155 } |
| 156 |
| 157 // Now load the requested url. |
| 158 ui_test_utils::NavigateToURL(browser(), url); |
| 159 } |
| 160 |
137 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key, | 161 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key, |
138 const std::string& expected_utterance) { | 162 const std::string& expected_utterance) { |
139 // This helper function is needed when you want to poll for something | 163 // This helper function is needed when you want to poll for something |
140 // that happens asynchronously. Keep pressing |key|, until | 164 // that happens asynchronously. Keep pressing |key|, until |
141 // the speech feedback that follows is |expected_utterance|. | 165 // the speech feedback that follows is |expected_utterance|. |
142 // Note that this doesn't work if pressing that key doesn't speak anything | 166 // Note that this doesn't work if pressing that key doesn't speak anything |
143 // at all before the asynchronous event occurred. | 167 // at all before the asynchronous event occurred. |
144 while (true) { | 168 while (true) { |
145 SendKeyPress(key); | 169 SendKeyPress(key); |
146 const std::string& utterance = speech_monitor_.GetNextUtterance(); | 170 const std::string& utterance = speech_monitor_.GetNextUtterance(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // AudioOutputResampler::Shutdown, see crbug.com/630031. | 302 // AudioOutputResampler::Shutdown, see crbug.com/630031. |
279 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_EnableSpokenFeedback) { | 303 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_EnableSpokenFeedback) { |
280 EnableChromeVox(); | 304 EnableChromeVox(); |
281 } | 305 } |
282 | 306 |
283 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { | 307 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { |
284 EnableChromeVox(); | 308 EnableChromeVox(); |
285 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); | 309 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); |
286 EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance()); | 310 EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance()); |
287 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); | 311 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
| 312 EXPECT_EQ("main", speech_monitor_.GetNextUtterance()); |
| 313 EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance()); |
| 314 EXPECT_TRUE( |
| 315 base::MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*")); |
288 } | 316 } |
289 | 317 |
290 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { | 318 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { |
291 EnableChromeVox(); | 319 EnableChromeVox(); |
292 | 320 |
293 // Location bar has focus by default so just start typing. | 321 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); |
| 322 EXPECT_EQ("Address and search bar", speech_monitor_.GetNextUtterance()); |
| 323 EXPECT_EQ("about:blank", speech_monitor_.GetNextUtterance()); |
| 324 EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance()); |
| 325 EXPECT_EQ("main", speech_monitor_.GetNextUtterance()); |
| 326 EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance()); |
| 327 EXPECT_TRUE( |
| 328 base::MatchPattern(speech_monitor_.GetNextUtterance(), "*about:blank*")); |
| 329 |
294 SendKeyPress(ui::VKEY_X); | 330 SendKeyPress(ui::VKEY_X); |
295 EXPECT_EQ("x", speech_monitor_.GetNextUtterance()); | 331 EXPECT_EQ("x", speech_monitor_.GetNextUtterance()); |
296 | 332 |
297 SendKeyPress(ui::VKEY_Y); | 333 SendKeyPress(ui::VKEY_Y); |
298 EXPECT_EQ("y", speech_monitor_.GetNextUtterance()); | 334 EXPECT_EQ("y", speech_monitor_.GetNextUtterance()); |
299 | 335 |
300 SendKeyPress(ui::VKEY_Z); | 336 SendKeyPress(ui::VKEY_Z); |
301 EXPECT_EQ("z", speech_monitor_.GetNextUtterance()); | 337 EXPECT_EQ("z", speech_monitor_.GetNextUtterance()); |
302 | 338 |
303 SendKeyPress(ui::VKEY_BACK); | 339 SendKeyPress(ui::VKEY_BACK); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 while (true) { | 431 while (true) { |
396 std::string utterance = speech_monitor_.GetNextUtterance(); | 432 std::string utterance = speech_monitor_.GetNextUtterance(); |
397 if (base::MatchPattern(utterance, "window")) | 433 if (base::MatchPattern(utterance, "window")) |
398 break; | 434 break; |
399 } | 435 } |
400 | 436 |
401 SendKeyPress(ui::VKEY_TAB); | 437 SendKeyPress(ui::VKEY_TAB); |
402 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); | 438 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); |
403 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); | 439 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); |
404 | 440 |
405 // Next element. | 441 // Compat next element. |
406 SendKeyPressWithSearch(ui::VKEY_RIGHT); | 442 SendKeyPressWithSearchAndShift(ui::VKEY_RIGHT); |
407 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); | 443 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); |
408 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); | 444 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); |
409 | 445 |
410 // Next button. | 446 // Compat next button. |
411 SendKeyPressWithSearch(ui::VKEY_B); | 447 SendKeyPressWithSearchAndShift(ui::VKEY_N); |
| 448 SendKeyPress(ui::VKEY_B); |
412 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); | 449 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "*")); |
413 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); | 450 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "Button")); |
414 | 451 |
415 // Navigate to Bluetooth sub-menu and open it. | 452 // Navigate to Bluetooth sub-menu and open it. |
416 while (true) { | 453 while (true) { |
417 SendKeyPress(ui::VKEY_TAB); | 454 SendKeyPress(ui::VKEY_TAB); |
418 std::string content = speech_monitor_.GetNextUtterance(); | 455 std::string content = speech_monitor_.GetNextUtterance(); |
419 std::string role = speech_monitor_.GetNextUtterance(); | 456 std::string role = speech_monitor_.GetNextUtterance(); |
420 if (base::MatchPattern(content, "*Bluetooth*") && | 457 if (base::MatchPattern(content, "*Bluetooth*") && |
421 base::MatchPattern(role, "Button")) | 458 base::MatchPattern(role, "Button")) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); | 520 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
484 } | 521 } |
485 | 522 |
486 #if defined(MEMORY_SANITIZER) | 523 #if defined(MEMORY_SANITIZER) |
487 // Fails under MemorySanitizer: http://crbug.com/472125 | 524 // Fails under MemorySanitizer: http://crbug.com/472125 |
488 #define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch | 525 #define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch |
489 #else | 526 #else |
490 #define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch | 527 #define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch |
491 #endif | 528 #endif |
492 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) { | 529 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) { |
493 EnableChromeVox(); | 530 LoadChromeVoxAndThenNavigateToURL( |
494 | |
495 ui_test_utils::NavigateToURL( | |
496 browser(), | |
497 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); | 531 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); |
498 while (true) { | 532 while (true) { |
499 std::string utterance = speech_monitor_.GetNextUtterance(); | 533 std::string utterance = speech_monitor_.GetNextUtterance(); |
500 if (utterance == "Click me") | 534 if (utterance == "Click me") |
501 break; | 535 break; |
502 } | 536 } |
503 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); | 537 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
504 | 538 |
505 // Press Search+/ to enter ChromeVox's "find in page". | 539 // Press Search+Shift+/ to enter ChromeVox's "find in page". |
506 SendKeyPressWithSearch(ui::VKEY_OEM_2); | 540 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2); |
507 EXPECT_EQ("webView", speech_monitor_.GetNextUtterance()); | |
508 EXPECT_EQ(", window", speech_monitor_.GetNextUtterance()); | |
509 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance()); | 541 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance()); |
| 542 EXPECT_EQ(",", speech_monitor_.GetNextUtterance()); |
| 543 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance()); |
510 } | 544 } |
511 | 545 |
512 #if defined(MEMORY_SANITIZER) | 546 #if defined(MEMORY_SANITIZER) |
| 547 // Fails under MemorySanitizer: http://crbug.com/472125 |
| 548 #define MAYBE_ChromeVoxPrefixKey DISABLED_ChromeVoxPrefixKey |
| 549 #else |
| 550 #define MAYBE_ChromeVoxPrefixKey ChromeVoxPrefixKey |
| 551 #endif |
| 552 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) { |
| 553 LoadChromeVoxAndThenNavigateToURL( |
| 554 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); |
| 555 while (true) { |
| 556 std::string utterance = speech_monitor_.GetNextUtterance(); |
| 557 if (utterance == "Click me") |
| 558 break; |
| 559 } |
| 560 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
| 561 |
| 562 // Press the prefix key Ctrl+';' followed by '/' |
| 563 // to enter ChromeVox's "find in page". |
| 564 SendKeyPressWithControl(ui::VKEY_OEM_1); |
| 565 SendKeyPress(ui::VKEY_OEM_2); |
| 566 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance()); |
| 567 EXPECT_EQ(",", speech_monitor_.GetNextUtterance()); |
| 568 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance()); |
| 569 } |
| 570 |
| 571 #if defined(MEMORY_SANITIZER) |
513 // Fails under MemorySanitizer: http://crbug.com/472125 | 572 // Fails under MemorySanitizer: http://crbug.com/472125 |
514 #define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect | 573 #define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect |
515 #else | 574 #else |
516 #define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect | 575 #define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect |
517 #endif | 576 #endif |
518 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) { | 577 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) { |
519 EnableChromeVox(); | 578 LoadChromeVoxAndThenNavigateToURL( |
520 | 579 GURL("data:text/html;charset=utf-8," |
521 ui_test_utils::NavigateToURL(browser(), | 580 "<h1>Title</h1>" |
522 GURL("data:text/html;charset=utf-8," | 581 "<button autofocus>Click me</button>")); |
523 "<h1>Title</h1>" | |
524 "<button autofocus>Click me</button>")); | |
525 while (true) { | 582 while (true) { |
526 std::string utterance = speech_monitor_.GetNextUtterance(); | 583 std::string utterance = speech_monitor_.GetNextUtterance(); |
527 if (utterance == "Click me") | 584 if (utterance == "Click me") |
528 break; | 585 break; |
529 } | 586 } |
530 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); | 587 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
531 | 588 |
532 // Press Search+Left to navigate to the previous item. | 589 // Press Search+Shift+Up to navigate to the previous item. |
533 SendKeyPressWithSearch(ui::VKEY_LEFT); | 590 SendKeyPressWithSearchAndShift(ui::VKEY_UP); |
534 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); | 591 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); |
535 EXPECT_EQ("Heading 1", speech_monitor_.GetNextUtterance()); | 592 EXPECT_EQ("Heading 1", speech_monitor_.GetNextUtterance()); |
536 | 593 |
537 // Press Search+S to select the text. | 594 // Press Search+Shift+S to select the text. |
538 SendKeyPressWithSearch(ui::VKEY_S); | 595 SendKeyPressWithSearchAndShift(ui::VKEY_S); |
| 596 EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance()); |
539 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); | 597 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); |
540 EXPECT_EQ("selected", speech_monitor_.GetNextUtterance()); | 598 EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance()); |
541 | 599 |
542 // Press again to end the selection. | 600 // Press again to end the selection. |
543 SendKeyPressWithSearch(ui::VKEY_S); | 601 SendKeyPressWithSearchAndShift(ui::VKEY_S); |
544 EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance()); | 602 EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance()); |
545 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); | 603 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance()); |
546 } | 604 } |
547 | 605 |
548 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextStickyMode) { | 606 // http://crbug.com/628060 |
549 EnableChromeVox(); | 607 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ChromeVoxStickyMode) { |
550 | 608 LoadChromeVoxAndThenNavigateToURL( |
551 ui_test_utils::NavigateToURL( | 609 GURL("data:text/html;charset=utf-8," |
552 browser(), | 610 "<label>Enter your name <input autofocus></label>" |
553 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); | 611 "<p>One</p>" |
554 while ("Button" != speech_monitor_.GetNextUtterance()) { | 612 "<h2>Two</h2>")); |
| 613 while (speech_monitor_.GetNextUtterance() != "Enter your name") { |
555 } | 614 } |
| 615 EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance()); |
556 | 616 |
557 // Press the sticky-key sequence: Search Search. | 617 // Press the sticky-key sequence: Search Search. |
558 SendKeyPress(ui::VKEY_LWIN); | 618 SendKeyPress(ui::VKEY_LWIN); |
559 | 619 |
560 // Sticky key has a minimum 100 ms check to prevent key repeat from toggling | 620 // Sticky key has a minimum 100 ms check to prevent key repeat from toggling |
561 // it. | 621 // it. |
562 content::BrowserThread::PostDelayedTask( | 622 content::BrowserThread::PostDelayedTask( |
563 content::BrowserThread::UI, FROM_HERE, | 623 content::BrowserThread::UI, FROM_HERE, |
564 base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress, | 624 base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress, |
565 base::Unretained(this), ui::VKEY_LWIN), | 625 base::Unretained(this), ui::VKEY_LWIN), |
566 base::TimeDelta::FromMilliseconds(200)); | 626 base::TimeDelta::FromMilliseconds(200)); |
567 | 627 |
568 EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance()); | 628 EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance()); |
569 | 629 |
570 SendKeyPress(ui::VKEY_H); | 630 // Even once we hear "sticky mode enabled" from the ChromeVox background |
571 while ("No next heading." != speech_monitor_.GetNextUtterance()) { | 631 // page, there's a short window of time when the content script still |
| 632 // hasn't switched to sticky mode. That's why we're focused on a text box. |
| 633 // Keep pressing the '/' key. If sticky mode is off, it will echo the word |
| 634 // "slash". If sticky mode is on, it will open "Find in page". Keep pressing |
| 635 // '/' until we get "Find in page.". |
| 636 PressRepeatedlyUntilUtterance(ui::VKEY_OEM_2, "Find in page."); |
| 637 while (speech_monitor_.GetNextUtterance() != "Enter a search query.") { |
572 } | 638 } |
573 | 639 |
| 640 // Press Esc to exit Find in Page mode. |
| 641 SendKeyPress(ui::VKEY_ESCAPE); |
| 642 EXPECT_EQ("Exited", speech_monitor_.GetNextUtterance()); |
| 643 while (speech_monitor_.GetNextUtterance() != "Find in page.") { |
| 644 } |
| 645 } |
| 646 |
| 647 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNextStickyMode) { |
| 648 LoadChromeVoxAndThenNavigateToURL( |
| 649 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>" |
| 650 "<!-- chromevox_next_test -->")); |
| 651 while ("Button" != speech_monitor_.GetNextUtterance()) { |
| 652 } |
| 653 |
| 654 // Press the sticky-key sequence: Search Search. |
574 SendKeyPress(ui::VKEY_LWIN); | 655 SendKeyPress(ui::VKEY_LWIN); |
575 | 656 |
576 // Sticky key has a minimum 100 ms check to prevent key repeat from toggling | 657 // Sticky key has a minimum 100 ms check to prevent key repeat from toggling |
577 // it. | 658 // it. |
578 content::BrowserThread::PostDelayedTask( | 659 content::BrowserThread::PostDelayedTask( |
579 content::BrowserThread::UI, FROM_HERE, | 660 content::BrowserThread::UI, FROM_HERE, |
580 base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress, | 661 base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress, |
581 base::Unretained(this), ui::VKEY_LWIN), | 662 base::Unretained(this), ui::VKEY_LWIN), |
582 base::TimeDelta::FromMilliseconds(200)); | 663 base::TimeDelta::FromMilliseconds(200)); |
583 | 664 |
| 665 EXPECT_EQ("Sticky mode enabled", speech_monitor_.GetNextUtterance()); |
| 666 |
| 667 SendKeyPress(ui::VKEY_H); |
| 668 while ("No next heading." != speech_monitor_.GetNextUtterance()) { |
| 669 } |
| 670 |
| 671 SendKeyPress(ui::VKEY_LWIN); |
| 672 |
| 673 // Sticky key has a minimum 100 ms check to prevent key repeat from toggling |
| 674 // it. |
| 675 content::BrowserThread::PostDelayedTask( |
| 676 content::BrowserThread::UI, FROM_HERE, |
| 677 base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress, |
| 678 base::Unretained(this), ui::VKEY_LWIN), |
| 679 base::TimeDelta::FromMilliseconds(200)); |
| 680 |
584 while ("Sticky mode disabled" != speech_monitor_.GetNextUtterance()) { | 681 while ("Sticky mode disabled" != speech_monitor_.GetNextUtterance()) { |
585 } | 682 } |
586 } | 683 } |
587 | 684 |
588 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { | 685 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { |
589 EnableChromeVox(); | 686 EnableChromeVox(); |
590 SimulateTouchScreenInChromeVox(); | 687 SimulateTouchScreenInChromeVox(); |
591 | 688 |
592 // Send an accessibility hover event on the system tray, which is | 689 // Send an accessibility hover event on the system tray, which is |
593 // what we get when you tap it on a touch screen when ChromeVox is on. | 690 // what we get when you tap it on a touch screen when ChromeVox is on. |
(...skipping 28 matching lines...) Expand all Loading... |
622 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest); | 719 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest); |
623 }; | 720 }; |
624 | 721 |
625 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { | 722 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { |
626 EnableChromeVox(); | 723 EnableChromeVox(); |
627 | 724 |
628 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); | 725 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); |
629 | 726 |
630 EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance()); | 727 EXPECT_EQ("Reload", speech_monitor_.GetNextUtterance()); |
631 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); | 728 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance()); |
| 729 EXPECT_EQ("main", speech_monitor_.GetNextUtterance()); |
| 730 EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance()); |
| 731 EXPECT_TRUE( |
| 732 base::MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*")); |
632 } | 733 } |
633 | 734 |
634 // | 735 // |
635 // Spoken feedback tests of the out-of-box experience. | 736 // Spoken feedback tests of the out-of-box experience. |
636 // | 737 // |
637 | 738 |
638 class OobeSpokenFeedbackTest : public LoginManagerTest { | 739 class OobeSpokenFeedbackTest : public LoginManagerTest { |
639 protected: | 740 protected: |
640 OobeSpokenFeedbackTest() : LoginManagerTest(false) {} | 741 OobeSpokenFeedbackTest() : LoginManagerTest(false) {} |
641 ~OobeSpokenFeedbackTest() override {} | 742 ~OobeSpokenFeedbackTest() override {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 785 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
685 window, ui::VKEY_TAB, false, true /*shift*/, false, false)); | 786 window, ui::VKEY_TAB, false, true /*shift*/, false, false)); |
686 while (speech_monitor_.GetNextUtterance() != "Select your language:") { | 787 while (speech_monitor_.GetNextUtterance() != "Select your language:") { |
687 } | 788 } |
688 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); | 789 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); |
689 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), | 790 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), |
690 "Combo box * of *")); | 791 "Combo box * of *")); |
691 } | 792 } |
692 | 793 |
693 } // namespace chromeos | 794 } // namespace chromeos |
OLD | NEW |