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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 [controller() close]; | 211 [controller() close]; |
212 StartProfileChooserController(); | 212 StartProfileChooserController(); |
213 | 213 |
214 // The tutorial must be manually dismissed so it should still be shown after | 214 // The tutorial must be manually dismissed so it should still be shown after |
215 // closing and reopening the menu, | 215 // closing and reopening the menu, |
216 [controller() close]; | 216 [controller() close]; |
217 StartProfileChooserController(); | 217 StartProfileChooserController(); |
218 } | 218 } |
219 | 219 |
220 TEST_F(ProfileChooserControllerTest, RightClickTutorialNotShownAfterDismiss) { | |
221 // The welcome upgrade tutorial takes precedence so show it then close the | |
222 // menu. Reopening the menu should show the tutorial. | |
223 StartProfileChooserController(); | |
224 | |
225 [controller() close]; | |
226 StartProfileChooserControllerWithTutorialMode( | |
227 profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING); | |
228 | |
229 // Dismissing the tutorial should prevent it from being shown forever. | |
230 [controller() dismissTutorial:nil]; | |
231 NSArray* subviews = [[[controller() window] contentView] subviews]; | |
232 ASSERT_EQ(2U, [subviews count]); | |
233 subviews = [[subviews objectAtIndex:0] subviews]; | |
234 | |
235 // There should be 3 views since there's no tutorial. There are 2 extra | |
236 // buttons in the MD user menu. | |
237 NSUInteger viewsCount = 5; | |
238 ASSERT_EQ(viewsCount, [subviews count]); | |
239 | |
240 // Closing and reopening the menu shouldn't show the tutorial. | |
241 [controller() close]; | |
242 StartProfileChooserControllerWithTutorialMode( | |
243 profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING); | |
244 subviews = [[[controller() window] contentView] subviews]; | |
245 ASSERT_EQ(2U, [subviews count]); | |
246 subviews = [[subviews objectAtIndex:0] subviews]; | |
247 | |
248 ASSERT_EQ(viewsCount, [subviews count]); | |
249 } | |
250 | |
251 TEST_F(ProfileChooserControllerTest, | 220 TEST_F(ProfileChooserControllerTest, |
252 LocalProfileActiveCardLinksWithNewMenu) { | 221 LocalProfileActiveCardLinksWithNewMenu) { |
253 StartProfileChooserController(); | 222 StartProfileChooserController(); |
254 NSArray* subviews = [[[controller() window] contentView] subviews]; | 223 NSArray* subviews = [[[controller() window] contentView] subviews]; |
255 ASSERT_EQ(2U, [subviews count]); | 224 ASSERT_EQ(2U, [subviews count]); |
256 subviews = [[subviews objectAtIndex:0] subviews]; | 225 subviews = [[subviews objectAtIndex:0] subviews]; |
257 // The active card is the last subview and the MD User Menu has 2 extra | 226 // The active card is the last subview and the MD User Menu has 2 extra |
258 // buttons. | 227 // buttons. |
259 NSUInteger lastSubviewIndex = 4; | 228 NSUInteger lastSubviewIndex = 4; |
260 NSArray* activeCardSubviews = | 229 NSArray* activeCardSubviews = |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 ASSERT_EQ(3U, [buttonSubviews count]); | 436 ASSERT_EQ(3U, [buttonSubviews count]); |
468 | 437 |
469 // There should be a lock button. | 438 // There should be a lock button. |
470 NSButton* lockButton = | 439 NSButton* lockButton = |
471 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 440 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
472 ASSERT_TRUE(lockButton); | 441 ASSERT_TRUE(lockButton); |
473 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 442 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
474 EXPECT_EQ(controller(), [lockButton target]); | 443 EXPECT_EQ(controller(), [lockButton target]); |
475 EXPECT_TRUE([lockButton isEnabled]); | 444 EXPECT_TRUE([lockButton isEnabled]); |
476 } | 445 } |
OLD | NEW |