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" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/prefs/pref_service_syncable.h" | 13 #include "chrome/browser/prefs/pref_service_syncable.h" |
14 #include "chrome/browser/profiles/avatar_menu.h" | 14 #include "chrome/browser/profiles/avatar_menu.h" |
15 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 17 #include "chrome/browser/signin/fake_account_tracker_service.h" |
16 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 18 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
17 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
19 #include "chrome/browser/signin/signin_header_helper.h" | 21 #include "chrome/browser/signin/signin_header_helper.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
21 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 24 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
23 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
24 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 26 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
25 #include "components/signin/core/browser/signin_manager.h" | 27 #include "components/signin/core/browser/signin_manager.h" |
26 #include "components/signin/core/common/profile_management_switches.h" | 28 #include "components/signin/core/common/profile_management_switches.h" |
27 | 29 |
28 const std::string kEmail = "user@gmail.com"; | 30 const std::string kEmail = "user@gmail.com"; |
29 const std::string kSecondaryEmail = "user2@gmail.com"; | 31 const std::string kSecondaryEmail = "user2@gmail.com"; |
30 const std::string kLoginToken = "oauth2_login_token"; | 32 const std::string kLoginToken = "oauth2_login_token"; |
31 | 33 |
32 class ProfileChooserControllerTest : public CocoaProfileTest { | 34 class ProfileChooserControllerTest : public CocoaProfileTest { |
33 public: | 35 public: |
34 ProfileChooserControllerTest() { | 36 ProfileChooserControllerTest() { |
35 } | 37 } |
36 | 38 |
37 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() OVERRIDE { |
38 CocoaProfileTest::SetUp(); | 40 CocoaProfileTest::SetUp(); |
39 ASSERT_TRUE(browser()->profile()); | 41 ASSERT_TRUE(browser()->profile()); |
40 | 42 |
| 43 AccountTrackerServiceFactory::GetInstance()->SetTestingFactory( |
| 44 browser()->profile(), FakeAccountTrackerService::Build); |
| 45 |
41 TestingProfile::TestingFactories factories; | 46 TestingProfile::TestingFactories factories; |
42 factories.push_back( | 47 factories.push_back( |
43 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 48 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
44 BuildFakeProfileOAuth2TokenService)); | 49 BuildFakeProfileOAuth2TokenService)); |
| 50 factories.push_back( |
| 51 std::make_pair(AccountTrackerServiceFactory::GetInstance(), |
| 52 FakeAccountTrackerService::Build)); |
45 testing_profile_manager()-> | 53 testing_profile_manager()-> |
46 CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), | 54 CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), |
47 base::ASCIIToUTF16("Test 1"), 0, std::string(), | 55 base::ASCIIToUTF16("Test 1"), 0, std::string(), |
48 factories); | 56 factories); |
49 testing_profile_manager()-> | 57 testing_profile_manager()-> |
50 CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(), | 58 CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(), |
51 base::ASCIIToUTF16("Test 2"), 1, std::string(), | 59 base::ASCIIToUTF16("Test 2"), 1, std::string(), |
52 TestingProfile::TestingFactories()); | 60 TestingProfile::TestingFactories()); |
53 | 61 |
54 menu_ = new AvatarMenu(testing_profile_manager()->profile_info_cache(), | 62 menu_ = new AvatarMenu(testing_profile_manager()->profile_info_cache(), |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 ASSERT_EQ(5U, [buttonSubviews count]); | 518 ASSERT_EQ(5U, [buttonSubviews count]); |
511 | 519 |
512 // There should be a lock button. | 520 // There should be a lock button. |
513 NSButton* lockButton = | 521 NSButton* lockButton = |
514 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 522 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
515 ASSERT_TRUE(lockButton); | 523 ASSERT_TRUE(lockButton); |
516 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 524 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
517 EXPECT_EQ(controller(), [lockButton target]); | 525 EXPECT_EQ(controller(), [lockButton target]); |
518 EXPECT_TRUE([lockButton isEnabled]); | 526 EXPECT_TRUE([lockButton isEnabled]); |
519 } | 527 } |
OLD | NEW |