[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 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. |
| 4 | |
| 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/tray_views.h" |
| 9 | #include "ash/system/tray_accessibility.h" |
| 10 | #include "ash/system/user/login_status.h" |
| 11 | #include "base/command_line.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 12 | #include "base/prefs/pref_service.h" |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 13 | #include "chrome/browser/browser_process.h" |
| 14 | #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 15 | #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 16 | #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 17 | #include "chrome/browser/chromeos/login/helper.h" |
| 18 | #include "chrome/browser/chromeos/login/login_utils.h" |
| 19 | #include "chrome/browser/chromeos/login/user_manager.h" |
| 20 | #include "chrome/browser/chromeos/login/user_manager_impl.h" |
[email protected] | 25cf28e | 2013-03-25 19:26:25 | [diff] [blame^] | 21 | #include "chrome/browser/chromeos/login/wizard_controller.h" |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 22 | #include "chrome/browser/profiles/profile.h" |
| 23 | #include "chrome/browser/profiles/profile_manager.h" |
| 24 | #include "chrome/common/chrome_notification_types.h" |
| 25 | #include "chrome/common/chrome_switches.h" |
| 26 | #include "chrome/common/pref_names.h" |
| 27 | #include "chrome/test/base/testing_profile.h" |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 28 | #include "content/public/test/test_utils.h" |
| 29 | #include "testing/gtest/include/gtest/gtest.h" |
| 30 | #include "ui/views/widget/widget.h" |
| 31 | |
| 32 | namespace chromeos { |
| 33 | |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 34 | void SetMagnifierEnabled(bool enabled) { |
| 35 | MagnificationManager::Get()->SetMagnifierEnabled(enabled); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | class TrayAccessibilityTest : public CrosInProcessBrowserTest { |
| 39 | protected: |
| 40 | TrayAccessibilityTest() {} |
| 41 | virtual ~TrayAccessibilityTest() {} |
[email protected] | 25cf28e | 2013-03-25 19:26:25 | [diff] [blame^] | 42 | |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 43 | virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 44 | command_line->AppendSwitch(switches::kLoginManager); |
| 45 | command_line->AppendSwitchASCII(switches::kLoginProfile, |
| 46 | TestingProfile::kTestUserProfileDir); |
| 47 | } |
| 48 | |
[email protected] | 25cf28e | 2013-03-25 19:26:25 | [diff] [blame^] | 49 | virtual void RunTestOnMainThreadLoop() OVERRIDE { |
| 50 | // Need to mark oobe completed to show detailed views. |
| 51 | WizardController::MarkOobeCompleted(); |
| 52 | CrosInProcessBrowserTest::RunTestOnMainThreadLoop(); |
| 53 | } |
| 54 | |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 55 | ash::internal::TrayAccessibility* tray() { |
| 56 | return ash::Shell::GetInstance()->GetPrimarySystemTray()-> |
| 57 | GetTrayAccessibilityForTest(); |
| 58 | } |
| 59 | |
| 60 | bool IsTrayIconVisible() { |
| 61 | return tray()->tray_icon_visible_; |
| 62 | } |
| 63 | |
| 64 | views::View* CreateMenuItem() { |
| 65 | return tray()->CreateDefaultView(GetLoginStatus()); |
| 66 | } |
| 67 | |
| 68 | void DestroyMenuItem() { |
| 69 | return tray()->DestroyDefaultView(); |
| 70 | } |
| 71 | |
| 72 | bool CanCreateMenuItem() { |
| 73 | views::View* menu_item_view = CreateMenuItem(); |
| 74 | DestroyMenuItem(); |
| 75 | return menu_item_view != NULL; |
| 76 | } |
| 77 | |
| 78 | void SetLoginStatus(ash::user::LoginStatus status) { |
| 79 | tray()->UpdateAfterLoginStatusChange(status); |
| 80 | } |
| 81 | |
| 82 | ash::user::LoginStatus GetLoginStatus() { |
| 83 | return tray()->login_; |
| 84 | } |
| 85 | |
| 86 | bool CreateDetailedMenu() { |
| 87 | tray()->PopupDetailedView(0, false); |
| 88 | return tray()->detailed_menu_ != NULL; |
| 89 | } |
| 90 | |
| 91 | void CloseDetailMenu() { |
| 92 | CHECK(tray()->detailed_menu_); |
| 93 | tray()->DestroyDetailedView(); |
| 94 | tray()->detailed_menu_ = NULL; |
| 95 | } |
| 96 | |
| 97 | void ClickSpokenFeedbackOnDetailMenu() { |
| 98 | views::View* button = tray()->detailed_menu_->spoken_feedback_view_; |
[email protected] | acd0fd7a | 2013-03-04 22:00:53 | [diff] [blame] | 99 | tray()->detailed_menu_->OnViewClicked(button); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void ClickHighContrastOnDetailMenu() { |
| 103 | views::View* button = tray()->detailed_menu_->high_contrast_view_; |
| 104 | EXPECT_TRUE(button); |
[email protected] | acd0fd7a | 2013-03-04 22:00:53 | [diff] [blame] | 105 | tray()->detailed_menu_->OnViewClicked(button); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | void ClickScreenMagnifierOnDetailMenu() { |
| 109 | views::View* button = tray()->detailed_menu_->screen_magnifier_view_; |
| 110 | EXPECT_TRUE(button); |
[email protected] | acd0fd7a | 2013-03-04 22:00:53 | [diff] [blame] | 111 | tray()->detailed_menu_->OnViewClicked(button); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | bool IsSpokenFeedbackEnabledOnDetailMenu() { |
| 115 | return tray()->detailed_menu_->spoken_feedback_enabled_; |
| 116 | } |
| 117 | |
| 118 | bool IsHighContrastEnabledOnDetailMenu() { |
| 119 | return tray()->detailed_menu_->high_contrast_enabled_; |
| 120 | } |
| 121 | |
| 122 | bool IsScreenMagnifierEnabledOnDetailMenu() { |
| 123 | return tray()->detailed_menu_->screen_magnifier_enabled_; |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, LoginStatus) { |
| 128 | EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus()); |
| 129 | |
| 130 | UserManager::Get()->UserLoggedIn("[email protected]", true); |
| 131 | UserManager::Get()->SessionStarted(); |
| 132 | |
| 133 | EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus()); |
| 134 | } |
| 135 | |
| 136 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) { |
| 137 | SetLoginStatus(ash::user::LOGGED_IN_NONE); |
| 138 | |
| 139 | // Confirms that the icon is invisible before login. |
| 140 | EXPECT_FALSE(IsTrayIconVisible()); |
| 141 | |
| 142 | UserManager::Get()->UserLoggedIn("[email protected]", true); |
| 143 | UserManager::Get()->SessionStarted(); |
| 144 | |
| 145 | // Confirms that the icon is invisible just after login. |
| 146 | EXPECT_FALSE(IsTrayIconVisible()); |
| 147 | |
| 148 | // Toggling spoken feedback changes the visibillity of the icon. |
| 149 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 150 | EXPECT_TRUE(IsTrayIconVisible()); |
| 151 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 152 | EXPECT_FALSE(IsTrayIconVisible()); |
| 153 | |
| 154 | // Toggling high contrast the visibillity of the icon. |
| 155 | accessibility::EnableHighContrast(true); |
| 156 | EXPECT_TRUE(IsTrayIconVisible()); |
| 157 | accessibility::EnableHighContrast(false); |
| 158 | EXPECT_FALSE(IsTrayIconVisible()); |
| 159 | |
| 160 | // Toggling magnifier the visibillity of the icon. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 161 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 162 | EXPECT_TRUE(IsTrayIconVisible()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 163 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 164 | EXPECT_FALSE(IsTrayIconVisible()); |
| 165 | |
| 166 | // Enabling all accessibility features. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 167 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 168 | EXPECT_TRUE(IsTrayIconVisible()); |
| 169 | accessibility::EnableHighContrast(true); |
| 170 | EXPECT_TRUE(IsTrayIconVisible()); |
| 171 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 172 | EXPECT_TRUE(IsTrayIconVisible()); |
| 173 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 174 | EXPECT_TRUE(IsTrayIconVisible()); |
| 175 | accessibility::EnableHighContrast(false); |
| 176 | EXPECT_TRUE(IsTrayIconVisible()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 177 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 178 | EXPECT_FALSE(IsTrayIconVisible()); |
| 179 | |
| 180 | // Confirms that prefs::kShouldAlwaysShowAccessibilityMenu doesn't affect |
| 181 | // the icon on the tray. |
| 182 | Profile* profile = ProfileManager::GetDefaultProfile(); |
| 183 | PrefService* prefs = profile->GetPrefs(); |
| 184 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
| 185 | prefs->CommitPendingWrite(); |
| 186 | accessibility::EnableHighContrast(true); |
| 187 | EXPECT_TRUE(IsTrayIconVisible()); |
| 188 | accessibility::EnableHighContrast(false); |
| 189 | EXPECT_FALSE(IsTrayIconVisible()); |
| 190 | } |
| 191 | |
| 192 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenu) { |
| 193 | // Login |
| 194 | UserManager::Get()->UserLoggedIn("[email protected]", true); |
| 195 | UserManager::Get()->SessionStarted(); |
| 196 | |
| 197 | // Sets prefs::kShouldAlwaysShowAccessibilityMenu = false. |
| 198 | Profile* profile = ProfileManager::GetDefaultProfile(); |
| 199 | PrefService* prefs = profile->GetPrefs(); |
| 200 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
| 201 | prefs->CommitPendingWrite(); |
| 202 | |
| 203 | // Confirms that the menu is hidden. |
| 204 | EXPECT_FALSE(CanCreateMenuItem()); |
| 205 | |
| 206 | // Toggling spoken feedback changes the visibillity of the menu. |
| 207 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 208 | EXPECT_TRUE(CanCreateMenuItem()); |
| 209 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 210 | EXPECT_FALSE(CanCreateMenuItem()); |
| 211 | |
| 212 | // Toggling high contrast changes the visibillity of the menu. |
| 213 | accessibility::EnableHighContrast(true); |
| 214 | EXPECT_TRUE(CanCreateMenuItem()); |
| 215 | accessibility::EnableHighContrast(false); |
| 216 | EXPECT_FALSE(CanCreateMenuItem()); |
| 217 | |
| 218 | // Toggling screen magnifier changes the visibillity of the menu. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 219 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 220 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 221 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 222 | EXPECT_FALSE(CanCreateMenuItem()); |
| 223 | |
| 224 | // Enabling all accessibility features. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 225 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 226 | EXPECT_TRUE(CanCreateMenuItem()); |
| 227 | accessibility::EnableHighContrast(true); |
| 228 | EXPECT_TRUE(CanCreateMenuItem()); |
| 229 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 230 | EXPECT_TRUE(CanCreateMenuItem()); |
| 231 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 232 | EXPECT_TRUE(CanCreateMenuItem()); |
| 233 | accessibility::EnableHighContrast(false); |
| 234 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 235 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 236 | EXPECT_FALSE(CanCreateMenuItem()); |
| 237 | } |
| 238 | |
| 239 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { |
| 240 | // Login |
| 241 | UserManager::Get()->UserLoggedIn("[email protected]", true); |
| 242 | UserManager::Get()->SessionStarted(); |
| 243 | |
| 244 | // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
| 245 | Profile* profile = ProfileManager::GetDefaultProfile(); |
| 246 | PrefService* prefs = profile->GetPrefs(); |
| 247 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
| 248 | prefs->CommitPendingWrite(); |
| 249 | |
| 250 | // Confirms that the menu is visible. |
| 251 | EXPECT_TRUE(CanCreateMenuItem()); |
| 252 | |
| 253 | // The menu is keeping visible regardless of toggling spoken feedback. |
| 254 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 255 | EXPECT_TRUE(CanCreateMenuItem()); |
| 256 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 257 | EXPECT_TRUE(CanCreateMenuItem()); |
| 258 | |
| 259 | // The menu is keeping visible regardless of toggling high contrast. |
| 260 | accessibility::EnableHighContrast(true); |
| 261 | EXPECT_TRUE(CanCreateMenuItem()); |
| 262 | accessibility::EnableHighContrast(false); |
| 263 | EXPECT_TRUE(CanCreateMenuItem()); |
| 264 | |
| 265 | // The menu is keeping visible regardless of toggling screen magnifier. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 266 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 267 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 268 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 269 | EXPECT_TRUE(CanCreateMenuItem()); |
| 270 | |
| 271 | // Enabling all accessibility features. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 272 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 273 | EXPECT_TRUE(CanCreateMenuItem()); |
| 274 | accessibility::EnableHighContrast(true); |
| 275 | EXPECT_TRUE(CanCreateMenuItem()); |
| 276 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 277 | EXPECT_TRUE(CanCreateMenuItem()); |
| 278 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 279 | EXPECT_TRUE(CanCreateMenuItem()); |
| 280 | accessibility::EnableHighContrast(false); |
| 281 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 282 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 283 | EXPECT_TRUE(CanCreateMenuItem()); |
| 284 | |
| 285 | // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
| 286 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
| 287 | |
| 288 | // Confirms that the menu is invisible. |
| 289 | EXPECT_FALSE(CanCreateMenuItem()); |
| 290 | } |
| 291 | |
| 292 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) { |
| 293 | SetLoginStatus(ash::user::LOGGED_IN_NONE); |
| 294 | |
| 295 | // Confirms that the menu is visible. |
| 296 | EXPECT_TRUE(CanCreateMenuItem()); |
| 297 | |
| 298 | // The menu is keeping visible regardless of toggling spoken feedback. |
| 299 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 300 | EXPECT_TRUE(CanCreateMenuItem()); |
| 301 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 302 | EXPECT_TRUE(CanCreateMenuItem()); |
| 303 | |
| 304 | // The menu is keeping visible regardless of toggling high contrast. |
| 305 | accessibility::EnableHighContrast(true); |
| 306 | EXPECT_TRUE(CanCreateMenuItem()); |
| 307 | accessibility::EnableHighContrast(false); |
| 308 | EXPECT_TRUE(CanCreateMenuItem()); |
| 309 | |
| 310 | // The menu is keeping visible regardless of toggling screen magnifier. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 311 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 312 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 313 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 314 | EXPECT_TRUE(CanCreateMenuItem()); |
| 315 | |
| 316 | // Enabling all accessibility features. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 317 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 318 | EXPECT_TRUE(CanCreateMenuItem()); |
| 319 | accessibility::EnableHighContrast(true); |
| 320 | EXPECT_TRUE(CanCreateMenuItem()); |
| 321 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 322 | EXPECT_TRUE(CanCreateMenuItem()); |
| 323 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 324 | EXPECT_TRUE(CanCreateMenuItem()); |
| 325 | accessibility::EnableHighContrast(false); |
| 326 | EXPECT_TRUE(CanCreateMenuItem()); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 327 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 328 | EXPECT_TRUE(CanCreateMenuItem()); |
| 329 | |
| 330 | // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
| 331 | Profile* profile = ProfileManager::GetDefaultProfile(); |
| 332 | PrefService* prefs = profile->GetPrefs(); |
| 333 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
| 334 | prefs->CommitPendingWrite(); |
| 335 | |
| 336 | // Confirms that the menu is keeping visible. |
| 337 | EXPECT_TRUE(CanCreateMenuItem()); |
| 338 | |
| 339 | // Sets prefs::kShouldAlwaysShowAccessibilityMenu = false. |
| 340 | prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
| 341 | prefs->CommitPendingWrite(); |
| 342 | |
| 343 | // Confirms that the menu is keeping visible. |
| 344 | EXPECT_TRUE(CanCreateMenuItem()); |
| 345 | } |
| 346 | |
[email protected] | 14c95c8 | 2013-01-30 06:30:29 | [diff] [blame] | 347 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
| 348 | // Enables high contrast mode. |
| 349 | accessibility::EnableHighContrast(true); |
| 350 | EXPECT_TRUE(CanCreateMenuItem()); |
| 351 | |
| 352 | // Locks the screen. |
| 353 | SetLoginStatus(ash::user::LOGGED_IN_LOCKED); |
| 354 | EXPECT_TRUE(CanCreateMenuItem()); |
| 355 | |
| 356 | // Disables high contrast mode. |
| 357 | accessibility::EnableHighContrast(false); |
| 358 | |
| 359 | // Confirms that the menu is still visible. |
| 360 | EXPECT_TRUE(CanCreateMenuItem()); |
| 361 | } |
| 362 | |
[email protected] | 8bacb66 | 2013-02-27 03:15:24 | [diff] [blame] | 363 | #if defined(OS_CHROMEOS) |
| 364 | #define MAYBE_ClickDetailMenu DISABLED_ClickDetailMenu |
| 365 | #else |
| 366 | #define MAYBE_ClickDetailMenu ClickDetailMenu |
| 367 | #endif |
| 368 | |
| 369 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, MAYBE_ClickDetailMenu) { |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 370 | // Confirms that the check item toggles the spoken feedback. |
| 371 | EXPECT_FALSE(accessibility::IsSpokenFeedbackEnabled()); |
| 372 | |
| 373 | EXPECT_TRUE(CreateDetailedMenu()); |
| 374 | ClickSpokenFeedbackOnDetailMenu(); |
| 375 | EXPECT_TRUE(accessibility::IsSpokenFeedbackEnabled()); |
| 376 | |
| 377 | EXPECT_TRUE(CreateDetailedMenu()); |
| 378 | ClickSpokenFeedbackOnDetailMenu(); |
| 379 | EXPECT_FALSE(accessibility::IsSpokenFeedbackEnabled()); |
| 380 | |
| 381 | // Confirms that the check item toggles the high contrast. |
| 382 | EXPECT_FALSE(accessibility::IsHighContrastEnabled()); |
| 383 | |
| 384 | EXPECT_TRUE(CreateDetailedMenu()); |
| 385 | ClickHighContrastOnDetailMenu(); |
| 386 | EXPECT_TRUE(accessibility::IsHighContrastEnabled()); |
| 387 | |
| 388 | EXPECT_TRUE(CreateDetailedMenu()); |
| 389 | ClickHighContrastOnDetailMenu(); |
| 390 | EXPECT_FALSE(accessibility::IsHighContrastEnabled()); |
| 391 | |
| 392 | // Confirms that the check item toggles the magnifier. |
| 393 | EXPECT_FALSE(accessibility::IsHighContrastEnabled()); |
| 394 | |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 395 | EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled()); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 396 | EXPECT_TRUE(CreateDetailedMenu()); |
| 397 | ClickScreenMagnifierOnDetailMenu(); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 398 | EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled()); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 399 | |
| 400 | EXPECT_TRUE(CreateDetailedMenu()); |
| 401 | ClickScreenMagnifierOnDetailMenu(); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 402 | EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled()); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, CheckMarksOnDetailMenu) { |
| 406 | // At first, all of the check is unchecked. |
| 407 | EXPECT_TRUE(CreateDetailedMenu()); |
| 408 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 409 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 410 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 411 | CloseDetailMenu(); |
| 412 | |
| 413 | // Enabling spoken feedback. |
| 414 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 415 | EXPECT_TRUE(CreateDetailedMenu()); |
| 416 | EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 417 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 418 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 419 | CloseDetailMenu(); |
| 420 | |
| 421 | // Disabling spoken feedback. |
| 422 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 423 | EXPECT_TRUE(CreateDetailedMenu()); |
| 424 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 425 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 426 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 427 | CloseDetailMenu(); |
| 428 | |
| 429 | // Enabling high contrast. |
| 430 | accessibility::EnableHighContrast(true); |
| 431 | EXPECT_TRUE(CreateDetailedMenu()); |
| 432 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 433 | EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu()); |
| 434 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 435 | CloseDetailMenu(); |
| 436 | |
| 437 | // Disabling high contrast. |
| 438 | accessibility::EnableHighContrast(false); |
| 439 | EXPECT_TRUE(CreateDetailedMenu()); |
| 440 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 441 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 442 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 443 | CloseDetailMenu(); |
| 444 | |
| 445 | // Enabling full screen magnifier. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 446 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 447 | EXPECT_TRUE(CreateDetailedMenu()); |
| 448 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 449 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 450 | EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 451 | CloseDetailMenu(); |
| 452 | |
| 453 | // Disabling screen magnifier. |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 454 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 455 | EXPECT_TRUE(CreateDetailedMenu()); |
| 456 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 457 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 458 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 459 | CloseDetailMenu(); |
| 460 | |
| 461 | // Enabling all of the a11y features. |
| 462 | accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 463 | accessibility::EnableHighContrast(true); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 464 | SetMagnifierEnabled(true); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 465 | EXPECT_TRUE(CreateDetailedMenu()); |
| 466 | EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 467 | EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu()); |
| 468 | EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 469 | CloseDetailMenu(); |
| 470 | |
| 471 | // Disabling all of the a11y features. |
| 472 | accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
| 473 | accessibility::EnableHighContrast(false); |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 474 | SetMagnifierEnabled(false); |
[email protected] | 806d94e | 2012-12-16 20:31:26 | [diff] [blame] | 475 | EXPECT_TRUE(CreateDetailedMenu()); |
| 476 | EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
| 477 | EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu()); |
| 478 | EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu()); |
| 479 | CloseDetailMenu(); |
| 480 | } |
| 481 | |
[email protected] | cce1bad6 | 2013-01-04 02:26:38 | [diff] [blame] | 482 | } // namespace chromeos |