blob: 5370b9869242d6af1db2a9dd315d112576e9084b [file] [log] [blame]
[email protected]806d94e2012-12-16 20:31:261// 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.
4
5#include "ash/magnifier/magnification_controller.h"
6#include "ash/shell.h"
7#include "ash/system/tray/system_tray.h"
[email protected]806d94e2012-12-16 20:31:268#include "ash/system/tray_accessibility.h"
9#include "ash/system/user/login_status.h"
[email protected]aecb6082013-07-09 14:29:4110#include "base/callback.h"
[email protected]806d94e2012-12-16 20:31:2611#include "base/command_line.h"
[email protected]3853a4c2013-02-11 17:15:5712#include "base/prefs/pref_service.h"
[email protected]806d94e2012-12-16 20:31:2613#include "chrome/browser/browser_process.h"
[email protected]fdf40f3e2013-07-11 23:55:4614#include "chrome/browser/chrome_notification_types.h"
[email protected]1dfebfc2013-06-04 03:14:3215#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
[email protected]806d94e2012-12-16 20:31:2616#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
17#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
18#include "chrome/browser/chromeos/login/helper.h"
19#include "chrome/browser/chromeos/login/login_utils.h"
[email protected]aa8328fb2013-04-19 15:09:0620#include "chrome/browser/chromeos/login/startup_utils.h"
[email protected]806d94e2012-12-16 20:31:2621#include "chrome/browser/chromeos/login/user_manager.h"
22#include "chrome/browser/chromeos/login/user_manager_impl.h"
[email protected]5ace0c232013-05-29 00:48:4123#include "chrome/browser/policy/browser_policy_connector.h"
[email protected]aecb6082013-07-09 14:29:4124#include "chrome/browser/policy/external_data_fetcher.h"
[email protected]5ace0c232013-05-29 00:48:4125#include "chrome/browser/policy/mock_configuration_policy_provider.h"
26#include "chrome/browser/policy/policy_map.h"
27#include "chrome/browser/policy/policy_types.h"
[email protected]806d94e2012-12-16 20:31:2628#include "chrome/browser/profiles/profile.h"
29#include "chrome/browser/profiles/profile_manager.h"
[email protected]806d94e2012-12-16 20:31:2630#include "chrome/common/chrome_switches.h"
31#include "chrome/common/pref_names.h"
32#include "chrome/test/base/testing_profile.h"
[email protected]931d1042013-04-05 17:50:4433#include "chromeos/chromeos_switches.h"
[email protected]57999022013-06-07 12:52:0334#include "chromeos/login/login_state.h"
[email protected]806d94e2012-12-16 20:31:2635#include "content/public/test/test_utils.h"
[email protected]5ace0c232013-05-29 00:48:4136#include "policy/policy_constants.h"
[email protected]806d94e2012-12-16 20:31:2637#include "testing/gtest/include/gtest/gtest.h"
38#include "ui/views/widget/widget.h"
39
[email protected]5ace0c232013-05-29 00:48:4140using testing::AnyNumber;
41using testing::Return;
42using testing::_;
43using testing::WithParamInterface;
44
[email protected]806d94e2012-12-16 20:31:2645namespace chromeos {
46
[email protected]5ace0c232013-05-29 00:48:4147enum PrefSettingMechanism {
48 PREF_SERVICE,
49 POLICY,
50};
51
[email protected]7585f4c2013-01-10 18:26:4152void SetMagnifierEnabled(bool enabled) {
53 MagnificationManager::Get()->SetMagnifierEnabled(enabled);
[email protected]806d94e2012-12-16 20:31:2654}
55
[email protected]5ace0c232013-05-29 00:48:4156class TrayAccessibilityTest
57 : public CrosInProcessBrowserTest,
58 public WithParamInterface<PrefSettingMechanism> {
[email protected]806d94e2012-12-16 20:31:2659 protected:
60 TrayAccessibilityTest() {}
61 virtual ~TrayAccessibilityTest() {}
[email protected]25cf28e2013-03-25 19:26:2562
[email protected]5ace0c232013-05-29 00:48:4163 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
64 EXPECT_CALL(provider_, IsInitializationComplete(_))
65 .WillRepeatedly(Return(true));
66 EXPECT_CALL(provider_, RegisterPolicyDomain(_)).Times(AnyNumber());
67 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
68 }
69
[email protected]806d94e2012-12-16 20:31:2670 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
71 command_line->AppendSwitch(switches::kLoginManager);
72 command_line->AppendSwitchASCII(switches::kLoginProfile,
73 TestingProfile::kTestUserProfileDir);
74 }
75
[email protected]d80f19302013-06-07 13:12:1476 virtual void SetUpOnMainThread() OVERRIDE {
77 AccessibilityManager::Get()->SetProfileForTest(
78 ProfileManager::GetDefaultProfile());
79 MagnificationManager::Get()->SetProfileForTest(
80 ProfileManager::GetDefaultProfile());
81 }
82
[email protected]25cf28e2013-03-25 19:26:2583 virtual void RunTestOnMainThreadLoop() OVERRIDE {
84 // Need to mark oobe completed to show detailed views.
[email protected]aa8328fb2013-04-19 15:09:0685 StartupUtils::MarkOobeCompleted();
[email protected]25cf28e2013-03-25 19:26:2586 CrosInProcessBrowserTest::RunTestOnMainThreadLoop();
87 }
88
[email protected]5ace0c232013-05-29 00:48:4189 void SetShowAccessibilityOptionsInSystemTrayMenu(bool value) {
90 if (GetParam() == PREF_SERVICE) {
91 Profile* profile = ProfileManager::GetDefaultProfile();
92 PrefService* prefs = profile->GetPrefs();
93 prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, value);
94 } else if (GetParam() == POLICY) {
95 policy::PolicyMap policy_map;
96 policy_map.Set(policy::key::kShowAccessibilityOptionsInSystemTrayMenu,
97 policy::POLICY_LEVEL_MANDATORY,
98 policy::POLICY_SCOPE_USER,
[email protected]aecb6082013-07-09 14:29:4199 base::Value::CreateBooleanValue(value),
100 NULL);
[email protected]5ace0c232013-05-29 00:48:41101 provider_.UpdateChromePolicy(policy_map);
102 base::RunLoop().RunUntilIdle();
103 } else {
104 FAIL() << "Unknown test parameterization";
105 }
106 }
107
[email protected]806d94e2012-12-16 20:31:26108 ash::internal::TrayAccessibility* tray() {
109 return ash::Shell::GetInstance()->GetPrimarySystemTray()->
110 GetTrayAccessibilityForTest();
111 }
112
113 bool IsTrayIconVisible() {
114 return tray()->tray_icon_visible_;
115 }
116
117 views::View* CreateMenuItem() {
118 return tray()->CreateDefaultView(GetLoginStatus());
119 }
120
121 void DestroyMenuItem() {
122 return tray()->DestroyDefaultView();
123 }
124
125 bool CanCreateMenuItem() {
126 views::View* menu_item_view = CreateMenuItem();
127 DestroyMenuItem();
128 return menu_item_view != NULL;
129 }
130
131 void SetLoginStatus(ash::user::LoginStatus status) {
132 tray()->UpdateAfterLoginStatusChange(status);
133 }
134
135 ash::user::LoginStatus GetLoginStatus() {
136 return tray()->login_;
137 }
138
139 bool CreateDetailedMenu() {
140 tray()->PopupDetailedView(0, false);
141 return tray()->detailed_menu_ != NULL;
142 }
143
144 void CloseDetailMenu() {
145 CHECK(tray()->detailed_menu_);
146 tray()->DestroyDetailedView();
147 tray()->detailed_menu_ = NULL;
148 }
149
150 void ClickSpokenFeedbackOnDetailMenu() {
151 views::View* button = tray()->detailed_menu_->spoken_feedback_view_;
[email protected]acd0fd7a2013-03-04 22:00:53152 tray()->detailed_menu_->OnViewClicked(button);
[email protected]806d94e2012-12-16 20:31:26153 }
154
155 void ClickHighContrastOnDetailMenu() {
156 views::View* button = tray()->detailed_menu_->high_contrast_view_;
157 EXPECT_TRUE(button);
[email protected]acd0fd7a2013-03-04 22:00:53158 tray()->detailed_menu_->OnViewClicked(button);
[email protected]806d94e2012-12-16 20:31:26159 }
160
161 void ClickScreenMagnifierOnDetailMenu() {
162 views::View* button = tray()->detailed_menu_->screen_magnifier_view_;
163 EXPECT_TRUE(button);
[email protected]acd0fd7a2013-03-04 22:00:53164 tray()->detailed_menu_->OnViewClicked(button);
[email protected]806d94e2012-12-16 20:31:26165 }
166
167 bool IsSpokenFeedbackEnabledOnDetailMenu() {
168 return tray()->detailed_menu_->spoken_feedback_enabled_;
169 }
170
171 bool IsHighContrastEnabledOnDetailMenu() {
172 return tray()->detailed_menu_->high_contrast_enabled_;
173 }
174
175 bool IsScreenMagnifierEnabledOnDetailMenu() {
176 return tray()->detailed_menu_->screen_magnifier_enabled_;
177 }
[email protected]5ace0c232013-05-29 00:48:41178
[email protected]57999022013-06-07 12:52:03179 bool IsLargeCursorEnabledOnDetailMenu() {
180 return tray()->detailed_menu_->large_cursor_enabled_;
181 }
182
183 bool IsSpokenFeedbackMenuShownOnDetailMenu() {
184 return tray()->detailed_menu_->spoken_feedback_view_;
185 }
186
187 bool IsHighContrastMenuShownOnDetailMenu() {
188 return tray()->detailed_menu_->high_contrast_view_;
189 }
190
191 bool IsScreenMagnifierMenuShownOnDetailMenu() {
192 return tray()->detailed_menu_->screen_magnifier_view_;
193 }
194
195 bool IsLargeCursorMenuShownOnDetailMenu() {
196 return tray()->detailed_menu_->large_cursor_view_;
197 }
198
[email protected]5ace0c232013-05-29 00:48:41199 policy::MockConfigurationPolicyProvider provider_;
[email protected]806d94e2012-12-16 20:31:26200};
201
[email protected]5ace0c232013-05-29 00:48:41202IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) {
[email protected]806d94e2012-12-16 20:31:26203 EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus());
204
[email protected]40429592013-03-29 17:52:33205 UserManager::Get()->UserLoggedIn(
206 "[email protected]", "[email protected]", true);
[email protected]806d94e2012-12-16 20:31:26207 UserManager::Get()->SessionStarted();
208
209 EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus());
210}
211
[email protected]5ace0c232013-05-29 00:48:41212IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) {
[email protected]806d94e2012-12-16 20:31:26213 SetLoginStatus(ash::user::LOGGED_IN_NONE);
214
215 // Confirms that the icon is invisible before login.
216 EXPECT_FALSE(IsTrayIconVisible());
217
[email protected]40429592013-03-29 17:52:33218 UserManager::Get()->UserLoggedIn(
219 "[email protected]", "[email protected]", true);
[email protected]806d94e2012-12-16 20:31:26220 UserManager::Get()->SessionStarted();
221
222 // Confirms that the icon is invisible just after login.
223 EXPECT_FALSE(IsTrayIconVisible());
224
[email protected]1dfebfc2013-06-04 03:14:32225 // Toggling spoken feedback changes the visibillity of the icon.
226 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50227 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26228 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32229 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50230 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26231 EXPECT_FALSE(IsTrayIconVisible());
232
[email protected]1dfebfc2013-06-04 03:14:32233 // Toggling high contrast the visibillity of the icon.
234 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26235 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32236 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26237 EXPECT_FALSE(IsTrayIconVisible());
238
[email protected]5ace0c232013-05-29 00:48:41239 // Toggling magnifier the visibility of the icon.
[email protected]7585f4c2013-01-10 18:26:41240 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26241 EXPECT_TRUE(IsTrayIconVisible());
[email protected]7585f4c2013-01-10 18:26:41242 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26243 EXPECT_FALSE(IsTrayIconVisible());
244
245 // Enabling all accessibility features.
[email protected]7585f4c2013-01-10 18:26:41246 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26247 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32248 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26249 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32250 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50251 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26252 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32253 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50254 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26255 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32256 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26257 EXPECT_TRUE(IsTrayIconVisible());
[email protected]7585f4c2013-01-10 18:26:41258 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26259 EXPECT_FALSE(IsTrayIconVisible());
260
261 // Confirms that prefs::kShouldAlwaysShowAccessibilityMenu doesn't affect
262 // the icon on the tray.
[email protected]5ace0c232013-05-29 00:48:41263 SetShowAccessibilityOptionsInSystemTrayMenu(true);
[email protected]1dfebfc2013-06-04 03:14:32264 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26265 EXPECT_TRUE(IsTrayIconVisible());
[email protected]1dfebfc2013-06-04 03:14:32266 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26267 EXPECT_FALSE(IsTrayIconVisible());
268}
269
[email protected]5ace0c232013-05-29 00:48:41270IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
[email protected]806d94e2012-12-16 20:31:26271 // Login
[email protected]40429592013-03-29 17:52:33272 UserManager::Get()->UserLoggedIn(
273 "[email protected]", "[email protected]", true);
[email protected]806d94e2012-12-16 20:31:26274 UserManager::Get()->SessionStarted();
275
[email protected]5ace0c232013-05-29 00:48:41276 SetShowAccessibilityOptionsInSystemTrayMenu(false);
[email protected]806d94e2012-12-16 20:31:26277
278 // Confirms that the menu is hidden.
279 EXPECT_FALSE(CanCreateMenuItem());
280
[email protected]1dfebfc2013-06-04 03:14:32281 // Toggling spoken feedback changes the visibillity of the menu.
282 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50283 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26284 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32285 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50286 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26287 EXPECT_FALSE(CanCreateMenuItem());
288
[email protected]1dfebfc2013-06-04 03:14:32289 // Toggling high contrast changes the visibillity of the menu.
290 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26291 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32292 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26293 EXPECT_FALSE(CanCreateMenuItem());
294
[email protected]5ace0c232013-05-29 00:48:41295 // Toggling screen magnifier changes the visibility of the menu.
[email protected]7585f4c2013-01-10 18:26:41296 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26297 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41298 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26299 EXPECT_FALSE(CanCreateMenuItem());
300
301 // Enabling all accessibility features.
[email protected]7585f4c2013-01-10 18:26:41302 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26303 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32304 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26305 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32306 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50307 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26308 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32309 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50310 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26311 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32312 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26313 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41314 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26315 EXPECT_FALSE(CanCreateMenuItem());
316}
317
[email protected]5ace0c232013-05-29 00:48:41318IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
[email protected]806d94e2012-12-16 20:31:26319 // Login
[email protected]40429592013-03-29 17:52:33320 UserManager::Get()->UserLoggedIn(
321 "[email protected]", "[email protected]", true);
[email protected]806d94e2012-12-16 20:31:26322 UserManager::Get()->SessionStarted();
323
[email protected]5ace0c232013-05-29 00:48:41324 SetShowAccessibilityOptionsInSystemTrayMenu(true);
[email protected]806d94e2012-12-16 20:31:26325
326 // Confirms that the menu is visible.
327 EXPECT_TRUE(CanCreateMenuItem());
328
329 // The menu is keeping visible regardless of toggling spoken feedback.
[email protected]1dfebfc2013-06-04 03:14:32330 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50331 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26332 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32333 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50334 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26335 EXPECT_TRUE(CanCreateMenuItem());
336
337 // The menu is keeping visible regardless of toggling high contrast.
[email protected]1dfebfc2013-06-04 03:14:32338 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26339 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32340 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26341 EXPECT_TRUE(CanCreateMenuItem());
342
343 // The menu is keeping visible regardless of toggling screen magnifier.
[email protected]7585f4c2013-01-10 18:26:41344 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26345 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41346 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26347 EXPECT_TRUE(CanCreateMenuItem());
348
349 // Enabling all accessibility features.
[email protected]7585f4c2013-01-10 18:26:41350 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26351 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32352 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26353 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32354 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50355 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26356 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32357 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50358 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26359 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32360 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26361 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41362 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26363 EXPECT_TRUE(CanCreateMenuItem());
364
[email protected]5ace0c232013-05-29 00:48:41365 SetShowAccessibilityOptionsInSystemTrayMenu(false);
[email protected]806d94e2012-12-16 20:31:26366
367 // Confirms that the menu is invisible.
368 EXPECT_FALSE(CanCreateMenuItem());
369}
370
[email protected]5ace0c232013-05-29 00:48:41371IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) {
[email protected]806d94e2012-12-16 20:31:26372 SetLoginStatus(ash::user::LOGGED_IN_NONE);
373
374 // Confirms that the menu is visible.
375 EXPECT_TRUE(CanCreateMenuItem());
376
377 // The menu is keeping visible regardless of toggling spoken feedback.
[email protected]1dfebfc2013-06-04 03:14:32378 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50379 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26380 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32381 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50382 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26383 EXPECT_TRUE(CanCreateMenuItem());
384
385 // The menu is keeping visible regardless of toggling high contrast.
[email protected]1dfebfc2013-06-04 03:14:32386 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26387 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32388 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26389 EXPECT_TRUE(CanCreateMenuItem());
390
391 // The menu is keeping visible regardless of toggling screen magnifier.
[email protected]7585f4c2013-01-10 18:26:41392 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26393 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41394 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26395 EXPECT_TRUE(CanCreateMenuItem());
396
397 // Enabling all accessibility features.
[email protected]7585f4c2013-01-10 18:26:41398 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26399 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32400 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26401 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32402 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50403 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26404 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32405 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50406 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26407 EXPECT_TRUE(CanCreateMenuItem());
[email protected]1dfebfc2013-06-04 03:14:32408 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26409 EXPECT_TRUE(CanCreateMenuItem());
[email protected]7585f4c2013-01-10 18:26:41410 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26411 EXPECT_TRUE(CanCreateMenuItem());
412
[email protected]5ace0c232013-05-29 00:48:41413 SetShowAccessibilityOptionsInSystemTrayMenu(true);
[email protected]806d94e2012-12-16 20:31:26414
415 // Confirms that the menu is keeping visible.
416 EXPECT_TRUE(CanCreateMenuItem());
417
[email protected]5ace0c232013-05-29 00:48:41418 SetShowAccessibilityOptionsInSystemTrayMenu(false);
[email protected]806d94e2012-12-16 20:31:26419
420 // Confirms that the menu is keeping visible.
421 EXPECT_TRUE(CanCreateMenuItem());
422}
423
[email protected]5ace0c232013-05-29 00:48:41424IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
[email protected]14c95c82013-01-30 06:30:29425 // Enables high contrast mode.
[email protected]1dfebfc2013-06-04 03:14:32426 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]14c95c82013-01-30 06:30:29427 EXPECT_TRUE(CanCreateMenuItem());
428
429 // Locks the screen.
430 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
431 EXPECT_TRUE(CanCreateMenuItem());
432
433 // Disables high contrast mode.
[email protected]1dfebfc2013-06-04 03:14:32434 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]14c95c82013-01-30 06:30:29435
436 // Confirms that the menu is still visible.
437 EXPECT_TRUE(CanCreateMenuItem());
438}
439
[email protected]8bacb662013-02-27 03:15:24440#if defined(OS_CHROMEOS)
441#define MAYBE_ClickDetailMenu DISABLED_ClickDetailMenu
442#else
443#define MAYBE_ClickDetailMenu ClickDetailMenu
444#endif
445
[email protected]5ace0c232013-05-29 00:48:41446IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, MAYBE_ClickDetailMenu) {
[email protected]806d94e2012-12-16 20:31:26447 // Confirms that the check item toggles the spoken feedback.
[email protected]1dfebfc2013-06-04 03:14:32448 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
[email protected]806d94e2012-12-16 20:31:26449
450 EXPECT_TRUE(CreateDetailedMenu());
451 ClickSpokenFeedbackOnDetailMenu();
[email protected]1dfebfc2013-06-04 03:14:32452 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
[email protected]806d94e2012-12-16 20:31:26453
454 EXPECT_TRUE(CreateDetailedMenu());
455 ClickSpokenFeedbackOnDetailMenu();
[email protected]1dfebfc2013-06-04 03:14:32456 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
[email protected]806d94e2012-12-16 20:31:26457
458 // Confirms that the check item toggles the high contrast.
[email protected]1dfebfc2013-06-04 03:14:32459 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
[email protected]806d94e2012-12-16 20:31:26460
461 EXPECT_TRUE(CreateDetailedMenu());
462 ClickHighContrastOnDetailMenu();
[email protected]1dfebfc2013-06-04 03:14:32463 EXPECT_TRUE(AccessibilityManager::Get()->IsHighContrastEnabled());
[email protected]806d94e2012-12-16 20:31:26464
465 EXPECT_TRUE(CreateDetailedMenu());
466 ClickHighContrastOnDetailMenu();
[email protected]1dfebfc2013-06-04 03:14:32467 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
[email protected]806d94e2012-12-16 20:31:26468
469 // Confirms that the check item toggles the magnifier.
[email protected]1dfebfc2013-06-04 03:14:32470 EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
[email protected]806d94e2012-12-16 20:31:26471
[email protected]7585f4c2013-01-10 18:26:41472 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
[email protected]806d94e2012-12-16 20:31:26473 EXPECT_TRUE(CreateDetailedMenu());
474 ClickScreenMagnifierOnDetailMenu();
[email protected]7585f4c2013-01-10 18:26:41475 EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled());
[email protected]806d94e2012-12-16 20:31:26476
477 EXPECT_TRUE(CreateDetailedMenu());
478 ClickScreenMagnifierOnDetailMenu();
[email protected]7585f4c2013-01-10 18:26:41479 EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
[email protected]806d94e2012-12-16 20:31:26480}
481
[email protected]5ace0c232013-05-29 00:48:41482IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMarksOnDetailMenu) {
[email protected]57999022013-06-07 12:52:03483 SetLoginStatus(ash::user::LOGGED_IN_NONE);
484
[email protected]806d94e2012-12-16 20:31:26485 // At first, all of the check is unchecked.
486 EXPECT_TRUE(CreateDetailedMenu());
487 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
488 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
489 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03490 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26491 CloseDetailMenu();
492
493 // Enabling spoken feedback.
[email protected]1dfebfc2013-06-04 03:14:32494 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50495 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26496 EXPECT_TRUE(CreateDetailedMenu());
497 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
498 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
499 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03500 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26501 CloseDetailMenu();
502
503 // Disabling spoken feedback.
[email protected]1dfebfc2013-06-04 03:14:32504 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50505 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]806d94e2012-12-16 20:31:26506 EXPECT_TRUE(CreateDetailedMenu());
507 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
508 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
509 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03510 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26511 CloseDetailMenu();
512
513 // Enabling high contrast.
[email protected]1dfebfc2013-06-04 03:14:32514 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]806d94e2012-12-16 20:31:26515 EXPECT_TRUE(CreateDetailedMenu());
516 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
517 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
518 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03519 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26520 CloseDetailMenu();
521
522 // Disabling high contrast.
[email protected]1dfebfc2013-06-04 03:14:32523 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]806d94e2012-12-16 20:31:26524 EXPECT_TRUE(CreateDetailedMenu());
525 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
526 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
527 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03528 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26529 CloseDetailMenu();
530
531 // Enabling full screen magnifier.
[email protected]7585f4c2013-01-10 18:26:41532 SetMagnifierEnabled(true);
[email protected]806d94e2012-12-16 20:31:26533 EXPECT_TRUE(CreateDetailedMenu());
534 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
535 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
536 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03537 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26538 CloseDetailMenu();
539
540 // Disabling screen magnifier.
[email protected]7585f4c2013-01-10 18:26:41541 SetMagnifierEnabled(false);
[email protected]806d94e2012-12-16 20:31:26542 EXPECT_TRUE(CreateDetailedMenu());
543 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
544 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
545 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03546 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
547 CloseDetailMenu();
548
549 // Enabling large cursor.
550 AccessibilityManager::Get()->EnableLargeCursor(true);
551 EXPECT_TRUE(CreateDetailedMenu());
552 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
553 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
554 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
555 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
556 CloseDetailMenu();
557
558 // Disabling large cursor.
559 AccessibilityManager::Get()->EnableLargeCursor(false);
560 EXPECT_TRUE(CreateDetailedMenu());
561 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
562 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
563 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
564 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26565 CloseDetailMenu();
566
567 // Enabling all of the a11y features.
[email protected]1dfebfc2013-06-04 03:14:32568 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50569 true, ash::A11Y_NOTIFICATION_NONE);
[email protected]1dfebfc2013-06-04 03:14:32570 AccessibilityManager::Get()->EnableHighContrast(true);
[email protected]7585f4c2013-01-10 18:26:41571 SetMagnifierEnabled(true);
[email protected]57999022013-06-07 12:52:03572 AccessibilityManager::Get()->EnableLargeCursor(true);
[email protected]806d94e2012-12-16 20:31:26573 EXPECT_TRUE(CreateDetailedMenu());
574 EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
575 EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
576 EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03577 EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26578 CloseDetailMenu();
579
580 // Disabling all of the a11y features.
[email protected]1dfebfc2013-06-04 03:14:32581 AccessibilityManager::Get()->EnableSpokenFeedback(
[email protected]681d0532013-06-11 12:52:50582 false, ash::A11Y_NOTIFICATION_NONE);
[email protected]1dfebfc2013-06-04 03:14:32583 AccessibilityManager::Get()->EnableHighContrast(false);
[email protected]7585f4c2013-01-10 18:26:41584 SetMagnifierEnabled(false);
[email protected]57999022013-06-07 12:52:03585 AccessibilityManager::Get()->EnableLargeCursor(false);
[email protected]806d94e2012-12-16 20:31:26586 EXPECT_TRUE(CreateDetailedMenu());
587 EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
588 EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
589 EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
[email protected]57999022013-06-07 12:52:03590 EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
591 CloseDetailMenu();
592}
593
594IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMenuVisibilityOnDetailMenu) {
595 SetLoginStatus(ash::user::LOGGED_IN_NONE);
596 EXPECT_TRUE(CreateDetailedMenu());
597 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
598 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
599 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
600 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
601 CloseDetailMenu();
602
603 SetLoginStatus(ash::user::LOGGED_IN_USER);
604 EXPECT_TRUE(CreateDetailedMenu());
605 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
606 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
607 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
608 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
609 CloseDetailMenu();
610
611 SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
612 EXPECT_TRUE(CreateDetailedMenu());
613 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
614 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
615 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
616 EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
[email protected]806d94e2012-12-16 20:31:26617 CloseDetailMenu();
618}
619
[email protected]5ace0c232013-05-29 00:48:41620INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
621 TrayAccessibilityTest,
622 testing::Values(PREF_SERVICE,
623 POLICY));
624
[email protected]cce1bad62013-01-04 02:26:38625} // namespace chromeos