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

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: Real fix that works Created 6 years, 3 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"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
13 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" 13 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 14 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #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"
19 #include "chrome/browser/speech/tts_controller.h" 19 #include "chrome/browser/speech/tts_controller.h"
20 #include "chrome/browser/speech/tts_platform.h" 20 #include "chrome/browser/speech/tts_platform.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
26 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/interactive_test_utils.h" 28 #include "chrome/test/base/interactive_test_utils.h"
28 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
29 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
30 #include "chromeos/chromeos_switches.h" 31 #include "chromeos/chromeos_switches.h"
31 #include "chromeos/login/user_names.h" 32 #include "chromeos/login/user_names.h"
32 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
33 #include "content/public/test/browser_test_utils.h" 34 #include "content/public/test/browser_test_utils.h"
(...skipping 19 matching lines...) Expand all
53 54
54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 55 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
55 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); 56 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
56 } 57 }
57 58
58 virtual void TearDownOnMainThread() OVERRIDE { 59 virtual void TearDownOnMainThread() OVERRIDE {
59 AccessibilityManager::SetBrailleControllerForTest(NULL); 60 AccessibilityManager::SetBrailleControllerForTest(NULL);
60 } 61 }
61 62
62 void SendKeyPress(ui::KeyboardCode key) { 63 void SendKeyPress(ui::KeyboardCode key) {
63 gfx::NativeWindow root_window = 64 LOG(ERROR) << "SendKeyPress " << key;
64 ash::Shell::GetInstance()->GetPrimaryRootWindow(); 65 ASSERT_NO_FATAL_FAILURE(
65 ASSERT_TRUE( 66 ASSERT_TRUE(
66 ui_test_utils::SendKeyPressToWindowSync( 67 ui_test_utils::SendKeyPressToWindowSync(
67 root_window, key, false, false, false, false)); 68 NULL, key, false, false, false, false)));
69 }
70
71 void SendKeyPressWithControl(ui::KeyboardCode key) {
72 LOG(ERROR) << "SendKeyPressWithControl " << key;
73 ASSERT_NO_FATAL_FAILURE(
74 ASSERT_TRUE(
75 ui_test_utils::SendKeyPressToWindowSync(
76 NULL, key, true, false, false, false)));
77 }
78
79 void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) {
80 LOG(ERROR) << "SendKeyPressWithSearchAndShift " << key;
81 ASSERT_NO_FATAL_FAILURE(
82 ASSERT_TRUE(
83 ui_test_utils::SendKeyPressToWindowSync(
84 NULL, key, false, true, false, true)));
68 } 85 }
69 86
70 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) { 87 void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
71 extensions::ExtensionHost* host = 88 extensions::ExtensionHost* host =
72 extensions::ExtensionSystem::Get(browser()->profile())-> 89 extensions::ExtensionSystem::Get(browser()->profile())->
73 process_manager()->GetBackgroundHostForExtension( 90 process_manager()->GetBackgroundHostForExtension(
74 extension_misc::kChromeVoxExtensionId); 91 extension_misc::kChromeVoxExtensionId);
75 CHECK(content::ExecuteScript(host->host_contents(), script)); 92 CHECK(content::ExecuteScript(host->host_contents(), script));
76 } 93 }
77 94
78 void SimulateTouchScreenInChromeVox() { 95 void SimulateTouchScreenInChromeVox() {
79 // ChromeVox looks at whether 'ontouchstart' exists to know whether 96 // ChromeVox looks at whether 'ontouchstart' exists to know whether
80 // or not it should respond to hover events. Fake it so that touch 97 // or not it should respond to hover events. Fake it so that touch
81 // exploration events get spoken. 98 // exploration events get spoken.
82 RunJavaScriptInChromeVoxBackgroundPage( 99 RunJavaScriptInChromeVoxBackgroundPage(
83 "window.ontouchstart = function() {};"); 100 "window.ontouchstart = function() {};");
84 } 101 }
85 102
86 void DisableEarcons() { 103 void DisableEarcons() {
87 // Playing earcons from within a test is not only annoying if you're 104 // Playing earcons from within a test is not only annoying if you're
88 // running the test locally, but seems to cause crashes 105 // running the test locally, but seems to cause crashes
89 // (http://crbug.com/396507). Work around this by just telling 106 // (http://crbug.com/396507). Work around this by just telling
90 // ChromeVox to not ever play earcons (prerecorded sound effects). 107 // ChromeVox to not ever play earcons (prerecorded sound effects).
91 RunJavaScriptInChromeVoxBackgroundPage( 108 RunJavaScriptInChromeVoxBackgroundPage(
92 "cvox.ChromeVox.earcons.playEarcon = function() {};"); 109 "cvox.ChromeVox.earcons.playEarcon = function() {};");
93 } 110 }
94 111
112 void LoadChromeVoxAndThenNavigateToURL(const GURL& url) {
113 // The goal of this helper function is to avoid race conditions between
114 // the page loading and the ChromeVox extension loading and fully
115 // initializing. To do this, we first load a test url that repeatedly
116 // asks ChromeVox to speak 'ready', then we load ChromeVox and block
117 // until we get that 'ready' speech.
118
119 ui_test_utils::NavigateToURL(
120 browser(),
121 GURL("data:text/html;charset=utf-8,"
122 "<script>"
123 "window.setInterval(function() {"
124 " try {"
125 " cvox.Api.speak('ready');"
126 " } catch (e) {}"
127 "}, 100);"
128 "</script>"));
129 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
130 AccessibilityManager::Get()->EnableSpokenFeedback(
131 true, ash::A11Y_NOTIFICATION_NONE);
132
133 // Block until we get "ready".
134 while (speech_monitor_.GetNextUtterance() != "ready")
135 continue;
136
137 // Now load the requested url.
138 ui_test_utils::NavigateToURL(browser(), url);
139 }
140
141 SpeechMonitor speech_monitor_;
142
95 private: 143 private:
96 StubBrailleController braille_controller_; 144 StubBrailleController braille_controller_;
97 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); 145 DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest);
98 }; 146 };
99 147
100 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) { 148 IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) {
101 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 149 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
102 150
103 SpeechMonitor monitor;
104 AccessibilityManager::Get()->EnableSpokenFeedback( 151 AccessibilityManager::Get()->EnableSpokenFeedback(
105 true, ash::A11Y_NOTIFICATION_NONE); 152 true, ash::A11Y_NOTIFICATION_NONE);
106 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 153 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
107 DisableEarcons(); 154 DisableEarcons();
108 155
109 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 156 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
110 157
111 // Create a bookmark with title "foo". 158 // Create a bookmark with title "foo".
112 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE); 159 chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE);
113 EXPECT_EQ("Bookmark added!,", monitor.GetNextUtterance()); 160 EXPECT_EQ("Bookmark added!,", speech_monitor_.GetNextUtterance());
114 EXPECT_EQ("about blank,", monitor.GetNextUtterance()); 161 EXPECT_EQ("about blank,", speech_monitor_.GetNextUtterance());
115 EXPECT_EQ("Bookmark name,", monitor.GetNextUtterance()); 162 EXPECT_EQ("Bookmark name,", speech_monitor_.GetNextUtterance());
116 EXPECT_EQ("text box", monitor.GetNextUtterance()); 163 EXPECT_EQ("text box", speech_monitor_.GetNextUtterance());
117 164
118 SendKeyPress(ui::VKEY_F); 165 SendKeyPress(ui::VKEY_F);
119 EXPECT_EQ("f", monitor.GetNextUtterance()); 166 EXPECT_EQ("f", speech_monitor_.GetNextUtterance());
120 SendKeyPress(ui::VKEY_O); 167 SendKeyPress(ui::VKEY_O);
121 EXPECT_EQ("o", monitor.GetNextUtterance()); 168 EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
122 SendKeyPress(ui::VKEY_O); 169 SendKeyPress(ui::VKEY_O);
123 EXPECT_EQ("o", monitor.GetNextUtterance()); 170 EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
124 171
125 SendKeyPress(ui::VKEY_TAB); 172 SendKeyPress(ui::VKEY_TAB);
126 EXPECT_EQ("Bookmarks bar,", monitor.GetNextUtterance()); 173 EXPECT_EQ("Bookmarks bar,", speech_monitor_.GetNextUtterance());
127 EXPECT_EQ("Bookmark folder,", monitor.GetNextUtterance()); 174 EXPECT_EQ("Bookmark folder,", speech_monitor_.GetNextUtterance());
128 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "combo box*")); 175 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "combo box*"));
129 176
130 SendKeyPress(ui::VKEY_RETURN); 177 SendKeyPress(ui::VKEY_RETURN);
131 178
132 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 179 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
133 // Wait for active window change to be announced to avoid interference from 180 // Wait for active window change to be announced to avoid interference from
134 // that below. 181 // that below.
135 while (monitor.GetNextUtterance() != "window about blank tab") { 182 while (speech_monitor_.GetNextUtterance() != "window about blank tab") {
136 // Do nothing. 183 // Do nothing.
137 } 184 }
138 185
139 // Focus bookmarks bar and listen for "foo". 186 // Focus bookmarks bar and listen for "foo".
140 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS); 187 chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS);
141 while (true) { 188 while (true) {
142 std::string utterance = monitor.GetNextUtterance(); 189 std::string utterance = speech_monitor_.GetNextUtterance();
143 VLOG(0) << "Got utterance: " << utterance; 190 VLOG(0) << "Got utterance: " << utterance;
144 if (utterance == "Bookmarks,") 191 if (utterance == "Bookmarks,")
145 break; 192 break;
146 } 193 }
147 EXPECT_EQ("foo,", monitor.GetNextUtterance()); 194 EXPECT_EQ("foo,", speech_monitor_.GetNextUtterance());
148 EXPECT_EQ("button", monitor.GetNextUtterance()); 195 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
149 } 196 }
150 197
151 // 198 //
152 // Spoken feedback tests in both a logged in browser window and guest mode. 199 // Spoken feedback tests in both a logged in browser window and guest mode.
153 // 200 //
154 201
155 enum SpokenFeedbackTestVariant { 202 enum SpokenFeedbackTestVariant {
156 kTestAsNormalUser, 203 kTestAsNormalUser,
157 kTestAsGuestUser 204 kTestAsGuestUser
158 }; 205 };
(...skipping 19 matching lines...) Expand all
178 225
179 INSTANTIATE_TEST_CASE_P( 226 INSTANTIATE_TEST_CASE_P(
180 TestAsNormalAndGuestUser, 227 TestAsNormalAndGuestUser,
181 SpokenFeedbackTest, 228 SpokenFeedbackTest,
182 ::testing::Values(kTestAsNormalUser, 229 ::testing::Values(kTestAsNormalUser,
183 kTestAsGuestUser)); 230 kTestAsGuestUser));
184 231
185 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { 232 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
186 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 233 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
187 234
188 SpeechMonitor monitor;
189 AccessibilityManager::Get()->EnableSpokenFeedback( 235 AccessibilityManager::Get()->EnableSpokenFeedback(
190 true, ash::A11Y_NOTIFICATION_NONE); 236 true, ash::A11Y_NOTIFICATION_NONE);
191 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 237 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
192 } 238 }
193 239
194 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { 240 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
195 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 241 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
196 242
197 SpeechMonitor monitor;
198 AccessibilityManager::Get()->EnableSpokenFeedback( 243 AccessibilityManager::Get()->EnableSpokenFeedback(
199 true, ash::A11Y_NOTIFICATION_NONE); 244 true, ash::A11Y_NOTIFICATION_NONE);
200 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 245 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
201 DisableEarcons(); 246 DisableEarcons();
202 247
203 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 248 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
204 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 249 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
205 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 250 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
206 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); 251 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
207 EXPECT_EQ("button", monitor.GetNextUtterance()); 252 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
208 } 253 }
209 254
210 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { 255 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
211 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 256 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
212 257
213 SpeechMonitor monitor;
214 AccessibilityManager::Get()->EnableSpokenFeedback( 258 AccessibilityManager::Get()->EnableSpokenFeedback(
215 true, ash::A11Y_NOTIFICATION_NONE); 259 true, ash::A11Y_NOTIFICATION_NONE);
216 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 260 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
217 DisableEarcons(); 261 DisableEarcons();
218 262
219 // Wait for ChromeVox to finish speaking. 263 // Wait for ChromeVox to finish speaking.
220 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); 264 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
221 while (true) { 265 while (true) {
222 std::string utterance = monitor.GetNextUtterance(); 266 std::string utterance = speech_monitor_.GetNextUtterance();
223 VLOG(0) << "Got utterance: " << utterance; 267 VLOG(0) << "Got utterance: " << utterance;
224 if (utterance == "text box") 268 if (utterance == "text box")
225 break; 269 break;
226 } 270 }
227 271
228 SendKeyPress(ui::VKEY_X); 272 SendKeyPress(ui::VKEY_X);
229 EXPECT_EQ("x", monitor.GetNextUtterance()); 273 EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
230 274
231 SendKeyPress(ui::VKEY_Y); 275 SendKeyPress(ui::VKEY_Y);
232 EXPECT_EQ("y", monitor.GetNextUtterance()); 276 EXPECT_EQ("y", speech_monitor_.GetNextUtterance());
233 277
234 SendKeyPress(ui::VKEY_Z); 278 SendKeyPress(ui::VKEY_Z);
235 EXPECT_EQ("z", monitor.GetNextUtterance()); 279 EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
236 280
237 SendKeyPress(ui::VKEY_BACK); 281 SendKeyPress(ui::VKEY_BACK);
238 EXPECT_EQ("z", monitor.GetNextUtterance()); 282 EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
283 }
284
285 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxShiftSearch) {
286 LoadChromeVoxAndThenNavigateToURL(
287 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
288 while (true) {
289 std::string utterance = speech_monitor_.GetNextUtterance();
290 if (utterance == "Click me")
291 break;
292 }
293 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
294
295 // Press Search+Shift+/ to enter ChromeVox's "find in page".
296 SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
297 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
298 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
299 }
300
301 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxPrefixKey) {
302 LoadChromeVoxAndThenNavigateToURL(
303 GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
304 while (true) {
305 std::string utterance = speech_monitor_.GetNextUtterance();
306 if (utterance == "Click me")
307 break;
308 }
309 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
310
311 // Press the prefix key Ctrl+';' followed by '/'
312 // to enter ChromeVox's "find in page".
313 SendKeyPressWithControl(ui::VKEY_OEM_1);
314 SendKeyPress(ui::VKEY_OEM_2);
315 EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
316 EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
317 }
318
319 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxNavigateAndSelect) {
320 LoadChromeVoxAndThenNavigateToURL(
321 GURL("data:text/html;charset=utf-8,"
322 "<h1>Title</h1>"
323 "<button autofocus>Click me</button>"));
324 while (true) {
325 std::string utterance = speech_monitor_.GetNextUtterance();
326 if (utterance == "Click me")
327 break;
328 }
329 EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
330
331 // Press Search+Shift+Up to navigate to the previous item.
332 SendKeyPressWithSearchAndShift(ui::VKEY_UP);
333 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
334 EXPECT_EQ("Heading 1", speech_monitor_.GetNextUtterance());
335
336 // Press Search+Shift+S to select the text.
337 SendKeyPressWithSearchAndShift(ui::VKEY_S);
338 EXPECT_EQ("Start selection", speech_monitor_.GetNextUtterance());
339 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
340 EXPECT_EQ(", selected", speech_monitor_.GetNextUtterance());
341
342 // Press again to end the selection.
343 SendKeyPressWithSearchAndShift(ui::VKEY_S);
344 EXPECT_EQ("End selection", speech_monitor_.GetNextUtterance());
345 EXPECT_EQ("Title", speech_monitor_.GetNextUtterance());
239 } 346 }
240 347
241 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { 348 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
242 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 349 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
243 350
244 SpeechMonitor monitor;
245 AccessibilityManager::Get()->EnableSpokenFeedback( 351 AccessibilityManager::Get()->EnableSpokenFeedback(
246 true, ash::A11Y_NOTIFICATION_NONE); 352 true, ash::A11Y_NOTIFICATION_NONE);
247 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 353 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
248 DisableEarcons(); 354 DisableEarcons();
249 355
250 SimulateTouchScreenInChromeVox(); 356 SimulateTouchScreenInChromeVox();
251 357
252 // Send an accessibility hover event on the system tray, which is 358 // Send an accessibility hover event on the system tray, which is
253 // what we get when you tap it on a touch screen when ChromeVox is on. 359 // what we get when you tap it on a touch screen when ChromeVox is on.
254 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); 360 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray();
255 tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); 361 tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true);
256 362
257 EXPECT_EQ("Status tray,", monitor.GetNextUtterance()); 363 EXPECT_EQ("Status tray,", speech_monitor_.GetNextUtterance());
258 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "time*,")); 364 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "time*,"));
259 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Battery*,")); 365 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "Battery*,"));
260 EXPECT_EQ("button", monitor.GetNextUtterance()); 366 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
261 } 367 }
262 368
263 // 369 //
264 // Spoken feedback tests that run only in guest mode. 370 // Spoken feedback tests that run only in guest mode.
265 // 371 //
266 372
267 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest { 373 class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest {
268 protected: 374 protected:
269 GuestSpokenFeedbackTest() {} 375 GuestSpokenFeedbackTest() {}
270 virtual ~GuestSpokenFeedbackTest() {} 376 virtual ~GuestSpokenFeedbackTest() {}
271 377
272 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 378 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
273 command_line->AppendSwitch(chromeos::switches::kGuestSession); 379 command_line->AppendSwitch(chromeos::switches::kGuestSession);
274 command_line->AppendSwitch(::switches::kIncognito); 380 command_line->AppendSwitch(::switches::kIncognito);
275 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 381 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
276 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, 382 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
277 chromeos::login::kGuestUserName); 383 chromeos::login::kGuestUserName);
278 } 384 }
279 385
280 private: 386 private:
281 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest); 387 DISALLOW_COPY_AND_ASSIGN(GuestSpokenFeedbackTest);
282 }; 388 };
283 389
284 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { 390 IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
285 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 391 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
286 392
287 SpeechMonitor monitor;
288 AccessibilityManager::Get()->EnableSpokenFeedback( 393 AccessibilityManager::Get()->EnableSpokenFeedback(
289 true, ash::A11Y_NOTIFICATION_NONE); 394 true, ash::A11Y_NOTIFICATION_NONE);
290 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 395 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
291 DisableEarcons(); 396 DisableEarcons();
292 397
293 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); 398 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
294 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". 399 // Might be "Google Chrome Toolbar" or "Chromium Toolbar".
295 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); 400 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
296 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); 401 EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
297 EXPECT_EQ("button", monitor.GetNextUtterance()); 402 EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
298 } 403 }
299 404
300 // 405 //
301 // Spoken feedback tests of the out-of-box experience. 406 // Spoken feedback tests of the out-of-box experience.
302 // 407 //
303 408
304 class OobeSpokenFeedbackTest : public InProcessBrowserTest { 409 class OobeSpokenFeedbackTest : public InProcessBrowserTest {
305 protected: 410 protected:
306 OobeSpokenFeedbackTest() {} 411 OobeSpokenFeedbackTest() {}
307 virtual ~OobeSpokenFeedbackTest() {} 412 virtual ~OobeSpokenFeedbackTest() {}
308 413
309 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 414 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
310 command_line->AppendSwitch(chromeos::switches::kLoginManager); 415 command_line->AppendSwitch(chromeos::switches::kLoginManager);
311 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); 416 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
312 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 417 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
313 } 418 }
314 419
315 virtual void SetUpOnMainThread() OVERRIDE { 420 virtual void SetUpOnMainThread() OVERRIDE {
316 AccessibilityManager::Get()-> 421 AccessibilityManager::Get()->
317 SetProfileForTest(ProfileHelper::GetSigninProfile()); 422 SetProfileForTest(ProfileHelper::GetSigninProfile());
318 } 423 }
319 424
425 SpeechMonitor speech_monitor_;
426
320 private: 427 private:
321 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest); 428 DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
322 }; 429 };
323 430
324 // Test is flaky: http://crbug.com/346797 431 // Test is flaky: http://crbug.com/346797
325 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) { 432 IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
326 ui_controls::EnableUIControls(); 433 ui_controls::EnableUIControls();
327 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 434 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
328 435
329 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); 436 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host();
330 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); 437 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView();
331 views::Widget* widget = web_ui_login_view->GetWidget(); 438 views::Widget* widget = web_ui_login_view->GetWidget();
332 gfx::NativeWindow window = widget->GetNativeWindow(); 439 gfx::NativeWindow window = widget->GetNativeWindow();
333 440
334 SpeechMonitor monitor;
335 AccessibilityManager::Get()->EnableSpokenFeedback( 441 AccessibilityManager::Get()->EnableSpokenFeedback(
336 true, ash::A11Y_NOTIFICATION_NONE); 442 true, ash::A11Y_NOTIFICATION_NONE);
337 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); 443 EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
338 444
339 EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); 445 EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance());
340 EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); 446 EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance());
341 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); 447 EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
448 "Combo box * of *"));
342 ASSERT_TRUE( 449 ASSERT_TRUE(
343 ui_test_utils::SendKeyPressToWindowSync( 450 ui_test_utils::SendKeyPressToWindowSync(
344 window, ui::VKEY_TAB, false, false, false, false)); 451 window, ui::VKEY_TAB, false, false, false, false));
345 EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance()); 452 EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance());
346 } 453 }
347 454
348 } // namespace chromeos 455 } // 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