| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 6 | 6 |
| 7 #include "ash/magnifier/magnification_controller.h" | 7 #include "ash/magnifier/magnification_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 *braille_controller_.GetDisplayState()); | 254 *braille_controller_.GetDisplayState()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 int default_autoclick_delay() const { return default_autoclick_delay_; } | 257 int default_autoclick_delay() const { return default_autoclick_delay_; } |
| 258 | 258 |
| 259 int default_autoclick_delay_; | 259 int default_autoclick_delay_; |
| 260 | 260 |
| 261 content::NotificationRegistrar registrar_; | 261 content::NotificationRegistrar registrar_; |
| 262 | 262 |
| 263 MockBrailleController braille_controller_; | 263 MockBrailleController braille_controller_; |
| 264 | |
| 265 const AccountId test_account_id_ = AccountId::FromUserEmail(kTestUserName); | |
| 266 | |
| 267 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); | 264 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); |
| 268 }; | 265 }; |
| 269 | 266 |
| 270 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { | 267 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { |
| 271 // Confirms that a11y features are disabled on the login screen. | 268 // Confirms that a11y features are disabled on the login screen. |
| 272 EXPECT_FALSE(IsLargeCursorEnabled()); | 269 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 273 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 270 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 274 EXPECT_FALSE(IsHighContrastEnabled()); | 271 EXPECT_FALSE(IsHighContrastEnabled()); |
| 275 EXPECT_FALSE(IsAutoclickEnabled()); | 272 EXPECT_FALSE(IsAutoclickEnabled()); |
| 276 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 273 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 277 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); | 274 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); |
| 278 | 275 |
| 279 // Logs in. | 276 // Logs in. |
| 280 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 277 user_manager::UserManager::Get()->UserLoggedIn( |
| 281 kTestUserName, true); | 278 kTestUserName, kTestUserName, true); |
| 282 | 279 |
| 283 // Confirms that the features still disabled just after login. | 280 // Confirms that the features still disabled just after login. |
| 284 EXPECT_FALSE(IsLargeCursorEnabled()); | 281 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 285 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 282 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 286 EXPECT_FALSE(IsHighContrastEnabled()); | 283 EXPECT_FALSE(IsHighContrastEnabled()); |
| 287 EXPECT_FALSE(IsAutoclickEnabled()); | 284 EXPECT_FALSE(IsAutoclickEnabled()); |
| 288 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 285 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 289 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); | 286 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); |
| 290 | 287 |
| 291 user_manager::UserManager::Get()->SessionStarted(); | 288 user_manager::UserManager::Get()->SessionStarted(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 329 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 333 | 330 |
| 334 // Signal the accessibility manager that a braille display was connected. | 331 // Signal the accessibility manager that a braille display was connected. |
| 335 SetBrailleDisplayAvailability(true); | 332 SetBrailleDisplayAvailability(true); |
| 336 // Confirms that the spoken feedback is enabled. | 333 // Confirms that the spoken feedback is enabled. |
| 337 EXPECT_TRUE(IsSpokenFeedbackEnabled()); | 334 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 338 } | 335 } |
| 339 | 336 |
| 340 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { | 337 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { |
| 341 // Logs in. | 338 // Logs in. |
| 342 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 339 user_manager::UserManager::Get()->UserLoggedIn( |
| 343 kTestUserName, true); | 340 kTestUserName, kTestUserName, true); |
| 344 user_manager::UserManager::Get()->SessionStarted(); | 341 user_manager::UserManager::Get()->SessionStarted(); |
| 345 | 342 |
| 346 // Confirms that the features are disabled just after login. | 343 // Confirms that the features are disabled just after login. |
| 347 EXPECT_FALSE(IsLargeCursorEnabled()); | 344 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 348 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 345 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 349 EXPECT_FALSE(IsHighContrastEnabled()); | 346 EXPECT_FALSE(IsHighContrastEnabled()); |
| 350 EXPECT_FALSE(IsAutoclickEnabled()); | 347 EXPECT_FALSE(IsAutoclickEnabled()); |
| 351 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); | 348 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); |
| 352 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 349 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 353 | 350 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 389 |
| 393 SetAutoclickEnabledPref(false); | 390 SetAutoclickEnabledPref(false); |
| 394 EXPECT_FALSE(IsAutoclickEnabled()); | 391 EXPECT_FALSE(IsAutoclickEnabled()); |
| 395 | 392 |
| 396 SetVirtualKeyboardEnabledPref(false); | 393 SetVirtualKeyboardEnabledPref(false); |
| 397 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 394 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 398 } | 395 } |
| 399 | 396 |
| 400 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { | 397 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { |
| 401 // Loads the profile of the user. | 398 // Loads the profile of the user. |
| 402 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 399 user_manager::UserManager::Get()->UserLoggedIn( |
| 403 kTestUserName, true); | 400 kTestUserName, kTestUserName, true); |
| 404 | 401 |
| 405 // Sets the pref to enable large cursor before login. | 402 // Sets the pref to enable large cursor before login. |
| 406 SetLargeCursorEnabledPref(true); | 403 SetLargeCursorEnabledPref(true); |
| 407 EXPECT_FALSE(IsLargeCursorEnabled()); | 404 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 408 | 405 |
| 409 // Sets the pref to enable spoken feedback before login. | 406 // Sets the pref to enable spoken feedback before login. |
| 410 SetSpokenFeedbackEnabledPref(true); | 407 SetSpokenFeedbackEnabledPref(true); |
| 411 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 408 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 412 | 409 |
| 413 // Sets the pref to enable high contrast before login. | 410 // Sets the pref to enable high contrast before login. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 437 EXPECT_TRUE(IsAutoclickEnabled()); | 434 EXPECT_TRUE(IsAutoclickEnabled()); |
| 438 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); | 435 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| 439 EXPECT_TRUE(IsVirtualKeyboardEnabled()); | 436 EXPECT_TRUE(IsVirtualKeyboardEnabled()); |
| 440 } | 437 } |
| 441 | 438 |
| 442 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, | 439 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, |
| 443 ChangingTypeInvokesNotification) { | 440 ChangingTypeInvokesNotification) { |
| 444 MockAccessibilityObserver observer; | 441 MockAccessibilityObserver observer; |
| 445 | 442 |
| 446 // Logs in. | 443 // Logs in. |
| 447 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 444 user_manager::UserManager::Get()->UserLoggedIn( |
| 448 kTestUserName, true); | 445 kTestUserName, kTestUserName, true); |
| 449 user_manager::UserManager::Get()->SessionStarted(); | 446 user_manager::UserManager::Get()->SessionStarted(); |
| 450 | 447 |
| 451 EXPECT_FALSE(observer.observed()); | 448 EXPECT_FALSE(observer.observed()); |
| 452 observer.reset(); | 449 observer.reset(); |
| 453 | 450 |
| 454 SetSpokenFeedbackEnabled(true); | 451 SetSpokenFeedbackEnabled(true); |
| 455 EXPECT_TRUE(observer.observed()); | 452 EXPECT_TRUE(observer.observed()); |
| 456 EXPECT_TRUE(observer.observed_enabled()); | 453 EXPECT_TRUE(observer.observed_enabled()); |
| 457 EXPECT_EQ(observer.observed_type(), | 454 EXPECT_EQ(observer.observed_type(), |
| 458 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); | 455 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 EXPECT_EQ(observer.observed_type(), | 494 EXPECT_EQ(observer.observed_type(), |
| 498 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); | 495 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); |
| 499 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 496 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 500 } | 497 } |
| 501 | 498 |
| 502 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, | 499 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, |
| 503 ChangingTypePrefInvokesNotification) { | 500 ChangingTypePrefInvokesNotification) { |
| 504 MockAccessibilityObserver observer; | 501 MockAccessibilityObserver observer; |
| 505 | 502 |
| 506 // Logs in. | 503 // Logs in. |
| 507 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 504 user_manager::UserManager::Get()->UserLoggedIn( |
| 508 kTestUserName, true); | 505 kTestUserName, kTestUserName, true); |
| 509 user_manager::UserManager::Get()->SessionStarted(); | 506 user_manager::UserManager::Get()->SessionStarted(); |
| 510 | 507 |
| 511 EXPECT_FALSE(observer.observed()); | 508 EXPECT_FALSE(observer.observed()); |
| 512 observer.reset(); | 509 observer.reset(); |
| 513 | 510 |
| 514 SetSpokenFeedbackEnabledPref(true); | 511 SetSpokenFeedbackEnabledPref(true); |
| 515 EXPECT_TRUE(observer.observed()); | 512 EXPECT_TRUE(observer.observed()); |
| 516 EXPECT_TRUE(observer.observed_enabled()); | 513 EXPECT_TRUE(observer.observed_enabled()); |
| 517 EXPECT_EQ(observer.observed_type(), | 514 EXPECT_EQ(observer.observed_type(), |
| 518 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); | 515 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 SetHighContrastEnabled(true); | 586 SetHighContrastEnabled(true); |
| 590 EXPECT_TRUE(IsHighContrastEnabled()); | 587 EXPECT_TRUE(IsHighContrastEnabled()); |
| 591 // Enables autoclick. | 588 // Enables autoclick. |
| 592 SetAutoclickEnabled(true); | 589 SetAutoclickEnabled(true); |
| 593 EXPECT_TRUE(IsAutoclickEnabled()); | 590 EXPECT_TRUE(IsAutoclickEnabled()); |
| 594 // Set autoclick delay. | 591 // Set autoclick delay. |
| 595 SetAutoclickDelay(kTestAutoclickDelayMs); | 592 SetAutoclickDelay(kTestAutoclickDelayMs); |
| 596 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); | 593 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| 597 | 594 |
| 598 // Logs in. | 595 // Logs in. |
| 599 const AccountId account_id = AccountId::FromUserEmail(GetParam()); | 596 const char* user_name = GetParam(); |
| 600 user_manager::UserManager::Get()->UserLoggedIn( | 597 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); |
| 601 account_id, account_id.GetUserEmail(), true); | |
| 602 | 598 |
| 603 // Confirms that the features are still enabled just after login. | 599 // Confirms that the features are still enabled just after login. |
| 604 EXPECT_TRUE(IsLargeCursorEnabled()); | 600 EXPECT_TRUE(IsLargeCursorEnabled()); |
| 605 EXPECT_TRUE(IsSpokenFeedbackEnabled()); | 601 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 606 EXPECT_TRUE(IsHighContrastEnabled()); | 602 EXPECT_TRUE(IsHighContrastEnabled()); |
| 607 EXPECT_TRUE(IsAutoclickEnabled()); | 603 EXPECT_TRUE(IsAutoclickEnabled()); |
| 608 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); | 604 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| 609 | 605 |
| 610 user_manager::UserManager::Get()->SessionStarted(); | 606 user_manager::UserManager::Get()->SessionStarted(); |
| 611 | 607 |
| 612 // Confirms that the features keep enabled after session starts. | 608 // Confirms that the features keep enabled after session starts. |
| 613 EXPECT_TRUE(IsLargeCursorEnabled()); | 609 EXPECT_TRUE(IsLargeCursorEnabled()); |
| 614 EXPECT_TRUE(IsSpokenFeedbackEnabled()); | 610 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 615 EXPECT_TRUE(IsHighContrastEnabled()); | 611 EXPECT_TRUE(IsHighContrastEnabled()); |
| 616 EXPECT_TRUE(IsAutoclickEnabled()); | 612 EXPECT_TRUE(IsAutoclickEnabled()); |
| 617 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); | 613 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| 618 | 614 |
| 619 // Confirms that the prefs have been copied to the user's profile. | 615 // Confirms that the prefs have been copied to the user's profile. |
| 620 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); | 616 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); |
| 621 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); | 617 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); |
| 622 EXPECT_TRUE(GetHighContrastEnabledFromPref()); | 618 EXPECT_TRUE(GetHighContrastEnabledFromPref()); |
| 623 EXPECT_TRUE(GetAutoclickEnabledFromPref()); | 619 EXPECT_TRUE(GetAutoclickEnabledFromPref()); |
| 624 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); | 620 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); |
| 625 } | 621 } |
| 626 | 622 |
| 627 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { | 623 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { |
| 628 // Logs in. | 624 // Logs in. |
| 629 const AccountId account_id = AccountId::FromUserEmail(GetParam()); | 625 const char* user_name = GetParam(); |
| 630 user_manager::UserManager::Get()->UserLoggedIn( | 626 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); |
| 631 account_id, account_id.GetUserEmail(), true); | |
| 632 user_manager::UserManager::Get()->SessionStarted(); | 627 user_manager::UserManager::Get()->SessionStarted(); |
| 633 // This object watches for IME preference changes and reflects those in | 628 // This object watches for IME preference changes and reflects those in |
| 634 // the IME framework state. | 629 // the IME framework state. |
| 635 chromeos::Preferences prefs; | 630 chromeos::Preferences prefs; |
| 636 prefs.InitUserPrefsForTesting( | 631 prefs.InitUserPrefsForTesting( |
| 637 PrefServiceSyncableFromProfile(GetProfile()), | 632 PrefServiceSyncableFromProfile(GetProfile()), |
| 638 user_manager::UserManager::Get()->GetActiveUser(), | 633 user_manager::UserManager::Get()->GetActiveUser(), |
| 639 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile())); | 634 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile())); |
| 640 | 635 |
| 641 // Make sure we start in the expected state. | 636 // Make sure we start in the expected state. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 666 | 661 |
| 667 // Plugging in a display while spoken feedback is enabled should activate | 662 // Plugging in a display while spoken feedback is enabled should activate |
| 668 // the Braille IME. | 663 // the Braille IME. |
| 669 SetBrailleDisplayAvailability(true); | 664 SetBrailleDisplayAvailability(true); |
| 670 EXPECT_TRUE(IsSpokenFeedbackEnabled()); | 665 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 671 EXPECT_TRUE(IsBrailleImeActive()); | 666 EXPECT_TRUE(IsBrailleImeActive()); |
| 672 } | 667 } |
| 673 | 668 |
| 674 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { | 669 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { |
| 675 // Log in. | 670 // Log in. |
| 676 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, | 671 user_manager::UserManager::Get()->UserLoggedIn( |
| 677 kTestUserName, true); | 672 kTestUserName, kTestUserName, true); |
| 678 user_manager::UserManager::Get()->SessionStarted(); | 673 user_manager::UserManager::Get()->SessionStarted(); |
| 679 | 674 |
| 680 // Confirms that the features are disabled. | 675 // Confirms that the features are disabled. |
| 681 EXPECT_FALSE(IsLargeCursorEnabled()); | 676 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 682 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | 677 EXPECT_FALSE(IsSpokenFeedbackEnabled()); |
| 683 EXPECT_FALSE(IsHighContrastEnabled()); | 678 EXPECT_FALSE(IsHighContrastEnabled()); |
| 684 EXPECT_FALSE(IsAutoclickEnabled()); | 679 EXPECT_FALSE(IsAutoclickEnabled()); |
| 685 EXPECT_FALSE(ShouldShowAccessibilityMenu()); | 680 EXPECT_FALSE(ShouldShowAccessibilityMenu()); |
| 686 EXPECT_FALSE(IsVirtualKeyboardEnabled()); | 681 EXPECT_FALSE(IsVirtualKeyboardEnabled()); |
| 687 | 682 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 710 EXPECT_FALSE(ShouldShowAccessibilityMenu()); | 705 EXPECT_FALSE(ShouldShowAccessibilityMenu()); |
| 711 | 706 |
| 712 // Check on-screen keyboard. | 707 // Check on-screen keyboard. |
| 713 SetVirtualKeyboardEnabled(true); | 708 SetVirtualKeyboardEnabled(true); |
| 714 EXPECT_TRUE(ShouldShowAccessibilityMenu()); | 709 EXPECT_TRUE(ShouldShowAccessibilityMenu()); |
| 715 SetVirtualKeyboardEnabled(false); | 710 SetVirtualKeyboardEnabled(false); |
| 716 EXPECT_FALSE(ShouldShowAccessibilityMenu()); | 711 EXPECT_FALSE(ShouldShowAccessibilityMenu()); |
| 717 } | 712 } |
| 718 | 713 |
| 719 } // namespace chromeos | 714 } // namespace chromeos |
| OLD | NEW |