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

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: 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
« no previous file with comments | « no previous file | ui/aura/test/ui_controls_factory_aurax11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_TRUE(
66 ui_test_utils::SendKeyPressToWindowSync( 66 ui_test_utils::SendKeyPressToWindowSync(
67 root_window, key, false, false, false, false)); 67 root_window, key, false, false, false, false));
68 } 68 }
69 69
70 void SendKeyPressWithControl(ui::KeyboardCode key) {
sky 2014/08/19 16:27:13 You need to wrap calls to these in ASSERT_NO_FATAL
dmazzoni 2014/08/19 16:53:55 Done.
71 gfx::NativeWindow root_window =
72 ash::Shell::GetInstance()->GetPrimaryRootWindow();
sky 2014/08/19 16:27:13 Why is this sending to ash?
dmazzoni 2014/08/19 16:53:55 These are very high-level integration tests that a
sky 2014/08/19 19:47:55 If you're saying the window doesn't matter, then s
73 ASSERT_TRUE(
74 ui_test_utils::SendKeyPressToWindowSync(
75 root_window, key, true, false, false, false));
76 }
77
78 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) {
79 gfx::NativeWindow root_window =
80 ash::Shell::GetInstance()->GetPrimaryRootWindow();
81 ASSERT_TRUE(
82 ui_test_utils::SendKeyPressToWindowSync(
83 root_window, key, false, true, false, true));
84 }
85
70 void SimulateTouchScreenInChromeVox() { 86 void SimulateTouchScreenInChromeVox() {
71 // ChromeVox looks at whether 'ontouchstart' exists to know whether 87 // ChromeVox looks at whether 'ontouchstart' exists to know whether
72 // or not it should respond to hover events. Fake it so that touch 88 // or not it should respond to hover events. Fake it so that touch
73 // exploration events get spoken. 89 // exploration events get spoken.
74 extensions::ExtensionHost* host = 90 extensions::ExtensionHost* host =
75 extensions::ExtensionSystem::Get(browser()->profile())-> 91 extensions::ExtensionSystem::Get(browser()->profile())->
76 process_manager()->GetBackgroundHostForExtension( 92 process_manager()->GetBackgroundHostForExtension(
77 extension_misc::kChromeVoxExtensionId); 93 extension_misc::kChromeVoxExtensionId);
78 CHECK(content::ExecuteScript( 94 CHECK(content::ExecuteScript(
79 host->host_contents(), 95 host->host_contents(),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SendKeyPress(ui::VKEY_Y); 233 SendKeyPress(ui::VKEY_Y);
218 EXPECT_EQ("y", monitor.GetNextUtterance()); 234 EXPECT_EQ("y", monitor.GetNextUtterance());
219 235
220 SendKeyPress(ui::VKEY_Z); 236 SendKeyPress(ui::VKEY_Z);
221 EXPECT_EQ("z", monitor.GetNextUtterance()); 237 EXPECT_EQ("z", monitor.GetNextUtterance());
222 238
223 SendKeyPress(ui::VKEY_BACK); 239 SendKeyPress(ui::VKEY_BACK);
224 EXPECT_EQ("z", monitor.GetNextUtterance()); 240 EXPECT_EQ("z", monitor.GetNextUtterance());
225 } 241 }
226 242
243 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxShiftSearch) {
244 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
245
246 SpeechMonitor monitor;
247 AccessibilityManager::Get()->EnableSpokenFeedback(
248 true, ash::A11Y_NOTIFICATION_NONE);
249 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
250
251 ui_test_utils::NavigateToURL(
252 browser(),
253 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
254 while (true) {
255 std::string utterance = monitor.GetNextUtterance();
256 if (utterance == "Click me")
257 break;
258 }
259 EXPECT_EQ("Button", monitor.GetNextUtterance());
260
261 // Press Search+Shift+/ to enter ChromeVox's "find in page".
262 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
263 EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
264 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
265 }
266
267 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxPrefixKey) {
268 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
269
270 SpeechMonitor monitor;
271 AccessibilityManager::Get()->EnableSpokenFeedback(
272 true, ash::A11Y_NOTIFICATION_NONE);
273 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
274
275 ui_test_utils::NavigateToURL(
276 browser(),
277 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
278 while (true) {
279 std::string utterance = monitor.GetNextUtterance();
280 if (utterance == "Click me")
281 break;
282 }
283 EXPECT_EQ("Button", monitor.GetNextUtterance());
284
285 // Press the prefix key Ctrl+';' followed by '/'
286 // to enter ChromeVox's "find in page".
287 SendKeyPressWithControl(ui::VKEY_OEM_1);
288 SendKeyPress(ui::VKEY_OEM_2);
289 EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
290 EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
291 }
292
227 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { 293 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
228 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 294 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
229 295
230 SpeechMonitor monitor; 296 SpeechMonitor monitor;
231 AccessibilityManager::Get()->EnableSpokenFeedback( 297 AccessibilityManager::Get()->EnableSpokenFeedback(
232 true, ash::A11Y_NOTIFICATION_NONE); 298 true, ash::A11Y_NOTIFICATION_NONE);
233 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 299 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
234 300
235 SimulateTouchScreenInChromeVox(); 301 SimulateTouchScreenInChromeVox();
236 302
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); 389 EXPECT_EQ("Select your language:", monitor.GetNextUtterance());
324 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); 390 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance());
325 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); 391 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *"));
326 ASSERT_TRUE( 392 ASSERT_TRUE(
327 ui_test_utils::SendKeyPressToWindowSync( 393 ui_test_utils::SendKeyPressToWindowSync(
328 window, ui::VKEY_TAB, false, false, false, false)); 394 window, ui::VKEY_TAB, false, false, false, false));
329 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); 395 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance());
330 } 396 }
331 397
332 } // namespace chromeos 398 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/ui_controls_factory_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698