Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm

Issue 2034093003: Added flags for previous code change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More unittest fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // Three profiles means we should have one active card, one separator and 175 // Three profiles means we should have one active card, one separator and
176 // one option buttons view. We also have an update promo for the new avatar 176 // one option buttons view. We also have an update promo for the new avatar
177 // menu. 177 // menu.
178 // TODO(noms): Enforcing 4U fails on the waterfall debug bots, but it's not 178 // TODO(noms): Enforcing 4U fails on the waterfall debug bots, but it's not
179 // reproducible anywhere else. 179 // reproducible anywhere else.
180 ASSERT_GE([subviews count], 3U); 180 ASSERT_GE([subviews count], 3U);
181 181
182 // There should be one button in the option buttons view. 182 // There should be one button in the option buttons view.
183 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 183 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
184 ASSERT_EQ(1U, [buttonSubviews count]); 184 NSButton* userSwitcherButton;
185 if (switches::IsMaterialDesignUserMenu()) {
186 ASSERT_EQ(1U, [buttonSubviews count]);
187 // There should be a user switcher button.
188 userSwitcherButton =
189 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
190 } else {
191 // For non-material-design user menu, there should be two buttons and a
192 // separator in the option buttons view.
193 ASSERT_EQ(3U, [buttonSubviews count]);
185 194
186 // There should be a user switcher button. 195 // There should be an incognito button.
187 NSButton* userSwitcherButton = 196 NSButton* incognitoButton =
188 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 197 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
198 EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]);
199 EXPECT_EQ(controller(), [incognitoButton target]);
200
201 // There should be a separator.
202 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
203
204 // There should be a user switcher button.
205 userSwitcherButton =
206 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:2]);
207 }
208
Roger Tawa OOO till Jul 10th 2016/06/06 13:37:12 This won't test both cases, only the default case.
189 EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]); 209 EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]);
190 EXPECT_EQ(controller(), [userSwitcherButton target]); 210 EXPECT_EQ(controller(), [userSwitcherButton target]);
191 211
192 // There should be a separator. 212 // There should be a separator.
193 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); 213 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
194 214
195 // There should be the profile avatar, name and links container in the active 215 // There should be the profile avatar, name and links container in the active
196 // card view. The links displayed in the container are checked separately. 216 // card view. The links displayed in the container are checked separately.
197 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; 217 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews];
198 ASSERT_EQ(3U, [activeCardSubviews count]); 218 ASSERT_EQ(3U, [activeCardSubviews count]);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 435 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
416 436
417 NSArray* subviews = [[[controller() window] contentView] subviews]; 437 NSArray* subviews = [[[controller() window] contentView] subviews];
418 ASSERT_EQ(2U, [subviews count]); 438 ASSERT_EQ(2U, [subviews count]);
419 subviews = [[subviews objectAtIndex:0] subviews]; 439 subviews = [[subviews objectAtIndex:0] subviews];
420 440
421 // There should be one active card, one accounts container, two separators 441 // There should be one active card, one accounts container, two separators
422 // and one option buttons view. 442 // and one option buttons view.
423 ASSERT_EQ(5U, [subviews count]); 443 ASSERT_EQ(5U, [subviews count]);
424 444
425 // There should be one button in the option buttons view.
426 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 445 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
427 ASSERT_EQ(1U, [buttonSubviews count]); 446 NSButton* userSwitcherButton;
447 if (switches::IsMaterialDesignUserMenu()) {
448 // There should be one button in the option buttons view.
449 ASSERT_EQ(1U, [buttonSubviews count]);
450 // There should be a user switcher button.
451 userSwitcherButton =
452 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
453 } else {
454 // For non-material-design user menu, there should be two buttons and one
455 // separator in the option buttons view.
456 ASSERT_EQ(3U, [buttonSubviews count]);
428 457
429 // There should be a user switcher button. 458 // There should be an incognito button.
430 NSButton* userSwitcherButton = 459 NSButton* incognitoButton =
431 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 460 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
461 EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]);
462 EXPECT_EQ(controller(), [incognitoButton target]);
463
464 // There should be a separator.
465 EXPECT_TRUE([[buttonSubviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
466
467 // There should be a user switcher button.
468 userSwitcherButton =
469 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:2]);
470 }
471
432 EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]); 472 EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]);
433 EXPECT_EQ(controller(), [userSwitcherButton target]); 473 EXPECT_EQ(controller(), [userSwitcherButton target]);
434 474
435 // There should be a separator. 475 // There should be a separator.
436 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); 476 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
437 477
438 // In the accounts view, there should be the account list container 478 // In the accounts view, there should be the account list container
439 // accounts and one "add accounts" button. 479 // accounts and one "add accounts" button.
440 NSArray* accountsSubviews = [[subviews objectAtIndex:2] subviews]; 480 NSArray* accountsSubviews = [[subviews objectAtIndex:2] subviews];
441 ASSERT_EQ(2U, [accountsSubviews count]); 481 ASSERT_EQ(2U, [accountsSubviews count]);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 541
502 // The preference, not the email, determines whether the profile can lock. 542 // The preference, not the email, determines whether the profile can lock.
503 browser()->profile()->GetPrefs()->SetString( 543 browser()->profile()->GetPrefs()->SetString(
504 prefs::kGoogleServicesHostedDomain, "chromium.org"); 544 prefs::kGoogleServicesHostedDomain, "chromium.org");
505 545
506 StartProfileChooserController(); 546 StartProfileChooserController();
507 NSArray* subviews = [[[controller() window] contentView] subviews]; 547 NSArray* subviews = [[[controller() window] contentView] subviews];
508 ASSERT_EQ(2U, [subviews count]); 548 ASSERT_EQ(2U, [subviews count]);
509 subviews = [[subviews objectAtIndex:0] subviews]; 549 subviews = [[subviews objectAtIndex:0] subviews];
510 550
511 // There will be one button in the option buttons view.
512 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 551 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
513 ASSERT_EQ(1U, [buttonSubviews count]); 552 if (switches::IsMaterialDesignUserMenu()) {
553 // There will be one button in the option buttons view.
554 ASSERT_EQ(1U, [buttonSubviews count]);
555 } else {
556 // For non-material-design user menu, there will be two buttons and one
557 // separators in the option buttons view.
558 ASSERT_EQ(3U, [buttonSubviews count]);
559 }
514 560
515 // The last button should not be the lock button. 561 // The last button should not be the lock button.
516 NSButton* lastButton = 562 NSButton* lastButton =
517 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 563 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
518 ASSERT_TRUE(lastButton); 564 ASSERT_TRUE(lastButton);
519 EXPECT_NE(@selector(lockProfile:), [lastButton action]); 565 EXPECT_NE(@selector(lockProfile:), [lastButton action]);
520 } 566 }
521 567
522 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { 568 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) {
523 switches::EnableNewProfileManagementForTesting( 569 switches::EnableNewProfileManagementForTesting(
524 base::CommandLine::ForCurrentProcess()); 570 base::CommandLine::ForCurrentProcess());
525 571
526 SignInFirstProfile(); 572 SignInFirstProfile();
527 573
528 // The preference, not the email, determines whether the profile can lock. 574 // The preference, not the email, determines whether the profile can lock.
529 browser()->profile()->GetPrefs()->SetString( 575 browser()->profile()->GetPrefs()->SetString(
530 prefs::kGoogleServicesHostedDomain, "google.com"); 576 prefs::kGoogleServicesHostedDomain, "google.com");
531 // Lock is only available where a supervised user is present. 577 // Lock is only available where a supervised user is present.
532 ProfileAttributesEntry* entry = testing_profile_manager()-> 578 ProfileAttributesEntry* entry = testing_profile_manager()->
533 profile_attributes_storage()->GetAllProfilesAttributes().front(); 579 profile_attributes_storage()->GetAllProfilesAttributes().front();
534 entry->SetSupervisedUserId(kEmail); 580 entry->SetSupervisedUserId(kEmail);
535 581
536 StartProfileChooserController(); 582 StartProfileChooserController();
537 NSArray* subviews = [[[controller() window] contentView] subviews]; 583 NSArray* subviews = [[[controller() window] contentView] subviews];
538 ASSERT_EQ(2U, [subviews count]); 584 ASSERT_EQ(2U, [subviews count]);
539 subviews = [[subviews objectAtIndex:0] subviews]; 585 subviews = [[subviews objectAtIndex:0] subviews];
540 586
541 // There will be two buttons and one separator in the option buttons view.
542 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 587 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
543 ASSERT_EQ(3U, [buttonSubviews count]); 588 if (switches::IsMaterialDesignUserMenu()) {
589 // There will be two buttons and one separator in the option buttons view.
590 ASSERT_EQ(3U, [buttonSubviews count]);
591 } else {
592 // FOr non-material-design user menu, There will be three buttons and two
593 // separators in the option buttons view.
594 ASSERT_EQ(5U, [buttonSubviews count]);
595 }
544 596
545 // There should be a lock button. 597 // There should be a lock button.
546 NSButton* lockButton = 598 NSButton* lockButton =
547 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 599 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
548 ASSERT_TRUE(lockButton); 600 ASSERT_TRUE(lockButton);
549 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); 601 EXPECT_EQ(@selector(lockProfile:), [lockButton action]);
550 EXPECT_EQ(controller(), [lockButton target]); 602 EXPECT_EQ(controller(), [lockButton target]);
551 EXPECT_TRUE([lockButton isEnabled]); 603 EXPECT_TRUE([lockButton isEnabled]);
552 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698