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