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

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: fix linux CrOS browser test Created 7 years, 5 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7b96cc4d4fd743b25d8f5af6d3e0e6de9d5fe9a4..5243d669aa36d553feb1577ab6efc98fea50ec77 100644
--- a/chrome/browser/profiles/profile_manager_browsertest.cc
+++ b/chrome/browser/profiles/profile_manager_browsertest.cc
@@ -8,6 +8,8 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_cache_observer.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/profiles/profile_window.h"
+#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -181,3 +183,55 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
BrowserList::CloseAllBrowsersWithProfile(*it);
}
}
+
+IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
+ SwitchToProfile) {
+ // If multiprofile mode is not enabled, you can't switch between profiles.
+ if (!profiles::IsMultipleProfilesEnabled())
+ return;
+
+
+ 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.
+ profiles::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.
+ profiles::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.
+ profiles::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());
+
+}
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698