Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc

Issue 2438063002: user_manager: Remove deps on session_manager (Closed)
Patch Set: fix nits in PS1 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/accessibility_types.h" 7 #include "ash/common/accessibility_types.h"
8 #include "ash/magnifier/magnification_controller.h" 8 #include "ash/magnifier/magnification_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 14 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
15 #include "chrome/browser/chromeos/login/helper.h" 15 #include "chrome/browser/chromeos/login/helper.h"
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 16 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
17 #include "chrome/browser/chromeos/preferences.h" 17 #include "chrome/browser/chromeos/preferences.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_con troller.h" 19 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_con troller.h"
20 #include "chrome/browser/prefs/pref_service_syncable_util.h" 20 #include "chrome/browser/prefs/pref_service_syncable_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "chrome/test/base/in_process_browser_test.h" 25 #include "chrome/test/base/in_process_browser_test.h"
26 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
27 #include "chromeos/chromeos_switches.h" 27 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/login/user_names.h" 28 #include "chromeos/login/user_names.h"
29 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
30 #include "components/session_manager/core/session_manager.h"
30 #include "components/signin/core/account_id/account_id.h" 31 #include "components/signin/core/account_id/account_id.h"
31 #include "components/syncable_prefs/pref_service_syncable.h" 32 #include "components/syncable_prefs/pref_service_syncable.h"
32 #include "components/user_manager/user_manager.h" 33 #include "components/user_manager/user_manager.h"
33 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
34 #include "content/public/test/test_utils.h" 35 #include "content/public/test/test_utils.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" 37 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
37 #include "ui/base/ime/chromeos/input_method_manager.h" 38 #include "ui/base/ime/chromeos/input_method_manager.h"
38 39
39 using chromeos::input_method::InputMethodManager; 40 using chromeos::input_method::InputMethodManager;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 // Confirms that the features still disabled just after login. 303 // Confirms that the features still disabled just after login.
303 EXPECT_FALSE(IsLargeCursorEnabled()); 304 EXPECT_FALSE(IsLargeCursorEnabled());
304 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 305 EXPECT_FALSE(IsSpokenFeedbackEnabled());
305 EXPECT_FALSE(IsHighContrastEnabled()); 306 EXPECT_FALSE(IsHighContrastEnabled());
306 EXPECT_FALSE(IsAutoclickEnabled()); 307 EXPECT_FALSE(IsAutoclickEnabled());
307 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 308 EXPECT_FALSE(IsVirtualKeyboardEnabled());
308 EXPECT_FALSE(IsMonoAudioEnabled()); 309 EXPECT_FALSE(IsMonoAudioEnabled());
309 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 310 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
310 311
311 user_manager::UserManager::Get()->SessionStarted(); 312 session_manager::SessionManager::Get()->SessionStarted();
312 313
313 // Confirms that the features are still disabled just after login. 314 // Confirms that the features are still disabled just after login.
314 EXPECT_FALSE(IsLargeCursorEnabled()); 315 EXPECT_FALSE(IsLargeCursorEnabled());
315 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 316 EXPECT_FALSE(IsSpokenFeedbackEnabled());
316 EXPECT_FALSE(IsHighContrastEnabled()); 317 EXPECT_FALSE(IsHighContrastEnabled());
317 EXPECT_FALSE(IsAutoclickEnabled()); 318 EXPECT_FALSE(IsAutoclickEnabled());
318 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 319 EXPECT_FALSE(IsVirtualKeyboardEnabled());
319 EXPECT_FALSE(IsMonoAudioEnabled()); 320 EXPECT_FALSE(IsMonoAudioEnabled());
320 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 321 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
321 322
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Signal the accessibility manager that a braille display was connected. 361 // Signal the accessibility manager that a braille display was connected.
361 SetBrailleDisplayAvailability(true); 362 SetBrailleDisplayAvailability(true);
362 // Confirms that the spoken feedback is enabled. 363 // Confirms that the spoken feedback is enabled.
363 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 364 EXPECT_TRUE(IsSpokenFeedbackEnabled());
364 } 365 }
365 366
366 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { 367 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
367 // Logs in. 368 // Logs in.
368 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 369 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
369 kTestUserName, true); 370 kTestUserName, true);
370 user_manager::UserManager::Get()->SessionStarted(); 371 session_manager::SessionManager::Get()->SessionStarted();
371 372
372 // Confirms that the features are disabled just after login. 373 // Confirms that the features are disabled just after login.
373 EXPECT_FALSE(IsLargeCursorEnabled()); 374 EXPECT_FALSE(IsLargeCursorEnabled());
374 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 375 EXPECT_FALSE(IsSpokenFeedbackEnabled());
375 EXPECT_FALSE(IsHighContrastEnabled()); 376 EXPECT_FALSE(IsHighContrastEnabled());
376 EXPECT_FALSE(IsAutoclickEnabled()); 377 EXPECT_FALSE(IsAutoclickEnabled());
377 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 378 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
378 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 379 EXPECT_FALSE(IsVirtualKeyboardEnabled());
379 EXPECT_FALSE(IsMonoAudioEnabled()); 380 EXPECT_FALSE(IsMonoAudioEnabled());
380 381
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 461
461 // Sets the pref to enable the on-screen keyboard before login. 462 // Sets the pref to enable the on-screen keyboard before login.
462 SetVirtualKeyboardEnabledPref(true); 463 SetVirtualKeyboardEnabledPref(true);
463 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 464 EXPECT_FALSE(IsVirtualKeyboardEnabled());
464 465
465 // Sets the pref to enable mono audio output before login. 466 // Sets the pref to enable mono audio output before login.
466 SetMonoAudioEnabledPref(true); 467 SetMonoAudioEnabledPref(true);
467 EXPECT_FALSE(IsMonoAudioEnabled()); 468 EXPECT_FALSE(IsMonoAudioEnabled());
468 469
469 // Logs in. 470 // Logs in.
470 user_manager::UserManager::Get()->SessionStarted(); 471 session_manager::SessionManager::Get()->SessionStarted();
471 472
472 // Confirms that features are enabled by restoring from pref just after login. 473 // Confirms that features are enabled by restoring from pref just after login.
473 EXPECT_TRUE(IsLargeCursorEnabled()); 474 EXPECT_TRUE(IsLargeCursorEnabled());
474 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 475 EXPECT_TRUE(IsSpokenFeedbackEnabled());
475 EXPECT_TRUE(IsHighContrastEnabled()); 476 EXPECT_TRUE(IsHighContrastEnabled());
476 EXPECT_TRUE(IsAutoclickEnabled()); 477 EXPECT_TRUE(IsAutoclickEnabled());
477 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 478 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
478 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 479 EXPECT_TRUE(IsVirtualKeyboardEnabled());
479 EXPECT_TRUE(IsMonoAudioEnabled()); 480 EXPECT_TRUE(IsMonoAudioEnabled());
480 } 481 }
481 482
482 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 483 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
483 ChangingTypeInvokesNotification) { 484 ChangingTypeInvokesNotification) {
484 MockAccessibilityObserver observer; 485 MockAccessibilityObserver observer;
485 486
486 // Logs in. 487 // Logs in.
487 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 488 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
488 kTestUserName, true); 489 kTestUserName, true);
489 user_manager::UserManager::Get()->SessionStarted(); 490 session_manager::SessionManager::Get()->SessionStarted();
490 491
491 EXPECT_FALSE(observer.observed()); 492 EXPECT_FALSE(observer.observed());
492 observer.reset(); 493 observer.reset();
493 494
494 SetSpokenFeedbackEnabled(true); 495 SetSpokenFeedbackEnabled(true);
495 EXPECT_TRUE(observer.observed()); 496 EXPECT_TRUE(observer.observed());
496 EXPECT_TRUE(observer.observed_enabled()); 497 EXPECT_TRUE(observer.observed_enabled());
497 EXPECT_EQ(observer.observed_type(), 498 EXPECT_EQ(observer.observed_type(),
498 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 499 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
499 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 500 EXPECT_TRUE(IsSpokenFeedbackEnabled());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_FALSE(IsMonoAudioEnabled()); 556 EXPECT_FALSE(IsMonoAudioEnabled());
556 } 557 }
557 558
558 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 559 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
559 ChangingTypePrefInvokesNotification) { 560 ChangingTypePrefInvokesNotification) {
560 MockAccessibilityObserver observer; 561 MockAccessibilityObserver observer;
561 562
562 // Logs in. 563 // Logs in.
563 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 564 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
564 kTestUserName, true); 565 kTestUserName, true);
565 user_manager::UserManager::Get()->SessionStarted(); 566 session_manager::SessionManager::Get()->SessionStarted();
566 567
567 EXPECT_FALSE(observer.observed()); 568 EXPECT_FALSE(observer.observed());
568 observer.reset(); 569 observer.reset();
569 570
570 SetSpokenFeedbackEnabledPref(true); 571 SetSpokenFeedbackEnabledPref(true);
571 EXPECT_TRUE(observer.observed()); 572 EXPECT_TRUE(observer.observed());
572 EXPECT_TRUE(observer.observed_enabled()); 573 EXPECT_TRUE(observer.observed_enabled());
573 EXPECT_EQ(observer.observed_type(), 574 EXPECT_EQ(observer.observed_type(),
574 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 575 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
575 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 576 EXPECT_TRUE(IsSpokenFeedbackEnabled());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 account_id, account_id.GetUserEmail(), true); 677 account_id, account_id.GetUserEmail(), true);
677 678
678 // Confirms that the features are still enabled just after login. 679 // Confirms that the features are still enabled just after login.
679 EXPECT_TRUE(IsLargeCursorEnabled()); 680 EXPECT_TRUE(IsLargeCursorEnabled());
680 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 681 EXPECT_TRUE(IsSpokenFeedbackEnabled());
681 EXPECT_TRUE(IsHighContrastEnabled()); 682 EXPECT_TRUE(IsHighContrastEnabled());
682 EXPECT_TRUE(IsAutoclickEnabled()); 683 EXPECT_TRUE(IsAutoclickEnabled());
683 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 684 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
684 EXPECT_TRUE(IsMonoAudioEnabled()); 685 EXPECT_TRUE(IsMonoAudioEnabled());
685 686
686 user_manager::UserManager::Get()->SessionStarted(); 687 session_manager::SessionManager::Get()->SessionStarted();
687 688
688 // Confirms that the features keep enabled after session starts. 689 // Confirms that the features keep enabled after session starts.
689 EXPECT_TRUE(IsLargeCursorEnabled()); 690 EXPECT_TRUE(IsLargeCursorEnabled());
690 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 691 EXPECT_TRUE(IsSpokenFeedbackEnabled());
691 EXPECT_TRUE(IsHighContrastEnabled()); 692 EXPECT_TRUE(IsHighContrastEnabled());
692 EXPECT_TRUE(IsAutoclickEnabled()); 693 EXPECT_TRUE(IsAutoclickEnabled());
693 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 694 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
694 EXPECT_TRUE(IsMonoAudioEnabled()); 695 EXPECT_TRUE(IsMonoAudioEnabled());
695 696
696 // Confirms that the prefs have been copied to the user's profile. 697 // Confirms that the prefs have been copied to the user's profile.
697 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); 698 EXPECT_TRUE(GetLargeCursorEnabledFromPref());
698 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); 699 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
699 EXPECT_TRUE(GetHighContrastEnabledFromPref()); 700 EXPECT_TRUE(GetHighContrastEnabledFromPref());
700 EXPECT_TRUE(GetAutoclickEnabledFromPref()); 701 EXPECT_TRUE(GetAutoclickEnabledFromPref());
701 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); 702 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref());
702 EXPECT_TRUE(GetMonoAudioEnabledFromPref()); 703 EXPECT_TRUE(GetMonoAudioEnabledFromPref());
703 } 704 }
704 705
705 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { 706 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) {
706 // Logs in. 707 // Logs in.
707 const AccountId account_id = AccountId::FromUserEmail(GetParam()); 708 const AccountId account_id = AccountId::FromUserEmail(GetParam());
708 user_manager::UserManager::Get()->UserLoggedIn( 709 user_manager::UserManager::Get()->UserLoggedIn(
709 account_id, account_id.GetUserEmail(), true); 710 account_id, account_id.GetUserEmail(), true);
710 user_manager::UserManager::Get()->SessionStarted(); 711 session_manager::SessionManager::Get()->SessionStarted();
711 // This object watches for IME preference changes and reflects those in 712 // This object watches for IME preference changes and reflects those in
712 // the IME framework state. 713 // the IME framework state.
713 chromeos::Preferences prefs; 714 chromeos::Preferences prefs;
714 prefs.InitUserPrefsForTesting( 715 prefs.InitUserPrefsForTesting(
715 PrefServiceSyncableFromProfile(GetProfile()), 716 PrefServiceSyncableFromProfile(GetProfile()),
716 user_manager::UserManager::Get()->GetActiveUser(), 717 user_manager::UserManager::Get()->GetActiveUser(),
717 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile())); 718 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile()));
718 719
719 // Make sure we start in the expected state. 720 // Make sure we start in the expected state.
720 EXPECT_FALSE(IsBrailleImeActive()); 721 EXPECT_FALSE(IsBrailleImeActive());
(...skipping 25 matching lines...) Expand all
746 // the Braille IME. 747 // the Braille IME.
747 SetBrailleDisplayAvailability(true); 748 SetBrailleDisplayAvailability(true);
748 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 749 EXPECT_TRUE(IsSpokenFeedbackEnabled());
749 EXPECT_TRUE(IsBrailleImeActive()); 750 EXPECT_TRUE(IsBrailleImeActive());
750 } 751 }
751 752
752 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { 753 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) {
753 // Log in. 754 // Log in.
754 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 755 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
755 kTestUserName, true); 756 kTestUserName, true);
756 user_manager::UserManager::Get()->SessionStarted(); 757 session_manager::SessionManager::Get()->SessionStarted();
757 758
758 // Confirms that the features are disabled. 759 // Confirms that the features are disabled.
759 EXPECT_FALSE(IsLargeCursorEnabled()); 760 EXPECT_FALSE(IsLargeCursorEnabled());
760 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 761 EXPECT_FALSE(IsSpokenFeedbackEnabled());
761 EXPECT_FALSE(IsHighContrastEnabled()); 762 EXPECT_FALSE(IsHighContrastEnabled());
762 EXPECT_FALSE(IsAutoclickEnabled()); 763 EXPECT_FALSE(IsAutoclickEnabled());
763 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 764 EXPECT_FALSE(ShouldShowAccessibilityMenu());
764 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 765 EXPECT_FALSE(IsVirtualKeyboardEnabled());
765 EXPECT_FALSE(IsMonoAudioEnabled()); 766 EXPECT_FALSE(IsMonoAudioEnabled());
766 767
(...skipping 28 matching lines...) Expand all
795 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 796 EXPECT_FALSE(ShouldShowAccessibilityMenu());
796 797
797 // Check mono audio output. 798 // Check mono audio output.
798 SetMonoAudioEnabled(true); 799 SetMonoAudioEnabled(true);
799 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 800 EXPECT_TRUE(ShouldShowAccessibilityMenu());
800 SetMonoAudioEnabled(false); 801 SetMonoAudioEnabled(false);
801 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 802 EXPECT_FALSE(ShouldShowAccessibilityMenu());
802 } 803 }
803 804
804 } // namespace chromeos 805 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698