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 "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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
55 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); | 55 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDownOnMainThread() OVERRIDE { | 58 virtual void TearDownOnMainThread() OVERRIDE { |
59 AccessibilityManager::SetBrailleControllerForTest(NULL); | 59 AccessibilityManager::SetBrailleControllerForTest(NULL); |
60 } | 60 } |
61 | 61 |
62 void SendKeyPress(ui::KeyboardCode key) { | 62 void SendKeyPress(ui::KeyboardCode key) { |
63 ASSERT_NO_FATAL_FAILURE( | 63 gfx::NativeWindow root_window = |
64 ASSERT_TRUE( | 64 ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
65 ui_test_utils::SendKeyPressToWindowSync( | 65 ASSERT_TRUE( |
66 NULL, key, false, false, false, false))); | 66 ui_test_utils::SendKeyPressToWindowSync( |
67 } | 67 root_window, key, false, false, false, false)); |
68 | |
69 void SendKeyPressWithControl(ui::KeyboardCode key) { | |
70 ASSERT_NO_FATAL_FAILURE( | |
71 ASSERT_TRUE( | |
72 ui_test_utils::SendKeyPressToWindowSync( | |
73 NULL, key, true, false, false, false))); | |
74 } | |
75 | |
76 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) { | |
77 ASSERT_NO_FATAL_FAILURE( | |
78 ASSERT_TRUE( | |
79 ui_test_utils::SendKeyPressToWindowSync( | |
80 NULL, key, false, true, false, true))); | |
81 } | 68 } |
82 | 69 |
83 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { | 70 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { |
84 extensions::ExtensionHost* host = | 71 extensions::ExtensionHost* host = |
85 extensions::ExtensionSystem::Get(browser()->profile())-> | 72 extensions::ExtensionSystem::Get(browser()->profile())-> |
86 process_manager()->GetBackgroundHostForExtension( | 73 process_manager()->GetBackgroundHostForExtension( |
87 extension_misc::kChromeVoxExtensionId); | 74 extension_misc::kChromeVoxExtensionId); |
88 CHECK(content::ExecuteScript(host->host_contents(), script)); | 75 CHECK(content::ExecuteScript(host->host_contents(), script)); |
89 } | 76 } |
90 | 77 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 SendKeyPress(ui::VKEY_Y); | 231 SendKeyPress(ui::VKEY_Y); |
245 EXPECT_EQ("y", monitor.GetNextUtterance()); | 232 EXPECT_EQ("y", monitor.GetNextUtterance()); |
246 | 233 |
247 SendKeyPress(ui::VKEY_Z); | 234 SendKeyPress(ui::VKEY_Z); |
248 EXPECT_EQ("z", monitor.GetNextUtterance()); | 235 EXPECT_EQ("z", monitor.GetNextUtterance()); |
249 | 236 |
250 SendKeyPress(ui::VKEY_BACK); | 237 SendKeyPress(ui::VKEY_BACK); |
251 EXPECT_EQ("z", monitor.GetNextUtterance()); | 238 EXPECT_EQ("z", monitor.GetNextUtterance()); |
252 } | 239 } |
253 | 240 |
254 // http://crbug.com/410534 | |
255 #if defined(USE_OZONE) | |
256 #define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch | |
257 #else | |
258 #define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch | |
259 #endif | |
260 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) { | |
261 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | |
262 | |
263 SpeechMonitor monitor; | |
264 AccessibilityManager::Get()->EnableSpokenFeedback( | |
265 true, ash::A11Y_NOTIFICATION_NONE); | |
266 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | |
267 | |
268 ui_test_utils::NavigateToURL( | |
269 browser(), | |
270 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); | |
271 while (true) { | |
272 std::string utterance = monitor.GetNextUtterance(); | |
273 if (utterance == "Click me") | |
274 break; | |
275 } | |
276 EXPECT_EQ("Button", monitor.GetNextUtterance()); | |
277 | |
278 // Press Search+Shift+/ to enter ChromeVox's "find in page". | |
279 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2); | |
280 EXPECT_EQ("Find in page.", monitor.GetNextUtterance()); | |
281 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance()); | |
282 } | |
283 | |
284 // http://crbug.com/410534 | |
285 #if defined(USE_OZONE) | |
286 #define MAYBE_ChromeVoxPrefixKey DISABLED_ChromeVoxPrefixKey | |
287 #else | |
288 #define MAYBE_ChromeVoxPrefixKey ChromeVoxPrefixKey | |
289 #endif | |
290 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) { | |
291 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | |
292 | |
293 SpeechMonitor monitor; | |
294 AccessibilityManager::Get()->EnableSpokenFeedback( | |
295 true, ash::A11Y_NOTIFICATION_NONE); | |
296 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | |
297 | |
298 ui_test_utils::NavigateToURL( | |
299 browser(), | |
300 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>")); | |
301 while (true) { | |
302 std::string utterance = monitor.GetNextUtterance(); | |
303 if (utterance == "Click me") | |
304 break; | |
305 } | |
306 EXPECT_EQ("Button", 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.", monitor.GetNextUtterance()); | |
313 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance()); | |
314 } | |
315 | |
316 // http://crbug.com/410534 | |
317 #if defined(USE_OZONE) | |
318 #define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect | |
319 #else | |
320 #define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect | |
321 #endif | |
322 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) { | |
323 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | |
324 | |
325 SpeechMonitor monitor; | |
326 AccessibilityManager::Get()->EnableSpokenFeedback( | |
327 true, ash::A11Y_NOTIFICATION_NONE); | |
328 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | |
329 | |
330 ui_test_utils::NavigateToURL( | |
331 browser(), | |
332 GURL("data:text/html;charset=utf-8," | |
333 "<h1>Title</h1>" | |
334 "<button autofocus>Click me</button>")); | |
335 while (true) { | |
336 std::string utterance = monitor.GetNextUtterance(); | |
337 if (utterance == "Click me") | |
338 break; | |
339 } | |
340 EXPECT_EQ("Button", monitor.GetNextUtterance()); | |
341 | |
342 // Press Search+Shift+Up to navigate to the previous item. | |
343 SendKeyPressWithSearchAndShift(ui::VKEY_UP); | |
344 EXPECT_EQ("Title", monitor.GetNextUtterance()); | |
345 EXPECT_EQ("Heading 1", monitor.GetNextUtterance()); | |
346 | |
347 // Press Search+Shift+S to select the text. | |
348 SendKeyPressWithSearchAndShift(ui::VKEY_S); | |
349 EXPECT_EQ("Start selection", monitor.GetNextUtterance()); | |
350 EXPECT_EQ("Title", monitor.GetNextUtterance()); | |
351 EXPECT_EQ(", selected", monitor.GetNextUtterance()); | |
352 | |
353 // Press again to end the selection. | |
354 SendKeyPressWithSearchAndShift(ui::VKEY_S); | |
355 EXPECT_EQ("End selection", monitor.GetNextUtterance()); | |
356 EXPECT_EQ("Title", monitor.GetNextUtterance()); | |
357 } | |
358 | |
359 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { | 241 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { |
360 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 242 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
361 | 243 |
362 SpeechMonitor monitor; | 244 SpeechMonitor monitor; |
363 AccessibilityManager::Get()->EnableSpokenFeedback( | 245 AccessibilityManager::Get()->EnableSpokenFeedback( |
364 true, ash::A11Y_NOTIFICATION_NONE); | 246 true, ash::A11Y_NOTIFICATION_NONE); |
365 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 247 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
366 DisableEarcons(); | 248 DisableEarcons(); |
367 | 249 |
368 SimulateTouchScreenInChromeVox(); | 250 SimulateTouchScreenInChromeVox(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); | 339 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); |
458 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); | 340 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); |
459 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); | 341 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); |
460 ASSERT_TRUE( | 342 ASSERT_TRUE( |
461 ui_test_utils::SendKeyPressToWindowSync( | 343 ui_test_utils::SendKeyPressToWindowSync( |
462 window, ui::VKEY_TAB, false, false, false, false)); | 344 window, ui::VKEY_TAB, false, false, false, false)); |
463 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); | 345 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); |
464 } | 346 } |
465 | 347 |
466 } // namespace chromeos | 348 } // namespace chromeos |
OLD | NEW |