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