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