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