Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / system / tray_accessibility_browsertest.cc
blob2badedad77f2c8ed5044f5762675b0fe4c80d8a5
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 "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;
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 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 policy::POLICY_SOURCE_CLOUD,
108 new base::FundamentalValue(value),
109 NULL);
110 provider_.UpdateChromePolicy(policy_map);
111 base::RunLoop().RunUntilIdle();
112 } else {
113 FAIL() << "Unknown test parameterization";
117 ash::TrayAccessibility* tray() {
118 return ash::Shell::GetInstance()->GetPrimarySystemTray()->
119 GetTrayAccessibilityForTest();
122 const ash::TrayAccessibility* tray() const {
123 return ash::Shell::GetInstance()
124 ->GetPrimarySystemTray()
125 ->GetTrayAccessibilityForTest();
128 bool IsTrayIconVisible() const { return tray()->tray_icon_visible_; }
130 views::View* CreateMenuItem() {
131 return tray()->CreateDefaultView(GetLoginStatus());
134 void DestroyMenuItem() {
135 return tray()->DestroyDefaultView();
138 bool CanCreateMenuItem() {
139 views::View* menu_item_view = CreateMenuItem();
140 DestroyMenuItem();
141 return menu_item_view != NULL;
144 void SetLoginStatus(ash::user::LoginStatus status) {
145 tray()->UpdateAfterLoginStatusChange(status);
148 ash::user::LoginStatus GetLoginStatus() {
149 return tray()->login_;
152 bool CreateDetailedMenu() {
153 tray()->PopupDetailedView(0, false);
154 return tray()->detailed_menu_ != NULL;
157 void CloseDetailMenu() {
158 CHECK(tray()->detailed_menu_);
159 tray()->DestroyDetailedView();
160 tray()->detailed_menu_ = NULL;
163 void ClickSpokenFeedbackOnDetailMenu() {
164 views::View* button = tray()->detailed_menu_->spoken_feedback_view_;
165 ASSERT_TRUE(button);
166 tray()->detailed_menu_->OnViewClicked(button);
169 void ClickHighContrastOnDetailMenu() {
170 views::View* button = tray()->detailed_menu_->high_contrast_view_;
171 ASSERT_TRUE(button);
172 tray()->detailed_menu_->OnViewClicked(button);
175 void ClickScreenMagnifierOnDetailMenu() {
176 views::View* button = tray()->detailed_menu_->screen_magnifier_view_;
177 ASSERT_TRUE(button);
178 tray()->detailed_menu_->OnViewClicked(button);
181 void ClickAutoclickOnDetailMenu() {
182 views::View* button = tray()->detailed_menu_->autoclick_view_;
183 ASSERT_TRUE(button);
184 tray()->detailed_menu_->OnViewClicked(button);
187 void ClickVirtualKeyboardOnDetailMenu() {
188 views::View* button = tray()->detailed_menu_->virtual_keyboard_view_;
189 ASSERT_TRUE(button);
190 tray()->detailed_menu_->OnViewClicked(button);
193 bool IsSpokenFeedbackEnabledOnDetailMenu() const {
194 return tray()->detailed_menu_->spoken_feedback_enabled_;
197 bool IsHighContrastEnabledOnDetailMenu() const {
198 return tray()->detailed_menu_->high_contrast_enabled_;
201 bool IsScreenMagnifierEnabledOnDetailMenu() const {
202 return tray()->detailed_menu_->screen_magnifier_enabled_;
205 bool IsLargeCursorEnabledOnDetailMenu() const {
206 return tray()->detailed_menu_->large_cursor_enabled_;
209 bool IsAutoclickEnabledOnDetailMenu() const {
210 return tray()->detailed_menu_->autoclick_enabled_;
213 bool IsVirtualKeyboardEnabledOnDetailMenu() const {
214 return tray()->detailed_menu_->virtual_keyboard_enabled_;
217 bool IsSpokenFeedbackMenuShownOnDetailMenu() const {
218 return tray()->detailed_menu_->spoken_feedback_view_;
221 bool IsHighContrastMenuShownOnDetailMenu() const {
222 return tray()->detailed_menu_->high_contrast_view_;
225 bool IsScreenMagnifierMenuShownOnDetailMenu() const {
226 return tray()->detailed_menu_->screen_magnifier_view_;
229 bool IsLargeCursorMenuShownOnDetailMenu() const {
230 return tray()->detailed_menu_->large_cursor_view_;
233 bool IsAutoclickMenuShownOnDetailMenu() const {
234 return tray()->detailed_menu_->autoclick_view_;
237 bool IsVirtualKeyboardMenuShownOnDetailMenu() const {
238 return tray()->detailed_menu_->virtual_keyboard_view_;
241 bool IsHelpShownOnDetailMenu() const {
242 return tray()->detailed_menu_->help_view_;
245 bool IsSettingsShownOnDetailMenu() const {
246 return tray()->detailed_menu_->settings_view_;
249 bool IsNotificationShown() const {
250 return (tray()->detailed_popup_ &&
251 !tray()->detailed_popup_->GetWidget()->IsClosed());
254 base::string16 GetNotificationText() const {
255 if (IsNotificationShown())
256 return tray()->detailed_popup_->label_for_test()->text();
257 else
258 return base::string16();
261 void SetBrailleConnected(bool connected) {
262 braille_controller_.SetAvailable(connected);
263 braille_controller_.GetObserver()->OnBrailleDisplayStateChanged(
264 *braille_controller_.GetDisplayState());
267 policy::MockConfigurationPolicyProvider provider_;
268 MockBrailleController braille_controller_;
271 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) {
272 EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus());
274 user_manager::UserManager::Get()->UserLoggedIn(
275 "owner@invalid.domain", "owner@invalid.domain", true);
276 user_manager::UserManager::Get()->SessionStarted();
278 EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus());
281 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, 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
315 // icon.
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 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
351 // Login
352 user_manager::UserManager::Get()->UserLoggedIn(
353 "owner@invalid.domain", "owner@invalid.domain", true);
354 user_manager::UserManager::Get()->SessionStarted();
356 SetShowAccessibilityOptionsInSystemTrayMenu(false);
358 // Confirms that the menu is hidden.
359 EXPECT_FALSE(CanCreateMenuItem());
361 // Toggling spoken feedback changes the visibillity of the menu.
362 AccessibilityManager::Get()->EnableSpokenFeedback(
363 true, ui::A11Y_NOTIFICATION_NONE);
364 EXPECT_TRUE(CanCreateMenuItem());
365 AccessibilityManager::Get()->EnableSpokenFeedback(
366 false, ui::A11Y_NOTIFICATION_NONE);
367 EXPECT_FALSE(CanCreateMenuItem());
369 // Toggling high contrast changes the visibillity of the menu.
370 AccessibilityManager::Get()->EnableHighContrast(true);
371 EXPECT_TRUE(CanCreateMenuItem());
372 AccessibilityManager::Get()->EnableHighContrast(false);
373 EXPECT_FALSE(CanCreateMenuItem());
375 // Toggling screen magnifier changes the visibility of the menu.
376 SetMagnifierEnabled(true);
377 EXPECT_TRUE(CanCreateMenuItem());
378 SetMagnifierEnabled(false);
379 EXPECT_FALSE(CanCreateMenuItem());
381 // Toggling autoclick changes the visibility of the menu.
382 AccessibilityManager::Get()->EnableAutoclick(true);
383 EXPECT_TRUE(CanCreateMenuItem());
384 AccessibilityManager::Get()->EnableAutoclick(false);
385 EXPECT_FALSE(CanCreateMenuItem());
387 // Toggling virtual keyboard changes the visibility of the menu.
388 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
389 EXPECT_TRUE(CanCreateMenuItem());
390 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
391 EXPECT_FALSE(CanCreateMenuItem());
393 // Enabling all accessibility features.
394 SetMagnifierEnabled(true);
395 EXPECT_TRUE(CanCreateMenuItem());
396 AccessibilityManager::Get()->EnableHighContrast(true);
397 EXPECT_TRUE(CanCreateMenuItem());
398 AccessibilityManager::Get()->EnableSpokenFeedback(
399 true, ui::A11Y_NOTIFICATION_NONE);
400 EXPECT_TRUE(CanCreateMenuItem());
401 AccessibilityManager::Get()->EnableAutoclick(true);
402 EXPECT_TRUE(CanCreateMenuItem());
403 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
404 EXPECT_TRUE(CanCreateMenuItem());
405 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
406 EXPECT_TRUE(CanCreateMenuItem());
407 AccessibilityManager::Get()->EnableAutoclick(false);
408 EXPECT_TRUE(CanCreateMenuItem());
409 AccessibilityManager::Get()->EnableSpokenFeedback(
410 false, ui::A11Y_NOTIFICATION_NONE);
411 EXPECT_TRUE(CanCreateMenuItem());
412 AccessibilityManager::Get()->EnableHighContrast(false);
413 EXPECT_TRUE(CanCreateMenuItem());
414 SetMagnifierEnabled(false);
415 EXPECT_FALSE(CanCreateMenuItem());
418 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
419 // Login
420 user_manager::UserManager::Get()->UserLoggedIn(
421 "owner@invalid.domain", "owner@invalid.domain", true);
422 user_manager::UserManager::Get()->SessionStarted();
424 SetShowAccessibilityOptionsInSystemTrayMenu(true);
426 // Confirms that the menu is visible.
427 EXPECT_TRUE(CanCreateMenuItem());
429 // The menu remains visible regardless of toggling spoken feedback.
430 AccessibilityManager::Get()->EnableSpokenFeedback(
431 true, ui::A11Y_NOTIFICATION_NONE);
432 EXPECT_TRUE(CanCreateMenuItem());
433 AccessibilityManager::Get()->EnableSpokenFeedback(
434 false, ui::A11Y_NOTIFICATION_NONE);
435 EXPECT_TRUE(CanCreateMenuItem());
437 // The menu remains visible regardless of toggling high contrast.
438 AccessibilityManager::Get()->EnableHighContrast(true);
439 EXPECT_TRUE(CanCreateMenuItem());
440 AccessibilityManager::Get()->EnableHighContrast(false);
441 EXPECT_TRUE(CanCreateMenuItem());
443 // The menu remains visible regardless of toggling screen magnifier.
444 SetMagnifierEnabled(true);
445 EXPECT_TRUE(CanCreateMenuItem());
446 SetMagnifierEnabled(false);
447 EXPECT_TRUE(CanCreateMenuItem());
449 // The menu remains visible regardless of toggling autoclick.
450 AccessibilityManager::Get()->EnableAutoclick(true);
451 EXPECT_TRUE(CanCreateMenuItem());
452 AccessibilityManager::Get()->EnableAutoclick(false);
453 EXPECT_TRUE(CanCreateMenuItem());
455 // The menu remains visible regardless of toggling on-screen keyboard.
456 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
457 EXPECT_TRUE(CanCreateMenuItem());
458 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
459 EXPECT_TRUE(CanCreateMenuItem());
461 // Enabling all accessibility features.
462 SetMagnifierEnabled(true);
463 EXPECT_TRUE(CanCreateMenuItem());
464 AccessibilityManager::Get()->EnableHighContrast(true);
465 EXPECT_TRUE(CanCreateMenuItem());
466 AccessibilityManager::Get()->EnableSpokenFeedback(
467 true, ui::A11Y_NOTIFICATION_NONE);
468 EXPECT_TRUE(CanCreateMenuItem());
469 AccessibilityManager::Get()->EnableAutoclick(true);
470 EXPECT_TRUE(CanCreateMenuItem());
471 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
472 EXPECT_TRUE(CanCreateMenuItem());
473 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
474 EXPECT_TRUE(CanCreateMenuItem());
475 AccessibilityManager::Get()->EnableAutoclick(false);
476 EXPECT_TRUE(CanCreateMenuItem());
477 AccessibilityManager::Get()->EnableSpokenFeedback(
478 false, ui::A11Y_NOTIFICATION_NONE);
479 EXPECT_TRUE(CanCreateMenuItem());
480 AccessibilityManager::Get()->EnableHighContrast(false);
481 EXPECT_TRUE(CanCreateMenuItem());
482 SetMagnifierEnabled(false);
483 EXPECT_TRUE(CanCreateMenuItem());
485 SetShowAccessibilityOptionsInSystemTrayMenu(false);
487 // Confirms that the menu is invisible.
488 EXPECT_FALSE(CanCreateMenuItem());
491 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) {
492 SetLoginStatus(ash::user::LOGGED_IN_NONE);
494 // Confirms that the menu is visible.
495 EXPECT_TRUE(CanCreateMenuItem());
497 // The menu remains visible regardless of toggling spoken feedback.
498 AccessibilityManager::Get()->EnableSpokenFeedback(
499 true, ui::A11Y_NOTIFICATION_NONE);
500 EXPECT_TRUE(CanCreateMenuItem());
501 AccessibilityManager::Get()->EnableSpokenFeedback(
502 false, ui::A11Y_NOTIFICATION_NONE);
503 EXPECT_TRUE(CanCreateMenuItem());
505 // The menu remains visible regardless of toggling high contrast.
506 AccessibilityManager::Get()->EnableHighContrast(true);
507 EXPECT_TRUE(CanCreateMenuItem());
508 AccessibilityManager::Get()->EnableHighContrast(false);
509 EXPECT_TRUE(CanCreateMenuItem());
511 // The menu remains visible regardless of toggling screen magnifier.
512 SetMagnifierEnabled(true);
513 EXPECT_TRUE(CanCreateMenuItem());
514 SetMagnifierEnabled(false);
515 EXPECT_TRUE(CanCreateMenuItem());
517 // The menu remains visible regardless of toggling on-screen keyboard.
518 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
519 EXPECT_TRUE(CanCreateMenuItem());
520 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
521 EXPECT_TRUE(CanCreateMenuItem());
523 // Enabling all accessibility features.
524 SetMagnifierEnabled(true);
525 EXPECT_TRUE(CanCreateMenuItem());
526 AccessibilityManager::Get()->EnableHighContrast(true);
527 EXPECT_TRUE(CanCreateMenuItem());
528 AccessibilityManager::Get()->EnableSpokenFeedback(
529 true, ui::A11Y_NOTIFICATION_NONE);
530 EXPECT_TRUE(CanCreateMenuItem());
531 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
532 EXPECT_TRUE(CanCreateMenuItem());
533 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
534 EXPECT_TRUE(CanCreateMenuItem());
535 AccessibilityManager::Get()->EnableSpokenFeedback(
536 false, ui::A11Y_NOTIFICATION_NONE);
537 EXPECT_TRUE(CanCreateMenuItem());
538 AccessibilityManager::Get()->EnableHighContrast(false);
539 EXPECT_TRUE(CanCreateMenuItem());
540 SetMagnifierEnabled(false);
541 EXPECT_TRUE(CanCreateMenuItem());
543 SetShowAccessibilityOptionsInSystemTrayMenu(true);
545 // Confirms that the menu remains visible.
546 EXPECT_TRUE(CanCreateMenuItem());
548 SetShowAccessibilityOptionsInSystemTrayMenu(false);
550 // Confirms that the menu remains visible.
551 EXPECT_TRUE(CanCreateMenuItem());
554 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) {
555 const base::string16 BRAILLE_CONNECTED =
556 base::ASCIIToUTF16("Braille display connected.");
557 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16(
558 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable.");
559 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED(
560 BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED);
562 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
564 // Enabling spoken feedback should show the notification.
565 AccessibilityManager::Get()->EnableSpokenFeedback(
566 true, ui::A11Y_NOTIFICATION_SHOW);
567 EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText());
569 // Connecting a braille display when spoken feedback is already enabled
570 // should only show the message about the braille display.
571 SetBrailleConnected(true);
572 EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText());
574 // Neither disconnecting a braille display, nor disabling spoken feedback
575 // should show any notification.
576 SetBrailleConnected(false);
577 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
578 EXPECT_FALSE(IsNotificationShown());
579 AccessibilityManager::Get()->EnableSpokenFeedback(
580 false, ui::A11Y_NOTIFICATION_SHOW);
581 EXPECT_FALSE(IsNotificationShown());
582 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
584 // Connecting a braille display should enable spoken feedback and show
585 // both messages.
586 SetBrailleConnected(true);
587 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
588 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText());
591 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
592 // Enables high contrast mode.
593 AccessibilityManager::Get()->EnableHighContrast(true);
594 EXPECT_TRUE(CanCreateMenuItem());
596 // Locks the screen.
597 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
598 EXPECT_TRUE(CanCreateMenuItem());
600 // Disables high contrast mode.
601 AccessibilityManager::Get()->EnableHighContrast(false);
603 // Confirms that the menu is still visible.
604 EXPECT_TRUE(CanCreateMenuItem());
607 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ClickDetailMenu) {
608 SetLoginStatus(ash::user::LOGGED_IN_USER);
610 // Confirms that the check item toggles the spoken feedback.
611 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
613 EXPECT_TRUE(CreateDetailedMenu());
614 ClickSpokenFeedbackOnDetailMenu();
615 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
617 EXPECT_TRUE(CreateDetailedMenu());
618 ClickSpokenFeedbackOnDetailMenu();
619 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
621 // Confirms that the check item toggles the high contrast.
622 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
624 EXPECT_TRUE(CreateDetailedMenu());
625 ClickHighContrastOnDetailMenu();
626 EXPECT_TRUE(AccessibilityManager::Get()->IsHighContrastEnabled());
628 EXPECT_TRUE(CreateDetailedMenu());
629 ClickHighContrastOnDetailMenu();
630 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
632 // Confirms that the check item toggles the magnifier.
633 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
635 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
636 EXPECT_TRUE(CreateDetailedMenu());
637 ClickScreenMagnifierOnDetailMenu();
638 EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled());
640 EXPECT_TRUE(CreateDetailedMenu());
641 ClickScreenMagnifierOnDetailMenu();
642 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
644 // Confirms that the check item toggles autoclick.
645 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
647 EXPECT_TRUE(CreateDetailedMenu());
648 ClickAutoclickOnDetailMenu();
649 EXPECT_TRUE(AccessibilityManager::Get()->IsAutoclickEnabled());
651 EXPECT_TRUE(CreateDetailedMenu());
652 ClickAutoclickOnDetailMenu();
653 EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
655 // Confirms that the check item toggles on-screen keyboard.
656 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
658 EXPECT_TRUE(CreateDetailedMenu());
659 ClickVirtualKeyboardOnDetailMenu();
660 EXPECT_TRUE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
662 EXPECT_TRUE(CreateDetailedMenu());
663 ClickVirtualKeyboardOnDetailMenu();
664 EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
667 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMarksOnDetailMenu) {
668 SetLoginStatus(ash::user::LOGGED_IN_NONE);
670 // At first, all of the check is unchecked.
671 EXPECT_TRUE(CreateDetailedMenu());
672 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
673 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
674 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
675 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
676 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
677 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
678 CloseDetailMenu();
680 // Enabling spoken feedback.
681 AccessibilityManager::Get()->EnableSpokenFeedback(
682 true, ui::A11Y_NOTIFICATION_NONE);
683 EXPECT_TRUE(CreateDetailedMenu());
684 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
685 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
686 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
687 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
688 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
689 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
690 CloseDetailMenu();
692 // Disabling spoken feedback.
693 AccessibilityManager::Get()->EnableSpokenFeedback(
694 false, ui::A11Y_NOTIFICATION_NONE);
695 EXPECT_TRUE(CreateDetailedMenu());
696 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
697 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
698 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
699 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
700 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
701 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
702 CloseDetailMenu();
704 // Enabling high contrast.
705 AccessibilityManager::Get()->EnableHighContrast(true);
706 EXPECT_TRUE(CreateDetailedMenu());
707 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
708 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
709 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
710 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
711 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
712 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
713 CloseDetailMenu();
715 // Disabling high contrast.
716 AccessibilityManager::Get()->EnableHighContrast(false);
717 EXPECT_TRUE(CreateDetailedMenu());
718 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
719 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
720 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
721 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
722 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
723 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
724 CloseDetailMenu();
726 // Enabling full screen magnifier.
727 SetMagnifierEnabled(true);
728 EXPECT_TRUE(CreateDetailedMenu());
729 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
730 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
731 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
732 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
733 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
734 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
735 CloseDetailMenu();
737 // Disabling screen magnifier.
738 SetMagnifierEnabled(false);
739 EXPECT_TRUE(CreateDetailedMenu());
740 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
741 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
742 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
743 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
744 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
745 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
746 CloseDetailMenu();
748 // Enabling large cursor.
749 AccessibilityManager::Get()->EnableLargeCursor(true);
750 EXPECT_TRUE(CreateDetailedMenu());
751 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
752 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
753 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
754 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
755 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
756 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
757 CloseDetailMenu();
759 // Disabling large cursor.
760 AccessibilityManager::Get()->EnableLargeCursor(false);
761 EXPECT_TRUE(CreateDetailedMenu());
762 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
763 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
764 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
765 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
766 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
767 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
768 CloseDetailMenu();
770 // Enable on-screen keyboard.
771 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
772 EXPECT_TRUE(CreateDetailedMenu());
773 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
774 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
775 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
776 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
777 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
778 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
779 CloseDetailMenu();
781 // Disable on-screen keyboard.
782 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
783 EXPECT_TRUE(CreateDetailedMenu());
784 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
785 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
786 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
787 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
788 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
789 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
790 CloseDetailMenu();
792 // Enabling all of the a11y features.
793 AccessibilityManager::Get()->EnableSpokenFeedback(
794 true, ui::A11Y_NOTIFICATION_NONE);
795 AccessibilityManager::Get()->EnableHighContrast(true);
796 SetMagnifierEnabled(true);
797 AccessibilityManager::Get()->EnableLargeCursor(true);
798 AccessibilityManager::Get()->EnableVirtualKeyboard(true);
799 EXPECT_TRUE(CreateDetailedMenu());
800 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
801 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
802 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
803 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
804 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
805 EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
806 CloseDetailMenu();
808 // Disabling all of the a11y features.
809 AccessibilityManager::Get()->EnableSpokenFeedback(
810 false, ui::A11Y_NOTIFICATION_NONE);
811 AccessibilityManager::Get()->EnableHighContrast(false);
812 SetMagnifierEnabled(false);
813 AccessibilityManager::Get()->EnableLargeCursor(false);
814 AccessibilityManager::Get()->EnableVirtualKeyboard(false);
815 EXPECT_TRUE(CreateDetailedMenu());
816 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
817 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
818 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
819 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
820 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
821 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
822 CloseDetailMenu();
824 // Autoclick is disabled on login screen.
825 SetLoginStatus(ash::user::LOGGED_IN_USER);
827 // Enabling autoclick.
828 AccessibilityManager::Get()->EnableAutoclick(true);
829 EXPECT_TRUE(CreateDetailedMenu());
830 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
831 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
832 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
833 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
834 EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
835 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
836 CloseDetailMenu();
838 // Disabling autoclick.
839 AccessibilityManager::Get()->EnableAutoclick(false);
840 EXPECT_TRUE(CreateDetailedMenu());
841 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
842 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
843 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
844 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
845 EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
846 EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
847 CloseDetailMenu();
850 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMenuVisibilityOnDetailMenu) {
851 SetLoginStatus(ash::user::LOGGED_IN_NONE);
852 EXPECT_TRUE(CreateDetailedMenu());
853 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
854 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
855 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
856 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
857 EXPECT_FALSE(IsAutoclickMenuShownOnDetailMenu());
858 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
859 EXPECT_FALSE(IsHelpShownOnDetailMenu());
860 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
861 CloseDetailMenu();
863 SetLoginStatus(ash::user::LOGGED_IN_USER);
864 EXPECT_TRUE(CreateDetailedMenu());
865 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
866 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
867 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
868 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
869 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
870 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
871 EXPECT_TRUE(IsHelpShownOnDetailMenu());
872 EXPECT_TRUE(IsSettingsShownOnDetailMenu());
873 CloseDetailMenu();
875 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
876 EXPECT_TRUE(CreateDetailedMenu());
877 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
878 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
879 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
880 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
881 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
882 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
883 EXPECT_FALSE(IsHelpShownOnDetailMenu());
884 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
885 CloseDetailMenu();
887 ash::test::TestSessionStateDelegate* session_state_delegate =
888 new ash::test::TestSessionStateDelegate;
889 ash::test::ShellTestApi test_api(ash::Shell::GetInstance());
890 test_api.SetSessionStateDelegate(session_state_delegate);
891 session_state_delegate->SetUserAddingScreenRunning(true);
892 SetLoginStatus(ash::user::LOGGED_IN_USER);
893 EXPECT_TRUE(CreateDetailedMenu());
894 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
895 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
896 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
897 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
898 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
899 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
900 EXPECT_FALSE(IsHelpShownOnDetailMenu());
901 EXPECT_FALSE(IsSettingsShownOnDetailMenu());
902 CloseDetailMenu();
905 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
906 TrayAccessibilityTest,
907 testing::Values(PREF_SERVICE,
908 POLICY));
910 } // namespace chromeos