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

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

Issue 490443002: Add test for ChromeVox keyboard commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ASSERT_NO_FATAL_FAILURE Created 6 years, 4 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 | Annotate | Revision Log
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 gfx::NativeWindow root_window = 63 gfx::NativeWindow root_window =
64 ash::Shell::GetInstance()->GetPrimaryRootWindow(); 64 ash::Shell::GetInstance()->GetPrimaryRootWindow();
65 ASSERT_TRUE( 65 ASSERT_NO_FATAL_FAILURE(
66 ui_test_utils::SendKeyPressToWindowSync( 66 ASSERT_TRUE(
67 root_window, key, false, false, false, false)); 67 ui_test_utils::SendKeyPressToWindowSync(
68 root_window, key, false, false, false, false)));
69 }
70
71 void SendKeyPressWithControl(ui::KeyboardCode key) {
72 gfx::NativeWindow root_window =
73 ash::Shell::GetInstance()->GetPrimaryRootWindow();
74 ASSERT_NO_FATAL_FAILURE(
75 ASSERT_TRUE(
76 ui_test_utils::SendKeyPressToWindowSync(
77 root_window, key, true, false, false, false)));
78 }
79
80 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) {
81 gfx::NativeWindow root_window =
82 ash::Shell::GetInstance()->GetPrimaryRootWindow();
83 ASSERT_NO_FATAL_FAILURE(
84 ASSERT_TRUE(
85 ui_test_utils::SendKeyPressToWindowSync(
86 root_window, key, false, true, false, true)));
68 } 87 }
69 88
70 void SimulateTouchScreenInChromeVox() { 89 void SimulateTouchScreenInChromeVox() {
71 // ChromeVox looks at whether 'ontouchstart' exists to know whether 90 // ChromeVox looks at whether 'ontouchstart' exists to know whether
72 // or not it should respond to hover events. Fake it so that touch 91 // or not it should respond to hover events. Fake it so that touch
73 // exploration events get spoken. 92 // exploration events get spoken.
74 extensions::ExtensionHost* host = 93 extensions::ExtensionHost* host =
75 extensions::ExtensionSystem::Get(browser()->profile())-> 94 extensions::ExtensionSystem::Get(browser()->profile())->
76 process_manager()->GetBackgroundHostForExtension( 95 process_manager()->GetBackgroundHostForExtension(
77 extension_misc::kChromeVoxExtensionId); 96 extension_misc::kChromeVoxExtensionId);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SendKeyPress(ui::VKEY_Y); 236 SendKeyPress(ui::VKEY_Y);
218 EXPECT_EQ("y", monitor.GetNextUtterance()); 237 EXPECT_EQ("y", monitor.GetNextUtterance());
219 238
220 SendKeyPress(ui::VKEY_Z); 239 SendKeyPress(ui::VKEY_Z);
221 EXPECT_EQ("z", monitor.GetNextUtterance()); 240 EXPECT_EQ("z", monitor.GetNextUtterance());
222 241
223 SendKeyPress(ui::VKEY_BACK); 242 SendKeyPress(ui::VKEY_BACK);
224 EXPECT_EQ("z", monitor.GetNextUtterance()); 243 EXPECT_EQ("z", monitor.GetNextUtterance());
225 } 244 }
226 245
246 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxShiftSearch) {
247 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
248
249 SpeechMonitor monitor;
250 AccessibilityManager::Get()->EnableSpokenFeedback(
251 true, ash::A11Y_NOTIFICATION_NONE);
252 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
253
254 ui_test_utils::NavigateToURL(
255 browser(),
256 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
257 while (true) {
258 std::string utterance = monitor.GetNextUtterance();
259 if (utterance == "Click me")
260 break;
261 }
262 EXPECT_EQ("Button", monitor.GetNextUtterance());
263
264 // Press Search+Shift+/ to enter ChromeVox's "find in page".
265 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
266 EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
267 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
268 }
269
270 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxPrefixKey) {
271 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
272
273 SpeechMonitor monitor;
274 AccessibilityManager::Get()->EnableSpokenFeedback(
275 true, ash::A11Y_NOTIFICATION_NONE);
276 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
277
278 ui_test_utils::NavigateToURL(
279 browser(),
280 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
281 while (true) {
282 std::string utterance = monitor.GetNextUtterance();
283 if (utterance == "Click me")
284 break;
285 }
286 EXPECT_EQ("Button", monitor.GetNextUtterance());
287
288 // Press the prefix key Ctrl+';' followed by '/'
289 // to enter ChromeVox's "find in page".
290 SendKeyPressWithControl(ui::VKEY_OEM_1);
291 SendKeyPress(ui::VKEY_OEM_2);
292 EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
293 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
294 }
David Tseng 2014/08/19 17:48:38 Want to also add a test for search+shift+s as disc
dmazzoni 2014/08/19 20:16:53 Done.
295
227 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { 296 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
228 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 297 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
229 298
230 SpeechMonitor monitor; 299 SpeechMonitor monitor;
231 AccessibilityManager::Get()->EnableSpokenFeedback( 300 AccessibilityManager::Get()->EnableSpokenFeedback(
232 true, ash::A11Y_NOTIFICATION_NONE); 301 true, ash::A11Y_NOTIFICATION_NONE);
233 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 302 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
234 303
235 SimulateTouchScreenInChromeVox(); 304 SimulateTouchScreenInChromeVox();
236 305
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); 392 EXPECT_EQ("Select your language:", monitor.GetNextUtterance());
324 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); 393 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance());
325 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); 394 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *"));
326 ASSERT_TRUE( 395 ASSERT_TRUE(
327 ui_test_utils::SendKeyPressToWindowSync( 396 ui_test_utils::SendKeyPressToWindowSync(
328 window, ui::VKEY_TAB, false, false, false, false)); 397 window, ui::VKEY_TAB, false, false, false, false));
329 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); 398 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance());
330 } 399 }
331 400
332 } // namespace chromeos 401 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/ui_controls_factory_aurax11.cc » ('j') | ui/aura/test/ui_controls_factory_aurax11.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698