Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
index 6751783ca658398053b08936ae5ec590a8e63ace..c39e15dc184fb0da1d11586134b11d9af7e43936 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
@@ -23,6 +23,7 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/pref_names.h" |
#include "components/signin/core/browser/profile_oauth2_token_service.h" |
#include "components/signin/core/browser/signin_manager.h" |
#include "components/signin/core/common/profile_management_switches.h" |
@@ -459,3 +460,72 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { |
EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
EXPECT_EQ(controller(), [link target]); |
} |
+ |
+TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { |
+ switches::EnableNewProfileManagementForTesting( |
+ CommandLine::ForCurrentProcess()); |
+ // Sign in the first profile. |
+ ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
+ cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
+ // The preference, not the email, determines whether the profile can lock. |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kProfileIsLockable, false); |
+ |
+ StartProfileChooserController(); |
+ NSArray* subviews = [[[controller() window] contentView] subviews]; |
+ ASSERT_EQ(2U, [subviews count]); |
+ subviews = [[subviews objectAtIndex:0] subviews]; |
+ |
+ // Three profiles means we should have one active card, one separator, one |
+ // option buttons view and a lock view. We also have an update promo for the |
+ // new avatar menu. |
+ // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not |
+ // reproducible anywhere else. |
+ ASSERT_GE([subviews count], 4U); |
+ |
+ // There will be three buttons and two separators in the option buttons view. |
+ NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
+ ASSERT_EQ(5U, [buttonSubviews count]); |
+ |
+ // There should be a lock button. |
+ NSButton* lockButton = |
+ base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
+ ASSERT_TRUE(lockButton); |
+ EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
+ EXPECT_EQ(controller(), [lockButton target]); |
+ EXPECT_FALSE([lockButton isEnabled]); |
+} |
+ |
+TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { |
+ switches::EnableNewProfileManagementForTesting( |
+ CommandLine::ForCurrentProcess()); |
+ // Sign in the first profile. |
+ ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
+ cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
+ // The preference, not the email, determines whether the profile can lock. |
+ browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsLockable, true); |
+ |
+ StartProfileChooserController(); |
+ NSArray* subviews = [[[controller() window] contentView] subviews]; |
+ ASSERT_EQ(2U, [subviews count]); |
+ subviews = [[subviews objectAtIndex:0] subviews]; |
+ |
+ // Three profiles means we should have one active card, one separator, one |
+ // option buttons view and a lock view. We also have an update promo for the |
+ // new avatar menu. |
+ // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not |
+ // reproducible anywhere else. |
+ ASSERT_GE([subviews count], 4U); |
+ |
+ // There will be three buttons and two separators in the option buttons view. |
+ NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
+ ASSERT_EQ(5U, [buttonSubviews count]); |
+ |
+ // There should be a lock button. |
+ NSButton* lockButton = |
+ base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
+ ASSERT_TRUE(lockButton); |
+ EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
+ EXPECT_EQ(controller(), [lockButton target]); |
+ EXPECT_TRUE([lockButton isEnabled]); |
+} |