OLD | NEW |
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 Loading... |
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 cache->SetLocalAuthCredentialsOfProfileAtIndex(0, std::string()); | |
470 | |
471 StartProfileChooserController(); | |
472 NSArray* subviews = [[[controller() window] contentView] subviews]; | |
473 ASSERT_EQ(2U, [subviews count]); | |
474 subviews = [[subviews objectAtIndex:0] subviews]; | |
475 | |
476 // Three profiles means we should have one active card, one separator, one | |
477 // option buttons view and a lock view. We also have an update promo for the | |
478 // new avatar menu. | |
479 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not | |
480 // reproducible anywhere else. | |
481 ASSERT_GE([subviews count], 4U); | |
482 | |
483 // There will be three buttons and two separators in the option buttons view. | |
484 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | |
485 ASSERT_EQ(5U, [buttonSubviews count]); | |
486 | |
487 // There should be a lock button. | |
488 NSButton* lockButton = | |
489 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | |
490 ASSERT_TRUE(lockButton); | |
491 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | |
492 EXPECT_EQ(controller(), [lockButton target]); | |
493 EXPECT_FALSE([lockButton isEnabled]); | |
494 } | |
495 | |
496 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { | |
497 switches::EnableNewProfileManagementForTesting( | |
498 CommandLine::ForCurrentProcess()); | |
499 // Sign in the first profile. | |
500 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | |
501 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | |
502 cache->SetLocalAuthCredentialsOfProfileAtIndex(0, "YourHashHere"); | |
503 | |
504 StartProfileChooserController(); | |
505 NSArray* subviews = [[[controller() window] contentView] subviews]; | |
506 ASSERT_EQ(2U, [subviews count]); | |
507 subviews = [[subviews objectAtIndex:0] subviews]; | |
508 | |
509 // Three profiles means we should have one active card, one separator, one | |
510 // option buttons view and a lock view. We also have an update promo for the | |
511 // new avatar menu. | |
512 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not | |
513 // reproducible anywhere else. | |
514 ASSERT_GE([subviews count], 4U); | |
515 | |
516 // There will be three buttons and two separators in the option buttons view. | |
517 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | |
518 ASSERT_EQ(5U, [buttonSubviews count]); | |
519 | |
520 // There should be a lock button. | |
521 NSButton* lockButton = | |
522 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | |
523 ASSERT_TRUE(lockButton); | |
524 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | |
525 EXPECT_EQ(controller(), [lockButton target]); | |
526 EXPECT_TRUE([lockButton isEnabled]); | |
527 } | |
OLD | NEW |