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

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

Issue 8801034: Revert 112856 - Making profile avatars and names sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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/profiles/profile_manager_unittest.cc
===================================================================
--- chrome/browser/profiles/profile_manager_unittest.cc (revision 113064)
+++ chrome/browser/profiles/profile_manager_unittest.cc (working copy)
@@ -97,14 +97,12 @@
virtual void SetUp() {
// Create a new temporary directory, and store the path
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
- new testing::ProfileManager(temp_dir_.path()));
+ profile_manager_.reset(new testing::ProfileManager(temp_dir_.path()));
#if defined(OS_WIN)
// Force the ProfileInfoCache to be created immediately, so we can
// remove the shortcut manager for testing.
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- profile_manager->GetProfileInfoCache();
- profile_manager->RemoveProfileShortcutManagerForTesting();
+ profile_manager_->GetProfileInfoCache();
+ profile_manager_->RemoveProfileShortcutManagerForTesting();
#endif
#if defined(OS_CHROMEOS)
CommandLine *cl = CommandLine::ForCurrentProcess();
@@ -113,8 +111,7 @@
}
virtual void TearDown() {
- static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
- NULL);
+ profile_manager_.reset();
message_loop_.RunAllPending();
}
@@ -144,30 +141,30 @@
IOThread io_thread_;
scoped_ptr<base::SystemMonitor> system_monitor_dummy_;
+
+ // Also will test profile deletion.
+ scoped_ptr<ProfileManager> profile_manager_;
};
TEST_F(ProfileManagerTest, GetProfile) {
FilePath dest_path = temp_dir_.path();
dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile"));
- ProfileManager* profile_manager = g_browser_process->profile_manager();
-
Profile* profile;
// Successfully create a profile.
- profile = profile_manager->GetProfile(dest_path);
+ profile = profile_manager_->GetProfile(dest_path);
EXPECT_TRUE(profile);
// The profile already exists when we call GetProfile. Just load it.
- EXPECT_EQ(profile, profile_manager->GetProfile(dest_path));
+ EXPECT_EQ(profile, profile_manager_->GetProfile(dest_path));
}
TEST_F(ProfileManagerTest, DefaultProfileDir) {
FilePath expected_default =
FilePath().AppendASCII(chrome::kInitialProfile);
- EXPECT_EQ(
- expected_default.value(),
- g_browser_process->profile_manager()->GetInitialProfileDir().value());
+ EXPECT_EQ(expected_default.value(),
+ profile_manager_->GetInitialProfileDir().value());
}
#if defined(OS_CHROMEOS)
@@ -180,18 +177,17 @@
FilePath expected_default =
FilePath().AppendASCII(chrome::kInitialProfile);
- ProfileManager* profile_manager = g_browser_process->profile_manager();
EXPECT_EQ(expected_default.value(),
- profile_manager->GetInitialProfileDir().value());
+ profile_manager_->GetInitialProfileDir().value());
- profile_manager->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
+ profile_manager_->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
FilePath expected_logged_in(profile_dir);
EXPECT_EQ(expected_logged_in.value(),
- profile_manager->GetInitialProfileDir().value());
+ profile_manager_->GetInitialProfileDir().value());
VLOG(1) << temp_dir_.path().Append(
- profile_manager->GetInitialProfileDir()).value();
+ profile_manager_->GetInitialProfileDir()).value();
}
#endif
@@ -203,15 +199,13 @@
FilePath dest_path2 = temp_dir_.path();
dest_path2 = dest_path2.Append(FILE_PATH_LITERAL("New Profile 2"));
- ProfileManager* profile_manager = g_browser_process->profile_manager();
-
// Successfully create the profiles.
TestingProfile* profile1 =
- static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path1));
+ static_cast<TestingProfile*>(profile_manager_->GetProfile(dest_path1));
ASSERT_TRUE(profile1);
TestingProfile* profile2 =
- static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2));
+ static_cast<TestingProfile*>(profile_manager_->GetProfile(dest_path2));
ASSERT_TRUE(profile2);
// Force lazy-init of some profile services to simulate use.
@@ -227,8 +221,7 @@
// Make sure any pending tasks run before we destroy the profiles.
message_loop_.RunAllPending();
- static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
- NULL);
+ profile_manager_.reset();
// Make sure history cleans up correctly.
message_loop_.RunAllPending();
@@ -248,8 +241,7 @@
EXPECT_CALL(mock_observer, OnProfileCreated(
testing::NotNull(), NotFail())).Times(testing::AtLeast(1));
- g_browser_process->profile_manager()->CreateProfileAsync(dest_path,
- &mock_observer);
+ profile_manager_->CreateProfileAsync(dest_path, &mock_observer);
message_loop_.RunAllPending();
}
@@ -276,12 +268,10 @@
EXPECT_CALL(mock_observer3, OnProfileCreated(
SameNotNull(), NotFail())).Times(testing::AtLeast(1));
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ profile_manager_->CreateProfileAsync(dest_path, &mock_observer1);
+ profile_manager_->CreateProfileAsync(dest_path, &mock_observer2);
+ profile_manager_->CreateProfileAsync(dest_path, &mock_observer3);
- profile_manager->CreateProfileAsync(dest_path, &mock_observer1);
- profile_manager->CreateProfileAsync(dest_path, &mock_observer2);
- profile_manager->CreateProfileAsync(dest_path, &mock_observer3);
-
message_loop_.RunAllPending();
}
@@ -295,17 +285,14 @@
EXPECT_CALL(mock_observer, OnProfileCreated(
testing::NotNull(), NotFail())).Times(testing::AtLeast(3));
- ProfileManager* profile_manager = g_browser_process->profile_manager();
+ profile_manager_->CreateProfileAsync(dest_path1, &mock_observer);
+ profile_manager_->CreateProfileAsync(dest_path2, &mock_observer);
- profile_manager->CreateProfileAsync(dest_path1, &mock_observer);
- profile_manager->CreateProfileAsync(dest_path2, &mock_observer);
-
message_loop_.RunAllPending();
}
TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
+ ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"),
@@ -318,31 +305,7 @@
cache.SetBackgroundStatusOfProfileAtIndex(2, true);
EXPECT_EQ(3u, cache.GetNumberOfProfiles());
- profile_manager->AutoloadProfiles();
+ profile_manager_->AutoloadProfiles();
- EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size());
+ EXPECT_EQ(2u, profile_manager_->GetLoadedProfiles().size());
}
-
-TEST_F(ProfileManagerTest, InitProfileUserPrefs) {
- FilePath dest_path = temp_dir_.path();
- dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile"));
-
- ProfileManager* profile_manager = g_browser_process->profile_manager();
-
- Profile* profile;
-
- // Successfully create the profile
- profile = profile_manager->GetProfile(dest_path);
- ASSERT_TRUE(profile);
-
- // Check that the profile name is non empty
- std::string profile_name =
- profile->GetPrefs()->GetString(prefs::kProfileName);
- EXPECT_FALSE(profile_name.empty());
-
- // Check that the profile avatar index is valid
- size_t avatar_index = profile->GetPrefs()->GetInteger(
- prefs::kProfileAvatarIndex);
- EXPECT_TRUE(profile_manager->GetProfileInfoCache().IsDefaultAvatarIconIndex(
- avatar_index));
-}
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698