Chromium Code Reviews| 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; |