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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { | 493 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { |
494 switches::EnableNewProfileManagementForTesting( | 494 switches::EnableNewProfileManagementForTesting( |
495 CommandLine::ForCurrentProcess()); | 495 CommandLine::ForCurrentProcess()); |
496 // Sign in the first profile. | 496 // Sign in the first profile. |
497 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 497 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
498 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 498 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
499 // The preference, not the email, determines whether the profile can lock. | 499 // The preference, not the email, determines whether the profile can lock. |
500 browser()->profile()->GetPrefs()->SetString( | 500 browser()->profile()->GetPrefs()->SetString( |
501 prefs::kGoogleServicesHostedDomain, "google.com"); | 501 prefs::kGoogleServicesHostedDomain, "google.com"); |
| 502 // Lock is only available where a supervised user is present. |
| 503 cache->SetSupervisedUserIdOfProfileAtIndex(1, kEmail); |
502 | 504 |
503 StartProfileChooserController(); | 505 StartProfileChooserController(); |
504 NSArray* subviews = [[[controller() window] contentView] subviews]; | 506 NSArray* subviews = [[[controller() window] contentView] subviews]; |
505 ASSERT_EQ(2U, [subviews count]); | 507 ASSERT_EQ(2U, [subviews count]); |
506 subviews = [[subviews objectAtIndex:0] subviews]; | 508 subviews = [[subviews objectAtIndex:0] subviews]; |
507 | 509 |
508 // There will be three buttons and two separators in the option buttons view. | 510 // There will be three buttons and two separators in the option buttons view. |
509 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | 511 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
510 ASSERT_EQ(5U, [buttonSubviews count]); | 512 ASSERT_EQ(5U, [buttonSubviews count]); |
511 | 513 |
512 // There should be a lock button. | 514 // There should be a lock button. |
513 NSButton* lockButton = | 515 NSButton* lockButton = |
514 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 516 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
515 ASSERT_TRUE(lockButton); | 517 ASSERT_TRUE(lockButton); |
516 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 518 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
517 EXPECT_EQ(controller(), [lockButton target]); | 519 EXPECT_EQ(controller(), [lockButton target]); |
518 EXPECT_TRUE([lockButton isEnabled]); | 520 EXPECT_TRUE([lockButton isEnabled]); |
519 } | 521 } |
OLD | NEW |