| 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/prefs/pref_service_mock_builder.h" | 5 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 6 #include "chrome/browser/prefs/testing_pref_store.h" | 6 #include "chrome/browser/prefs/testing_pref_store.h" |
| 7 #include "chrome/browser/signin/signin_manager.h" | |
| 8 #include "chrome/browser/signin/signin_manager_factory.h" | 7 #include "chrome/browser/signin/signin_manager_factory.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_mock.h" | 8 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 9 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 11 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 14 | 13 |
| 15 ProfileSyncServiceMock::ProfileSyncServiceMock() | 14 ProfileSyncServiceMock::ProfileSyncServiceMock() |
| 16 : ProfileSyncService(NULL, | 15 : ProfileSyncService(NULL, |
| 17 NULL, | 16 NULL, |
| 18 new SigninManager(), | 17 NULL, |
| 19 ProfileSyncService::MANUAL_START) { | 18 ProfileSyncService::MANUAL_START) { |
| 20 } | 19 } |
| 21 | 20 |
| 22 ProfileSyncServiceMock::ProfileSyncServiceMock( | 21 ProfileSyncServiceMock::ProfileSyncServiceMock( |
| 23 Profile* profile) : ProfileSyncService(NULL, | 22 Profile* profile) : ProfileSyncService(NULL, |
| 24 profile, | 23 profile, |
| 25 NULL, | 24 NULL, |
| 26 ProfileSyncService::MANUAL_START) { | 25 ProfileSyncService::MANUAL_START) { |
| 27 } | 26 } |
| 28 | 27 |
| 29 ProfileSyncServiceMock::~ProfileSyncServiceMock() { | 28 ProfileSyncServiceMock::~ProfileSyncServiceMock() { |
| 30 delete signin(); | |
| 31 } | 29 } |
| 32 | 30 |
| 33 // static | 31 // static |
| 34 Profile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { | 32 Profile* ProfileSyncServiceMock::MakeSignedInTestingProfile() { |
| 35 TestingProfile* profile = new TestingProfile(); | 33 TestingProfile* profile = new TestingProfile(); |
| 36 TestingPrefStore* user_prefs = new TestingPrefStore(); | 34 TestingPrefStore* user_prefs = new TestingPrefStore(); |
| 37 PrefService* prefs = PrefServiceMockBuilder() | 35 PrefService* prefs = PrefServiceMockBuilder() |
| 38 .WithUserPrefs(user_prefs) | 36 .WithUserPrefs(user_prefs) |
| 39 .Create(); | 37 .Create(); |
| 40 profile->SetPrefService(prefs); | 38 profile->SetPrefService(prefs); |
| 41 // We just blew away our prefs, so reregister them. | 39 // We just blew away our prefs, so reregister them. |
| 42 SigninManagerFactory::GetInstance()->RegisterUserPrefs(prefs); | 40 SigninManagerFactory::GetInstance()->RegisterUserPrefs(prefs); |
| 43 user_prefs->SetString(prefs::kGoogleServicesUsername, "foo"); | 41 user_prefs->SetString(prefs::kGoogleServicesUsername, "foo"); |
| 44 return profile; | 42 return profile; |
| 45 } | 43 } |
| OLD | NEW |