Chromium Code Reviews| 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 e253775477040c76e2ead163752693b06422b016..d0df2bd1a58959f83a14b7a7e55b6e17d0e9693c 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm |
| @@ -451,3 +451,69 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { |
| EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
| EXPECT_EQ(controller(), [link target]); |
| } |
| + |
| +TEST_F(ProfileChooserControllerTest, |
| + SignedInProfileLockDisabled) { |
|
Scott Hess - ex-Googler
2014/08/22 20:51:27
Alignment.
msw
2014/08/22 21:46:48
nit: this fits on the line above.
Mike Lerman
2014/08/25 14:44:31
Done and done.
|
| + switches::EnableNewProfileManagementForTesting( |
| + CommandLine::ForCurrentProcess()); |
| + // Sign in the first profile. |
| + ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| + cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| + cache->SetLocalAuthCredentialsOfProfileAtIndex(0, ""); |
|
msw
2014/08/22 21:46:49
nit: use std::string() instead of empty constant.
Mike Lerman
2014/08/25 14:44:31
Done.
|
| + |
| + StartProfileChooserController(); |
| + NSArray* subviews = [[[controller() window] contentView] subviews]; |
| + ASSERT_EQ(1U, [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 |
|
msw
2014/08/22 21:46:48
nit q: Is there a bug filed for this? It seems qui
Mike Lerman
2014/08/25 14:44:31
Hey, chatted with noms. She didn't file a bug for
msw
2014/08/25 17:39:55
Filing a bug would help track that information and
Mike Lerman
2014/08/25 18:11:37
crbug.com/407227
|
| + // 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 an lock button. |
|
msw
2014/08/22 21:46:49
nit: "a lock"
Mike Lerman
2014/08/25 14:44:30
Done.
|
| + NSButton* lockButton = |
| + base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| + EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| + EXPECT_EQ(controller(), [lockButton target]); |
| + EXPECT_FALSE([lockButton isEnabled]); |
|
Scott Hess - ex-Googler
2014/08/22 20:51:27
Suggest an explicit test that lockButton is not ni
Mike Lerman
2014/08/25 14:44:30
Done.
|
| +} |
| + |
| +TEST_F(ProfileChooserControllerTest, |
| + SignedInProfileLockEnabled) { |
|
Scott Hess - ex-Googler
2014/08/22 20:51:27
Alignment
Mike Lerman
2014/08/25 14:44:31
Done.
|
| + switches::EnableNewProfileManagementForTesting( |
| + CommandLine::ForCurrentProcess()); |
| + // Sign in the first profile. |
| + ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| + cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| + cache->SetLocalAuthCredentialsOfProfileAtIndex(0, "YourHashHere"); |
| + |
| + StartProfileChooserController(); |
| + NSArray* subviews = [[[controller() window] contentView] subviews]; |
| + ASSERT_EQ(1U, [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 an lock button. |
|
msw
2014/08/22 21:46:49
ditto nit: "a lock"
Mike Lerman
2014/08/25 14:44:30
Done.
|
| + NSButton* lockButton = |
| + base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| + EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| + EXPECT_EQ(controller(), [lockButton target]); |
| + EXPECT_TRUE([lockButton isEnabled]); |
|
Scott Hess - ex-Googler
2014/08/22 20:51:27
This case is failsafe against nil, but it wouldn't
Mike Lerman
2014/08/25 14:44:31
Done.
|
| +} |