| 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 <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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 EXPECT_EQ(3U, menu_->GetNumberOfItems()); | 82 EXPECT_EQ(3U, menu_->GetNumberOfItems()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void TearDown() override { | 85 void TearDown() override { |
| 86 [controller() close]; | 86 [controller() close]; |
| 87 controller_.reset(); | 87 controller_.reset(); |
| 88 CocoaProfileTest::TearDown(); | 88 CocoaProfileTest::TearDown(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void StartProfileChooserController() { | 91 void StartProfileChooserController() { |
| 92 StartProfileChooserControllerWithTutorialMode(profiles::TUTORIAL_MODE_NONE); | |
| 93 } | |
| 94 | |
| 95 void StartProfileChooserControllerWithTutorialMode( | |
| 96 profiles::TutorialMode mode) { | |
| 97 NSRect frame = [test_window() frame]; | 92 NSRect frame = [test_window() frame]; |
| 98 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); | 93 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); |
| 99 controller_.reset([[ProfileChooserController alloc] | 94 controller_.reset([[ProfileChooserController alloc] |
| 100 initWithBrowser:browser() | 95 initWithBrowser:browser() |
| 101 anchoredAt:point | 96 anchoredAt:point |
| 102 viewMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER | 97 viewMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER |
| 103 tutorialMode:mode | |
| 104 serviceType:signin::GAIA_SERVICE_TYPE_NONE | 98 serviceType:signin::GAIA_SERVICE_TYPE_NONE |
| 105 accessPoint:signin_metrics::AccessPoint:: | 99 accessPoint:signin_metrics::AccessPoint:: |
| 106 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN]); | 100 ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN]); |
| 107 [controller_ showWindow:nil]; | 101 [controller_ showWindow:nil]; |
| 108 } | 102 } |
| 109 | 103 |
| 110 void SignInFirstProfile() { | 104 void SignInFirstProfile() { |
| 111 std::vector<ProfileAttributesEntry*> entries = testing_profile_manager()-> | 105 std::vector<ProfileAttributesEntry*> entries = testing_profile_manager()-> |
| 112 profile_attributes_storage()->GetAllProfilesAttributes(); | 106 profile_attributes_storage()->GetAllProfilesAttributes(); |
| 113 ASSERT_LE(1U, entries.size()); | 107 ASSERT_LE(1U, entries.size()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 cocoa_l10n_util::ScopedForceRTLMac rtl; | 181 cocoa_l10n_util::ScopedForceRTLMac rtl; |
| 188 StartProfileChooserController(); | 182 StartProfileChooserController(); |
| 189 info_bubble::BubbleAlignment expected_alignment = | 183 info_bubble::BubbleAlignment expected_alignment = |
| 190 cocoa_l10n_util::ShouldFlipWindowControlsInRTL() | 184 cocoa_l10n_util::ShouldFlipWindowControlsInRTL() |
| 191 ? info_bubble::kAlignTrailingEdgeToAnchorEdge | 185 ? info_bubble::kAlignTrailingEdgeToAnchorEdge |
| 192 : info_bubble::kAlignLeadingEdgeToAnchorEdge; | 186 : info_bubble::kAlignLeadingEdgeToAnchorEdge; |
| 193 EXPECT_EQ(expected_alignment, [[controller() bubble] alignment]); | 187 EXPECT_EQ(expected_alignment, [[controller() bubble] alignment]); |
| 194 [controller() close]; | 188 [controller() close]; |
| 195 } | 189 } |
| 196 | 190 |
| 197 TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterWelcome) { | |
| 198 // The welcome upgrade tutorial takes precedence so show it then dismiss it. | |
| 199 // The right click tutorial should be shown right away. | |
| 200 StartProfileChooserControllerWithTutorialMode( | |
| 201 profiles::TUTORIAL_MODE_WELCOME_UPGRADE); | |
| 202 | |
| 203 [controller() dismissTutorial:nil]; | |
| 204 } | |
| 205 | |
| 206 TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterReopen) { | |
| 207 // The welcome upgrade tutorial takes precedence so show it then close the | |
| 208 // menu. Reopening the menu should show the tutorial. | |
| 209 StartProfileChooserController(); | |
| 210 | |
| 211 [controller() close]; | |
| 212 StartProfileChooserController(); | |
| 213 | |
| 214 // The tutorial must be manually dismissed so it should still be shown after | |
| 215 // closing and reopening the menu, | |
| 216 [controller() close]; | |
| 217 StartProfileChooserController(); | |
| 218 } | |
| 219 | |
| 220 TEST_F(ProfileChooserControllerTest, | 191 TEST_F(ProfileChooserControllerTest, |
| 221 LocalProfileActiveCardLinksWithNewMenu) { | 192 LocalProfileActiveCardLinksWithNewMenu) { |
| 222 StartProfileChooserController(); | 193 StartProfileChooserController(); |
| 223 NSArray* subviews = [[[controller() window] contentView] subviews]; | 194 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 224 ASSERT_EQ(2U, [subviews count]); | 195 ASSERT_EQ(2U, [subviews count]); |
| 225 subviews = [[subviews objectAtIndex:0] subviews]; | 196 subviews = [[subviews objectAtIndex:0] subviews]; |
| 226 // The active card is the last subview and the MD User Menu has 2 extra | 197 // The active card is the last subview and the MD User Menu has 2 extra |
| 227 // buttons. | 198 // buttons. |
| 228 NSUInteger lastSubviewIndex = 4; | 199 NSUInteger lastSubviewIndex = 4; |
| 229 NSArray* activeCardSubviews = | 200 NSArray* activeCardSubviews = |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 ASSERT_EQ(3U, [buttonSubviews count]); | 401 ASSERT_EQ(3U, [buttonSubviews count]); |
| 431 | 402 |
| 432 // There should be a lock button. | 403 // There should be a lock button. |
| 433 NSButton* lockButton = | 404 NSButton* lockButton = |
| 434 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 405 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 435 ASSERT_TRUE(lockButton); | 406 ASSERT_TRUE(lockButton); |
| 436 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 407 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| 437 EXPECT_EQ(controller(), [lockButton target]); | 408 EXPECT_EQ(controller(), [lockButton target]); |
| 438 EXPECT_TRUE([lockButton isEnabled]); | 409 EXPECT_TRUE([lockButton isEnabled]); |
| 439 } | 410 } |
| OLD | NEW |