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

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: forgot untracked files 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 unified diff | Download patch
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/utf_string_conversions.h" 7 #include "base/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"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); 181 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U);
182 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); 182 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U);
183 183
184 // Now close all browser windows. 184 // Now close all browser windows.
185 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); 185 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
186 for (std::vector<Profile*>::const_iterator it = profiles.begin(); 186 for (std::vector<Profile*>::const_iterator it = profiles.begin();
187 it != profiles.end(); ++it) { 187 it != profiles.end(); ++it) {
188 BrowserList::CloseAllBrowsersWithProfile(*it); 188 BrowserList::CloseAllBrowsersWithProfile(*it);
189 } 189 }
190 } 190 }
191
192 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
193 SwitchToProfile) {
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 ProfileManager::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 ProfileManager::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 ProfileManager::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

Powered by Google App Engine
This is Rietveld 408576698