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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 : debug_ptr_factory_(this), | 116 : debug_ptr_factory_(this), |
117 example_url0_("http://example.com/0"), | 117 example_url0_("http://example.com/0"), |
118 example_url1_("http://example.com/1"), | 118 example_url1_("http://example.com/1"), |
119 example_url2_("http://example.com/2"), | 119 example_url2_("http://example.com/2"), |
120 not_synced_preference_name_("nonsense_pref_name"), | 120 not_synced_preference_name_("nonsense_pref_name"), |
121 not_synced_preference_default_value_("default"), | 121 not_synced_preference_default_value_("default"), |
122 non_default_charset_value_("foo") {} | 122 non_default_charset_value_("foo") {} |
123 | 123 |
124 virtual void SetUp() { | 124 virtual void SetUp() { |
125 AbstractProfileSyncServiceTest::SetUp(); | 125 AbstractProfileSyncServiceTest::SetUp(); |
126 profile_.reset(new TestingProfile()); | 126 TestingProfile::Builder builder; |
| 127 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 128 FakeOAuth2TokenService::BuildTokenService); |
| 129 profile_ = builder.Build().Pass(); |
127 invalidation::InvalidationServiceFactory::GetInstance()-> | 130 invalidation::InvalidationServiceFactory::GetInstance()-> |
128 SetBuildOnlyFakeInvalidatorsForTest(true); | 131 SetBuildOnlyFakeInvalidatorsForTest(true); |
129 prefs_ = profile_->GetTestingPrefService(); | 132 prefs_ = profile_->GetTestingPrefService(); |
130 | 133 |
131 prefs_->registry()->RegisterStringPref( | 134 prefs_->registry()->RegisterStringPref( |
132 not_synced_preference_name_.c_str(), | 135 not_synced_preference_name_.c_str(), |
133 not_synced_preference_default_value_, | 136 not_synced_preference_default_value_, |
134 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 137 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
135 } | 138 } |
136 | 139 |
(...skipping 12 matching lines...) Expand all Loading... |
149 } | 152 } |
150 | 153 |
151 bool StartSyncService(const base::Closure& callback, | 154 bool StartSyncService(const base::Closure& callback, |
152 bool will_fail_association) { | 155 bool will_fail_association) { |
153 if (sync_service_) | 156 if (sync_service_) |
154 return false; | 157 return false; |
155 | 158 |
156 SigninManagerBase* signin = | 159 SigninManagerBase* signin = |
157 SigninManagerFactory::GetForProfile(profile_.get()); | 160 SigninManagerFactory::GetForProfile(profile_.get()); |
158 signin->SetAuthenticatedUsername("test"); | 161 signin->SetAuthenticatedUsername("test"); |
159 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | |
160 profile_.get(), FakeOAuth2TokenService::BuildTokenService); | |
161 sync_service_ = static_cast<TestProfileSyncService*>( | 162 sync_service_ = static_cast<TestProfileSyncService*>( |
162 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 163 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
163 profile_.get(), &TestProfileSyncService::BuildAutoStartAsyncInit)); | 164 profile_.get(), &TestProfileSyncService::BuildAutoStartAsyncInit)); |
164 sync_service_->set_backend_init_callback(callback); | 165 sync_service_->set_backend_init_callback(callback); |
165 pref_sync_service_ = reinterpret_cast<PrefModelAssociator*>( | 166 pref_sync_service_ = reinterpret_cast<PrefModelAssociator*>( |
166 prefs_->GetSyncableService(syncer::PREFERENCES)); | 167 prefs_->GetSyncableService(syncer::PREFERENCES)); |
167 if (!pref_sync_service_) | 168 if (!pref_sync_service_) |
168 return false; | 169 return false; |
169 ProfileSyncComponentsFactoryMock* components = | 170 ProfileSyncComponentsFactoryMock* components = |
170 sync_service_->components_factory_mock(); | 171 sync_service_->components_factory_mock(); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 EXPECT_FALSE(pref->IsDefaultValue()); | 685 EXPECT_FALSE(pref->IsDefaultValue()); |
685 // There should be no synced value. | 686 // There should be no synced value. |
686 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); | 687 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); |
687 // Switch kHomePage back to unmanaged. | 688 // Switch kHomePage back to unmanaged. |
688 profile_->GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage); | 689 profile_->GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage); |
689 // The original value should be picked up. | 690 // The original value should be picked up. |
690 EXPECT_TRUE(pref->IsDefaultValue()); | 691 EXPECT_TRUE(pref->IsDefaultValue()); |
691 // There should still be no synced value. | 692 // There should still be no synced value. |
692 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); | 693 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); |
693 } | 694 } |
OLD | NEW |