| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 controller_.reset(); | 61 controller_.reset(); |
| 62 CocoaProfileTest::TearDown(); | 62 CocoaProfileTest::TearDown(); |
| 63 } | 63 } |
| 64 | 64 |
| 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:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]); |
| 72 [controller_ showWindow:nil]; | 72 [controller_ showWindow:nil]; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void EnableNewProfileManagement() { | 75 void EnableNewProfileManagement() { |
| 76 CommandLine::ForCurrentProcess()->AppendSwitch( | 76 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 77 switches::kNewProfileManagement); | 77 switches::kNewProfileManagement); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void EnableNewAvatarMenuOnly() { | 80 void EnableNewAvatarMenuOnly() { |
| 81 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNewAvatarMenu); | 81 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNewAvatarMenu); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // Set up the signin manager and the OAuth2Tokens. | 371 // Set up the signin manager and the OAuth2Tokens. |
| 372 Profile* profile = browser()->profile(); | 372 Profile* profile = browser()->profile(); |
| 373 SigninManagerFactory::GetForProfile(profile)-> | 373 SigninManagerFactory::GetForProfile(profile)-> |
| 374 SetAuthenticatedUsername(kEmail); | 374 SetAuthenticatedUsername(kEmail); |
| 375 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | 375 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 376 UpdateCredentials(kEmail, kLoginToken); | 376 UpdateCredentials(kEmail, kLoginToken); |
| 377 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | 377 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 378 UpdateCredentials(kSecondaryEmail, kLoginToken); | 378 UpdateCredentials(kSecondaryEmail, kLoginToken); |
| 379 | 379 |
| 380 StartProfileChooserController(); | 380 StartProfileChooserController(); |
| 381 [controller() initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 381 [controller() initMenuContentsWithView: |
| 382 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
| 382 | 383 |
| 383 NSArray* subviews = [[[controller() window] contentView] subviews]; | 384 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 384 EXPECT_EQ(1U, [subviews count]); | 385 EXPECT_EQ(1U, [subviews count]); |
| 385 subviews = [[subviews objectAtIndex:0] subviews]; | 386 subviews = [[subviews objectAtIndex:0] subviews]; |
| 386 | 387 |
| 387 // There should be one active card, one accounts container, two separators | 388 // There should be one active card, one accounts container, two separators |
| 388 // and one option buttons view. | 389 // and one option buttons view. |
| 389 EXPECT_EQ(5U, [subviews count]); | 390 EXPECT_EQ(5U, [subviews count]); |
| 390 | 391 |
| 391 // There should be two buttons in the option buttons view. | 392 // There should be two buttons in the option buttons view. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( | 452 EXPECT_EQ(menu()->GetItemAt(0).name, base::SysNSStringToUTF16( |
| 452 [static_cast<NSButton*>(activeProfileName) title])); | 453 [static_cast<NSButton*>(activeProfileName) title])); |
| 453 | 454 |
| 454 // Profile links. This is a local profile, so there should be a signin button. | 455 // Profile links. This is a local profile, so there should be a signin button. |
| 455 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; | 456 NSArray* linksSubviews = [[activeCardSubviews objectAtIndex:0] subviews]; |
| 456 EXPECT_EQ(1U, [linksSubviews count]); | 457 EXPECT_EQ(1U, [linksSubviews count]); |
| 457 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]); | 458 NSButton* link = static_cast<NSButton*>([linksSubviews objectAtIndex:0]); |
| 458 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); | 459 EXPECT_EQ(@selector(hideAccountManagement:), [link action]); |
| 459 EXPECT_EQ(controller(), [link target]); | 460 EXPECT_EQ(controller(), [link target]); |
| 460 } | 461 } |
| OLD | NEW |