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

Unified Diff: chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc

Issue 2918203002: cros: Fix loading user profile w/o UserSessionManager (Closed)
Patch Set: rebase Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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..d92279dd67e3e2620c75fe6fafcfc2ceef829e0e 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 marking session as started.
+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());
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698