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

Unified Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm

Issue 497783002: Disable lock if no credentials are present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return [false] if profile_index = ::npos Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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..4137d7740c6192a682029b4cfd8f9a5539209433 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) {
+ 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, std::string());
+
+ 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 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));
+ 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 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]);
+}

Powered by Google App Engine
This is Rietveld 408576698