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

Unified Diff: chrome/browser/profiles/profile_manager_unittest.cc

Issue 2732973007: Forced ephemeral profile deletion on browser removal crash fix. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager_unittest.cc
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 58ff1710d1b8f427a8d71ee4242707ae83c725ca..b68675bd87e9fdb44460f7da9ecbfdbcf93126c7 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -178,6 +178,21 @@ class ProfileManagerTest : public testing::Test {
return profile_manager->GetProfile(path);
}
+ // Helper function to set profile ephemeral at prefs and attributes storage.
+ void SetProfileEphemeral(Profile* profile) {
+ profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true);
+
+ // Update IsEphemeral in attributes storage, normally it happened via
+ // kForceEphemeralProfiles pref change event routed to
+ // ProfileImpl::UpdateIsEphemeralInStorage().
+ ProfileAttributesEntry* entry;
+ ProfileAttributesStorage& storage =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage();
+ EXPECT_TRUE(
+ storage.GetProfileAttributesWithPath(profile->GetPath(), &entry));
+ entry->SetIsEphemeral(true);
+ }
+
#if defined(OS_CHROMEOS)
// Helper function to register an user with id |user_id| and create profile
// with a correct path.
@@ -878,7 +893,7 @@ TEST_F(ProfileManagerTest, EphemeralProfilesDontEndUpAsLastProfile) {
TestingProfile* profile =
static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path));
ASSERT_TRUE(profile);
- profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true);
+ SetProfileEphemeral(profile);
// Here the last used profile is still the "Default" profile.
Profile* last_used_profile = profile_manager->GetLastUsedProfile();
@@ -918,8 +933,7 @@ TEST_F(ProfileManagerTest, EphemeralProfilesDontEndUpAsLastOpenedAtShutdown) {
TestingProfile* ephemeral_profile1 =
static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2));
ASSERT_TRUE(ephemeral_profile1);
- ephemeral_profile1->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles,
- true);
+ SetProfileEphemeral(ephemeral_profile1);
// Add second ephemeral profile but don't mark it as such yet.
TestingProfile* ephemeral_profile2 =
@@ -947,8 +961,7 @@ TEST_F(ProfileManagerTest, EphemeralProfilesDontEndUpAsLastOpenedAtShutdown) {
EXPECT_EQ(ephemeral_profile2, last_opened_profiles[1]);
// Mark the second profile ephemeral.
- ephemeral_profile2->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles,
- true);
+ SetProfileEphemeral(ephemeral_profile2);
// Simulate a shutdown.
content::NotificationService::current()->Notify(
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698