| 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/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/common/accessibility_types.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/strings/pattern.h" | 14 #include "base/strings/pattern.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 18 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 18 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 19 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 RunJavaScriptInChromeVoxBackgroundPage( | 115 RunJavaScriptInChromeVoxBackgroundPage( |
| 115 "cvox.ChromeVox.earcons.playEarcon = function() {};"); | 116 "cvox.ChromeVox.earcons.playEarcon = function() {};"); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void EnableChromeVox() { | 119 void EnableChromeVox() { |
| 119 // Test setup. | 120 // Test setup. |
| 120 // Enable ChromeVox, skip welcome message, and disable earcons. | 121 // Enable ChromeVox, skip welcome message, and disable earcons. |
| 121 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 122 ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 122 | 123 |
| 123 AccessibilityManager::Get()->EnableSpokenFeedback( | 124 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 124 true, ui::A11Y_NOTIFICATION_NONE); | 125 true, ash::A11Y_NOTIFICATION_NONE); |
| 125 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); | 126 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); |
| 126 DisableEarcons(); | 127 DisableEarcons(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void LoadChromeVoxAndThenNavigateToURL(const GURL& url) { | 130 void LoadChromeVoxAndThenNavigateToURL(const GURL& url) { |
| 130 // The goal of this helper function is to avoid race conditions between | 131 // The goal of this helper function is to avoid race conditions between |
| 131 // the page loading and the ChromeVox extension loading and fully | 132 // the page loading and the ChromeVox extension loading and fully |
| 132 // initializing. To do this, we first load a test url that repeatedly | 133 // initializing. To do this, we first load a test url that repeatedly |
| 133 // asks ChromeVox to speak 'ready', then we load ChromeVox and block | 134 // asks ChromeVox to speak 'ready', then we load ChromeVox and block |
| 134 // until we get that 'ready' speech. | 135 // until we get that 'ready' speech. |
| 135 | 136 |
| 136 ui_test_utils::NavigateToURL( | 137 ui_test_utils::NavigateToURL( |
| 137 browser(), | 138 browser(), |
| 138 GURL("data:text/html;charset=utf-8," | 139 GURL("data:text/html;charset=utf-8," |
| 139 "<script>" | 140 "<script>" |
| 140 "window.setInterval(function() {" | 141 "window.setInterval(function() {" |
| 141 " try {" | 142 " try {" |
| 142 " cvox.Api.speak('ready');" | 143 " cvox.Api.speak('ready');" |
| 143 " } catch (e) {}" | 144 " } catch (e) {}" |
| 144 "}, 100);" | 145 "}, 100);" |
| 145 "</script>")); | 146 "</script>")); |
| 146 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 147 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 147 AccessibilityManager::Get()->EnableSpokenFeedback( | 148 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 148 true, ui::A11Y_NOTIFICATION_NONE); | 149 true, ash::A11Y_NOTIFICATION_NONE); |
| 149 | 150 |
| 150 // Block until we get "ready". | 151 // Block until we get "ready". |
| 151 while (speech_monitor_.GetNextUtterance() != "ready") { | 152 while (speech_monitor_.GetNextUtterance() != "ready") { |
| 152 } | 153 } |
| 153 | 154 |
| 154 // Now load the requested url. | 155 // Now load the requested url. |
| 155 ui_test_utils::NavigateToURL(browser(), url); | 156 ui_test_utils::NavigateToURL(browser(), url); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key, | 159 void PressRepeatedlyUntilUtterance(ui::KeyboardCode key, |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 704 |
| 704 LoginDisplayHost* login_display_host = LoginDisplayHost::default_host(); | 705 LoginDisplayHost* login_display_host = LoginDisplayHost::default_host(); |
| 705 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); | 706 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); |
| 706 views::Widget* widget = web_ui_login_view->GetWidget(); | 707 views::Widget* widget = web_ui_login_view->GetWidget(); |
| 707 gfx::NativeWindow window = widget->GetNativeWindow(); | 708 gfx::NativeWindow window = widget->GetNativeWindow(); |
| 708 | 709 |
| 709 // We expect to be in the language select dropdown for this test to work, | 710 // We expect to be in the language select dropdown for this test to work, |
| 710 // so make sure that's the case. | 711 // so make sure that's the case. |
| 711 js_checker().ExecuteAsync("$('language-select').focus()"); | 712 js_checker().ExecuteAsync("$('language-select').focus()"); |
| 712 AccessibilityManager::Get()->EnableSpokenFeedback( | 713 AccessibilityManager::Get()->EnableSpokenFeedback( |
| 713 true, ui::A11Y_NOTIFICATION_NONE); | 714 true, ash::A11Y_NOTIFICATION_NONE); |
| 714 ASSERT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); | 715 ASSERT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage()); |
| 715 // There's no guarantee that ChromeVox speaks anything when injected after | 716 // There's no guarantee that ChromeVox speaks anything when injected after |
| 716 // the page loads, which is by design. Tab forward and then backward | 717 // the page loads, which is by design. Tab forward and then backward |
| 717 // to make sure we get the right feedback from the language and keyboard | 718 // to make sure we get the right feedback from the language and keyboard |
| 718 // selection fields. | 719 // selection fields. |
| 719 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 720 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 720 window, ui::VKEY_TAB, false, false, false, false)); | 721 window, ui::VKEY_TAB, false, false, false, false)); |
| 721 | 722 |
| 722 while (speech_monitor_.GetNextUtterance() != "Select your keyboard:") { | 723 while (speech_monitor_.GetNextUtterance() != "Select your keyboard:") { |
| 723 } | 724 } |
| 724 EXPECT_EQ("U S", speech_monitor_.GetNextUtterance()); | 725 EXPECT_EQ("U S", speech_monitor_.GetNextUtterance()); |
| 725 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), | 726 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), |
| 726 "Combo box * of *")); | 727 "Combo box * of *")); |
| 727 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 728 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 728 window, ui::VKEY_TAB, false, true /*shift*/, false, false)); | 729 window, ui::VKEY_TAB, false, true /*shift*/, false, false)); |
| 729 while (speech_monitor_.GetNextUtterance() != "Select your language:") { | 730 while (speech_monitor_.GetNextUtterance() != "Select your language:") { |
| 730 } | 731 } |
| 731 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); | 732 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance()); |
| 732 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), | 733 EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), |
| 733 "Combo box * of *")); | 734 "Combo box * of *")); |
| 734 } | 735 } |
| 735 | 736 |
| 736 } // namespace chromeos | 737 } // namespace chromeos |
| OLD | NEW |