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

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

Issue 16104008: First try at a user management screen for the desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up JS code Created 7 years, 6 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_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());
+
+}

Powered by Google App Engine
This is Rietveld 408576698