accessibility_manager_browsertest.cc revision effb81e5f8246d0db0270817048dc992db66e9fb
1// Copyright (c) 2013 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 "chrome/browser/chromeos/accessibility/accessibility_manager.h" 6 7#include "ash/magnifier/magnification_controller.h" 8#include "ash/shell.h" 9#include "base/command_line.h" 10#include "base/prefs/pref_service.h" 11#include "chrome/browser/browser_process.h" 12#include "chrome/browser/chrome_notification_types.h" 13#include "chrome/browser/chromeos/accessibility/magnification_manager.h" 14#include "chrome/browser/chromeos/login/helper.h" 15#include "chrome/browser/chromeos/login/login_utils.h" 16#include "chrome/browser/chromeos/login/user_manager.h" 17#include "chrome/browser/chromeos/login/user_manager_impl.h" 18#include "chrome/browser/chromeos/profiles/profile_helper.h" 19#include "chrome/browser/extensions/api/braille_display_private/mock_braille_controller.h" 20#include "chrome/browser/profiles/profile.h" 21#include "chrome/browser/profiles/profile_manager.h" 22#include "chrome/common/pref_names.h" 23#include "chrome/test/base/in_process_browser_test.h" 24#include "chrome/test/base/testing_profile.h" 25#include "chromeos/chromeos_switches.h" 26#include "content/public/browser/notification_service.h" 27#include "testing/gtest/include/gtest/gtest.h" 28 29using extensions::api::braille_display_private::BrailleObserver; 30using extensions::api::braille_display_private::DisplayState; 31using extensions::api::braille_display_private::MockBrailleController; 32 33namespace chromeos { 34 35namespace { 36 37const char kTestUserName[] = "owner@invalid.domain"; 38 39const int kTestAutoclickDelayMs = 2000; 40 41// Test user name for locally managed user. The domain part must be matched 42// with UserManager::kLocallyManagedUserDomain. 43const char kTestLocallyManagedUserName[] = "test@locally-managed.localhost"; 44 45class MockAccessibilityObserver { 46 public: 47 MockAccessibilityObserver() : observed_(false), 48 observed_enabled_(false), 49 observed_type_(-1) 50 { 51 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 52 CHECK(accessibility_manager); 53 accessibility_subscription_ = accessibility_manager->RegisterCallback( 54 base::Bind(&MockAccessibilityObserver::OnAccessibilityStatusChanged, 55 base::Unretained(this))); 56 } 57 58 virtual ~MockAccessibilityObserver() {} 59 60 bool observed() const { return observed_; } 61 bool observed_enabled() const { return observed_enabled_; } 62 int observed_type() const { return observed_type_; } 63 64 void reset() { observed_ = false; } 65 66 private: 67 void OnAccessibilityStatusChanged( 68 const AccessibilityStatusEventDetails& details) { 69 if (details.notification_type != ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER) { 70 observed_type_ = details.notification_type; 71 observed_enabled_ = details.enabled; 72 observed_ = true; 73 } 74 } 75 76 bool observed_; 77 bool observed_enabled_; 78 int observed_type_; 79 80 scoped_ptr<AccessibilityStatusSubscription> accessibility_subscription_; 81 82 DISALLOW_COPY_AND_ASSIGN(MockAccessibilityObserver); 83}; 84 85void SetLargeCursorEnabled(bool enabled) { 86 return AccessibilityManager::Get()->EnableLargeCursor(enabled); 87} 88 89bool IsLargeCursorEnabled() { 90 return AccessibilityManager::Get()->IsLargeCursorEnabled(); 91} 92 93bool ShouldShowAccessibilityMenu() { 94 return AccessibilityManager::Get()->ShouldShowAccessibilityMenu(); 95} 96 97void SetHighContrastEnabled(bool enabled) { 98 return AccessibilityManager::Get()->EnableHighContrast(enabled); 99} 100 101bool IsHighContrastEnabled() { 102 return AccessibilityManager::Get()->IsHighContrastEnabled(); 103} 104 105void SetSpokenFeedbackEnabled(bool enabled) { 106 return AccessibilityManager::Get()->EnableSpokenFeedback( 107 enabled, ash::A11Y_NOTIFICATION_NONE); 108} 109 110bool IsSpokenFeedbackEnabled() { 111 return AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); 112} 113 114void SetAutoclickEnabled(bool enabled) { 115 return AccessibilityManager::Get()->EnableAutoclick(enabled); 116} 117 118bool IsAutoclickEnabled() { 119 return AccessibilityManager::Get()->IsAutoclickEnabled(); 120} 121 122void SetAutoclickDelay(int delay_ms) { 123 return AccessibilityManager::Get()->SetAutoclickDelay(delay_ms); 124} 125 126int GetAutoclickDelay() { 127 return AccessibilityManager::Get()->GetAutoclickDelay(); 128} 129 130void SetVirtualKeyboardEnabled(bool enabled) { 131 return AccessibilityManager::Get()->EnableVirtualKeyboard(enabled); 132} 133 134bool IsVirtualKeyboardEnabled() { 135 return AccessibilityManager::Get()->IsVirtualKeyboardEnabled(); 136} 137 138Profile* GetProfile() { 139 Profile* profile = ProfileManager::GetActiveUserProfile(); 140 DCHECK(profile); 141 return profile; 142} 143 144PrefService* GetPrefs() { 145 return GetProfile()->GetPrefs(); 146} 147 148void SetLargeCursorEnabledPref(bool enabled) { 149 GetPrefs()->SetBoolean(prefs::kLargeCursorEnabled, enabled); 150} 151 152void SetHighContrastEnabledPref(bool enabled) { 153 GetPrefs()->SetBoolean(prefs::kHighContrastEnabled, enabled); 154} 155 156void SetSpokenFeedbackEnabledPref(bool enabled) { 157 GetPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled); 158} 159 160void SetAutoclickEnabledPref(bool enabled) { 161 GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled); 162} 163 164void SetAutoclickDelayPref(int delay_ms) { 165 GetPrefs()->SetInteger(prefs::kAutoclickDelayMs, delay_ms); 166} 167 168void SetVirtualKeyboardEnabledPref(bool enabled) { 169 GetPrefs()->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); 170} 171 172bool GetLargeCursorEnabledFromPref() { 173 return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled); 174} 175 176bool GetHighContrastEnabledFromPref() { 177 return GetPrefs()->GetBoolean(prefs::kHighContrastEnabled); 178} 179 180bool GetSpokenFeedbackEnabledFromPref() { 181 return GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); 182} 183 184bool GetAutoclickEnabledFromPref() { 185 return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled); 186} 187 188int GetAutoclickDelayFromPref() { 189 return GetPrefs()->GetInteger(prefs::kAutoclickDelayMs); 190} 191 192} // anonymouse namespace 193 194class AccessibilityManagerTest : public InProcessBrowserTest { 195 protected: 196 AccessibilityManagerTest() : default_autoclick_delay_(0) {} 197 virtual ~AccessibilityManagerTest() {} 198 199 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 200 command_line->AppendSwitch(chromeos::switches::kLoginManager); 201 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, 202 TestingProfile::kTestUserProfileDir); 203 } 204 205 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 206 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); 207 } 208 209 virtual void SetUpOnMainThread() OVERRIDE { 210 // Sets the login-screen profile. 211 AccessibilityManager::Get()-> 212 SetProfileForTest(ProfileHelper::GetSigninProfile()); 213 default_autoclick_delay_ = GetAutoclickDelay(); 214 } 215 216 virtual void CleanUpOnMainThread() OVERRIDE { 217 AccessibilityManager::SetBrailleControllerForTest(NULL); 218 } 219 220 int default_autoclick_delay() const { return default_autoclick_delay_; } 221 222 int default_autoclick_delay_; 223 224 content::NotificationRegistrar registrar_; 225 226 MockBrailleController braille_controller_; 227 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); 228}; 229 230IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { 231 // Confirms that a11y features are disabled on the login screen. 232 EXPECT_FALSE(IsLargeCursorEnabled()); 233 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 234 EXPECT_FALSE(IsHighContrastEnabled()); 235 EXPECT_FALSE(IsAutoclickEnabled()); 236 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 237 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 238 239 // Logs in. 240 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 241 242 // Confirms that the features still disabled just after login. 243 EXPECT_FALSE(IsLargeCursorEnabled()); 244 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 245 EXPECT_FALSE(IsHighContrastEnabled()); 246 EXPECT_FALSE(IsAutoclickEnabled()); 247 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 248 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 249 250 UserManager::Get()->SessionStarted(); 251 252 // Confirms that the features are still disabled just after login. 253 EXPECT_FALSE(IsLargeCursorEnabled()); 254 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 255 EXPECT_FALSE(IsHighContrastEnabled()); 256 EXPECT_FALSE(IsAutoclickEnabled()); 257 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 258 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 259 260 // Enables large cursor. 261 SetLargeCursorEnabled(true); 262 // Confirms that large cursor is enabled. 263 EXPECT_TRUE(IsLargeCursorEnabled()); 264 265 // Enables spoken feedback. 266 SetSpokenFeedbackEnabled(true); 267 // Confirms that the spoken feedback is enabled. 268 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 269 270 // Enables high contrast. 271 SetHighContrastEnabled(true); 272 // Confirms that high cotrast is enabled. 273 EXPECT_TRUE(IsHighContrastEnabled()); 274 275 // Enables autoclick. 276 SetAutoclickEnabled(true); 277 // Confirms that autoclick is enabled. 278 EXPECT_TRUE(IsAutoclickEnabled()); 279 280 // Test that autoclick delay is set properly. 281 SetAutoclickDelay(kTestAutoclickDelayMs); 282 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 283 284 // Enable on-screen keyboard 285 SetVirtualKeyboardEnabled(true); 286 // Confirm that the on-screen keyboard option is enabled. 287 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 288} 289 290IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, BrailleOnLoginScreen) { 291 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 292 293 // Signal the accessibility manager that a braille display was connected. 294 braille_controller_.SetAvailable(true); 295 braille_controller_.GetObserver()->OnDisplayStateChanged( 296 *braille_controller_.GetDisplayState()); 297 298 // Confirms that the spoken feedback is enabled. 299 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 300} 301 302IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { 303 // Logs in. 304 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 305 UserManager::Get()->SessionStarted(); 306 307 // Confirms that the features are disabled just after login. 308 EXPECT_FALSE(IsLargeCursorEnabled()); 309 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 310 EXPECT_FALSE(IsHighContrastEnabled()); 311 EXPECT_FALSE(IsAutoclickEnabled()); 312 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 313 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 314 315 // Sets the pref as true to enable the large cursor. 316 SetLargeCursorEnabledPref(true); 317 // Confirms that the large cursor is enabled. 318 EXPECT_TRUE(IsLargeCursorEnabled()); 319 320 // Sets the pref as true to enable the spoken feedback. 321 SetSpokenFeedbackEnabledPref(true); 322 // Confirms that the spoken feedback is enabled. 323 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 324 325 // Sets the pref as true to enable high contrast mode. 326 SetHighContrastEnabledPref(true); 327 // Confirms that the high contrast mode is enabled. 328 EXPECT_TRUE(IsHighContrastEnabled()); 329 330 // Sets the pref as true to enable autoclick. 331 SetAutoclickEnabledPref(true); 332 // Confirms that autoclick is enabled. 333 EXPECT_TRUE(IsAutoclickEnabled()); 334 335 // Set autoclick delay pref. 336 SetAutoclickDelayPref(kTestAutoclickDelayMs); 337 // Confirm that the correct value is set. 338 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 339 340 // Sets the on-screen keyboard pref. 341 SetVirtualKeyboardEnabledPref(true); 342 // Confirm that the on-screen keyboard option is enabled. 343 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 344 345 SetLargeCursorEnabledPref(false); 346 EXPECT_FALSE(IsLargeCursorEnabled()); 347 348 SetSpokenFeedbackEnabledPref(false); 349 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 350 351 SetHighContrastEnabledPref(false); 352 EXPECT_FALSE(IsHighContrastEnabled()); 353 354 SetAutoclickEnabledPref(false); 355 EXPECT_FALSE(IsAutoclickEnabled()); 356 357 SetVirtualKeyboardEnabledPref(false); 358 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 359} 360 361IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { 362 // Loads the profile of the user. 363 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 364 365 // Sets the pref to enable large cursor before login. 366 SetLargeCursorEnabledPref(true); 367 EXPECT_FALSE(IsLargeCursorEnabled()); 368 369 // Sets the pref to enable spoken feedback before login. 370 SetSpokenFeedbackEnabledPref(true); 371 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 372 373 // Sets the pref to enable high contrast before login. 374 SetHighContrastEnabledPref(true); 375 EXPECT_FALSE(IsHighContrastEnabled()); 376 377 // Sets the pref to enable autoclick before login. 378 SetAutoclickEnabledPref(true); 379 EXPECT_FALSE(IsAutoclickEnabled()); 380 381 // Sets the autoclick delay pref before login but the 382 // initial value should not change. 383 SetAutoclickDelayPref(kTestAutoclickDelayMs); 384 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 385 386 // Sets the pref to enable the on-screen keyboard before login. 387 SetVirtualKeyboardEnabledPref(true); 388 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 389 390 // Logs in. 391 UserManager::Get()->SessionStarted(); 392 393 // Confirms that features are enabled by restoring from pref just after login. 394 EXPECT_TRUE(IsLargeCursorEnabled()); 395 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 396 EXPECT_TRUE(IsHighContrastEnabled()); 397 EXPECT_TRUE(IsAutoclickEnabled()); 398 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 399 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 400} 401 402IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 403 ChangingTypeInvokesNotification) { 404 MockAccessibilityObserver observer; 405 406 // Logs in. 407 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 408 UserManager::Get()->SessionStarted(); 409 410 EXPECT_FALSE(observer.observed()); 411 observer.reset(); 412 413 SetSpokenFeedbackEnabled(true); 414 EXPECT_TRUE(observer.observed()); 415 EXPECT_TRUE(observer.observed_enabled()); 416 EXPECT_EQ(observer.observed_type(), 417 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 418 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 419 420 observer.reset(); 421 SetSpokenFeedbackEnabled(false); 422 EXPECT_TRUE(observer.observed()); 423 EXPECT_FALSE(observer.observed_enabled()); 424 EXPECT_EQ(observer.observed_type(), 425 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 426 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 427 428 observer.reset(); 429 SetHighContrastEnabled(true); 430 EXPECT_TRUE(observer.observed()); 431 EXPECT_TRUE(observer.observed_enabled()); 432 EXPECT_EQ(observer.observed_type(), 433 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE); 434 EXPECT_TRUE(IsHighContrastEnabled()); 435 436 observer.reset(); 437 SetHighContrastEnabled(false); 438 EXPECT_TRUE(observer.observed()); 439 EXPECT_FALSE(observer.observed_enabled()); 440 EXPECT_EQ(observer.observed_type(), 441 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE); 442 EXPECT_FALSE(IsHighContrastEnabled()); 443 444 observer.reset(); 445 SetVirtualKeyboardEnabled(true); 446 EXPECT_TRUE(observer.observed()); 447 EXPECT_TRUE(observer.observed_enabled()); 448 EXPECT_EQ(observer.observed_type(), 449 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 450 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 451 452 observer.reset(); 453 SetVirtualKeyboardEnabled(false); 454 EXPECT_TRUE(observer.observed()); 455 EXPECT_FALSE(observer.observed_enabled()); 456 EXPECT_EQ(observer.observed_type(), 457 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 458 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 459} 460 461IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 462 ChangingTypePrefInvokesNotification) { 463 MockAccessibilityObserver observer; 464 465 // Logs in. 466 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 467 UserManager::Get()->SessionStarted(); 468 469 EXPECT_FALSE(observer.observed()); 470 observer.reset(); 471 472 SetSpokenFeedbackEnabledPref(true); 473 EXPECT_TRUE(observer.observed()); 474 EXPECT_TRUE(observer.observed_enabled()); 475 EXPECT_EQ(observer.observed_type(), 476 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 477 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 478 479 observer.reset(); 480 SetSpokenFeedbackEnabledPref(false); 481 EXPECT_TRUE(observer.observed()); 482 EXPECT_FALSE(observer.observed_enabled()); 483 EXPECT_EQ(observer.observed_type(), 484 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 485 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 486 487 observer.reset(); 488 SetHighContrastEnabledPref(true); 489 EXPECT_TRUE(observer.observed()); 490 EXPECT_TRUE(observer.observed_enabled()); 491 EXPECT_EQ(observer.observed_type(), 492 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE); 493 EXPECT_TRUE(IsHighContrastEnabled()); 494 495 observer.reset(); 496 SetHighContrastEnabledPref(false); 497 EXPECT_TRUE(observer.observed()); 498 EXPECT_FALSE(observer.observed_enabled()); 499 EXPECT_EQ(observer.observed_type(), 500 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE); 501 EXPECT_FALSE(IsHighContrastEnabled()); 502 503 observer.reset(); 504 SetVirtualKeyboardEnabledPref(true); 505 EXPECT_TRUE(observer.observed()); 506 EXPECT_TRUE(observer.observed_enabled()); 507 EXPECT_EQ(observer.observed_type(), 508 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 509 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 510 511 observer.reset(); 512 SetVirtualKeyboardEnabledPref(false); 513 EXPECT_TRUE(observer.observed()); 514 EXPECT_FALSE(observer.observed_enabled()); 515 EXPECT_EQ(observer.observed_type(), 516 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 517 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 518} 519 520class AccessibilityManagerUserTypeTest 521 : public AccessibilityManagerTest, 522 public ::testing::WithParamInterface<const char*> { 523 protected: 524 AccessibilityManagerUserTypeTest() {} 525 virtual ~AccessibilityManagerUserTypeTest() {} 526 527 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerUserTypeTest); 528}; 529 530// TODO(yoshiki): Enable a test for retail mode. 531INSTANTIATE_TEST_CASE_P( 532 UserTypeInstantiation, 533 AccessibilityManagerUserTypeTest, 534 ::testing::Values(kTestUserName, 535 UserManager::kGuestUserName, 536 //UserManager::kRetailModeUserName, 537 kTestLocallyManagedUserName)); 538 539IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, 540 EnableOnLoginScreenAndLogin) { 541 // Enables large cursor. 542 SetLargeCursorEnabled(true); 543 EXPECT_TRUE(IsLargeCursorEnabled()); 544 // Enables spoken feedback. 545 SetSpokenFeedbackEnabled(true); 546 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 547 // Enables high contrast. 548 SetHighContrastEnabled(true); 549 EXPECT_TRUE(IsHighContrastEnabled()); 550 // Enables autoclick. 551 SetAutoclickEnabled(true); 552 EXPECT_TRUE(IsAutoclickEnabled()); 553 // Set autoclick delay. 554 SetAutoclickDelay(kTestAutoclickDelayMs); 555 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 556 557 // Logs in. 558 const char* user_name = GetParam(); 559 UserManager::Get()->UserLoggedIn(user_name, user_name, true); 560 561 // Confirms that the features are still enabled just after login. 562 EXPECT_TRUE(IsLargeCursorEnabled()); 563 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 564 EXPECT_TRUE(IsHighContrastEnabled()); 565 EXPECT_TRUE(IsAutoclickEnabled()); 566 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 567 568 UserManager::Get()->SessionStarted(); 569 570 // Confirms that the features keep enabled after session starts. 571 EXPECT_TRUE(IsLargeCursorEnabled()); 572 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 573 EXPECT_TRUE(IsHighContrastEnabled()); 574 EXPECT_TRUE(IsAutoclickEnabled()); 575 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 576 577 // Confirms that the prefs have been copied to the user's profile. 578 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); 579 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); 580 EXPECT_TRUE(GetHighContrastEnabledFromPref()); 581 EXPECT_TRUE(GetAutoclickEnabledFromPref()); 582 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); 583} 584 585IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AcessibilityMenuVisibility) { 586 // Log in. 587 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); 588 UserManager::Get()->SessionStarted(); 589 590 // Confirms that the features are disabled. 591 EXPECT_FALSE(IsLargeCursorEnabled()); 592 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 593 EXPECT_FALSE(IsHighContrastEnabled()); 594 EXPECT_FALSE(IsAutoclickEnabled()); 595 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 596 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 597 598 // Check large cursor. 599 SetLargeCursorEnabled(true); 600 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 601 SetLargeCursorEnabled(false); 602 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 603 604 // Check spoken feedback. 605 SetSpokenFeedbackEnabled(true); 606 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 607 SetSpokenFeedbackEnabled(false); 608 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 609 610 // Check high contrast. 611 SetHighContrastEnabled(true); 612 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 613 SetHighContrastEnabled(false); 614 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 615 616 // Check autoclick. 617 SetAutoclickEnabled(true); 618 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 619 SetAutoclickEnabled(false); 620 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 621 622 // Check on-screen keyboard. 623 SetVirtualKeyboardEnabled(true); 624 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 625 SetVirtualKeyboardEnabled(false); 626 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 627} 628 629} // namespace chromeos 630