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

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

Issue 566933005: Do not display lock for hosted domains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests Created 6 years, 3 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #import "base/mac/foundation_util.h" 8 #import "base/mac/foundation_util.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 [base::mac::ObjCCast<NSButton>(activeProfileName) title])); 452 [base::mac::ObjCCast<NSButton>(activeProfileName) title]));
453 453
454 // Profile links. This is a local profile, so there should be a signin button. 454 // Profile links. This is a local profile, so there should be a signin button.
455 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; 455 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews];
456 ASSERT_EQ(1U, [linksSubviews count]); 456 ASSERT_EQ(1U, [linksSubviews count]);
457 NSButton* link = base::mac::ObjCCast<NSButton>( 457 NSButton* link = base::mac::ObjCCast<NSButton>(
458 [linksSubviews objectAtIndex:0]); 458 [linksSubviews objectAtIndex:0]);
459 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); 459 EXPECT_EQ(@selector(hideAccountManagement:), [link action]);
460 EXPECT_EQ(controller(), [link target]); 460 EXPECT_EQ(controller(), [link target]);
461 } 461 }
462
463 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) {
464 switches::EnableNewProfileManagementForTesting(
465 CommandLine::ForCurrentProcess());
466 // Sign in the first profile.
467 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
468 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
469 browser()->profile()->GetPrefs()->SetBoolean(
noms (inactive) 2014/09/15 18:52:40 This test confused me a lot because the kEmail is
Mike Lerman 2014/09/15 19:51:41 Added the former comment, I don't want a reader of
470 prefs::kProfileIsLockable, false);
471
472 StartProfileChooserController();
473 NSArray* subviews = [[[controller() window] contentView] subviews];
474 ASSERT_EQ(2U, [subviews count]);
475 subviews = [[subviews objectAtIndex:0] subviews];
476
477 // Three profiles means we should have one active card, one separator, one
478 // option buttons view and a lock view. We also have an update promo for the
479 // new avatar menu.
480 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not
481 // reproducible anywhere else.
482 ASSERT_GE([subviews count], 4U);
483
484 // There will be three buttons and two separators in the option buttons view.
485 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
486 ASSERT_EQ(5U, [buttonSubviews count]);
487
488 // There should be a lock button.
489 NSButton* lockButton =
490 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
491 ASSERT_TRUE(lockButton);
492 EXPECT_EQ(@selector(lockProfile:), [lockButton action]);
493 EXPECT_EQ(controller(), [lockButton target]);
494 EXPECT_FALSE([lockButton isEnabled]);
495 }
496
497 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) {
498 switches::EnableNewProfileManagementForTesting(
499 CommandLine::ForCurrentProcess());
500 // Sign in the first profile.
501 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
502 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
503 browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsLockable, true);
504
505 StartProfileChooserController();
506 NSArray* subviews = [[[controller() window] contentView] subviews];
507 ASSERT_EQ(2U, [subviews count]);
508 subviews = [[subviews objectAtIndex:0] subviews];
509
510 // Three profiles means we should have one active card, one separator, one
511 // option buttons view and a lock view. We also have an update promo for the
512 // new avatar menu.
513 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not
514 // reproducible anywhere else.
515 ASSERT_GE([subviews count], 4U);
516
517 // There will be three buttons and two separators in the option buttons view.
518 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
519 ASSERT_EQ(5U, [buttonSubviews count]);
520
521 // There should be a lock button.
522 NSButton* lockButton =
523 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
524 ASSERT_TRUE(lockButton);
525 EXPECT_EQ(@selector(lockProfile:), [lockButton action]);
526 EXPECT_EQ(controller(), [lockButton target]);
527 EXPECT_TRUE([lockButton isEnabled]);
528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698