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) { | |
Scott Hess - ex-Googler
2014/08/22 20:51:27
Alignment.
msw
2014/08/22 21:46:48
nit: this fits on the line above.
Mike Lerman
2014/08/25 14:44:31
Done and done.
| |
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, ""); | |
msw
2014/08/22 21:46:49
nit: use std::string() instead of empty constant.
Mike Lerman
2014/08/25 14:44:31
Done.
| |
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 | |
msw
2014/08/22 21:46:48
nit q: Is there a bug filed for this? It seems qui
Mike Lerman
2014/08/25 14:44:31
Hey, chatted with noms. She didn't file a bug for
msw
2014/08/25 17:39:55
Filing a bug would help track that information and
Mike Lerman
2014/08/25 18:11:37
crbug.com/407227
| |
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. | |
msw
2014/08/22 21:46:49
nit: "a lock"
Mike Lerman
2014/08/25 14:44:30
Done.
| |
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]); | |
Scott Hess - ex-Googler
2014/08/22 20:51:27
Suggest an explicit test that lockButton is not ni
Mike Lerman
2014/08/25 14:44:30
Done.
| |
486 } | |
487 | |
488 TEST_F(ProfileChooserControllerTest, | |
489 SignedInProfileLockEnabled) { | |
Scott Hess - ex-Googler
2014/08/22 20:51:27
Alignment
Mike Lerman
2014/08/25 14:44:31
Done.
| |
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. | |
msw
2014/08/22 21:46:49
ditto nit: "a lock"
Mike Lerman
2014/08/25 14:44:30
Done.
| |
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]); | |
Scott Hess - ex-Googler
2014/08/22 20:51:27
This case is failsafe against nil, but it wouldn't
Mike Lerman
2014/08/25 14:44:31
Done.
| |
519 } | |
OLD | NEW |