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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm

Issue 2762173003: Remove IsNewProfileManagement and EnableNewProfileManagementForTesting (Closed)
Patch Set: Fix compile (add back an include) Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 EXPECT_TRUE([[subviews objectAtIndex:3] isKindOfClass:[NSBox class]]); 425 EXPECT_TRUE([[subviews objectAtIndex:3] isKindOfClass:[NSBox class]]);
426 426
427 // There should be the profile avatar, name and a "hide accounts" link 427 // There should be the profile avatar, name and a "hide accounts" link
428 // container in the active card view. 428 // container in the active card view.
429 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews]; 429 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews];
430 // In the MD user menu, the profile name and avatar are in the same subview. 430 // In the MD user menu, the profile name and avatar are in the same subview.
431 ASSERT_EQ(2U, [activeCardSubviews count]); 431 ASSERT_EQ(2U, [activeCardSubviews count]);
432 } 432 }
433 433
434 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { 434 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) {
435 switches::EnableNewProfileManagementForTesting(
436 base::CommandLine::ForCurrentProcess());
437
438 SignInFirstProfile(); 435 SignInFirstProfile();
439 436
440 // The preference, not the email, determines whether the profile can lock. 437 // The preference, not the email, determines whether the profile can lock.
441 browser()->profile()->GetPrefs()->SetString( 438 browser()->profile()->GetPrefs()->SetString(
442 prefs::kGoogleServicesHostedDomain, "chromium.org"); 439 prefs::kGoogleServicesHostedDomain, "chromium.org");
443 440
444 StartProfileChooserController(); 441 StartProfileChooserController();
445 NSArray* subviews = [[[controller() window] contentView] subviews]; 442 NSArray* subviews = [[[controller() window] contentView] subviews];
446 ASSERT_EQ(2U, [subviews count]); 443 ASSERT_EQ(2U, [subviews count]);
447 subviews = [[subviews objectAtIndex:0] subviews]; 444 subviews = [[subviews objectAtIndex:0] subviews];
448 445
449 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 446 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
450 // There will be two buttons in the option buttons view. 447 // There will be two buttons in the option buttons view.
451 ASSERT_EQ(2U, [buttonSubviews count]); 448 ASSERT_EQ(2U, [buttonSubviews count]);
452 449
453 // The last button should not be the lock button. 450 // The last button should not be the lock button.
454 NSButton* lastButton = 451 NSButton* lastButton =
455 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 452 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
456 ASSERT_TRUE(lastButton); 453 ASSERT_TRUE(lastButton);
457 EXPECT_NE(@selector(lockProfile:), [lastButton action]); 454 EXPECT_NE(@selector(lockProfile:), [lastButton action]);
458 } 455 }
459 456
460 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { 457 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) {
461 switches::EnableNewProfileManagementForTesting(
462 base::CommandLine::ForCurrentProcess());
463
464 SignInFirstProfile(); 458 SignInFirstProfile();
465 459
466 // The preference, not the email, determines whether the profile can lock. 460 // The preference, not the email, determines whether the profile can lock.
467 browser()->profile()->GetPrefs()->SetString( 461 browser()->profile()->GetPrefs()->SetString(
468 prefs::kGoogleServicesHostedDomain, "google.com"); 462 prefs::kGoogleServicesHostedDomain, "google.com");
469 // Lock is only available where a supervised user is present. 463 // Lock is only available where a supervised user is present.
470 ProfileAttributesEntry* entry = testing_profile_manager()-> 464 ProfileAttributesEntry* entry = testing_profile_manager()->
471 profile_attributes_storage()->GetAllProfilesAttributes().front(); 465 profile_attributes_storage()->GetAllProfilesAttributes().front();
472 entry->SetSupervisedUserId(kEmail); 466 entry->SetSupervisedUserId(kEmail);
473 467
474 StartProfileChooserController(); 468 StartProfileChooserController();
475 NSArray* subviews = [[[controller() window] contentView] subviews]; 469 NSArray* subviews = [[[controller() window] contentView] subviews];
476 ASSERT_EQ(2U, [subviews count]); 470 ASSERT_EQ(2U, [subviews count]);
477 subviews = [[subviews objectAtIndex:0] subviews]; 471 subviews = [[subviews objectAtIndex:0] subviews];
478 472
479 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 473 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
480 // There will be two buttons and one separator in the option buttons view. 474 // There will be two buttons and one separator in the option buttons view.
481 ASSERT_EQ(3U, [buttonSubviews count]); 475 ASSERT_EQ(3U, [buttonSubviews count]);
482 476
483 // There should be a lock button. 477 // There should be a lock button.
484 NSButton* lockButton = 478 NSButton* lockButton =
485 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 479 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
486 ASSERT_TRUE(lockButton); 480 ASSERT_TRUE(lockButton);
487 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); 481 EXPECT_EQ(@selector(lockProfile:), [lockButton action]);
488 EXPECT_EQ(controller(), [lockButton target]); 482 EXPECT_EQ(controller(), [lockButton target]);
489 EXPECT_TRUE([lockButton isEnabled]); 483 EXPECT_TRUE([lockButton isEnabled]);
490 } 484 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_disabled.cc ('k') | chrome/browser/ui/startup/startup_browser_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698