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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 true, true, false, true, syncer::STORAGE_IN_MEMORY); | 96 true, true, false, true, syncer::STORAGE_IN_MEMORY); |
97 } | 97 } |
98 | 98 |
99 void StartSyncServiceAndSetInitialSyncEnded( | 99 void StartSyncServiceAndSetInitialSyncEnded( |
100 bool set_initial_sync_ended, | 100 bool set_initial_sync_ended, |
101 bool issue_auth_token, | 101 bool issue_auth_token, |
102 bool synchronous_sync_configuration, | 102 bool synchronous_sync_configuration, |
103 bool sync_setup_completed, | 103 bool sync_setup_completed, |
104 syncer::StorageOption storage_option) { | 104 syncer::StorageOption storage_option) { |
105 if (!service.get()) { | 105 if (!service.get()) { |
106 SigninManager* signin = | 106 SigninManagerBase* signin = |
107 SigninManagerFactory::GetForProfile(profile.get()); | 107 SigninManagerFactory::GetForProfile(profile.get()); |
108 signin->SetAuthenticatedUsername("test"); | 108 signin->SetAuthenticatedUsername("test"); |
109 ProfileSyncComponentsFactoryMock* factory = | 109 ProfileSyncComponentsFactoryMock* factory = |
110 new ProfileSyncComponentsFactoryMock(); | 110 new ProfileSyncComponentsFactoryMock(); |
111 service.reset(new TestProfileSyncService( | 111 service.reset(new TestProfileSyncService( |
112 factory, | 112 factory, |
113 profile.get(), | 113 profile.get(), |
114 signin, | 114 signin, |
115 ProfileSyncService::AUTO_START, | 115 ProfileSyncService::AUTO_START, |
116 true)); | 116 true)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 | 177 |
178 virtual void TearDown() { | 178 virtual void TearDown() { |
179 harness_.TearDown(); | 179 harness_.TearDown(); |
180 } | 180 } |
181 | 181 |
182 ProfileSyncServiceTestHarness harness_; | 182 ProfileSyncServiceTestHarness harness_; |
183 }; | 183 }; |
184 | 184 |
185 TEST_F(ProfileSyncServiceTest, InitialState) { | 185 TEST_F(ProfileSyncServiceTest, InitialState) { |
186 SigninManager* signin = | 186 SigninManagerBase* signin = |
187 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 187 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
188 harness_.service.reset(new TestProfileSyncService( | 188 harness_.service.reset(new TestProfileSyncService( |
189 new ProfileSyncComponentsFactoryMock(), | 189 new ProfileSyncComponentsFactoryMock(), |
190 harness_.profile.get(), | 190 harness_.profile.get(), |
191 signin, | 191 signin, |
192 ProfileSyncService::MANUAL_START, | 192 ProfileSyncService::MANUAL_START, |
193 true)); | 193 true)); |
194 harness_.service->Initialize(); | 194 harness_.service->Initialize(); |
195 EXPECT_TRUE( | 195 EXPECT_TRUE( |
196 harness_.service->sync_service_url().spec() == | 196 harness_.service->sync_service_url().spec() == |
(...skipping 13 matching lines...) Expand all Loading... |
210 EXPECT_TRUE(observer.first_setup_in_progress()); | 210 EXPECT_TRUE(observer.first_setup_in_progress()); |
211 service.SetSetupInProgress(false); | 211 service.SetSetupInProgress(false); |
212 EXPECT_FALSE(observer.first_setup_in_progress()); | 212 EXPECT_FALSE(observer.first_setup_in_progress()); |
213 service.RemoveObserver(&observer); | 213 service.RemoveObserver(&observer); |
214 } | 214 } |
215 | 215 |
216 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { | 216 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { |
217 harness_.profile->GetTestingPrefService()->SetManagedPref( | 217 harness_.profile->GetTestingPrefService()->SetManagedPref( |
218 prefs::kSyncManaged, | 218 prefs::kSyncManaged, |
219 Value::CreateBooleanValue(true)); | 219 Value::CreateBooleanValue(true)); |
220 SigninManager* signin = | 220 SigninManagerBase* signin = |
221 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 221 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
222 harness_.service.reset(new TestProfileSyncService( | 222 harness_.service.reset(new TestProfileSyncService( |
223 new ProfileSyncComponentsFactoryMock(), | 223 new ProfileSyncComponentsFactoryMock(), |
224 harness_.profile.get(), | 224 harness_.profile.get(), |
225 signin, | 225 signin, |
226 ProfileSyncService::MANUAL_START, | 226 ProfileSyncService::MANUAL_START, |
227 true)); | 227 true)); |
228 harness_.service->Initialize(); | 228 harness_.service->Initialize(); |
229 EXPECT_TRUE(harness_.service->IsManaged()); | 229 EXPECT_TRUE(harness_.service->IsManaged()); |
230 } | 230 } |
231 | 231 |
232 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 232 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { |
233 SigninManager* signin = | 233 SigninManagerBase* signin = |
234 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 234 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
235 signin->SetAuthenticatedUsername("test"); | 235 signin->SetAuthenticatedUsername("test"); |
236 ProfileSyncComponentsFactoryMock* factory = | 236 ProfileSyncComponentsFactoryMock* factory = |
237 new ProfileSyncComponentsFactoryMock(); | 237 new ProfileSyncComponentsFactoryMock(); |
238 harness_.service.reset(new TestProfileSyncService( | 238 harness_.service.reset(new TestProfileSyncService( |
239 factory, | 239 factory, |
240 harness_.profile.get(), | 240 harness_.profile.get(), |
241 signin, | 241 signin, |
242 ProfileSyncService::AUTO_START, | 242 ProfileSyncService::AUTO_START, |
243 true)); | 243 true)); |
244 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)).Times(0); | 244 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)).Times(0); |
245 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). | 245 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). |
246 Times(0); | 246 Times(0); |
247 harness_.service->RegisterDataTypeController( | 247 harness_.service->RegisterDataTypeController( |
248 new BookmarkDataTypeController(harness_.service->factory(), | 248 new BookmarkDataTypeController(harness_.service->factory(), |
249 harness_.profile.get(), | 249 harness_.profile.get(), |
250 harness_.service.get())); | 250 harness_.service.get())); |
251 | 251 |
252 harness_.service->Initialize(); | 252 harness_.service->Initialize(); |
253 harness_.service->Shutdown(); | 253 harness_.service->Shutdown(); |
254 harness_.service.reset(); | 254 harness_.service.reset(); |
255 } | 255 } |
256 | 256 |
257 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { | 257 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { |
258 SigninManager* signin = | 258 SigninManagerBase* signin = |
259 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 259 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
260 signin->SetAuthenticatedUsername("test"); | 260 signin->SetAuthenticatedUsername("test"); |
261 ProfileSyncComponentsFactoryMock* factory = | 261 ProfileSyncComponentsFactoryMock* factory = |
262 new ProfileSyncComponentsFactoryMock(); | 262 new ProfileSyncComponentsFactoryMock(); |
263 harness_.service.reset(new TestProfileSyncService( | 263 harness_.service.reset(new TestProfileSyncService( |
264 factory, | 264 factory, |
265 harness_.profile.get(), | 265 harness_.profile.get(), |
266 signin, | 266 signin, |
267 ProfileSyncService::AUTO_START, | 267 ProfileSyncService::AUTO_START, |
268 true)); | 268 true)); |
(...skipping 14 matching lines...) Expand all Loading... |
283 EXPECT_TRUE( | 283 EXPECT_TRUE( |
284 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 284 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
285 | 285 |
286 harness_.service->UnsuppressAndStart(); | 286 harness_.service->UnsuppressAndStart(); |
287 EXPECT_TRUE(harness_.service->sync_initialized()); | 287 EXPECT_TRUE(harness_.service->sync_initialized()); |
288 EXPECT_FALSE( | 288 EXPECT_FALSE( |
289 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 289 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
290 } | 290 } |
291 | 291 |
292 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { | 292 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { |
293 SigninManager* signin = | 293 SigninManagerBase* signin = |
294 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 294 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
295 signin->SetAuthenticatedUsername("test@test.com"); | 295 signin->SetAuthenticatedUsername("test@test.com"); |
296 ProfileSyncComponentsFactoryMock* factory = | 296 ProfileSyncComponentsFactoryMock* factory = |
297 new ProfileSyncComponentsFactoryMock(); | 297 new ProfileSyncComponentsFactoryMock(); |
298 harness_.service.reset(new TestProfileSyncService( | 298 harness_.service.reset(new TestProfileSyncService( |
299 factory, | 299 factory, |
300 harness_.profile.get(), | 300 harness_.profile.get(), |
301 signin, | 301 signin, |
302 ProfileSyncService::AUTO_START, | 302 ProfileSyncService::AUTO_START, |
303 true)); | 303 true)); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 namespace syncer { | 630 namespace syncer { |
631 namespace { | 631 namespace { |
632 | 632 |
633 // ProfileSyncService should behave just like an invalidator. | 633 // ProfileSyncService should behave just like an invalidator. |
634 INSTANTIATE_TYPED_TEST_CASE_P( | 634 INSTANTIATE_TYPED_TEST_CASE_P( |
635 ProfileSyncServiceInvalidatorTest, InvalidatorTest, | 635 ProfileSyncServiceInvalidatorTest, InvalidatorTest, |
636 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); | 636 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); |
637 | 637 |
638 } // namespace | 638 } // namespace |
639 } // namespace syncer | 639 } // namespace syncer |
OLD | NEW |