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

Side by Side Diff: chrome/browser/app_controller_mac_browsertest.mm

Issue 847733005: Move User Manager onto a System profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile Error - Windows Created 5 years, 11 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 | « no previous file | chrome/browser/profiles/profile.h » ('j') | chrome/browser/profiles/profile.h » ('J')
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 #import <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 #import <Cocoa/Cocoa.h> 6 #import <Cocoa/Cocoa.h>
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #import <Foundation/NSAppleEventDescriptor.h> 8 #import <Foundation/NSAppleEventDescriptor.h>
9 #import <objc/message.h> 9 #import <objc/message.h>
10 #import <objc/runtime.h> 10 #import <objc/runtime.h>
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Profile::CreateStatus status) { 195 Profile::CreateStatus status) {
196 EXPECT_TRUE(profile); 196 EXPECT_TRUE(profile);
197 EXPECT_NE(Profile::CREATE_STATUS_LOCAL_FAIL, status); 197 EXPECT_NE(Profile::CREATE_STATUS_LOCAL_FAIL, status);
198 EXPECT_NE(Profile::CREATE_STATUS_REMOTE_FAIL, status); 198 EXPECT_NE(Profile::CREATE_STATUS_REMOTE_FAIL, status);
199 // This will be called multiple times. Wait until the profile is initialized 199 // This will be called multiple times. Wait until the profile is initialized
200 // fully to quit the loop. 200 // fully to quit the loop.
201 if (status == Profile::CREATE_STATUS_INITIALIZED) 201 if (status == Profile::CREATE_STATUS_INITIALIZED)
202 quit_closure.Run(); 202 quit_closure.Run();
203 } 203 }
204 204
205 void CreateAndWaitForGuestProfile() { 205 void CreateAndWaitForSystemProfile() {
206 ProfileManager::CreateCallback create_callback = 206 ProfileManager::CreateCallback create_callback =
207 base::Bind(&CreateProfileCallback, 207 base::Bind(&CreateProfileCallback,
208 base::MessageLoop::current()->QuitClosure()); 208 base::MessageLoop::current()->QuitClosure());
209 g_browser_process->profile_manager()->CreateProfileAsync( 209 g_browser_process->profile_manager()->CreateProfileAsync(
210 ProfileManager::GetGuestProfilePath(), 210 ProfileManager::GetSystemProfilePath(),
211 create_callback, 211 create_callback,
212 base::string16(), 212 base::string16(),
213 base::string16(), 213 base::string16(),
214 std::string()); 214 std::string());
215 base::RunLoop().Run(); 215 base::RunLoop().Run();
216 } 216 }
217 217
218 class AppControllerNewProfileManagementBrowserTest 218 class AppControllerNewProfileManagementBrowserTest
219 : public InProcessBrowserTest { 219 : public InProcessBrowserTest {
220 protected: 220 protected:
(...skipping 17 matching lines...) Expand all
238 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 238 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
239 239
240 EXPECT_FALSE(result); 240 EXPECT_FALSE(result);
241 EXPECT_EQ(2u, active_browser_list_->size()); 241 EXPECT_EQ(2u, active_browser_list_->size());
242 EXPECT_FALSE(UserManager::IsShowing()); 242 EXPECT_FALSE(UserManager::IsShowing());
243 } 243 }
244 244
245 // Test that for a locked last profile, a reopen event opens the User Manager. 245 // Test that for a locked last profile, a reopen event opens the User Manager.
246 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, 246 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest,
247 LockedProfileReopenWithNoWindows) { 247 LockedProfileReopenWithNoWindows) {
248 // The User Manager uses the guest profile as its underlying profile. To 248 // The User Manager uses the system profile as its underlying profile. To
249 // minimize flakiness due to the scheduling/descheduling of tasks on the 249 // minimize flakiness due to the scheduling/descheduling of tasks on the
250 // different threads, pre-initialize the guest profile before it is needed. 250 // different threads, pre-initialize the guest profile before it is needed.
251 CreateAndWaitForGuestProfile(); 251 CreateAndWaitForSystemProfile();
252 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); 252 base::scoped_nsobject<AppController> ac([[AppController alloc] init]);
253 253
254 // Lock the active profile. 254 // Lock the active profile.
255 Profile* profile = [ac lastProfile]; 255 Profile* profile = [ac lastProfile];
256 ProfileInfoCache& cache = 256 ProfileInfoCache& cache =
257 g_browser_process->profile_manager()->GetProfileInfoCache(); 257 g_browser_process->profile_manager()->GetProfileInfoCache();
258 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 258 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
259 cache.SetProfileSigninRequiredAtIndex(profile_index, true); 259 cache.SetProfileSigninRequiredAtIndex(profile_index, true);
260 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(profile_index)); 260 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(profile_index));
261 261
262 EXPECT_EQ(1u, active_browser_list_->size()); 262 EXPECT_EQ(1u, active_browser_list_->size());
263 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 263 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
264 EXPECT_FALSE(result); 264 EXPECT_FALSE(result);
265 265
266 base::RunLoop().RunUntilIdle(); 266 base::RunLoop().RunUntilIdle();
267 EXPECT_EQ(1u, active_browser_list_->size()); 267 EXPECT_EQ(1u, active_browser_list_->size());
268 EXPECT_TRUE(UserManager::IsShowing()); 268 EXPECT_TRUE(UserManager::IsShowing());
269 UserManager::Hide(); 269 UserManager::Hide();
270 } 270 }
271 271
272 // Test that for a guest last profile, a reopen event opens the User Manager. 272 // Test that for a guest last profile, a reopen event opens the User Manager.
273 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, 273 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest,
274 GuestProfileReopenWithNoWindows) { 274 GuestProfileReopenWithNoWindows) {
275 // Create the guest profile, and set it as the last used profile so the 275 // Create the system profile. Set the guest as the last used profile so the
276 // app controller can use it on init. 276 // app controller can use it on init.
277 CreateAndWaitForGuestProfile(); 277 CreateAndWaitForSystemProfile();
278 PrefService* local_state = g_browser_process->local_state(); 278 PrefService* local_state = g_browser_process->local_state();
279 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir); 279 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir);
280 280
281 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); 281 base::scoped_nsobject<AppController> ac([[AppController alloc] init]);
282 282
283 Profile* profile = [ac lastProfile]; 283 Profile* profile = [ac lastProfile];
284 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), profile->GetPath()); 284 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), profile->GetPath());
285 EXPECT_TRUE(profile->IsGuestSession()); 285 EXPECT_TRUE(profile->IsGuestSession());
286 286
287 EXPECT_EQ(1u, active_browser_list_->size()); 287 EXPECT_EQ(1u, active_browser_list_->size());
288 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 288 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
289 EXPECT_FALSE(result); 289 EXPECT_FALSE(result);
290 290
291 base::RunLoop().RunUntilIdle(); 291 base::RunLoop().RunUntilIdle();
292 292
293 EXPECT_EQ(1u, active_browser_list_->size()); 293 EXPECT_EQ(1u, active_browser_list_->size());
294 EXPECT_TRUE(UserManager::IsShowing()); 294 EXPECT_TRUE(UserManager::IsShowing());
295 UserManager::Hide(); 295 UserManager::Hide();
296 } 296 }
297 297
298 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, 298 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest,
299 AboutChromeForcesUserManager) { 299 AboutChromeForcesUserManager) {
300 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); 300 base::scoped_nsobject<AppController> ac([[AppController alloc] init]);
301 301
302 // Create the guest profile, and set it as the last used profile so the 302 // Create the guest profile, and set it as the last used profile so the
303 // app controller can use it on init. 303 // app controller can use it on init.
304 CreateAndWaitForGuestProfile(); 304 CreateAndWaitForSystemProfile();
305 PrefService* local_state = g_browser_process->local_state(); 305 PrefService* local_state = g_browser_process->local_state();
306 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir); 306 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir);
307 307
308 // Prohibiting guest mode forces the user manager flow for About Chrome. 308 // Prohibiting guest mode forces the user manager flow for About Chrome.
309 local_state->SetBoolean(prefs::kBrowserGuestModeEnabled, false); 309 local_state->SetBoolean(prefs::kBrowserGuestModeEnabled, false);
310 310
311 Profile* guest_profile = [ac lastProfile]; 311 Profile* guest_profile = [ac lastProfile];
312 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), guest_profile->GetPath()); 312 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), guest_profile->GetPath());
313 EXPECT_TRUE(guest_profile->IsGuestSession()); 313 EXPECT_TRUE(guest_profile->IsGuestSession());
314 314
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 ui_test_utils::NavigateToURL(browser3, test_url1); 615 ui_test_utils::NavigateToURL(browser3, test_url1);
616 EXPECT_EQ(g_handoff_url, GURL()); 616 EXPECT_EQ(g_handoff_url, GURL());
617 617
618 // Activate the original browser window. 618 // Activate the original browser window.
619 Browser* browser1 = active_browser_list->get(0); 619 Browser* browser1 = active_browser_list->get(0);
620 browser1->window()->Show(); 620 browser1->window()->Show();
621 EXPECT_EQ(g_handoff_url, test_url2); 621 EXPECT_EQ(g_handoff_url, test_url2);
622 } 622 }
623 623
624 } // namespace 624 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile.h » ('j') | chrome/browser/profiles/profile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698