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

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

Issue 235833002: [Mac] Redesign the avatar bubble UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: preemptive nits Created 6 years, 8 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 | Annotate | Revision Log
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 "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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void StartProfileChooserController() { 65 void StartProfileChooserController() {
66 NSRect frame = [test_window() frame]; 66 NSRect frame = [test_window() frame];
67 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); 67 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
68 controller_.reset([[ProfileChooserController alloc] 68 controller_.reset([[ProfileChooserController alloc]
69 initWithBrowser:browser() 69 initWithBrowser:browser()
70 anchoredAt:point 70 anchoredAt:point
71 withMode:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]); 71 withMode:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]);
72 [controller_ showWindow:nil]; 72 [controller_ showWindow:nil];
73 } 73 }
74 74
75 void EnableNewProfileManagement() {
76 CommandLine::ForCurrentProcess()->AppendSwitch(
77 switches::kNewProfileManagement);
78 }
79
80 void EnableNewAvatarMenuOnly() {
81 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNewAvatarMenu);
82 }
83
84 void EnableFastUserSwitching() {
85 CommandLine::ForCurrentProcess()->AppendSwitch(
86 switches::kFastUserSwitching);
87 }
88
75 ProfileChooserController* controller() { return controller_; } 89 ProfileChooserController* controller() { return controller_; }
76 AvatarMenu* menu() { return menu_; } 90 AvatarMenu* menu() { return menu_; }
77 91
78 private: 92 private:
79 base::scoped_nsobject<ProfileChooserController> controller_; 93 base::scoped_nsobject<ProfileChooserController> controller_;
80 94
81 // Weak; owned by |controller_|. 95 // Weak; owned by |controller_|.
82 AvatarMenu* menu_; 96 AvatarMenu* menu_;
83 97
84 DISALLOW_COPY_AND_ASSIGN(ProfileChooserControllerTest); 98 DISALLOW_COPY_AND_ASSIGN(ProfileChooserControllerTest);
85 }; 99 };
86 100
87 TEST_F(ProfileChooserControllerTest, InitialLayout) { 101 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewManagement) {
102 EnableNewProfileManagement();
88 StartProfileChooserController(); 103 StartProfileChooserController();
104
89 NSArray* subviews = [[[controller() window] contentView] subviews]; 105 NSArray* subviews = [[[controller() window] contentView] subviews];
90 106
91 // Three profiles means we should have one active card, one separator and 107 // Three profiles means we should have one active card, one separator and
92 // one option buttons view. 108 // one option buttons view.
93 EXPECT_EQ(3U, [subviews count]); 109 EXPECT_EQ(3U, [subviews count]);
94 110
95 // For a local profile, there should be one button in the option buttons view. 111 // For a local profile, there should be one button in the option buttons view.
96 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 112 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
97 EXPECT_EQ(1U, [buttonSubviews count]); 113 EXPECT_EQ(1U, [buttonSubviews count]);
98 NSButton* button = static_cast<NSButton*>([buttonSubviews objectAtIndex:0]); 114 NSButton* button = static_cast<NSButton*>([buttonSubviews objectAtIndex:0]);
99 EXPECT_EQ(@selector(showUserManager:), [button action]); 115 EXPECT_EQ(@selector(showUserManager:), [button action]);
100 EXPECT_EQ(controller(), [button target]); 116 EXPECT_EQ(controller(), [button target]);
101 117
102 // There should be a separator. 118 // There should be a separator.
103 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); 119 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
104 120
105 // There should be the profile avatar, name and links container in the active 121 // There should be the profile avatar, name and links container in the active
106 // card view. The links displayed in the container are checked separately. 122 // card view. The links displayed in the container are checked separately.
107 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; 123 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews];
108 EXPECT_EQ(3U, [activeCardSubviews count]); 124 EXPECT_EQ(3U, [activeCardSubviews count]);
109 125
110 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:0]; 126 // Profile icon.
127 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:2];
111 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]); 128 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]);
112 129
113 // There are some links in between. The profile name is added last. 130 // Profile name.
114 CGFloat index = [activeCardSubviews count] - 1; 131 NSView* activeProfileName = [activeCardSubviews objectAtIndex:1];
115 NSView* activeProfileName = [activeCardSubviews objectAtIndex:index];
116 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]); 132 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]);
117 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( 133 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16(
118 [static_cast<NSButton*>(activeProfileName) title])); 134 [static_cast<NSButton*>(activeProfileName) title]));
135
136 // Profile links. This is a local profile, so there should be a signin button.
137 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews];
138 EXPECT_EQ(1U, [linksSubviews count]);
139 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]);
140 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]);
141 EXPECT_EQ(controller(), [link target]);
142 }
143
144 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
145 EnableNewAvatarMenuOnly();
146 StartProfileChooserController();
147
148 NSArray* subviews = [[[controller() window] contentView] subviews];
149
150 // Three profiles means we should have one active card and a
151 // fast user switcher which has two "other" profiles and 2 separators.
152 EXPECT_EQ(5U, [subviews count]);
153
154 // There should be two "other profiles" items. The items are drawn from the
155 // bottom up, so in the opposite order of those in the AvatarMenu.
156 int profileIndex = 1;
157 for (int i = 3; i >= 0; i -= 2) {
158 // Each profile button has a separator.
159 EXPECT_TRUE([[subviews objectAtIndex:i] isKindOfClass:[NSBox class]]);
160
161 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i-1]);
162 EXPECT_EQ(menu()->GetItemAt(profileIndex).name,
163 base::SysNSStringToUTF16([button title]));
164 EXPECT_EQ(profileIndex, [button tag]);
165 EXPECT_EQ(@selector(switchToProfile:), [button action]);
166 EXPECT_EQ(controller(), [button target]);
167 profileIndex++;
168 }
169
170 // There should be the profile avatar, name and links container in the active
171 // card view. The links displayed in the container are checked separately.
172 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews];
173 EXPECT_EQ(3U, [activeCardSubviews count]);
174
175 // Profile icon.
176 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:2];
177 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]);
178
179 // Profile name.
180 NSView* activeProfileName = [activeCardSubviews objectAtIndex:1];
181 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]);
182 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16(
183 [static_cast<NSButton*>(activeProfileName) title]));
184
185 // Profile links. This is a local profile, so there should be a signin button.
186 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews];
187 EXPECT_EQ(1U, [linksSubviews count]);
188 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]);
189 EXPECT_EQ(@selector(showTabbedSigninPage:), [link action]);
190 EXPECT_EQ(controller(), [link target]);
119 } 191 }
120 192
121 TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { 193 TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) {
122 // The fast user switcher is only availbale behind a flag. 194 EnableNewProfileManagement();
123 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kFastUserSwitching); 195 EnableFastUserSwitching();
196 StartProfileChooserController();
124 197
125 StartProfileChooserController();
126 NSArray* subviews = [[[controller() window] contentView] subviews]; 198 NSArray* subviews = [[[controller() window] contentView] subviews];
127 199
128 // Three profiles means we should have one active card, two "other" profiles, 200 // Three profiles means we should have one active card, two "other" profiles,
129 // one separator and one option buttons view. 201 // each with a separator, and one option buttons view.
130 EXPECT_EQ(5U, [subviews count]); 202 EXPECT_EQ(7U, [subviews count]);
131 203
132 // For a local profile, there should be one button in the option buttons view. 204 // For a local profile, there should be one button in the option buttons view.
133 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; 205 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
134 EXPECT_EQ(1U, [buttonSubviews count]); 206 EXPECT_EQ(1U, [buttonSubviews count]);
135 NSButton* button = static_cast<NSButton*>([buttonSubviews objectAtIndex:0]); 207 NSButton* button = static_cast<NSButton*>([buttonSubviews objectAtIndex:0]);
136 EXPECT_EQ(@selector(showUserManager:), [button action]); 208 EXPECT_EQ(@selector(showUserManager:), [button action]);
137 EXPECT_EQ(controller(), [button target]); 209 EXPECT_EQ(controller(), [button target]);
138 210
139 // There should be a separator. 211 // There should be a separator.
140 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]); 212 EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
141 213
142 // There should be two "other profiles" items. The items are drawn from the 214 // There should be two "other profiles" items. The items are drawn from the
143 // bottom up, so in the opposite order of those in the AvatarMenu. 215 // bottom up, so in the opposite order of those in the AvatarMenu.
144 int profileIndex = 1; 216 int profileIndex = 1;
145 for (NSUInteger i = 3; i >= 2; --i) { 217 for (int i = 5; i >= 2; i -= 2) {
146 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i]); 218 // Each profile button has a separator.
219 EXPECT_TRUE([[subviews objectAtIndex:i] isKindOfClass:[NSBox class]]);
220
221 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i-1]);
147 EXPECT_EQ(menu()->GetItemAt(profileIndex).name, 222 EXPECT_EQ(menu()->GetItemAt(profileIndex).name,
148 base::SysNSStringToUTF16([button title])); 223 base::SysNSStringToUTF16([button title]));
149 EXPECT_EQ(profileIndex, [button tag]); 224 EXPECT_EQ(profileIndex, [button tag]);
150 EXPECT_EQ(@selector(switchToProfile:), [button action]); 225 EXPECT_EQ(@selector(switchToProfile:), [button action]);
151 EXPECT_EQ(controller(), [button target]); 226 EXPECT_EQ(controller(), [button target]);
152 profileIndex++; 227 profileIndex++;
153 } 228 }
154 229
155 // There should be the profile avatar, name and links container in the active 230 // There should be the profile avatar, name and links container in the active
156 // card view. The links displayed in the container are checked separately. 231 // card view. These have been checked separately.
157 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews]; 232 NSArray* activeCardSubviews = [[subviews objectAtIndex:6] subviews];
158 EXPECT_EQ(3U, [activeCardSubviews count]); 233 EXPECT_EQ(3U, [activeCardSubviews count]);
159
160 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:0];
161 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]);
162
163 // There are some links in between. The profile name is added last.
164 CGFloat index = [activeCardSubviews count] - 1;
165 NSView* activeProfileName = [activeCardSubviews objectAtIndex:index];
166 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]);
167 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16(
168 [static_cast<NSButton*>(activeProfileName) title]));
169 } 234 }
170 235
171 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { 236 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
172 // The fast user switcher is only availbale behind a flag. 237 EnableNewAvatarMenuOnly();
173 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kFastUserSwitching);
174 238
175 // Add two extra profiles, to make sure sorting is alphabetical and not 239 // Add two extra profiles, to make sure sorting is alphabetical and not
176 // by order of creation. 240 // by order of creation.
177 testing_profile_manager()-> 241 testing_profile_manager()->
178 CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), 242 CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(),
179 base::ASCIIToUTF16("New Profile"), 1, std::string(), 243 base::ASCIIToUTF16("New Profile"), 1, std::string(),
180 TestingProfile::TestingFactories()); 244 TestingProfile::TestingFactories());
181 testing_profile_manager()-> 245 testing_profile_manager()->
182 CreateTestingProfile("test4", scoped_ptr<PrefServiceSyncable>(), 246 CreateTestingProfile("test4", scoped_ptr<PrefServiceSyncable>(),
183 base::ASCIIToUTF16("Another Test"), 1, std::string(), 247 base::ASCIIToUTF16("Another Test"), 1, std::string(),
184 TestingProfile::TestingFactories()); 248 TestingProfile::TestingFactories());
185 StartProfileChooserController(); 249 StartProfileChooserController();
186 250
187 NSArray* subviews = [[[controller() window] contentView] subviews]; 251 NSArray* subviews = [[[controller() window] contentView] subviews];
188 NSString* sortedNames[] = { @"Another Test", 252 NSString* sortedNames[] = { @"Another Test",
189 @"New Profile", 253 @"New Profile",
190 @"Test 1", 254 @"Test 1",
191 @"Test 2" }; 255 @"Test 2" };
192 // There should be three "other profiles" items, sorted alphabetically. 256 EXPECT_EQ(9U, [subviews count]);
193 // The "other profiles" start at index 2, after the option buttons and 257 // There should be four "other profiles" items, sorted alphabetically.
194 // a separator. We need to iterate through the profiles in the order 258 // The "other profiles" start at index 0, and each have a separator. We
195 // displayed in the bubble, which is opposite from the drawn order. 259 // need to iterate through the profiles in the order displayed in the bubble,
260 // which is opposite from the drawn order.
196 int sortedNameIndex = 0; 261 int sortedNameIndex = 0;
197 for (NSUInteger i = 5; i >= 2; --i) { 262 for (int i = 7; i >= 0; i -= 2) {
198 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i]); 263 // The item at index i is the separator.
264 NSButton* button = static_cast<NSButton*>([subviews objectAtIndex:i-1]);
199 EXPECT_TRUE( 265 EXPECT_TRUE(
200 [[button title] isEqualToString:sortedNames[sortedNameIndex++]]); 266 [[button title] isEqualToString:sortedNames[sortedNameIndex++]]);
201 } 267 }
202 } 268 }
203 269
204 TEST_F(ProfileChooserControllerTest, LocalProfileActiveCardLinks) { 270 TEST_F(ProfileChooserControllerTest,
271 LocalProfileActiveCardLinksWithNewManagement) {
272 EnableNewProfileManagement();
205 StartProfileChooserController(); 273 StartProfileChooserController();
206 NSArray* subviews = [[[controller() window] contentView] subviews]; 274 NSArray* subviews = [[[controller() window] contentView] subviews];
207 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; 275 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews];
208 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:1] subviews]; 276 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews];
209 277
210 // There should be one "sign in" link. 278 // There should be one "sign in" link.
211 EXPECT_EQ(1U, [activeCardLinks count]); 279 EXPECT_EQ(1U, [activeCardLinks count]);
212 NSButton* signinLink = 280 NSButton* signinLink =
213 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]); 281 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]);
214 EXPECT_EQ(@selector(showSigninPage:), [signinLink action]); 282 EXPECT_EQ(@selector(showInlineSigninPage:), [signinLink action]);
215 EXPECT_EQ(controller(), [signinLink target]); 283 EXPECT_EQ(controller(), [signinLink target]);
216 } 284 }
217 285
218 TEST_F(ProfileChooserControllerTest, SignedInProfileActiveCardLinks) { 286 TEST_F(ProfileChooserControllerTest,
287 LocalProfileActiveCardLinksWithNewMenu) {
288 EnableNewAvatarMenuOnly();
289 StartProfileChooserController();
290 NSArray* subviews = [[[controller() window] contentView] subviews];
291 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews];
292 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews];
293
294 // There should be one "sign in" link.
295 EXPECT_EQ(1U, [activeCardLinks count]);
296 NSButton* signinLink =
297 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]);
298 EXPECT_EQ(@selector(showTabbedSigninPage:), [signinLink action]);
299 EXPECT_EQ(controller(), [signinLink target]);
300 }
301
302 TEST_F(ProfileChooserControllerTest,
303 SignedInProfileActiveCardLinksWithNewManagement) {
304 EnableNewProfileManagement();
219 // Sign in the first profile. 305 // Sign in the first profile.
220 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); 306 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
221 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); 307 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
222 308
223 StartProfileChooserController(); 309 StartProfileChooserController();
224 NSArray* subviews = [[[controller() window] contentView] subviews]; 310 NSArray* subviews = [[[controller() window] contentView] subviews];
225 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; 311 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews];
226 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:1] subviews]; 312 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews];
227 313
228 // There is one link: manage accounts. 314 // There is one link: manage accounts.
229 EXPECT_EQ(1U, [activeCardLinks count]); 315 EXPECT_EQ(1U, [activeCardLinks count]);
230 NSButton* manageAccountsLink = 316 NSButton* manageAccountsLink =
231 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]); 317 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]);
232 EXPECT_EQ(@selector(showAccountManagement:), [manageAccountsLink action]); 318 EXPECT_EQ(@selector(showAccountManagement:), [manageAccountsLink action]);
233 EXPECT_EQ(controller(), [manageAccountsLink target]); 319 EXPECT_EQ(controller(), [manageAccountsLink target]);
234 } 320 }
235 321
236 TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { 322 TEST_F(ProfileChooserControllerTest,
323 SignedInProfileActiveCardLinksWithNewMenu) {
324 EnableNewAvatarMenuOnly();
237 // Sign in the first profile. 325 // Sign in the first profile.
238 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); 326 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
239 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); 327 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
328
329 StartProfileChooserController();
330 NSArray* subviews = [[[controller() window] contentView] subviews];
331 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews];
332 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews];
333
334 // There is one link, without a target and with the user's email.
335 EXPECT_EQ(1U, [activeCardLinks count]);
336 NSButton* emailLink =
337 static_cast<NSButton*>([activeCardLinks objectAtIndex:0]);
338 EXPECT_EQ(nil, [emailLink action]);
339 EXPECT_EQ(kEmail, base::SysNSStringToUTF8([emailLink title]));
340 EXPECT_EQ(controller(), [emailLink target]);
341 }
342
343 TEST_F(ProfileChooserControllerTest, AccountManagementLayout) {
344 EnableNewProfileManagement();
345 // Sign in the first profile.
346 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
347 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
240 348
241 // Set up the signin manager and the OAuth2Tokens. 349 // Set up the signin manager and the OAuth2Tokens.
242 Profile* profile = browser()->profile(); 350 Profile* profile = browser()->profile();
243 SigninManagerFactory::GetForProfile(profile)-> 351 SigninManagerFactory::GetForProfile(profile)->
244 SetAuthenticatedUsername(kEmail); 352 SetAuthenticatedUsername(kEmail);
245 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> 353 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
246 UpdateCredentials(kEmail, kLoginToken); 354 UpdateCredentials(kEmail, kLoginToken);
247 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> 355 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
248 UpdateCredentials(kSecondaryEmail, kLoginToken); 356 UpdateCredentials(kSecondaryEmail, kLoginToken);
249 357
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 EXPECT_EQ(controller(), [addAccountsButton target]); 389 EXPECT_EQ(controller(), [addAccountsButton target]);
282 390
283 // There should be two accounts in the account list container. 391 // There should be two accounts in the account list container.
284 NSArray* accountsListSubviews = [[accountsSubviews objectAtIndex:1] subviews]; 392 NSArray* accountsListSubviews = [[accountsSubviews objectAtIndex:1] subviews];
285 EXPECT_EQ(2U, [accountsListSubviews count]); 393 EXPECT_EQ(2U, [accountsListSubviews count]);
286 394
287 NSButton* genericAccount = 395 NSButton* genericAccount =
288 static_cast<NSButton*>([accountsListSubviews objectAtIndex:0]); 396 static_cast<NSButton*>([accountsListSubviews objectAtIndex:0]);
289 EXPECT_EQ(@selector(showAccountRemovalView:), [genericAccount action]); 397 EXPECT_EQ(@selector(showAccountRemovalView:), [genericAccount action]);
290 EXPECT_EQ(controller(), [genericAccount target]); 398 EXPECT_EQ(controller(), [genericAccount target]);
399 EXPECT_NE(-1, [genericAccount tag]);
291 400
292 // Primary accounts are always last. 401 // Primary accounts are always last.
293 NSButton* primaryAccount = 402 NSButton* primaryAccount =
294 static_cast<NSButton*>([accountsListSubviews objectAtIndex:1]); 403 static_cast<NSButton*>([accountsListSubviews objectAtIndex:1]);
295 EXPECT_EQ(@selector(showAccountRemovalView:), [primaryAccount action]); 404 EXPECT_EQ(@selector(showAccountRemovalView:), [primaryAccount action]);
296 EXPECT_EQ(controller(), [primaryAccount target]); 405 EXPECT_EQ(controller(), [primaryAccount target]);
406 EXPECT_EQ(-1, [primaryAccount tag]);
297 407
298 // There should be another separator. 408 // There should be another separator.
299 EXPECT_TRUE([[subviews objectAtIndex:3] isKindOfClass:[NSBox class]]); 409 EXPECT_TRUE([[subviews objectAtIndex:3] isKindOfClass:[NSBox class]]);
300 410
301 // There should be the profile avatar, name and no links container in the 411 // There should be the profile avatar, name and a "hide accounts" link
302 // active card view. 412 // container in the active card view.
303 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews]; 413 NSArray* activeCardSubviews = [[subviews objectAtIndex:4] subviews];
304 EXPECT_EQ(2U, [activeCardSubviews count]); 414 EXPECT_EQ(3U, [activeCardSubviews count]);
305 415
306 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:0]; 416 // Profile icon.
417 NSView* activeProfileImage = [activeCardSubviews objectAtIndex:2];
307 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]); 418 EXPECT_TRUE([activeProfileImage isKindOfClass:[NSImageView class]]);
308 419
420 // Profile name.
309 NSView* activeProfileName = [activeCardSubviews objectAtIndex:1]; 421 NSView* activeProfileName = [activeCardSubviews objectAtIndex:1];
310 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]); 422 EXPECT_TRUE([activeProfileName isKindOfClass:[NSButton class]]);
311 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( 423 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16(
312 [static_cast<NSButton*>(activeProfileName) title])); 424 [static_cast<NSButton*>(activeProfileName) title]));
425
426 // Profile links. This is a local profile, so there should be a signin button.
427 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews];
428 EXPECT_EQ(1U, [linksSubviews count]);
429 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]);
430 EXPECT_EQ(@selector(hideAccountManagement:), [link action]);
431 EXPECT_EQ(controller(), [link target]);
313 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698