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

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

Issue 2698683002: Forced ephemeral profile deletion on browser removal crash fix. (Closed)
Patch Set: Changed active profile selection logic upon ephemeral profile deletion. Created 3 years, 10 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 6a66ac55f2c3c9a757d50e71e551db91e13a9ff6..645727114976bdf99d82135566b90ca82c7e795a 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.
@@ -877,7 +892,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();
@@ -917,8 +932,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 =
@@ -946,8 +960,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