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 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { | 95 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { |
96 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 96 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); |
97 StartProfileChooserController(); | 97 StartProfileChooserController(); |
98 | 98 |
99 NSArray* subviews = [[[controller() window] contentView] subviews]; | 99 NSArray* subviews = [[[controller() window] contentView] subviews]; |
100 ASSERT_EQ(1U, [subviews count]); | 100 ASSERT_EQ(1U, [subviews count]); |
101 subviews = [[subviews objectAtIndex:0] subviews]; | 101 subviews = [[subviews objectAtIndex:0] subviews]; |
102 | 102 |
103 // Three profiles means we should have one active card, one separator and | 103 // Three profiles means we should have one active card, one separator and |
104 // one option buttons view. We also have an update promo for the new avatar | 104 // one option buttons view. |
105 // menu. | 105 ASSERT_EQ(3U, [subviews count]); |
106 ASSERT_EQ(4U, [subviews count]); | |
107 | 106 |
108 // There should be two buttons and a separator in the option buttons view. | 107 // There should be two buttons and a separator in the option buttons view. |
109 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | 108 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
110 ASSERT_EQ(3U, [buttonSubviews count]); | 109 ASSERT_EQ(3U, [buttonSubviews count]); |
111 | 110 |
112 // There should be an incognito button. | 111 // There should be an incognito button. |
113 NSButton* incognitoButton = | 112 NSButton* incognitoButton = |
114 static_cast<NSButton*>([buttonSubviews objectAtIndex:0]); | 113 static_cast<NSButton*>([buttonSubviews objectAtIndex:0]); |
115 EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]); | 114 EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]); |
116 EXPECT_EQ(controller(), [incognitoButton target]); | 115 EXPECT_EQ(controller(), [incognitoButton target]); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 158 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); |
160 EnableFastUserSwitching(); | 159 EnableFastUserSwitching(); |
161 StartProfileChooserController(); | 160 StartProfileChooserController(); |
162 | 161 |
163 NSArray* subviews = [[[controller() window] contentView] subviews]; | 162 NSArray* subviews = [[[controller() window] contentView] subviews]; |
164 ASSERT_EQ(1U, [subviews count]); | 163 ASSERT_EQ(1U, [subviews count]); |
165 subviews = [[subviews objectAtIndex:0] subviews]; | 164 subviews = [[subviews objectAtIndex:0] subviews]; |
166 | 165 |
167 // Three profiles means we should have one active card and a | 166 // Three profiles means we should have one active card and a |
168 // fast user switcher which has two "other" profiles and 2 separators, and | 167 // fast user switcher which has two "other" profiles and 2 separators, and |
169 // an option buttons view with its separator. We also have a promo for | 168 // an option buttons view with its separator. |
170 // the new avatar menu. | 169 ASSERT_EQ(7U, [subviews count]); |
171 ASSERT_EQ(8U, [subviews count]); | |
172 | 170 |
173 // There should be two buttons and a separator in the option buttons view. | 171 // There should be two buttons and a separator in the option buttons view. |
174 // These buttons are tested in InitialLayoutWithNewMenu. | 172 // These buttons are tested in InitialLayoutWithNewMenu. |
175 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | 173 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
176 ASSERT_EQ(3U, [buttonSubviews count]); | 174 ASSERT_EQ(3U, [buttonSubviews count]); |
177 | 175 |
178 // There should be a separator. | 176 // There should be a separator. |
179 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); | 177 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); |
180 | 178 |
181 // There should be two "other profiles" items. The items are drawn from the | 179 // There should be two "other profiles" items. The items are drawn from the |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 StartProfileChooserController(); | 230 StartProfileChooserController(); |
233 | 231 |
234 NSArray* subviews = [[[controller() window] contentView] subviews]; | 232 NSArray* subviews = [[[controller() window] contentView] subviews]; |
235 ASSERT_EQ(1U, [subviews count]); | 233 ASSERT_EQ(1U, [subviews count]); |
236 subviews = [[subviews objectAtIndex:0] subviews]; | 234 subviews = [[subviews objectAtIndex:0] subviews]; |
237 NSString* sortedNames[] = { @"Another Test", | 235 NSString* sortedNames[] = { @"Another Test", |
238 @"New Profile", | 236 @"New Profile", |
239 @"Test 1", | 237 @"Test 1", |
240 @"Test 2" }; | 238 @"Test 2" }; |
241 // There are four "other" profiles, each with a button and a separator, an | 239 // There are four "other" profiles, each with a button and a separator, an |
242 // active profile card, and an option buttons view with a separator. We | 240 // active profile card, and an option buttons view with a separator. |
243 // also have an update promo for the new avatar menu. | 241 ASSERT_EQ(11U, [subviews count]); |
244 ASSERT_EQ(12U, [subviews count]); | |
245 // There should be four "other profiles" items, sorted alphabetically. The | 242 // There should be four "other profiles" items, sorted alphabetically. The |
246 // "other profiles" start at index 2 (after the option buttons view and its | 243 // "other profiles" start at index 2 (after the option buttons view and its |
247 // separator), and each have a separator. We need to iterate through the | 244 // separator), and each have a separator. We need to iterate through the |
248 // profiles in the order displayed in the bubble, which is opposite from the | 245 // profiles in the order displayed in the bubble, which is opposite from the |
249 // drawn order. | 246 // drawn order. |
250 int sortedNameIndex = 0; | 247 int sortedNameIndex = 0; |
251 for (int i = 9; i >= 2; i -= 2) { | 248 for (int i = 9; i >= 2; i -= 2) { |
252 // The item at index i is the separator. | 249 // The item at index i is the separator. |
253 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i-1]); | 250 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i-1]); |
254 EXPECT_TRUE( | 251 EXPECT_TRUE( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( | 426 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( |
430 [static_cast<NSButton*>(activeProfileName) title])); | 427 [static_cast<NSButton*>(activeProfileName) title])); |
431 | 428 |
432 // Profile links. This is a local profile, so there should be a signin button. | 429 // Profile links. This is a local profile, so there should be a signin button. |
433 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; | 430 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; |
434 ASSERT_EQ(1U, [linksSubviews count]); | 431 ASSERT_EQ(1U, [linksSubviews count]); |
435 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]); | 432 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]); |
436 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); | 433 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
437 EXPECT_EQ(controller(), [link target]); | 434 EXPECT_EQ(controller(), [link target]); |
438 } | 435 } |
OLD | NEW |