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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 [base::mac::ObjCCast<NSButton>(activeProfileName) title])); | 444 [base::mac::ObjCCast<NSButton>(activeProfileName) title])); |
445 | 445 |
446 // Profile links. This is a local profile, so there should be a signin button. | 446 // Profile links. This is a local profile, so there should be a signin button. |
447 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; | 447 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; |
448 ASSERT_EQ(1U, [linksSubviews count]); | 448 ASSERT_EQ(1U, [linksSubviews count]); |
449 NSButton* link = base::mac::ObjCCast<NSButton>( | 449 NSButton* link = base::mac::ObjCCast<NSButton>( |
450 [linksSubviews objectAtIndex:0]); | 450 [linksSubviews objectAtIndex:0]); |
451 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); | 451 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
452 EXPECT_EQ(controller(), [link target]); | 452 EXPECT_EQ(controller(), [link target]); |
453 } | 453 } |
| 454 |
| 455 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { |
| 456 switches::EnableNewProfileManagementForTesting( |
| 457 CommandLine::ForCurrentProcess()); |
| 458 // Sign in the first profile. |
| 459 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 460 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 461 cache->SetLocalAuthCredentialsOfProfileAtIndex(0, std::string()); |
| 462 |
| 463 StartProfileChooserController(); |
| 464 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 465 ASSERT_EQ(1U, [subviews count]); |
| 466 subviews = [[subviews objectAtIndex:0] subviews]; |
| 467 |
| 468 // Three profiles means we should have one active card, one separator, one |
| 469 // option buttons view and a lock view. We also have an update promo for the |
| 470 // new avatar menu. |
| 471 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not |
| 472 // reproducible anywhere else. |
| 473 ASSERT_GE([subviews count], 4U); |
| 474 |
| 475 // There will be three buttons and two separators in the option buttons view. |
| 476 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
| 477 ASSERT_EQ(5U, [buttonSubviews count]); |
| 478 |
| 479 // There should be a lock button. |
| 480 NSButton* lockButton = |
| 481 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 482 ASSERT_TRUE(lockButton); |
| 483 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| 484 EXPECT_EQ(controller(), [lockButton target]); |
| 485 EXPECT_FALSE([lockButton isEnabled]); |
| 486 } |
| 487 |
| 488 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { |
| 489 switches::EnableNewProfileManagementForTesting( |
| 490 CommandLine::ForCurrentProcess()); |
| 491 // Sign in the first profile. |
| 492 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 493 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 494 cache->SetLocalAuthCredentialsOfProfileAtIndex(0, "YourHashHere"); |
| 495 |
| 496 StartProfileChooserController(); |
| 497 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 498 ASSERT_EQ(1U, [subviews count]); |
| 499 subviews = [[subviews objectAtIndex:0] subviews]; |
| 500 |
| 501 // Three profiles means we should have one active card, one separator, one |
| 502 // option buttons view and a lock view. We also have an update promo for the |
| 503 // new avatar menu. |
| 504 // TODO(noms): Enforcing 5U fails on the waterfall debug bots, but it's not |
| 505 // reproducible anywhere else. |
| 506 ASSERT_GE([subviews count], 4U); |
| 507 |
| 508 // There will be three buttons and two separators in the option buttons view. |
| 509 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
| 510 ASSERT_EQ(5U, [buttonSubviews count]); |
| 511 |
| 512 // There should be a lock button. |
| 513 NSButton* lockButton = |
| 514 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 515 ASSERT_TRUE(lockButton); |
| 516 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| 517 EXPECT_EQ(controller(), [lockButton target]); |
| 518 EXPECT_TRUE([lockButton isEnabled]); |
| 519 } |
OLD | NEW |