OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/sync/profile_sync_service_mock.h" | 5 #include "chrome/browser/sync/profile_sync_service_mock.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/prefs/testing_pref_store.h" | 8 #include "base/prefs/testing_pref_store.h" |
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 11 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
11 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 12 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
16 #include "components/signin/core/browser/signin_manager.h" | 17 #include "components/signin/core/browser/signin_manager.h" |
17 | 18 |
18 ProfileSyncServiceMock::ProfileSyncServiceMock(Profile* profile) | 19 ProfileSyncServiceMock::ProfileSyncServiceMock(Profile* profile) |
19 : ProfileSyncService( | 20 : ProfileSyncService( |
20 NULL, | 21 new ProfileSyncComponentsFactoryMock(), |
21 profile, | 22 profile, |
22 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( | 23 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( |
23 profile, | 24 profile, |
| 25 SigninManagerFactory::GetForProfile(profile))), |
| 26 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 27 browser_sync::MANUAL_START) { |
| 28 } |
| 29 |
| 30 ProfileSyncServiceMock::ProfileSyncServiceMock( |
| 31 ProfileSyncComponentsFactory* factory, Profile* profile) |
| 32 : ProfileSyncService( |
| 33 factory, |
| 34 profile, |
| 35 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( |
| 36 profile, |
24 SigninManagerFactory::GetForProfile(profile))), | 37 SigninManagerFactory::GetForProfile(profile))), |
25 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 38 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
26 browser_sync::MANUAL_START) { | 39 browser_sync::MANUAL_START) { |
27 } | 40 } |
28 | 41 |
29 ProfileSyncServiceMock::~ProfileSyncServiceMock() { | 42 ProfileSyncServiceMock::~ProfileSyncServiceMock() { |
30 } | 43 } |
31 | 44 |
32 // static | 45 // static |
33 TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { | 46 TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { |
34 TestingProfile* profile = new TestingProfile(); | 47 TestingProfile* profile = new TestingProfile(); |
35 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "foo"); | 48 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "foo"); |
36 return profile; | 49 return profile; |
37 } | 50 } |
38 | 51 |
39 // static | 52 // static |
40 KeyedService* ProfileSyncServiceMock::BuildMockProfileSyncService( | 53 KeyedService* ProfileSyncServiceMock::BuildMockProfileSyncService( |
41 content::BrowserContext* profile) { | 54 content::BrowserContext* profile) { |
42 return new ProfileSyncServiceMock(static_cast<Profile*>(profile)); | 55 return new ProfileSyncServiceMock(static_cast<Profile*>(profile)); |
43 } | 56 } |
44 | 57 |
45 ScopedVector<browser_sync::DeviceInfo> | 58 ScopedVector<browser_sync::DeviceInfo> |
46 ProfileSyncServiceMock::GetAllSignedInDevices() const { | 59 ProfileSyncServiceMock::GetAllSignedInDevices() const { |
47 ScopedVector<browser_sync::DeviceInfo> devices; | 60 ScopedVector<browser_sync::DeviceInfo> devices; |
48 std::vector<browser_sync::DeviceInfo*>* device_vector = | 61 std::vector<browser_sync::DeviceInfo*>* device_vector = |
49 GetAllSignedInDevicesMock(); | 62 GetAllSignedInDevicesMock(); |
50 devices.get() = *device_vector; | 63 devices.get() = *device_vector; |
51 return devices.Pass(); | 64 return devices.Pass(); |
52 } | 65 } |
53 | |
54 scoped_ptr<browser_sync::DeviceInfo> | |
55 ProfileSyncServiceMock::GetLocalDeviceInfo() const { | |
56 return scoped_ptr<browser_sync::DeviceInfo>(GetLocalDeviceInfoMock()).Pass(); | |
57 } | |
OLD | NEW |