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

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

Issue 1113333003: Don't create a new profile when cleaning up stale ephemeral profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: fix Created 5 years, 7 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') | chrome/browser/ui/app_list/app_list_service_impl.h » ('j') | 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 f818f61f8fd7fa3965d6b657c26061a0c9febe05..78e3273a37579eb6096ae28fe4cb7b6bd18c3ec7 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -876,6 +876,53 @@ TEST_F(ProfileManagerTest, EphemeralProfilesDontEndUpAsLastOpenedAtShutdown) {
EXPECT_EQ(normal_profile, last_opened_profiles[0]);
}
+TEST_F(ProfileManagerTest, CleanUpEphemeralProfiles) {
+ // Create two profiles, one of them ephemeral.
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
+ ASSERT_EQ(0u, cache.GetNumberOfProfiles());
+
+ const std::string profile_name1 = "Homer";
+ base::FilePath path1 = temp_dir_.path().AppendASCII(profile_name1);
+ cache.AddProfileToCache(path1, base::UTF8ToUTF16(profile_name1),
+ std::string(), base::UTF8ToUTF16(profile_name1), 0,
+ std::string());
+ cache.SetProfileIsEphemeralAtIndex(0, true);
+ ASSERT_TRUE(base::CreateDirectory(path1));
+
+ const std::string profile_name2 = "Marge";
+ base::FilePath path2 = temp_dir_.path().AppendASCII(profile_name2);
+ cache.AddProfileToCache(path2, base::UTF8ToUTF16(profile_name2),
+ std::string(), base::UTF8ToUTF16(profile_name2), 0,
+ std::string());
+ ASSERT_EQ(2u, cache.GetNumberOfProfiles());
+ ASSERT_TRUE(base::CreateDirectory(path2));
+
+ // Set the active profile.
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetString(prefs::kProfileLastUsed, profile_name1);
+
+ profile_manager->CleanUpEphemeralProfiles();
+ base::RunLoop().RunUntilIdle();
+
+ // The ephemeral profile should be deleted, and the last used profile set to
+ // the other one.
+ EXPECT_FALSE(base::DirectoryExists(path1));
+ EXPECT_TRUE(base::DirectoryExists(path2));
+ EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed));
+ ASSERT_EQ(1u, cache.GetNumberOfProfiles());
+
+ // Mark the remaining profile ephemeral and clean up.
+ cache.SetProfileIsEphemeralAtIndex(0, true);
+ profile_manager->CleanUpEphemeralProfiles();
+ base::RunLoop().RunUntilIdle();
+
+ // The profile should be deleted, and the last used profile set to a new one.
+ EXPECT_FALSE(base::DirectoryExists(path2));
+ EXPECT_EQ(0u, cache.GetNumberOfProfiles());
+ EXPECT_EQ("Profile 1", local_state->GetString(prefs::kProfileLastUsed));
+}
+
TEST_F(ProfileManagerTest, ActiveProfileDeleted) {
ProfileManager* profile_manager = g_browser_process->profile_manager();
ASSERT_TRUE(profile_manager);
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/ui/app_list/app_list_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698