Chromium Code Reviews| Index: chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc |
| diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc |
| index 817565a5cb7a05f04cb4a74f78157e2b18fe2d7e..cb114016ab6c51d16f5837e4556c037eeab41e81 100644 |
| --- a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc |
| +++ b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc |
| @@ -160,7 +160,12 @@ bool IsMonoAudioEnabled() { |
| } |
| Profile* GetProfile() { |
| - Profile* profile = ProfileManager::GetActiveUserProfile(); |
| + // ProfileManager::GetActiveUserProfile() does not load user profile |
| + // implicitly any more. Use ProfileHelper::GetProfileByUserIdHashForTest() to |
| + // do an explicit load. |
| + Profile* const profile = ProfileHelper::GetProfileByUserIdHashForTest( |
| + user_manager::UserManager::Get()->GetActiveUser()->username_hash()); |
| + |
| DCHECK(profile); |
| return profile; |
| } |
| @@ -169,6 +174,15 @@ PrefService* GetPrefs() { |
| return GetProfile()->GetPrefs(); |
| } |
| +// Simulates how UserSessionManager starts a user session by loading user |
| +// profile and mark session as started. |
|
emaxx
2017/06/08 19:43:53
nit: s/mark/marking/ ?
xiyuan
2017/06/08 20:30:40
Done.
|
| +void StartUserSession(const AccountId& account_id) { |
| + ProfileHelper::GetProfileByUserIdHashForTest( |
| + user_manager::UserManager::Get()->FindUser(account_id)->username_hash()); |
| + |
| + session_manager::SessionManager::Get()->SessionStarted(); |
| +} |
| + |
| void SetLargeCursorEnabledPref(bool enabled) { |
| GetPrefs()->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, enabled); |
| } |
| @@ -239,6 +253,7 @@ bool IsBrailleImeCurrent() { |
| return imm->GetActiveIMEState()->GetCurrentInputMethod().id() == |
| extension_ime_util::kBrailleImeEngineId; |
| } |
| + |
| } // anonymous namespace |
| class AccessibilityManagerTest : public InProcessBrowserTest { |
| @@ -309,7 +324,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { |
| EXPECT_FALSE(IsMonoAudioEnabled()); |
| EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| // Confirms that the features are still disabled just after login. |
| EXPECT_FALSE(IsLargeCursorEnabled()); |
| @@ -368,7 +383,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { |
| // Logs in. |
| auto* session_manager = session_manager::SessionManager::Get(); |
| session_manager->CreateSession(test_account_id_, kTestUserName); |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| // Confirms that the features are disabled just after login. |
| EXPECT_FALSE(IsLargeCursorEnabled()); |
| @@ -468,7 +483,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { |
| EXPECT_FALSE(IsMonoAudioEnabled()); |
| // Logs in. |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| // Confirms that features are enabled by restoring from pref just after login. |
| EXPECT_TRUE(IsLargeCursorEnabled()); |
| @@ -487,7 +502,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, |
| // Logs in. |
| auto* session_manager = session_manager::SessionManager::Get(); |
| session_manager->CreateSession(test_account_id_, kTestUserName); |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| EXPECT_FALSE(observer.observed()); |
| observer.reset(); |
| @@ -563,7 +578,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, |
| // Logs in. |
| auto* session_manager = session_manager::SessionManager::Get(); |
| session_manager->CreateSession(test_account_id_, kTestUserName); |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| EXPECT_FALSE(observer.observed()); |
| observer.reset(); |
| @@ -684,7 +699,7 @@ IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, |
| EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| EXPECT_TRUE(IsMonoAudioEnabled()); |
| - session_manager->SessionStarted(); |
| + StartUserSession(account_id); |
| // Confirms that the features keep enabled after session starts. |
| EXPECT_TRUE(IsLargeCursorEnabled()); |
| @@ -708,7 +723,7 @@ IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { |
| const AccountId account_id = AccountId::FromUserEmail(GetParam()); |
| auto* session_manager = session_manager::SessionManager::Get(); |
| session_manager->CreateSession(account_id, account_id.GetUserEmail()); |
| - session_manager->SessionStarted(); |
| + StartUserSession(account_id); |
| // This object watches for IME preference changes and reflects those in |
| // the IME framework state. |
| chromeos::Preferences prefs; |
| @@ -754,7 +769,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { |
| // Log in. |
| auto* session_manager = session_manager::SessionManager::Get(); |
| session_manager->CreateSession(test_account_id_, kTestUserName); |
| - session_manager->SessionStarted(); |
| + StartUserSession(test_account_id_); |
| // Confirms that the features are disabled. |
| EXPECT_FALSE(IsLargeCursorEnabled()); |