Chromium Code Reviews| 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 "ash/system/tray/system_tray.h" | |
| 8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 12 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 13 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
| 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 14 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #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" |
| 18 #include "chrome/browser/speech/tts_controller.h" | 19 #include "chrome/browser/speech/tts_controller.h" |
| 19 #include "chrome/browser/speech/tts_platform.h" | 20 #include "chrome/browser/speech/tts_platform.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/extensions/extension_constants.h" | |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/interactive_test_utils.h" | 27 #include "chrome/test/base/interactive_test_utils.h" |
| 26 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 29 #include "chromeos/login/user_names.h" | 31 #include "chromeos/login/user_names.h" |
| 30 #include "content/public/common/url_constants.h" | 32 #include "content/public/common/url_constants.h" |
| 33 #include "content/public/test/browser_test_utils.h" | |
| 31 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
| 35 #include "extensions/browser/extension_host.h" | |
| 36 #include "extensions/browser/process_manager.h" | |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "ui/base/test/ui_controls.h" | 38 #include "ui/base/test/ui_controls.h" |
| 34 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 35 | 40 |
| 36 using extensions::api::braille_display_private::StubBrailleController; | 41 using extensions::api::braille_display_private::StubBrailleController; |
| 37 | 42 |
| 38 namespace chromeos { | 43 namespace chromeos { |
| 39 | 44 |
| 40 // | 45 // |
| 41 // Spoken feedback tests only in a logged in user's window. | 46 // Spoken feedback tests only in a logged in user's window. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 55 } | 60 } |
| 56 | 61 |
| 57 void SendKeyPress(ui::KeyboardCode key) { | 62 void SendKeyPress(ui::KeyboardCode key) { |
| 58 gfx::NativeWindow root_window = | 63 gfx::NativeWindow root_window = |
| 59 ash::Shell::GetInstance()->GetPrimaryRootWindow(); | 64 ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
| 60 ASSERT_TRUE( | 65 ASSERT_TRUE( |
| 61 ui_test_utils::SendKeyPressToWindowSync( | 66 ui_test_utils::SendKeyPressToWindowSync( |
| 62 root_window, key, false, false, false, false)); | 67 root_window, key, false, false, false, false)); |
| 63 } | 68 } |
| 64 | 69 |
| 70 void SimulateTouchScreenInChromeVox() { | |
| 71 // ChromeVox looks at whether 'ontouchstart' exists to know whether | |
| 72 // or not it should respond to hover events. Fake it so that touch | |
| 73 // exploration events get spoken. | |
| 74 extensions::ExtensionHost* host = | |
| 75 extensions::ExtensionSystem::Get(browser()->profile())-> | |
| 76 process_manager()->GetBackgroundHostForExtension( | |
| 77 extension_misc::kChromeVoxExtensionId); | |
| 78 CHECK(content::ExecuteScript( | |
| 79 host->host_contents(), | |
| 80 "window.ontouchstart = function() {};")); | |
| 81 } | |
| 82 | |
| 65 private: | 83 private: |
| 66 StubBrailleController braille_controller_; | 84 StubBrailleController braille_controller_; |
| 67 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); | 85 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); |
| 68 }; | 86 }; |
| 69 | 87 |
| 70 // http://crbug.com/396507 | 88 // http://crbug.com/396507 |
| 71 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, DISABLED_AddBookmark) { | 89 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, DISABLED_AddBookmark) { |
| 72 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 90 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 73 | 91 |
| 74 SpeechMonitor monitor; | 92 SpeechMonitor monitor; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 SendKeyPress(ui::VKEY_Y); | 217 SendKeyPress(ui::VKEY_Y); |
| 200 EXPECT_EQ("y", monitor.GetNextUtterance()); | 218 EXPECT_EQ("y", monitor.GetNextUtterance()); |
| 201 | 219 |
| 202 SendKeyPress(ui::VKEY_Z); | 220 SendKeyPress(ui::VKEY_Z); |
| 203 EXPECT_EQ("z", monitor.GetNextUtterance()); | 221 EXPECT_EQ("z", monitor.GetNextUtterance()); |
| 204 | 222 |
| 205 SendKeyPress(ui::VKEY_BACK); | 223 SendKeyPress(ui::VKEY_BACK); |
| 206 EXPECT_EQ("z", monitor.GetNextUtterance()); | 224 EXPECT_EQ("z", monitor.GetNextUtterance()); |
| 207 } | 225 } |
| 208 | 226 |
| 227 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { | |
| 228 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | |
| 229 | |
| 230 SpeechMonitor monitor; | |
| 231 AccessibilityManager::Get()->EnableSpokenFeedback( | |
| 232 true, ash::A11Y_NOTIFICATION_NONE); | |
| 233 printf("*** Skipping ChromeVox enabled message\n"); | |
| 234 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | |
| 235 printf("*** Skipped\n"); | |
| 236 | |
|
evy1
2014/07/25 22:02:13
Whoops - you forgot to remove your printf statemen
dmazzoni
2014/07/25 22:05:22
Done.
| |
| 237 SimulateTouchScreenInChromeVox(); | |
| 238 | |
| 239 // Send an accessibility hover event on the system tray, which is | |
| 240 // what we get when you tap it on a touch screen when ChromeVox is on. | |
| 241 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | |
| 242 printf("Tray: %p\n", tray); | |
| 243 tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); | |
| 244 | |
| 245 EXPECT_EQ("Status tray,", monitor.GetNextUtterance()); | |
| 246 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "time*,")); | |
| 247 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Battery*,")); | |
| 248 EXPECT_EQ("button", monitor.GetNextUtterance()); | |
| 249 } | |
| 250 | |
| 209 // | 251 // |
| 210 // Spoken feedback tests that run only in guest mode. | 252 // Spoken feedback tests that run only in guest mode. |
| 211 // | 253 // |
| 212 | 254 |
| 213 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest { | 255 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest { |
| 214 protected: | 256 protected: |
| 215 GuestSpokenFeedbackTest() {} | 257 GuestSpokenFeedbackTest() {} |
| 216 virtual ~GuestSpokenFeedbackTest() {} | 258 virtual ~GuestSpokenFeedbackTest() {} |
| 217 | 259 |
| 218 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 260 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); | 326 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); |
| 285 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); | 327 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); |
| 286 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); | 328 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); |
| 287 ASSERT_TRUE( | 329 ASSERT_TRUE( |
| 288 ui_test_utils::SendKeyPressToWindowSync( | 330 ui_test_utils::SendKeyPressToWindowSync( |
| 289 window, ui::VKEY_TAB, false, false, false, false)); | 331 window, ui::VKEY_TAB, false, false, false, false)); |
| 290 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); | 332 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); |
| 291 } | 333 } |
| 292 | 334 |
| 293 } // namespace chromeos | 335 } // namespace chromeos |
| OLD | NEW |