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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile_info_cache.h" 8 #include "chrome/browser/profiles/profile_info_cache.h"
9 #include "chrome/browser/profiles/profile_info_cache_observer.h" 9 #include "chrome/browser/profiles/profile_info_cache_observer.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/profiles/profile_window.h"
12 #include "chrome/browser/profiles/profiles_state.h"
11 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/host_desktop.h" 15 #include "chrome/browser/ui/host_desktop.h"
14 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
18 20
19 namespace { 21 namespace {
20 22
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); 176 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U);
175 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); 177 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
176 178
177 // Now close all browser windows. 179 // Now close all browser windows.
178 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); 180 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
179 for (std::vector<Profile*>::const_iterator it = profiles.begin(); 181 for (std::vector<Profile*>::const_iterator it = profiles.begin();
180 it != profiles.end(); ++it) { 182 it != profiles.end(); ++it) {
181 BrowserList::CloseAllBrowsersWithProfile(*it); 183 BrowserList::CloseAllBrowsersWithProfile(*it);
182 } 184 }
183 } 185 }
186
187 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
188 SwitchToProfile) {
189 // If multiprofile mode is not enabled, you can't switch between profiles.
190 if (!profiles::IsMultipleProfilesEnabled())
191 return;
192
193
194 ProfileManager* profile_manager = g_browser_process->profile_manager();
195 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
196 base::FilePath path_profile1 = cache.GetPathOfProfileAtIndex(0);
197
198 ASSERT_EQ(profile_manager->GetNumberOfProfiles(), 1U);
199 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U);
200
201 // Create an additional profile.
202 base::FilePath path_profile2 =
203 profile_manager->GenerateNextProfileDirectoryPath();
204 profile_manager->CreateProfileAsync(path_profile2,
205 base::Bind(&OnUnblockOnProfileCreation),
206 string16(), string16(), false);
207
208 // Spin to allow profile creation to take place, loop is terminated
209 // by OnUnblockOnProfileCreation when the profile is created.
210 content::RunMessageLoop();
211
212 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
213 BrowserList* browser_list = BrowserList::GetInstance(desktop_type);
214 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U);
215 EXPECT_EQ(1U, browser_list->size());
216
217 // Open a browser window for the first profile.
218 profiles::SwitchToProfile(path_profile1, desktop_type, false);
219 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U);
220 EXPECT_EQ(1U, browser_list->size());
221 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
222
223 // Open a browser window for the second profile.
224 profiles::SwitchToProfile(path_profile2, desktop_type, false);
225 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
226 EXPECT_EQ(2U, browser_list->size());
227 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
228
229 // Switch to the first profile without opening a new window.
230 profiles::SwitchToProfile(path_profile1, desktop_type, false);
231 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
232 EXPECT_EQ(2U, browser_list->size());
233
234 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
235 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
236
237 }
OLDNEW
« 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