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"
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 "ash/test/shell_test_api.h"
11 #include "ash/test/test_session_state_delegate.h"
12 #include "base/callback.h"
13 #include "base/command_line.h"
14 #include "base/prefs/pref_service.h"
15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
19 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
20 #include "chrome/browser/chromeos/login/helper.h"
21 #include "chrome/browser/chromeos/login/startup_utils.h"
22 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_controller.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/in_process_browser_test.h"
28 #include "chrome/test/base/testing_profile.h"
29 #include "chromeos/chromeos_switches.h"
30 #include "components/policy/core/browser/browser_policy_connector.h"
31 #include "components/policy/core/common/external_data_fetcher.h"
32 #include "components/policy/core/common/mock_configuration_policy_provider.h"
33 #include "components/policy/core/common/policy_map.h"
34 #include "components/policy/core/common/policy_types.h"
35 #include "components/user_manager/user_manager.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
;
47 using testing::WithParamInterface
;
51 enum PrefSettingMechanism
{
56 void SetMagnifierEnabled(bool enabled
) {
57 MagnificationManager::Get()->SetMagnifierEnabled(enabled
);
60 class TrayAccessibilityTest
61 : public InProcessBrowserTest
,
62 public WithParamInterface
<PrefSettingMechanism
> {
64 TrayAccessibilityTest() {}
65 virtual ~TrayAccessibilityTest() {}
67 // The profile which should be used by these tests.
68 Profile
* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
70 void SetUpInProcessBrowserTestFixture() override
{
71 EXPECT_CALL(provider_
, IsInitializationComplete(_
))
72 .WillRepeatedly(Return(true));
73 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_
);
74 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_
);
77 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
78 command_line
->AppendSwitch(switches::kLoginManager
);
79 command_line
->AppendSwitchASCII(switches::kLoginProfile
,
80 TestingProfile::kTestUserProfileDir
);
83 void SetUpOnMainThread() override
{
84 AccessibilityManager::Get()->SetProfileForTest(GetProfile());
85 MagnificationManager::Get()->SetProfileForTest(GetProfile());
88 void RunTestOnMainThreadLoop() override
{
89 // Need to mark oobe completed to show detailed views.
90 StartupUtils::MarkOobeCompleted();
91 InProcessBrowserTest::RunTestOnMainThreadLoop();
94 void TearDownOnMainThread() 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 new base::FundamentalValue(value
),
109 provider_
.UpdateChromePolicy(policy_map
);
110 base::RunLoop().RunUntilIdle();
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();
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_
;
165 tray()->detailed_menu_
->OnViewClicked(button
);
168 void ClickHighContrastOnDetailMenu() {
169 views::View
* button
= tray()->detailed_menu_
->high_contrast_view_
;
171 tray()->detailed_menu_
->OnViewClicked(button
);
174 void ClickScreenMagnifierOnDetailMenu() {
175 views::View
* button
= tray()->detailed_menu_
->screen_magnifier_view_
;
177 tray()->detailed_menu_
->OnViewClicked(button
);
180 void ClickAutoclickOnDetailMenu() {
181 views::View
* button
= tray()->detailed_menu_
->autoclick_view_
;
183 tray()->detailed_menu_
->OnViewClicked(button
);
186 void ClickVirtualKeyboardOnDetailMenu() {
187 views::View
* button
= tray()->detailed_menu_
->virtual_keyboard_view_
;
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 IsHelpShownOnDetailMenu() const {
241 return tray()->detailed_menu_
->help_view_
;
244 bool IsSettingsShownOnDetailMenu() const {
245 return tray()->detailed_menu_
->settings_view_
;
248 bool IsNotificationShown() const {
249 return (tray()->detailed_popup_
&&
250 !tray()->detailed_popup_
->GetWidget()->IsClosed());
253 base::string16
GetNotificationText() const {
254 if (IsNotificationShown())
255 return tray()->detailed_popup_
->label_for_test()->text();
257 return base::string16();
260 void SetBrailleConnected(bool connected
) {
261 braille_controller_
.SetAvailable(connected
);
262 braille_controller_
.GetObserver()->OnBrailleDisplayStateChanged(
263 *braille_controller_
.GetDisplayState());
266 policy::MockConfigurationPolicyProvider provider_
;
267 MockBrailleController braille_controller_
;
270 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, LoginStatus
) {
271 EXPECT_EQ(ash::user::LOGGED_IN_NONE
, GetLoginStatus());
273 user_manager::UserManager::Get()->UserLoggedIn(
274 "owner@invalid.domain", "owner@invalid.domain", true);
275 user_manager::UserManager::Get()->SessionStarted();
277 EXPECT_EQ(ash::user::LOGGED_IN_USER
, GetLoginStatus());
280 // http://crbug.com/396342
281 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, DISABLED_ShowTrayIcon
) {
282 SetLoginStatus(ash::user::LOGGED_IN_NONE
);
284 // Confirms that the icon is invisible before login.
285 EXPECT_FALSE(IsTrayIconVisible());
287 user_manager::UserManager::Get()->UserLoggedIn(
288 "owner@invalid.domain", "owner@invalid.domain", true);
289 user_manager::UserManager::Get()->SessionStarted();
291 // Confirms that the icon is invisible just after login.
292 EXPECT_FALSE(IsTrayIconVisible());
294 // Toggling spoken feedback changes the visibillity of the icon.
295 AccessibilityManager::Get()->EnableSpokenFeedback(
296 true, ui::A11Y_NOTIFICATION_NONE
);
297 EXPECT_TRUE(IsTrayIconVisible());
298 AccessibilityManager::Get()->EnableSpokenFeedback(
299 false, ui::A11Y_NOTIFICATION_NONE
);
300 EXPECT_FALSE(IsTrayIconVisible());
302 // Toggling high contrast the visibillity of the icon.
303 AccessibilityManager::Get()->EnableHighContrast(true);
304 EXPECT_TRUE(IsTrayIconVisible());
305 AccessibilityManager::Get()->EnableHighContrast(false);
306 EXPECT_FALSE(IsTrayIconVisible());
308 // Toggling magnifier the visibility of the icon.
309 SetMagnifierEnabled(true);
310 EXPECT_TRUE(IsTrayIconVisible());
311 SetMagnifierEnabled(false);
312 EXPECT_FALSE(IsTrayIconVisible());
314 // Toggling the virtual keyboard setting changes the visibility of the a11y
316 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
317 EXPECT_TRUE(IsTrayIconVisible());
318 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
319 EXPECT_FALSE(IsTrayIconVisible());
321 // Enabling all accessibility features.
322 SetMagnifierEnabled(true);
323 EXPECT_TRUE(IsTrayIconVisible());
324 AccessibilityManager::Get()->EnableHighContrast(true);
325 EXPECT_TRUE(IsTrayIconVisible());
326 AccessibilityManager::Get()->EnableSpokenFeedback(
327 true, ui::A11Y_NOTIFICATION_NONE
);
328 EXPECT_TRUE(IsTrayIconVisible());
329 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
330 EXPECT_TRUE(IsTrayIconVisible());
331 AccessibilityManager::Get()->EnableSpokenFeedback(
332 false, ui::A11Y_NOTIFICATION_NONE
);
333 EXPECT_TRUE(IsTrayIconVisible());
334 AccessibilityManager::Get()->EnableHighContrast(false);
335 EXPECT_TRUE(IsTrayIconVisible());
336 SetMagnifierEnabled(false);
337 EXPECT_TRUE(IsTrayIconVisible());
338 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
339 EXPECT_FALSE(IsTrayIconVisible());
341 // Confirms that prefs::kShouldAlwaysShowAccessibilityMenu doesn't affect
342 // the icon on the tray.
343 SetShowAccessibilityOptionsInSystemTrayMenu(true);
344 AccessibilityManager::Get()->EnableHighContrast(true);
345 EXPECT_TRUE(IsTrayIconVisible());
346 AccessibilityManager::Get()->EnableHighContrast(false);
347 EXPECT_FALSE(IsTrayIconVisible());
350 // http://crbug.com/396342
351 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, DISABLED_ShowMenu
) {
353 user_manager::UserManager::Get()->UserLoggedIn(
354 "owner@invalid.domain", "owner@invalid.domain", true);
355 user_manager::UserManager::Get()->SessionStarted();
357 SetShowAccessibilityOptionsInSystemTrayMenu(false);
359 // Confirms that the menu is hidden.
360 EXPECT_FALSE(CanCreateMenuItem());
362 // Toggling spoken feedback changes the visibillity of the menu.
363 AccessibilityManager::Get()->EnableSpokenFeedback(
364 true, ui::A11Y_NOTIFICATION_NONE
);
365 EXPECT_TRUE(CanCreateMenuItem());
366 AccessibilityManager::Get()->EnableSpokenFeedback(
367 false, ui::A11Y_NOTIFICATION_NONE
);
368 EXPECT_FALSE(CanCreateMenuItem());
370 // Toggling high contrast changes the visibillity of the menu.
371 AccessibilityManager::Get()->EnableHighContrast(true);
372 EXPECT_TRUE(CanCreateMenuItem());
373 AccessibilityManager::Get()->EnableHighContrast(false);
374 EXPECT_FALSE(CanCreateMenuItem());
376 // Toggling screen magnifier changes the visibility of the menu.
377 SetMagnifierEnabled(true);
378 EXPECT_TRUE(CanCreateMenuItem());
379 SetMagnifierEnabled(false);
380 EXPECT_FALSE(CanCreateMenuItem());
382 // Toggling autoclick changes the visibility of the menu.
383 AccessibilityManager::Get()->EnableAutoclick(true);
384 EXPECT_TRUE(CanCreateMenuItem());
385 AccessibilityManager::Get()->EnableAutoclick(false);
386 EXPECT_FALSE(CanCreateMenuItem());
388 // Toggling virtual keyboard changes the visibility of the menu.
389 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
390 EXPECT_TRUE(CanCreateMenuItem());
391 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
392 EXPECT_FALSE(CanCreateMenuItem());
394 // Enabling all accessibility features.
395 SetMagnifierEnabled(true);
396 EXPECT_TRUE(CanCreateMenuItem());
397 AccessibilityManager::Get()->EnableHighContrast(true);
398 EXPECT_TRUE(CanCreateMenuItem());
399 AccessibilityManager::Get()->EnableSpokenFeedback(
400 true, ui::A11Y_NOTIFICATION_NONE
);
401 EXPECT_TRUE(CanCreateMenuItem());
402 AccessibilityManager::Get()->EnableAutoclick(true);
403 EXPECT_TRUE(CanCreateMenuItem());
404 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
405 EXPECT_TRUE(CanCreateMenuItem());
406 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
407 EXPECT_TRUE(CanCreateMenuItem());
408 AccessibilityManager::Get()->EnableAutoclick(false);
409 EXPECT_TRUE(CanCreateMenuItem());
410 AccessibilityManager::Get()->EnableSpokenFeedback(
411 false, ui::A11Y_NOTIFICATION_NONE
);
412 EXPECT_TRUE(CanCreateMenuItem());
413 AccessibilityManager::Get()->EnableHighContrast(false);
414 EXPECT_TRUE(CanCreateMenuItem());
415 SetMagnifierEnabled(false);
416 EXPECT_FALSE(CanCreateMenuItem());
419 // http://crbug.com/396318
420 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
,
421 DISABLED_ShowMenuWithShowMenuOption
) {
423 user_manager::UserManager::Get()->UserLoggedIn(
424 "owner@invalid.domain", "owner@invalid.domain", true);
425 user_manager::UserManager::Get()->SessionStarted();
427 SetShowAccessibilityOptionsInSystemTrayMenu(true);
429 // Confirms that the menu is visible.
430 EXPECT_TRUE(CanCreateMenuItem());
432 // The menu remains visible regardless of toggling spoken feedback.
433 AccessibilityManager::Get()->EnableSpokenFeedback(
434 true, ui::A11Y_NOTIFICATION_NONE
);
435 EXPECT_TRUE(CanCreateMenuItem());
436 AccessibilityManager::Get()->EnableSpokenFeedback(
437 false, ui::A11Y_NOTIFICATION_NONE
);
438 EXPECT_TRUE(CanCreateMenuItem());
440 // The menu remains visible regardless of toggling high contrast.
441 AccessibilityManager::Get()->EnableHighContrast(true);
442 EXPECT_TRUE(CanCreateMenuItem());
443 AccessibilityManager::Get()->EnableHighContrast(false);
444 EXPECT_TRUE(CanCreateMenuItem());
446 // The menu remains visible regardless of toggling screen magnifier.
447 SetMagnifierEnabled(true);
448 EXPECT_TRUE(CanCreateMenuItem());
449 SetMagnifierEnabled(false);
450 EXPECT_TRUE(CanCreateMenuItem());
452 // The menu remains visible regardless of toggling autoclick.
453 AccessibilityManager::Get()->EnableAutoclick(true);
454 EXPECT_TRUE(CanCreateMenuItem());
455 AccessibilityManager::Get()->EnableAutoclick(false);
456 EXPECT_TRUE(CanCreateMenuItem());
458 // The menu remains visible regardless of toggling on-screen keyboard.
459 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
460 EXPECT_TRUE(CanCreateMenuItem());
461 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
462 EXPECT_TRUE(CanCreateMenuItem());
464 // Enabling all accessibility features.
465 SetMagnifierEnabled(true);
466 EXPECT_TRUE(CanCreateMenuItem());
467 AccessibilityManager::Get()->EnableHighContrast(true);
468 EXPECT_TRUE(CanCreateMenuItem());
469 AccessibilityManager::Get()->EnableSpokenFeedback(
470 true, ui::A11Y_NOTIFICATION_NONE
);
471 EXPECT_TRUE(CanCreateMenuItem());
472 AccessibilityManager::Get()->EnableAutoclick(true);
473 EXPECT_TRUE(CanCreateMenuItem());
474 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
475 EXPECT_TRUE(CanCreateMenuItem());
476 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
477 EXPECT_TRUE(CanCreateMenuItem());
478 AccessibilityManager::Get()->EnableAutoclick(false);
479 EXPECT_TRUE(CanCreateMenuItem());
480 AccessibilityManager::Get()->EnableSpokenFeedback(
481 false, ui::A11Y_NOTIFICATION_NONE
);
482 EXPECT_TRUE(CanCreateMenuItem());
483 AccessibilityManager::Get()->EnableHighContrast(false);
484 EXPECT_TRUE(CanCreateMenuItem());
485 SetMagnifierEnabled(false);
486 EXPECT_TRUE(CanCreateMenuItem());
488 SetShowAccessibilityOptionsInSystemTrayMenu(false);
490 // Confirms that the menu is invisible.
491 EXPECT_FALSE(CanCreateMenuItem());
494 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, ShowMenuWithShowOnLoginScreen
) {
495 SetLoginStatus(ash::user::LOGGED_IN_NONE
);
497 // Confirms that the menu is visible.
498 EXPECT_TRUE(CanCreateMenuItem());
500 // The menu remains visible regardless of toggling spoken feedback.
501 AccessibilityManager::Get()->EnableSpokenFeedback(
502 true, ui::A11Y_NOTIFICATION_NONE
);
503 EXPECT_TRUE(CanCreateMenuItem());
504 AccessibilityManager::Get()->EnableSpokenFeedback(
505 false, ui::A11Y_NOTIFICATION_NONE
);
506 EXPECT_TRUE(CanCreateMenuItem());
508 // The menu remains visible regardless of toggling high contrast.
509 AccessibilityManager::Get()->EnableHighContrast(true);
510 EXPECT_TRUE(CanCreateMenuItem());
511 AccessibilityManager::Get()->EnableHighContrast(false);
512 EXPECT_TRUE(CanCreateMenuItem());
514 // The menu remains visible regardless of toggling screen magnifier.
515 SetMagnifierEnabled(true);
516 EXPECT_TRUE(CanCreateMenuItem());
517 SetMagnifierEnabled(false);
518 EXPECT_TRUE(CanCreateMenuItem());
520 // The menu remains visible regardless of toggling on-screen keyboard.
521 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
522 EXPECT_TRUE(CanCreateMenuItem());
523 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
524 EXPECT_TRUE(CanCreateMenuItem());
526 // Enabling all accessibility features.
527 SetMagnifierEnabled(true);
528 EXPECT_TRUE(CanCreateMenuItem());
529 AccessibilityManager::Get()->EnableHighContrast(true);
530 EXPECT_TRUE(CanCreateMenuItem());
531 AccessibilityManager::Get()->EnableSpokenFeedback(
532 true, ui::A11Y_NOTIFICATION_NONE
);
533 EXPECT_TRUE(CanCreateMenuItem());
534 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
535 EXPECT_TRUE(CanCreateMenuItem());
536 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
537 EXPECT_TRUE(CanCreateMenuItem());
538 AccessibilityManager::Get()->EnableSpokenFeedback(
539 false, ui::A11Y_NOTIFICATION_NONE
);
540 EXPECT_TRUE(CanCreateMenuItem());
541 AccessibilityManager::Get()->EnableHighContrast(false);
542 EXPECT_TRUE(CanCreateMenuItem());
543 SetMagnifierEnabled(false);
544 EXPECT_TRUE(CanCreateMenuItem());
546 SetShowAccessibilityOptionsInSystemTrayMenu(true);
548 // Confirms that the menu remains visible.
549 EXPECT_TRUE(CanCreateMenuItem());
551 SetShowAccessibilityOptionsInSystemTrayMenu(false);
553 // Confirms that the menu remains visible.
554 EXPECT_TRUE(CanCreateMenuItem());
557 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, ShowNotification
) {
558 const base::string16 BRAILLE_CONNECTED
=
559 base::ASCIIToUTF16("Braille display connected.");
560 const base::string16 CHROMEVOX_ENABLED
= base::ASCIIToUTF16(
561 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable.");
562 const base::string16
BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED(
563 BRAILLE_CONNECTED
+ base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED
);
565 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
567 // Enabling spoken feedback should show the notification.
568 AccessibilityManager::Get()->EnableSpokenFeedback(
569 true, ui::A11Y_NOTIFICATION_SHOW
);
570 EXPECT_EQ(CHROMEVOX_ENABLED
, GetNotificationText());
572 // Connecting a braille display when spoken feedback is already enabled
573 // should only show the message about the braille display.
574 SetBrailleConnected(true);
575 EXPECT_EQ(BRAILLE_CONNECTED
, GetNotificationText());
577 // Neither disconnecting a braille display, nor disabling spoken feedback
578 // should show any notification.
579 SetBrailleConnected(false);
580 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
581 EXPECT_FALSE(IsNotificationShown());
582 AccessibilityManager::Get()->EnableSpokenFeedback(
583 false, ui::A11Y_NOTIFICATION_SHOW
);
584 EXPECT_FALSE(IsNotificationShown());
585 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
587 // Connecting a braille display should enable spoken feedback and show
589 SetBrailleConnected(true);
590 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
591 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED
, GetNotificationText());
594 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, KeepMenuVisibilityOnLockScreen
) {
595 // Enables high contrast mode.
596 AccessibilityManager::Get()->EnableHighContrast(true);
597 EXPECT_TRUE(CanCreateMenuItem());
600 SetLoginStatus(ash::user::LOGGED_IN_LOCKED
);
601 EXPECT_TRUE(CanCreateMenuItem());
603 // Disables high contrast mode.
604 AccessibilityManager::Get()->EnableHighContrast(false);
606 // Confirms that the menu is still visible.
607 EXPECT_TRUE(CanCreateMenuItem());
610 #if defined(OS_CHROMEOS)
611 #define MAYBE_ClickDetailMenu DISABLED_ClickDetailMenu
613 #define MAYBE_ClickDetailMenu ClickDetailMenu
616 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, MAYBE_ClickDetailMenu
) {
617 // Confirms that the check item toggles the spoken feedback.
618 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
620 EXPECT_TRUE(CreateDetailedMenu());
621 ClickSpokenFeedbackOnDetailMenu();
622 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
624 EXPECT_TRUE(CreateDetailedMenu());
625 ClickSpokenFeedbackOnDetailMenu();
626 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
628 // Confirms that the check item toggles the high contrast.
629 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
631 EXPECT_TRUE(CreateDetailedMenu());
632 ClickHighContrastOnDetailMenu();
633 EXPECT_TRUE(AccessibilityManager::Get()->IsHighContrastEnabled());
635 EXPECT_TRUE(CreateDetailedMenu());
636 ClickHighContrastOnDetailMenu();
637 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
639 // Confirms that the check item toggles the magnifier.
640 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
642 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
643 EXPECT_TRUE(CreateDetailedMenu());
644 ClickScreenMagnifierOnDetailMenu();
645 EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled());
647 EXPECT_TRUE(CreateDetailedMenu());
648 ClickScreenMagnifierOnDetailMenu();
649 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
651 // Confirms that the check item toggles autoclick.
652 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
654 EXPECT_TRUE(CreateDetailedMenu());
655 ClickAutoclickOnDetailMenu();
656 EXPECT_TRUE(AccessibilityManager::Get()->IsAutoclickEnabled());
658 EXPECT_TRUE(CreateDetailedMenu());
659 ClickAutoclickOnDetailMenu();
660 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
662 // Confirms that the check item toggles on-screen keyboard.
663 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
665 EXPECT_TRUE(CreateDetailedMenu());
666 ClickVirtualKeyboardOnDetailMenu();
667 EXPECT_TRUE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
669 EXPECT_TRUE(CreateDetailedMenu());
670 ClickVirtualKeyboardOnDetailMenu();
671 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
674 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, CheckMarksOnDetailMenu
) {
675 SetLoginStatus(ash::user::LOGGED_IN_NONE
);
677 // At first, all of the check is unchecked.
678 EXPECT_TRUE(CreateDetailedMenu());
679 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
680 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
681 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
682 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
683 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
684 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
687 // Enabling spoken feedback.
688 AccessibilityManager::Get()->EnableSpokenFeedback(
689 true, ui::A11Y_NOTIFICATION_NONE
);
690 EXPECT_TRUE(CreateDetailedMenu());
691 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
692 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
693 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
694 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
695 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
696 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
699 // Disabling spoken feedback.
700 AccessibilityManager::Get()->EnableSpokenFeedback(
701 false, ui::A11Y_NOTIFICATION_NONE
);
702 EXPECT_TRUE(CreateDetailedMenu());
703 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
704 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
705 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
706 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
707 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
708 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
711 // Enabling high contrast.
712 AccessibilityManager::Get()->EnableHighContrast(true);
713 EXPECT_TRUE(CreateDetailedMenu());
714 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
715 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
716 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
717 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
718 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
719 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
722 // Disabling high contrast.
723 AccessibilityManager::Get()->EnableHighContrast(false);
724 EXPECT_TRUE(CreateDetailedMenu());
725 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
726 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
727 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
728 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
729 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
730 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
733 // Enabling full screen magnifier.
734 SetMagnifierEnabled(true);
735 EXPECT_TRUE(CreateDetailedMenu());
736 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
737 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
738 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
739 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
740 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
741 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
744 // Disabling screen magnifier.
745 SetMagnifierEnabled(false);
746 EXPECT_TRUE(CreateDetailedMenu());
747 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
748 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
749 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
750 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
751 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
752 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
755 // Enabling large cursor.
756 AccessibilityManager::Get()->EnableLargeCursor(true);
757 EXPECT_TRUE(CreateDetailedMenu());
758 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
759 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
760 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
761 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
762 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
763 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
766 // Disabling large cursor.
767 AccessibilityManager::Get()->EnableLargeCursor(false);
768 EXPECT_TRUE(CreateDetailedMenu());
769 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
770 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
771 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
772 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
773 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
774 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
777 // Enable on-screen keyboard.
778 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
779 EXPECT_TRUE(CreateDetailedMenu());
780 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
781 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
782 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
783 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
784 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
785 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
788 // Disable on-screen keyboard.
789 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
790 EXPECT_TRUE(CreateDetailedMenu());
791 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
792 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
793 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
794 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
795 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
796 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
799 // Enabling all of the a11y features.
800 AccessibilityManager::Get()->EnableSpokenFeedback(
801 true, ui::A11Y_NOTIFICATION_NONE
);
802 AccessibilityManager::Get()->EnableHighContrast(true);
803 SetMagnifierEnabled(true);
804 AccessibilityManager::Get()->EnableLargeCursor(true);
805 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
806 EXPECT_TRUE(CreateDetailedMenu());
807 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
808 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
809 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
810 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
811 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
812 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
815 // Disabling all of the a11y features.
816 AccessibilityManager::Get()->EnableSpokenFeedback(
817 false, ui::A11Y_NOTIFICATION_NONE
);
818 AccessibilityManager::Get()->EnableHighContrast(false);
819 SetMagnifierEnabled(false);
820 AccessibilityManager::Get()->EnableLargeCursor(false);
821 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
822 EXPECT_TRUE(CreateDetailedMenu());
823 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
824 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
825 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
826 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
827 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
828 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
831 // Autoclick is disabled on login screen.
832 SetLoginStatus(ash::user::LOGGED_IN_USER
);
834 // Enabling autoclick.
835 AccessibilityManager::Get()->EnableAutoclick(true);
836 EXPECT_TRUE(CreateDetailedMenu());
837 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
838 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
839 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
840 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
841 EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
842 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
845 // Disabling autoclick.
846 AccessibilityManager::Get()->EnableAutoclick(false);
847 EXPECT_TRUE(CreateDetailedMenu());
848 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
849 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
850 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
851 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
852 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
853 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
857 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest
, CheckMenuVisibilityOnDetailMenu
) {
858 SetLoginStatus(ash::user::LOGGED_IN_NONE
);
859 EXPECT_TRUE(CreateDetailedMenu());
860 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
861 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
862 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
863 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
864 EXPECT_FALSE(IsAutoclickMenuShownOnDetailMenu());
865 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
866 EXPECT_FALSE(IsHelpShownOnDetailMenu());
867 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
870 SetLoginStatus(ash::user::LOGGED_IN_USER
);
871 EXPECT_TRUE(CreateDetailedMenu());
872 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
873 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
874 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
875 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
876 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
877 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
878 EXPECT_TRUE(IsHelpShownOnDetailMenu());
879 EXPECT_TRUE(IsSettingsShownOnDetailMenu());
882 SetLoginStatus(ash::user::LOGGED_IN_LOCKED
);
883 EXPECT_TRUE(CreateDetailedMenu());
884 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
885 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
886 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
887 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
888 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
889 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
890 EXPECT_FALSE(IsHelpShownOnDetailMenu());
891 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
894 ash::test::TestSessionStateDelegate
* session_state_delegate
=
895 new ash::test::TestSessionStateDelegate
;
896 ash::test::ShellTestApi
test_api(ash::Shell::GetInstance());
897 test_api
.SetSessionStateDelegate(session_state_delegate
);
898 session_state_delegate
->SetUserAddingScreenRunning(true);
899 SetLoginStatus(ash::user::LOGGED_IN_USER
);
900 EXPECT_TRUE(CreateDetailedMenu());
901 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
902 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
903 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
904 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
905 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
906 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
907 EXPECT_FALSE(IsHelpShownOnDetailMenu());
908 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
912 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance
,
913 TrayAccessibilityTest
,
914 testing::Values(PREF_SERVICE
,
917 } // namespace chromeos