Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / chromeos / system / tray_accessibility_browsertest.cc
blobb6fc802f3fb00b28ba0d853eb86da38a60a58f5a
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/magnifier/magnification_controller.h"
6 #include "ash/shell.h"
7 #include "ash/system/tray/system_tray.h"
8 #include "ash/system/tray_accessibility.h"
9 #include "ash/system/user/login_status.h"
10 #include "base/callback.h"
11 #include "base/command_line.h"
12 #include "base/prefs/pref_service.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
17 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
18 #include "chrome/browser/chromeos/login/helper.h"
19 #include "chrome/browser/chromeos/login/login_utils.h"
20 #include "chrome/browser/chromeos/login/startup_utils.h"
21 #include "chrome/browser/chromeos/login/user_manager.h"
22 #include "chrome/browser/chromeos/login/user_manager_impl.h"
23 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_controller.h"
24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/pref_names.h"
28 #include "chrome/test/base/in_process_browser_test.h"
29 #include "chrome/test/base/testing_profile.h"
30 #include "chromeos/chromeos_switches.h"
31 #include "components/policy/core/browser/browser_policy_connector.h"
32 #include "components/policy/core/common/external_data_fetcher.h"
33 #include "components/policy/core/common/mock_configuration_policy_provider.h"
34 #include "components/policy/core/common/policy_map.h"
35 #include "components/policy/core/common/policy_types.h"
36 #include "content/public/test/test_utils.h"
37 #include "policy/policy_constants.h"
38 #include "testing/gtest/include/gtest/gtest.h"
39 #include "ui/views/controls/label.h"
40 #include "ui/views/widget/widget.h"
42 using extensions::api::braille_display_private::BrailleObserver;
43 using extensions::api::braille_display_private::DisplayState;
44 using extensions::api::braille_display_private::MockBrailleController;
45 using testing::Return;
46 using testing::_;
47 using testing::WithParamInterface;
49 namespace chromeos {
51 enum PrefSettingMechanism {
52 PREF_SERVICE,
53 POLICY,
56 void SetMagnifierEnabled(bool enabled) {
57 MagnificationManager::Get()->SetMagnifierEnabled(enabled);
60 class TrayAccessibilityTest
61 : public InProcessBrowserTest,
62 public WithParamInterface<PrefSettingMechanism> {
63 protected:
64 TrayAccessibilityTest() {}
65 virtual ~TrayAccessibilityTest() {}
67 // The profile which should be used by these tests.
68 Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
70 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
71 EXPECT_CALL(provider_, IsInitializationComplete(_))
72 .WillRepeatedly(Return(true));
73 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
74 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
77 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
78 command_line->AppendSwitch(switches::kLoginManager);
79 command_line->AppendSwitchASCII(switches::kLoginProfile,
80 TestingProfile::kTestUserProfileDir);
83 virtual void SetUpOnMainThread() OVERRIDE {
84 AccessibilityManager::Get()->SetProfileForTest(GetProfile());
85 MagnificationManager::Get()->SetProfileForTest(GetProfile());
88 virtual void RunTestOnMainThreadLoop() OVERRIDE {
89 // Need to mark oobe completed to show detailed views.
90 StartupUtils::MarkOobeCompleted();
91 InProcessBrowserTest::RunTestOnMainThreadLoop();
94 virtual void CleanUpOnMainThread() OVERRIDE {
95 AccessibilityManager::SetBrailleControllerForTest(NULL);
98 void SetShowAccessibilityOptionsInSystemTrayMenu(bool value) {
99 if (GetParam() == PREF_SERVICE) {
100 PrefService* prefs = GetProfile()->GetPrefs();
101 prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, value);
102 } else if (GetParam() == POLICY) {
103 policy::PolicyMap policy_map;
104 policy_map.Set(policy::key::kShowAccessibilityOptionsInSystemTrayMenu,
105 policy::POLICY_LEVEL_MANDATORY,
106 policy::POLICY_SCOPE_USER,
107 base::Value::CreateBooleanValue(value),
108 NULL);
109 provider_.UpdateChromePolicy(policy_map);
110 base::RunLoop().RunUntilIdle();
111 } else {
112 FAIL() << "Unknown test parameterization";
116 ash::TrayAccessibility* tray() {
117 return ash::Shell::GetInstance()->GetPrimarySystemTray()->
118 GetTrayAccessibilityForTest();
121 const ash::TrayAccessibility* tray() const {
122 return ash::Shell::GetInstance()
123 ->GetPrimarySystemTray()
124 ->GetTrayAccessibilityForTest();
127 bool IsTrayIconVisible() const { return tray()->tray_icon_visible_; }
129 views::View* CreateMenuItem() {
130 return tray()->CreateDefaultView(GetLoginStatus());
133 void DestroyMenuItem() {
134 return tray()->DestroyDefaultView();
137 bool CanCreateMenuItem() {
138 views::View* menu_item_view = CreateMenuItem();
139 DestroyMenuItem();
140 return menu_item_view != NULL;
143 void SetLoginStatus(ash::user::LoginStatus status) {
144 tray()->UpdateAfterLoginStatusChange(status);
147 ash::user::LoginStatus GetLoginStatus() {
148 return tray()->login_;
151 bool CreateDetailedMenu() {
152 tray()->PopupDetailedView(0, false);
153 return tray()->detailed_menu_ != NULL;
156 void CloseDetailMenu() {
157 CHECK(tray()->detailed_menu_);
158 tray()->DestroyDetailedView();
159 tray()->detailed_menu_ = NULL;
162 void ClickSpokenFeedbackOnDetailMenu() {
163 views::View* button = tray()->detailed_menu_->spoken_feedback_view_;
164 ASSERT_TRUE(button);
165 tray()->detailed_menu_->OnViewClicked(button);
168 void ClickHighContrastOnDetailMenu() {
169 views::View* button = tray()->detailed_menu_->high_contrast_view_;
170 ASSERT_TRUE(button);
171 tray()->detailed_menu_->OnViewClicked(button);
174 void ClickScreenMagnifierOnDetailMenu() {
175 views::View* button = tray()->detailed_menu_->screen_magnifier_view_;
176 ASSERT_TRUE(button);
177 tray()->detailed_menu_->OnViewClicked(button);
180 void ClickAutoclickOnDetailMenu() {
181 views::View* button = tray()->detailed_menu_->autoclick_view_;
182 ASSERT_TRUE(button);
183 tray()->detailed_menu_->OnViewClicked(button);
186 void ClickVirtualKeyboardOnDetailMenu() {
187 views::View* button = tray()->detailed_menu_->virtual_keyboard_view_;
188 ASSERT_TRUE(button);
189 tray()->detailed_menu_->OnViewClicked(button);
192 bool IsSpokenFeedbackEnabledOnDetailMenu() const {
193 return tray()->detailed_menu_->spoken_feedback_enabled_;
196 bool IsHighContrastEnabledOnDetailMenu() const {
197 return tray()->detailed_menu_->high_contrast_enabled_;
200 bool IsScreenMagnifierEnabledOnDetailMenu() const {
201 return tray()->detailed_menu_->screen_magnifier_enabled_;
204 bool IsLargeCursorEnabledOnDetailMenu() const {
205 return tray()->detailed_menu_->large_cursor_enabled_;
208 bool IsAutoclickEnabledOnDetailMenu() const {
209 return tray()->detailed_menu_->autoclick_enabled_;
212 bool IsVirtualKeyboardEnabledOnDetailMenu() const {
213 return tray()->detailed_menu_->virtual_keyboard_enabled_;
216 bool IsSpokenFeedbackMenuShownOnDetailMenu() const {
217 return tray()->detailed_menu_->spoken_feedback_view_;
220 bool IsHighContrastMenuShownOnDetailMenu() const {
221 return tray()->detailed_menu_->high_contrast_view_;
224 bool IsScreenMagnifierMenuShownOnDetailMenu() const {
225 return tray()->detailed_menu_->screen_magnifier_view_;
228 bool IsLargeCursorMenuShownOnDetailMenu() const {
229 return tray()->detailed_menu_->large_cursor_view_;
232 bool IsAutoclickMenuShownOnDetailMenu() const {
233 return tray()->detailed_menu_->autoclick_view_;
236 bool IsVirtualKeyboardMenuShownOnDetailMenu() const {
237 return tray()->detailed_menu_->virtual_keyboard_view_;
240 bool IsNotificationShown() const {
241 return (tray()->detailed_popup_ &&
242 !tray()->detailed_popup_->GetWidget()->IsClosed());
245 base::string16 GetNotificationText() const {
246 if (IsNotificationShown())
247 return tray()->detailed_popup_->label_for_test()->text();
248 else
249 return base::string16();
252 void SetBrailleConnected(bool connected) {
253 braille_controller_.SetAvailable(connected);
254 braille_controller_.GetObserver()->OnDisplayStateChanged(
255 *braille_controller_.GetDisplayState());
258 policy::MockConfigurationPolicyProvider provider_;
259 MockBrailleController braille_controller_;
262 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) {
263 EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus());
265 UserManager::Get()->UserLoggedIn(
266 "owner@invalid.domain", "owner@invalid.domain", true);
267 UserManager::Get()->SessionStarted();
269 EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus());
272 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) {
273 SetLoginStatus(ash::user::LOGGED_IN_NONE);
275 // Confirms that the icon is invisible before login.
276 EXPECT_FALSE(IsTrayIconVisible());
278 UserManager::Get()->UserLoggedIn(
279 "owner@invalid.domain", "owner@invalid.domain", true);
280 UserManager::Get()->SessionStarted();
282 // Confirms that the icon is invisible just after login.
283 EXPECT_FALSE(IsTrayIconVisible());
285 // Toggling spoken feedback changes the visibillity of the icon.
286 AccessibilityManager::Get()->EnableSpokenFeedback(
287 true, ash::A11Y_NOTIFICATION_NONE);
288 EXPECT_TRUE(IsTrayIconVisible());
289 AccessibilityManager::Get()->EnableSpokenFeedback(
290 false, ash::A11Y_NOTIFICATION_NONE);
291 EXPECT_FALSE(IsTrayIconVisible());
293 // Toggling high contrast the visibillity of the icon.
294 AccessibilityManager::Get()->EnableHighContrast(true);
295 EXPECT_TRUE(IsTrayIconVisible());
296 AccessibilityManager::Get()->EnableHighContrast(false);
297 EXPECT_FALSE(IsTrayIconVisible());
299 // Toggling magnifier the visibility of the icon.
300 SetMagnifierEnabled(true);
301 EXPECT_TRUE(IsTrayIconVisible());
302 SetMagnifierEnabled(false);
303 EXPECT_FALSE(IsTrayIconVisible());
305 // Toggling the virtual keyboard setting changes the visibility of the a11y
306 // icon.
307 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
308 EXPECT_TRUE(IsTrayIconVisible());
309 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
310 EXPECT_FALSE(IsTrayIconVisible());
312 // Enabling all accessibility features.
313 SetMagnifierEnabled(true);
314 EXPECT_TRUE(IsTrayIconVisible());
315 AccessibilityManager::Get()->EnableHighContrast(true);
316 EXPECT_TRUE(IsTrayIconVisible());
317 AccessibilityManager::Get()->EnableSpokenFeedback(
318 true, ash::A11Y_NOTIFICATION_NONE);
319 EXPECT_TRUE(IsTrayIconVisible());
320 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
321 EXPECT_TRUE(IsTrayIconVisible());
322 AccessibilityManager::Get()->EnableSpokenFeedback(
323 false, ash::A11Y_NOTIFICATION_NONE);
324 EXPECT_TRUE(IsTrayIconVisible());
325 AccessibilityManager::Get()->EnableHighContrast(false);
326 EXPECT_TRUE(IsTrayIconVisible());
327 SetMagnifierEnabled(false);
328 EXPECT_TRUE(IsTrayIconVisible());
329 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
330 EXPECT_FALSE(IsTrayIconVisible());
332 // Confirms that prefs::kShouldAlwaysShowAccessibilityMenu doesn't affect
333 // the icon on the tray.
334 SetShowAccessibilityOptionsInSystemTrayMenu(true);
335 AccessibilityManager::Get()->EnableHighContrast(true);
336 EXPECT_TRUE(IsTrayIconVisible());
337 AccessibilityManager::Get()->EnableHighContrast(false);
338 EXPECT_FALSE(IsTrayIconVisible());
341 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
342 // Login
343 UserManager::Get()->UserLoggedIn(
344 "owner@invalid.domain", "owner@invalid.domain", true);
345 UserManager::Get()->SessionStarted();
347 SetShowAccessibilityOptionsInSystemTrayMenu(false);
349 // Confirms that the menu is hidden.
350 EXPECT_FALSE(CanCreateMenuItem());
352 // Toggling spoken feedback changes the visibillity of the menu.
353 AccessibilityManager::Get()->EnableSpokenFeedback(
354 true, ash::A11Y_NOTIFICATION_NONE);
355 EXPECT_TRUE(CanCreateMenuItem());
356 AccessibilityManager::Get()->EnableSpokenFeedback(
357 false, ash::A11Y_NOTIFICATION_NONE);
358 EXPECT_FALSE(CanCreateMenuItem());
360 // Toggling high contrast changes the visibillity of the menu.
361 AccessibilityManager::Get()->EnableHighContrast(true);
362 EXPECT_TRUE(CanCreateMenuItem());
363 AccessibilityManager::Get()->EnableHighContrast(false);
364 EXPECT_FALSE(CanCreateMenuItem());
366 // Toggling screen magnifier changes the visibility of the menu.
367 SetMagnifierEnabled(true);
368 EXPECT_TRUE(CanCreateMenuItem());
369 SetMagnifierEnabled(false);
370 EXPECT_FALSE(CanCreateMenuItem());
372 // Toggling autoclick changes the visibility of the menu.
373 AccessibilityManager::Get()->EnableAutoclick(true);
374 EXPECT_TRUE(CanCreateMenuItem());
375 AccessibilityManager::Get()->EnableAutoclick(false);
376 EXPECT_FALSE(CanCreateMenuItem());
378 // Toggling virtual keyboard changes the visibility of the menu.
379 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
380 EXPECT_TRUE(CanCreateMenuItem());
381 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
382 EXPECT_FALSE(CanCreateMenuItem());
384 // Enabling all accessibility features.
385 SetMagnifierEnabled(true);
386 EXPECT_TRUE(CanCreateMenuItem());
387 AccessibilityManager::Get()->EnableHighContrast(true);
388 EXPECT_TRUE(CanCreateMenuItem());
389 AccessibilityManager::Get()->EnableSpokenFeedback(
390 true, ash::A11Y_NOTIFICATION_NONE);
391 EXPECT_TRUE(CanCreateMenuItem());
392 AccessibilityManager::Get()->EnableAutoclick(true);
393 EXPECT_TRUE(CanCreateMenuItem());
394 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
395 EXPECT_TRUE(CanCreateMenuItem());
396 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
397 EXPECT_TRUE(CanCreateMenuItem());
398 AccessibilityManager::Get()->EnableAutoclick(false);
399 EXPECT_TRUE(CanCreateMenuItem());
400 AccessibilityManager::Get()->EnableSpokenFeedback(
401 false, ash::A11Y_NOTIFICATION_NONE);
402 EXPECT_TRUE(CanCreateMenuItem());
403 AccessibilityManager::Get()->EnableHighContrast(false);
404 EXPECT_TRUE(CanCreateMenuItem());
405 SetMagnifierEnabled(false);
406 EXPECT_FALSE(CanCreateMenuItem());
409 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
410 // Login
411 UserManager::Get()->UserLoggedIn(
412 "owner@invalid.domain", "owner@invalid.domain", true);
413 UserManager::Get()->SessionStarted();
415 SetShowAccessibilityOptionsInSystemTrayMenu(true);
417 // Confirms that the menu is visible.
418 EXPECT_TRUE(CanCreateMenuItem());
420 // The menu remains visible regardless of toggling spoken feedback.
421 AccessibilityManager::Get()->EnableSpokenFeedback(
422 true, ash::A11Y_NOTIFICATION_NONE);
423 EXPECT_TRUE(CanCreateMenuItem());
424 AccessibilityManager::Get()->EnableSpokenFeedback(
425 false, ash::A11Y_NOTIFICATION_NONE);
426 EXPECT_TRUE(CanCreateMenuItem());
428 // The menu remains visible regardless of toggling high contrast.
429 AccessibilityManager::Get()->EnableHighContrast(true);
430 EXPECT_TRUE(CanCreateMenuItem());
431 AccessibilityManager::Get()->EnableHighContrast(false);
432 EXPECT_TRUE(CanCreateMenuItem());
434 // The menu remains visible regardless of toggling screen magnifier.
435 SetMagnifierEnabled(true);
436 EXPECT_TRUE(CanCreateMenuItem());
437 SetMagnifierEnabled(false);
438 EXPECT_TRUE(CanCreateMenuItem());
440 // The menu remains visible regardless of toggling autoclick.
441 AccessibilityManager::Get()->EnableAutoclick(true);
442 EXPECT_TRUE(CanCreateMenuItem());
443 AccessibilityManager::Get()->EnableAutoclick(false);
444 EXPECT_TRUE(CanCreateMenuItem());
446 // The menu remains visible regardless of toggling on-screen keyboard.
447 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
448 EXPECT_TRUE(CanCreateMenuItem());
449 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
450 EXPECT_TRUE(CanCreateMenuItem());
452 // Enabling all accessibility features.
453 SetMagnifierEnabled(true);
454 EXPECT_TRUE(CanCreateMenuItem());
455 AccessibilityManager::Get()->EnableHighContrast(true);
456 EXPECT_TRUE(CanCreateMenuItem());
457 AccessibilityManager::Get()->EnableSpokenFeedback(
458 true, ash::A11Y_NOTIFICATION_NONE);
459 EXPECT_TRUE(CanCreateMenuItem());
460 AccessibilityManager::Get()->EnableAutoclick(true);
461 EXPECT_TRUE(CanCreateMenuItem());
462 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
463 EXPECT_TRUE(CanCreateMenuItem());
464 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
465 EXPECT_TRUE(CanCreateMenuItem());
466 AccessibilityManager::Get()->EnableAutoclick(false);
467 EXPECT_TRUE(CanCreateMenuItem());
468 AccessibilityManager::Get()->EnableSpokenFeedback(
469 false, ash::A11Y_NOTIFICATION_NONE);
470 EXPECT_TRUE(CanCreateMenuItem());
471 AccessibilityManager::Get()->EnableHighContrast(false);
472 EXPECT_TRUE(CanCreateMenuItem());
473 SetMagnifierEnabled(false);
474 EXPECT_TRUE(CanCreateMenuItem());
476 SetShowAccessibilityOptionsInSystemTrayMenu(false);
478 // Confirms that the menu is invisible.
479 EXPECT_FALSE(CanCreateMenuItem());
482 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) {
483 SetLoginStatus(ash::user::LOGGED_IN_NONE);
485 // Confirms that the menu is visible.
486 EXPECT_TRUE(CanCreateMenuItem());
488 // The menu remains visible regardless of toggling spoken feedback.
489 AccessibilityManager::Get()->EnableSpokenFeedback(
490 true, ash::A11Y_NOTIFICATION_NONE);
491 EXPECT_TRUE(CanCreateMenuItem());
492 AccessibilityManager::Get()->EnableSpokenFeedback(
493 false, ash::A11Y_NOTIFICATION_NONE);
494 EXPECT_TRUE(CanCreateMenuItem());
496 // The menu remains visible regardless of toggling high contrast.
497 AccessibilityManager::Get()->EnableHighContrast(true);
498 EXPECT_TRUE(CanCreateMenuItem());
499 AccessibilityManager::Get()->EnableHighContrast(false);
500 EXPECT_TRUE(CanCreateMenuItem());
502 // The menu remains visible regardless of toggling screen magnifier.
503 SetMagnifierEnabled(true);
504 EXPECT_TRUE(CanCreateMenuItem());
505 SetMagnifierEnabled(false);
506 EXPECT_TRUE(CanCreateMenuItem());
508 // The menu remains visible regardless of toggling on-screen keyboard.
509 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
510 EXPECT_TRUE(CanCreateMenuItem());
511 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
512 EXPECT_TRUE(CanCreateMenuItem());
514 // Enabling all accessibility features.
515 SetMagnifierEnabled(true);
516 EXPECT_TRUE(CanCreateMenuItem());
517 AccessibilityManager::Get()->EnableHighContrast(true);
518 EXPECT_TRUE(CanCreateMenuItem());
519 AccessibilityManager::Get()->EnableSpokenFeedback(
520 true, ash::A11Y_NOTIFICATION_NONE);
521 EXPECT_TRUE(CanCreateMenuItem());
522 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
523 EXPECT_TRUE(CanCreateMenuItem());
524 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
525 EXPECT_TRUE(CanCreateMenuItem());
526 AccessibilityManager::Get()->EnableSpokenFeedback(
527 false, ash::A11Y_NOTIFICATION_NONE);
528 EXPECT_TRUE(CanCreateMenuItem());
529 AccessibilityManager::Get()->EnableHighContrast(false);
530 EXPECT_TRUE(CanCreateMenuItem());
531 SetMagnifierEnabled(false);
532 EXPECT_TRUE(CanCreateMenuItem());
534 SetShowAccessibilityOptionsInSystemTrayMenu(true);
536 // Confirms that the menu remains visible.
537 EXPECT_TRUE(CanCreateMenuItem());
539 SetShowAccessibilityOptionsInSystemTrayMenu(false);
541 // Confirms that the menu remains visible.
542 EXPECT_TRUE(CanCreateMenuItem());
545 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) {
546 const base::string16 BRAILLE_CONNECTED =
547 base::ASCIIToUTF16("Braille display connected.");
548 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16(
549 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable.");
550 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED(
551 BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED);
553 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
555 // Enabling spoken feedback should show the notification.
556 AccessibilityManager::Get()->EnableSpokenFeedback(
557 true, ash::A11Y_NOTIFICATION_SHOW);
558 EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText());
560 // Connecting a braille display when spoken feedback is already enabled
561 // should only show the message about the braille display.
562 SetBrailleConnected(true);
563 EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText());
565 // Neither disconnecting a braille display, nor disabling spoken feedback
566 // should show any notification.
567 SetBrailleConnected(false);
568 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
569 EXPECT_FALSE(IsNotificationShown());
570 AccessibilityManager::Get()->EnableSpokenFeedback(
571 false, ash::A11Y_NOTIFICATION_SHOW);
572 EXPECT_FALSE(IsNotificationShown());
573 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
575 // Connecting a braille display should enable spoken feedback and show
576 // both messages.
577 SetBrailleConnected(true);
578 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
579 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText());
582 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
583 // Enables high contrast mode.
584 AccessibilityManager::Get()->EnableHighContrast(true);
585 EXPECT_TRUE(CanCreateMenuItem());
587 // Locks the screen.
588 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
589 EXPECT_TRUE(CanCreateMenuItem());
591 // Disables high contrast mode.
592 AccessibilityManager::Get()->EnableHighContrast(false);
594 // Confirms that the menu is still visible.
595 EXPECT_TRUE(CanCreateMenuItem());
598 #if defined(OS_CHROMEOS)
599 #define MAYBE_ClickDetailMenu DISABLED_ClickDetailMenu
600 #else
601 #define MAYBE_ClickDetailMenu ClickDetailMenu
602 #endif
604 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, MAYBE_ClickDetailMenu) {
605 // Confirms that the check item toggles the spoken feedback.
606 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
608 EXPECT_TRUE(CreateDetailedMenu());
609 ClickSpokenFeedbackOnDetailMenu();
610 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
612 EXPECT_TRUE(CreateDetailedMenu());
613 ClickSpokenFeedbackOnDetailMenu();
614 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
616 // Confirms that the check item toggles the high contrast.
617 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
619 EXPECT_TRUE(CreateDetailedMenu());
620 ClickHighContrastOnDetailMenu();
621 EXPECT_TRUE(AccessibilityManager::Get()->IsHighContrastEnabled());
623 EXPECT_TRUE(CreateDetailedMenu());
624 ClickHighContrastOnDetailMenu();
625 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
627 // Confirms that the check item toggles the magnifier.
628 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
630 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
631 EXPECT_TRUE(CreateDetailedMenu());
632 ClickScreenMagnifierOnDetailMenu();
633 EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled());
635 EXPECT_TRUE(CreateDetailedMenu());
636 ClickScreenMagnifierOnDetailMenu();
637 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
639 // Confirms that the check item toggles autoclick.
640 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
642 EXPECT_TRUE(CreateDetailedMenu());
643 ClickAutoclickOnDetailMenu();
644 EXPECT_TRUE(AccessibilityManager::Get()->IsAutoclickEnabled());
646 EXPECT_TRUE(CreateDetailedMenu());
647 ClickAutoclickOnDetailMenu();
648 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
650 // Confirms that the check item toggles on-screen keyboard.
651 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
653 EXPECT_TRUE(CreateDetailedMenu());
654 ClickVirtualKeyboardOnDetailMenu();
655 EXPECT_TRUE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
657 EXPECT_TRUE(CreateDetailedMenu());
658 ClickVirtualKeyboardOnDetailMenu();
659 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
662 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMarksOnDetailMenu) {
663 SetLoginStatus(ash::user::LOGGED_IN_NONE);
665 // At first, all of the check is unchecked.
666 EXPECT_TRUE(CreateDetailedMenu());
667 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
668 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
669 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
670 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
671 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
672 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
673 CloseDetailMenu();
675 // Enabling spoken feedback.
676 AccessibilityManager::Get()->EnableSpokenFeedback(
677 true, ash::A11Y_NOTIFICATION_NONE);
678 EXPECT_TRUE(CreateDetailedMenu());
679 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
680 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
681 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
682 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
683 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
684 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
685 CloseDetailMenu();
687 // Disabling spoken feedback.
688 AccessibilityManager::Get()->EnableSpokenFeedback(
689 false, ash::A11Y_NOTIFICATION_NONE);
690 EXPECT_TRUE(CreateDetailedMenu());
691 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
692 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
693 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
694 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
695 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
696 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
697 CloseDetailMenu();
699 // Enabling high contrast.
700 AccessibilityManager::Get()->EnableHighContrast(true);
701 EXPECT_TRUE(CreateDetailedMenu());
702 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
703 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
704 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
705 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
706 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
707 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
708 CloseDetailMenu();
710 // Disabling high contrast.
711 AccessibilityManager::Get()->EnableHighContrast(false);
712 EXPECT_TRUE(CreateDetailedMenu());
713 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
714 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
715 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
716 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
717 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
718 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
719 CloseDetailMenu();
721 // Enabling full screen magnifier.
722 SetMagnifierEnabled(true);
723 EXPECT_TRUE(CreateDetailedMenu());
724 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
725 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
726 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
727 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
728 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
729 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
730 CloseDetailMenu();
732 // Disabling screen magnifier.
733 SetMagnifierEnabled(false);
734 EXPECT_TRUE(CreateDetailedMenu());
735 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
736 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
737 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
738 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
739 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
740 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
741 CloseDetailMenu();
743 // Enabling large cursor.
744 AccessibilityManager::Get()->EnableLargeCursor(true);
745 EXPECT_TRUE(CreateDetailedMenu());
746 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
747 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
748 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
749 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
750 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
751 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
752 CloseDetailMenu();
754 // Disabling large cursor.
755 AccessibilityManager::Get()->EnableLargeCursor(false);
756 EXPECT_TRUE(CreateDetailedMenu());
757 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
758 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
759 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
760 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
761 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
762 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
763 CloseDetailMenu();
765 // Enable on-screen keyboard.
766 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
767 EXPECT_TRUE(CreateDetailedMenu());
768 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
769 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
770 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
771 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
772 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
773 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
774 CloseDetailMenu();
776 // Disable on-screen keyboard.
777 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
778 EXPECT_TRUE(CreateDetailedMenu());
779 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
780 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
781 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
782 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
783 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
784 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
785 CloseDetailMenu();
787 // Enabling all of the a11y features.
788 AccessibilityManager::Get()->EnableSpokenFeedback(
789 true, ash::A11Y_NOTIFICATION_NONE);
790 AccessibilityManager::Get()->EnableHighContrast(true);
791 SetMagnifierEnabled(true);
792 AccessibilityManager::Get()->EnableLargeCursor(true);
793 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
794 EXPECT_TRUE(CreateDetailedMenu());
795 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
796 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
797 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
798 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
799 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
800 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
801 CloseDetailMenu();
803 // Disabling all of the a11y features.
804 AccessibilityManager::Get()->EnableSpokenFeedback(
805 false, ash::A11Y_NOTIFICATION_NONE);
806 AccessibilityManager::Get()->EnableHighContrast(false);
807 SetMagnifierEnabled(false);
808 AccessibilityManager::Get()->EnableLargeCursor(false);
809 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
810 EXPECT_TRUE(CreateDetailedMenu());
811 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
812 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
813 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
814 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
815 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
816 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
817 CloseDetailMenu();
819 // Autoclick is disabled on login screen.
820 SetLoginStatus(ash::user::LOGGED_IN_USER);
822 // Enabling autoclick.
823 AccessibilityManager::Get()->EnableAutoclick(true);
824 EXPECT_TRUE(CreateDetailedMenu());
825 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
826 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
827 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
828 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
829 EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
830 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
831 CloseDetailMenu();
833 // Disabling autoclick.
834 AccessibilityManager::Get()->EnableAutoclick(false);
835 EXPECT_TRUE(CreateDetailedMenu());
836 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
837 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
838 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
839 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
840 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
841 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
842 CloseDetailMenu();
845 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMenuVisibilityOnDetailMenu) {
846 SetLoginStatus(ash::user::LOGGED_IN_NONE);
847 EXPECT_TRUE(CreateDetailedMenu());
848 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
849 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
850 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
851 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
852 EXPECT_FALSE(IsAutoclickMenuShownOnDetailMenu());
853 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
854 CloseDetailMenu();
856 SetLoginStatus(ash::user::LOGGED_IN_USER);
857 EXPECT_TRUE(CreateDetailedMenu());
858 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
859 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
860 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
861 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
862 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
863 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
864 CloseDetailMenu();
866 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
867 EXPECT_TRUE(CreateDetailedMenu());
868 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
869 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
870 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
871 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
872 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
873 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
874 CloseDetailMenu();
877 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
878 TrayAccessibilityTest,
879 testing::Values(PREF_SERVICE,
880 POLICY));
882 } // namespace chromeos