| Index: chrome/browser/profiles/profile_manager_browsertest.cc
|
| diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc
|
| index b0a37156cc16ec4b52dfff1d189ddb4e6aeb73eb..c63eef95c695fb2d7667930e56a91863f1ea1a10 100644
|
| --- a/chrome/browser/profiles/profile_manager_browsertest.cc
|
| +++ b/chrome/browser/profiles/profile_manager_browsertest.cc
|
| @@ -188,3 +188,50 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
|
| BrowserList::CloseAllBrowsersWithProfile(*it);
|
| }
|
| }
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
|
| + SwitchToProfile) {
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| + ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
|
| + base::FilePath path_profile1 = cache.GetPathOfProfileAtIndex(0);
|
| +
|
| + ASSERT_EQ(profile_manager->GetNumberOfProfiles(), 1U);
|
| + EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U);
|
| +
|
| + // Create an additional profile.
|
| + base::FilePath path_profile2 =
|
| + profile_manager->GenerateNextProfileDirectoryPath();
|
| + profile_manager->CreateProfileAsync(path_profile2,
|
| + base::Bind(&OnUnblockOnProfileCreation),
|
| + string16(), string16(), false);
|
| +
|
| + // Spin to allow profile creation to take place, loop is terminated
|
| + // by OnUnblockOnProfileCreation when the profile is created.
|
| + content::RunMessageLoop();
|
| +
|
| + chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
|
| + BrowserList* browser_list = BrowserList::GetInstance(desktop_type);
|
| + ASSERT_EQ(cache.GetNumberOfProfiles(), 2U);
|
| + EXPECT_EQ(1U, browser_list->size());
|
| +
|
| + // Open a browser window for the first profile.
|
| + ProfileManager::SwitchToProfile(path_profile1, desktop_type, false);
|
| + EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U);
|
| + EXPECT_EQ(1U, browser_list->size());
|
| + EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
|
| +
|
| + // Open a browser window for the second profile.
|
| + ProfileManager::SwitchToProfile(path_profile2, desktop_type, false);
|
| + EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
|
| + EXPECT_EQ(2U, browser_list->size());
|
| + EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
|
| +
|
| + // Switch to the first profile without opening a new window.
|
| + ProfileManager::SwitchToProfile(path_profile1, desktop_type, false);
|
| + EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
|
| + EXPECT_EQ(2U, browser_list->size());
|
| +
|
| + EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
|
| + EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
|
| +
|
| +}
|
|
|