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

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

Issue 1782443006: Create LoadProfile method in profile_manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 9b123393a2058816673a3bea182ce48feeea65d9..ca5c03008bb94d4c83806e70e472d65931c6505d 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -93,6 +93,25 @@ class UnittestProfileManager : public ::ProfileManagerWithoutInit {
}
};
+void ExpectNullProfile(Profile* profile) {
+ EXPECT_EQ(nullptr, profile);
+}
+
+void ExpectProfileWithName(const std::string& profile_name,
+ bool incognito,
+ Profile* profile) {
+ EXPECT_NE(nullptr, profile);
+ EXPECT_EQ(profile->IsOffTheRecord(), incognito);
Peter Beverloo 2016/03/11 17:45:16 nit: for lines 104, 107 and 110, change the parame
Miguel Garcia 2016/03/14 18:29:01 Done.
Bernhard Bauer 2016/03/14 19:05:34 For a given value of "soon", because we can't roll
+ if (!incognito) {
+#if defined(OS_WIN)
+ EXPECT_EQ(profile->GetPath().BaseName().value(),
+ base::ASCIIToUTF16(profile_name));
+#else
+ EXPECT_EQ(profile->GetPath().BaseName().value(), profile_name);
+#endif
+ }
+}
+
} // namespace
class ProfileManagerTest : public testing::Test {
@@ -293,6 +312,47 @@ TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) {
base::RunLoop().RunUntilIdle();
}
+TEST_F(ProfileManagerTest, LoadProfileDoesNotExist) {
+ const std::string profile_name = "NonExistingProfile";
+
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ profile_manager->LoadProfile(profile_name, false /* incognito */,
+ base::Bind(&ExpectNullProfile));
+ base::RunLoop().RunUntilIdle();
+ profile_manager->LoadProfile(profile_name, true /* incognito */,
+ base::Bind(&ExpectNullProfile));
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST_F(ProfileManagerTest, LoadProfileExisting) {
+ const std::string profile_name = "MyProfile";
+ const std::string other_name = "SomeOtherProfile";
+ MockObserver mock_observer1;
Bernhard Bauer 2016/03/14 19:05:34 Nit: no "1" suffix?
+ EXPECT_CALL(mock_observer1, OnProfileCreated(SameNotNull(), NotFail()))
+ .Times(testing::AtLeast(1));
+
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ CreateProfileAsync(profile_manager, profile_name, false, &mock_observer1);
+
+ // Make sure a real profile is created before continuing.
+ base::RunLoop().RunUntilIdle();
+
+ bool incognito = false;
+ profile_manager->LoadProfile(
+ profile_name, incognito,
+ base::Bind(&ExpectProfileWithName, profile_name, incognito));
+
+ incognito = true;
+ profile_manager->LoadProfile(
+ profile_name, incognito,
+ base::Bind(&ExpectProfileWithName, profile_name, incognito));
+
+ // Loading some other non existing profile should still return null.
+ profile_manager->LoadProfile(other_name, false,
+ base::Bind(&ExpectNullProfile));
+ base::RunLoop().RunUntilIdle();
+}
+
TEST_F(ProfileManagerTest, CreateProfileAsyncMultipleRequests) {
g_created_profile = NULL;
« chrome/browser/profiles/profile_manager.cc ('K') | « chrome/browser/profiles/profile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698