| 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/chrome_sync_client.h" | 11 #include "chrome/browser/sync/chrome_sync_client.h" |
| 12 #include "chrome/browser/sync/profile_sync_test_util.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 #include "components/sync_driver/signin_manager_wrapper.h" | 18 #include "components/sync_driver/signin_manager_wrapper.h" |
| 18 #include "components/sync_driver/sync_api_component_factory_mock.h" | 19 #include "components/sync_driver/sync_api_component_factory_mock.h" |
| 19 | 20 |
| 20 ProfileSyncServiceMock::ProfileSyncServiceMock(Profile* profile) | 21 ProfileSyncServiceMock::ProfileSyncServiceMock(Profile* profile) |
| 21 : ProfileSyncServiceMock( | 22 : ProfileSyncServiceMock( |
| 22 make_scoped_ptr( | 23 make_scoped_ptr( |
| 23 new browser_sync::ChromeSyncClient( | 24 new browser_sync::ChromeSyncClient( |
| 24 profile, | 25 profile, |
| 25 make_scoped_ptr(new SyncApiComponentFactoryMock()))) | 26 make_scoped_ptr(new SyncApiComponentFactoryMock()))) |
| 26 .Pass(), | 27 .Pass(), |
| 27 profile) {} | 28 profile) {} |
| 28 | 29 |
| 29 ProfileSyncServiceMock::ProfileSyncServiceMock( | 30 ProfileSyncServiceMock::ProfileSyncServiceMock( |
| 30 scoped_ptr<sync_driver::SyncClient> sync_client, | 31 scoped_ptr<sync_driver::SyncClient> sync_client, |
| 31 Profile* profile) | 32 Profile* profile) |
| 32 : ProfileSyncService( | 33 : ProfileSyncService( |
| 33 sync_client.Pass(), | 34 sync_client.Pass(), |
| 34 profile, | 35 profile, |
| 35 make_scoped_ptr(new SigninManagerWrapper( | 36 make_scoped_ptr(new SigninManagerWrapper( |
| 36 SigninManagerFactory::GetForProfile(profile))), | 37 SigninManagerFactory::GetForProfile(profile))), |
| 37 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 38 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 38 browser_sync::MANUAL_START) { | 39 browser_sync::MANUAL_START, |
| 40 base::Bind(&EmptyNetworkTimeUpdate)) { |
| 39 ON_CALL(*this, IsSyncRequested()).WillByDefault(testing::Return(true)); | 41 ON_CALL(*this, IsSyncRequested()).WillByDefault(testing::Return(true)); |
| 40 } | 42 } |
| 41 | 43 |
| 42 ProfileSyncServiceMock::~ProfileSyncServiceMock() { | 44 ProfileSyncServiceMock::~ProfileSyncServiceMock() { |
| 43 } | 45 } |
| 44 | 46 |
| 45 // static | 47 // static |
| 46 TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { | 48 TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { |
| 47 TestingProfile* profile = new TestingProfile(); | 49 TestingProfile* profile = new TestingProfile(); |
| 48 SigninManagerFactory::GetForProfile(profile)-> | 50 SigninManagerFactory::GetForProfile(profile)-> |
| 49 SetAuthenticatedAccountInfo("12345", "foo"); | 51 SetAuthenticatedAccountInfo("12345", "foo"); |
| 50 return profile; | 52 return profile; |
| 51 } | 53 } |
| 52 | 54 |
| 53 // static | 55 // static |
| 54 scoped_ptr<KeyedService> ProfileSyncServiceMock::BuildMockProfileSyncService( | 56 scoped_ptr<KeyedService> ProfileSyncServiceMock::BuildMockProfileSyncService( |
| 55 content::BrowserContext* profile) { | 57 content::BrowserContext* profile) { |
| 56 return make_scoped_ptr( | 58 return make_scoped_ptr( |
| 57 new ProfileSyncServiceMock(static_cast<Profile*>(profile))); | 59 new ProfileSyncServiceMock(static_cast<Profile*>(profile))); |
| 58 } | 60 } |
| OLD | NEW |