| 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 #import "base/mac/foundation_util.h" | 8 #import "base/mac/foundation_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 controller_.reset([[ProfileChooserController alloc] | 84 controller_.reset([[ProfileChooserController alloc] |
| 85 initWithBrowser:browser() | 85 initWithBrowser:browser() |
| 86 anchoredAt:point | 86 anchoredAt:point |
| 87 viewMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER | 87 viewMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER |
| 88 tutorialMode:profiles::TUTORIAL_MODE_NONE | 88 tutorialMode:profiles::TUTORIAL_MODE_NONE |
| 89 serviceType:signin::GAIA_SERVICE_TYPE_NONE]); | 89 serviceType:signin::GAIA_SERVICE_TYPE_NONE]); |
| 90 [controller_ showWindow:nil]; | 90 [controller_ showWindow:nil]; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void EnableFastUserSwitching() { | 93 void EnableFastUserSwitching() { |
| 94 CommandLine::ForCurrentProcess()->AppendSwitch( | 94 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 95 switches::kFastUserSwitching); | 95 switches::kFastUserSwitching); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ProfileChooserController* controller() { return controller_; } | 98 ProfileChooserController* controller() { return controller_; } |
| 99 AvatarMenu* menu() { return menu_; } | 99 AvatarMenu* menu() { return menu_; } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 base::scoped_nsobject<ProfileChooserController> controller_; | 102 base::scoped_nsobject<ProfileChooserController> controller_; |
| 103 | 103 |
| 104 // Weak; owned by |controller_|. | 104 // Weak; owned by |controller_|. |
| 105 AvatarMenu* menu_; | 105 AvatarMenu* menu_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(ProfileChooserControllerTest); | 107 DISALLOW_COPY_AND_ASSIGN(ProfileChooserControllerTest); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { | 110 TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { |
| 111 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 111 switches::EnableNewAvatarMenuForTesting( |
| 112 base::CommandLine::ForCurrentProcess()); |
| 112 StartProfileChooserController(); | 113 StartProfileChooserController(); |
| 113 | 114 |
| 114 NSArray* subviews = [[[controller() window] contentView] subviews]; | 115 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 115 ASSERT_EQ(2U, [subviews count]); | 116 ASSERT_EQ(2U, [subviews count]); |
| 116 subviews = [[subviews objectAtIndex:0] subviews]; | 117 subviews = [[subviews objectAtIndex:0] subviews]; |
| 117 | 118 |
| 118 // Three profiles means we should have one active card, one separator and | 119 // Three profiles means we should have one active card, one separator and |
| 119 // one option buttons view. We also have an update promo for the new avatar | 120 // one option buttons view. We also have an update promo for the new avatar |
| 120 // menu. | 121 // menu. |
| 121 // TODO(noms): Enforcing 4U fails on the waterfall debug bots, but it's not | 122 // TODO(noms): Enforcing 4U fails on the waterfall debug bots, but it's not |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 [linksSubviews objectAtIndex:0]); | 168 [linksSubviews objectAtIndex:0]); |
| 168 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]); | 169 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]); |
| 169 EXPECT_EQ(controller(), [link target]); | 170 EXPECT_EQ(controller(), [link target]); |
| 170 | 171 |
| 171 NSTextField* promo = base::mac::ObjCCast<NSTextField>( | 172 NSTextField* promo = base::mac::ObjCCast<NSTextField>( |
| 172 [linksSubviews objectAtIndex:1]); | 173 [linksSubviews objectAtIndex:1]); |
| 173 EXPECT_GT([[promo stringValue] length], 0U); | 174 EXPECT_GT([[promo stringValue] length], 0U); |
| 174 } | 175 } |
| 175 | 176 |
| 176 TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { | 177 TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { |
| 177 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 178 switches::EnableNewAvatarMenuForTesting( |
| 179 base::CommandLine::ForCurrentProcess()); |
| 178 EnableFastUserSwitching(); | 180 EnableFastUserSwitching(); |
| 179 StartProfileChooserController(); | 181 StartProfileChooserController(); |
| 180 | 182 |
| 181 NSArray* subviews = [[[controller() window] contentView] subviews]; | 183 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 182 ASSERT_EQ(2U, [subviews count]); | 184 ASSERT_EQ(2U, [subviews count]); |
| 183 subviews = [[subviews objectAtIndex:0] subviews]; | 185 subviews = [[subviews objectAtIndex:0] subviews]; |
| 184 | 186 |
| 185 // Three profiles means we should have one active card and a | 187 // Three profiles means we should have one active card and a |
| 186 // fast user switcher which has two "other" profiles and 2 separators, and | 188 // fast user switcher which has two "other" profiles and 2 separators, and |
| 187 // an option buttons view with its separator. We also have a promo for | 189 // an option buttons view with its separator. We also have a promo for |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( | 232 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( |
| 231 [base::mac::ObjCCast<NSButton>(activeProfileName) title])); | 233 [base::mac::ObjCCast<NSButton>(activeProfileName) title])); |
| 232 | 234 |
| 233 // Profile links. This is a local profile, so there should be a signin button | 235 // Profile links. This is a local profile, so there should be a signin button |
| 234 // and a signin promo. These are also tested in InitialLayoutWithNewMenu. | 236 // and a signin promo. These are also tested in InitialLayoutWithNewMenu. |
| 235 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; | 237 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 236 EXPECT_EQ(2U, [linksSubviews count]); | 238 EXPECT_EQ(2U, [linksSubviews count]); |
| 237 } | 239 } |
| 238 | 240 |
| 239 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { | 241 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { |
| 240 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 242 switches::EnableNewAvatarMenuForTesting( |
| 243 base::CommandLine::ForCurrentProcess()); |
| 241 EnableFastUserSwitching(); | 244 EnableFastUserSwitching(); |
| 242 | 245 |
| 243 // Add two extra profiles, to make sure sorting is alphabetical and not | 246 // Add two extra profiles, to make sure sorting is alphabetical and not |
| 244 // by order of creation. | 247 // by order of creation. |
| 245 testing_profile_manager()-> | 248 testing_profile_manager()-> |
| 246 CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), | 249 CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), |
| 247 base::ASCIIToUTF16("New Profile"), 1, std::string(), | 250 base::ASCIIToUTF16("New Profile"), 1, std::string(), |
| 248 TestingProfile::TestingFactories()); | 251 TestingProfile::TestingFactories()); |
| 249 testing_profile_manager()-> | 252 testing_profile_manager()-> |
| 250 CreateTestingProfile("test4", scoped_ptr<PrefServiceSyncable>(), | 253 CreateTestingProfile("test4", scoped_ptr<PrefServiceSyncable>(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 275 // The item at index i is the separator. | 278 // The item at index i is the separator. |
| 276 NSButton* button = base::mac::ObjCCast<NSButton>( | 279 NSButton* button = base::mac::ObjCCast<NSButton>( |
| 277 [subviews objectAtIndex:i-1]); | 280 [subviews objectAtIndex:i-1]); |
| 278 EXPECT_TRUE( | 281 EXPECT_TRUE( |
| 279 [[button title] isEqualToString:sortedNames[sortedNameIndex++]]); | 282 [[button title] isEqualToString:sortedNames[sortedNameIndex++]]); |
| 280 } | 283 } |
| 281 } | 284 } |
| 282 | 285 |
| 283 TEST_F(ProfileChooserControllerTest, | 286 TEST_F(ProfileChooserControllerTest, |
| 284 LocalProfileActiveCardLinksWithNewMenu) { | 287 LocalProfileActiveCardLinksWithNewMenu) { |
| 285 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 288 switches::EnableNewAvatarMenuForTesting( |
| 289 base::CommandLine::ForCurrentProcess()); |
| 286 StartProfileChooserController(); | 290 StartProfileChooserController(); |
| 287 NSArray* subviews = [[[controller() window] contentView] subviews]; | 291 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 288 ASSERT_EQ(2U, [subviews count]); | 292 ASSERT_EQ(2U, [subviews count]); |
| 289 subviews = [[subviews objectAtIndex:0] subviews]; | 293 subviews = [[subviews objectAtIndex:0] subviews]; |
| 290 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; | 294 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; |
| 291 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; | 295 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 292 | 296 |
| 293 ASSERT_EQ(2U, [activeCardLinks count]); | 297 ASSERT_EQ(2U, [activeCardLinks count]); |
| 294 | 298 |
| 295 // There should be a sign in button. | 299 // There should be a sign in button. |
| 296 NSButton* link = base::mac::ObjCCast<NSButton>( | 300 NSButton* link = base::mac::ObjCCast<NSButton>( |
| 297 [activeCardLinks objectAtIndex:0]); | 301 [activeCardLinks objectAtIndex:0]); |
| 298 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]); | 302 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]); |
| 299 EXPECT_EQ(controller(), [link target]); | 303 EXPECT_EQ(controller(), [link target]); |
| 300 | 304 |
| 301 // Local profiles have a signin promo. | 305 // Local profiles have a signin promo. |
| 302 NSTextField* promo = base::mac::ObjCCast<NSTextField>( | 306 NSTextField* promo = base::mac::ObjCCast<NSTextField>( |
| 303 [activeCardLinks objectAtIndex:1]); | 307 [activeCardLinks objectAtIndex:1]); |
| 304 EXPECT_GT([[promo stringValue] length], 0U); | 308 EXPECT_GT([[promo stringValue] length], 0U); |
| 305 } | 309 } |
| 306 | 310 |
| 307 TEST_F(ProfileChooserControllerTest, | 311 TEST_F(ProfileChooserControllerTest, |
| 308 SignedInProfileActiveCardLinksWithAccountConsistency) { | 312 SignedInProfileActiveCardLinksWithAccountConsistency) { |
| 309 switches::EnableAccountConsistencyForTesting( | 313 switches::EnableAccountConsistencyForTesting( |
| 310 CommandLine::ForCurrentProcess()); | 314 base::CommandLine::ForCurrentProcess()); |
| 311 // Sign in the first profile. | 315 // Sign in the first profile. |
| 312 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 316 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 313 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 317 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 314 | 318 |
| 315 StartProfileChooserController(); | 319 StartProfileChooserController(); |
| 316 NSArray* subviews = [[[controller() window] contentView] subviews]; | 320 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 317 ASSERT_EQ(2U, [subviews count]); | 321 ASSERT_EQ(2U, [subviews count]); |
| 318 subviews = [[subviews objectAtIndex:0] subviews]; | 322 subviews = [[subviews objectAtIndex:0] subviews]; |
| 319 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; | 323 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; |
| 320 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; | 324 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 321 | 325 |
| 322 // There is one link: manage accounts. | 326 // There is one link: manage accounts. |
| 323 ASSERT_EQ(1U, [activeCardLinks count]); | 327 ASSERT_EQ(1U, [activeCardLinks count]); |
| 324 NSButton* manageAccountsLink = | 328 NSButton* manageAccountsLink = |
| 325 base::mac::ObjCCast<NSButton>([activeCardLinks objectAtIndex:0]); | 329 base::mac::ObjCCast<NSButton>([activeCardLinks objectAtIndex:0]); |
| 326 EXPECT_EQ(@selector(showAccountManagement:), [manageAccountsLink action]); | 330 EXPECT_EQ(@selector(showAccountManagement:), [manageAccountsLink action]); |
| 327 EXPECT_EQ(controller(), [manageAccountsLink target]); | 331 EXPECT_EQ(controller(), [manageAccountsLink target]); |
| 328 } | 332 } |
| 329 | 333 |
| 330 TEST_F(ProfileChooserControllerTest, | 334 TEST_F(ProfileChooserControllerTest, |
| 331 SignedInProfileActiveCardLinksWithNewMenu) { | 335 SignedInProfileActiveCardLinksWithNewMenu) { |
| 332 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 336 switches::EnableNewAvatarMenuForTesting( |
| 337 base::CommandLine::ForCurrentProcess()); |
| 333 // Sign in the first profile. | 338 // Sign in the first profile. |
| 334 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 339 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 335 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 340 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 336 | 341 |
| 337 StartProfileChooserController(); | 342 StartProfileChooserController(); |
| 338 NSArray* subviews = [[[controller() window] contentView] subviews]; | 343 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 339 ASSERT_EQ(2U, [subviews count]); | 344 ASSERT_EQ(2U, [subviews count]); |
| 340 subviews = [[subviews objectAtIndex:0] subviews]; | 345 subviews = [[subviews objectAtIndex:0] subviews]; |
| 341 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; | 346 NSArray* activeCardSubviews = [[subviews objectAtIndex:2] subviews]; |
| 342 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; | 347 NSArray* activeCardLinks = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 343 | 348 |
| 344 // There is one disabled button with the user's email. | 349 // There is one disabled button with the user's email. |
| 345 ASSERT_EQ(1U, [activeCardLinks count]); | 350 ASSERT_EQ(1U, [activeCardLinks count]); |
| 346 NSButton* emailButton = | 351 NSButton* emailButton = |
| 347 base::mac::ObjCCast<NSButton>([activeCardLinks objectAtIndex:0]); | 352 base::mac::ObjCCast<NSButton>([activeCardLinks objectAtIndex:0]); |
| 348 EXPECT_EQ(kEmail, base::SysNSStringToUTF8([emailButton title])); | 353 EXPECT_EQ(kEmail, base::SysNSStringToUTF8([emailButton title])); |
| 349 EXPECT_EQ(nil, [emailButton action]); | 354 EXPECT_EQ(nil, [emailButton action]); |
| 350 EXPECT_FALSE([emailButton isEnabled]); | 355 EXPECT_FALSE([emailButton isEnabled]); |
| 351 } | 356 } |
| 352 | 357 |
| 353 TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { | 358 TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { |
| 354 switches::EnableAccountConsistencyForTesting( | 359 switches::EnableAccountConsistencyForTesting( |
| 355 CommandLine::ForCurrentProcess()); | 360 base::CommandLine::ForCurrentProcess()); |
| 356 // Sign in the first profile. | 361 // Sign in the first profile. |
| 357 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 362 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 358 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 363 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 359 | 364 |
| 360 // Mark that we are using the profile name on purpose, so that we don't | 365 // Mark that we are using the profile name on purpose, so that we don't |
| 361 // fallback to testing the algorithm that chooses which default name | 366 // fallback to testing the algorithm that chooses which default name |
| 362 // should be used. | 367 // should be used. |
| 363 cache->SetProfileIsUsingDefaultNameAtIndex(0, false); | 368 cache->SetProfileIsUsingDefaultNameAtIndex(0, false); |
| 364 | 369 |
| 365 // Set up the signin manager and the OAuth2Tokens. | 370 // Set up the signin manager and the OAuth2Tokens. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; | 464 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 460 ASSERT_EQ(1U, [linksSubviews count]); | 465 ASSERT_EQ(1U, [linksSubviews count]); |
| 461 NSButton* link = base::mac::ObjCCast<NSButton>( | 466 NSButton* link = base::mac::ObjCCast<NSButton>( |
| 462 [linksSubviews objectAtIndex:0]); | 467 [linksSubviews objectAtIndex:0]); |
| 463 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); | 468 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
| 464 EXPECT_EQ(controller(), [link target]); | 469 EXPECT_EQ(controller(), [link target]); |
| 465 } | 470 } |
| 466 | 471 |
| 467 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { | 472 TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { |
| 468 switches::EnableNewProfileManagementForTesting( | 473 switches::EnableNewProfileManagementForTesting( |
| 469 CommandLine::ForCurrentProcess()); | 474 base::CommandLine::ForCurrentProcess()); |
| 470 // Sign in the first profile. | 475 // Sign in the first profile. |
| 471 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 476 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 472 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 477 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 473 // The preference, not the email, determines whether the profile can lock. | 478 // The preference, not the email, determines whether the profile can lock. |
| 474 browser()->profile()->GetPrefs()->SetString( | 479 browser()->profile()->GetPrefs()->SetString( |
| 475 prefs::kGoogleServicesHostedDomain, "chromium.org"); | 480 prefs::kGoogleServicesHostedDomain, "chromium.org"); |
| 476 | 481 |
| 477 StartProfileChooserController(); | 482 StartProfileChooserController(); |
| 478 NSArray* subviews = [[[controller() window] contentView] subviews]; | 483 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 479 ASSERT_EQ(2U, [subviews count]); | 484 ASSERT_EQ(2U, [subviews count]); |
| 480 subviews = [[subviews objectAtIndex:0] subviews]; | 485 subviews = [[subviews objectAtIndex:0] subviews]; |
| 481 | 486 |
| 482 // There will be two buttons and one separators in the option buttons view. | 487 // There will be two buttons and one separators in the option buttons view. |
| 483 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | 488 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
| 484 ASSERT_EQ(3U, [buttonSubviews count]); | 489 ASSERT_EQ(3U, [buttonSubviews count]); |
| 485 | 490 |
| 486 // The last button should not be the lock button. | 491 // The last button should not be the lock button. |
| 487 NSButton* lastButton = | 492 NSButton* lastButton = |
| 488 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 493 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 489 ASSERT_TRUE(lastButton); | 494 ASSERT_TRUE(lastButton); |
| 490 EXPECT_NE(@selector(lockProfile:), [lastButton action]); | 495 EXPECT_NE(@selector(lockProfile:), [lastButton action]); |
| 491 } | 496 } |
| 492 | 497 |
| 493 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { | 498 TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { |
| 494 switches::EnableNewProfileManagementForTesting( | 499 switches::EnableNewProfileManagementForTesting( |
| 495 CommandLine::ForCurrentProcess()); | 500 base::CommandLine::ForCurrentProcess()); |
| 496 // Sign in the first profile. | 501 // Sign in the first profile. |
| 497 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); | 502 ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); |
| 498 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); | 503 cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); |
| 499 // The preference, not the email, determines whether the profile can lock. | 504 // The preference, not the email, determines whether the profile can lock. |
| 500 browser()->profile()->GetPrefs()->SetString( | 505 browser()->profile()->GetPrefs()->SetString( |
| 501 prefs::kGoogleServicesHostedDomain, "google.com"); | 506 prefs::kGoogleServicesHostedDomain, "google.com"); |
| 502 // Lock is only available where a supervised user is present. | 507 // Lock is only available where a supervised user is present. |
| 503 cache->SetSupervisedUserIdOfProfileAtIndex(1, kEmail); | 508 cache->SetSupervisedUserIdOfProfileAtIndex(1, kEmail); |
| 504 | 509 |
| 505 StartProfileChooserController(); | 510 StartProfileChooserController(); |
| 506 NSArray* subviews = [[[controller() window] contentView] subviews]; | 511 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 507 ASSERT_EQ(2U, [subviews count]); | 512 ASSERT_EQ(2U, [subviews count]); |
| 508 subviews = [[subviews objectAtIndex:0] subviews]; | 513 subviews = [[subviews objectAtIndex:0] subviews]; |
| 509 | 514 |
| 510 // There will be three buttons and two separators in the option buttons view. | 515 // There will be three buttons and two separators in the option buttons view. |
| 511 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; | 516 NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; |
| 512 ASSERT_EQ(5U, [buttonSubviews count]); | 517 ASSERT_EQ(5U, [buttonSubviews count]); |
| 513 | 518 |
| 514 // There should be a lock button. | 519 // There should be a lock button. |
| 515 NSButton* lockButton = | 520 NSButton* lockButton = |
| 516 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 521 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 517 ASSERT_TRUE(lockButton); | 522 ASSERT_TRUE(lockButton); |
| 518 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 523 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| 519 EXPECT_EQ(controller(), [lockButton target]); | 524 EXPECT_EQ(controller(), [lockButton target]); |
| 520 EXPECT_TRUE([lockButton isEnabled]); | 525 EXPECT_TRUE([lockButton isEnabled]); |
| 521 } | 526 } |
| OLD | NEW |