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/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 17 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
18 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 18 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
19 #include "chrome/browser/signin/account_tracker_service_factory.h" | 19 #include "chrome/browser/signin/account_tracker_service_factory.h" |
20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
22 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
23 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 23 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
24 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 24 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
| 25 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 26 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/sync_util.h" | 29 #include "chrome/common/sync_util.h" |
29 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
30 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
31 #include "chrome/test/base/testing_pref_service_syncable.h" | 32 #include "chrome/test/base/testing_pref_service_syncable.h" |
32 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
33 #include "chrome/test/base/testing_profile_manager.h" | 34 #include "chrome/test/base/testing_profile_manager.h" |
34 #include "components/invalidation/impl/profile_invalidation_provider.h" | 35 #include "components/invalidation/impl/profile_invalidation_provider.h" |
35 #include "components/invalidation/public/invalidation_service.h" | 36 #include "components/invalidation/public/invalidation_service.h" |
36 #include "components/signin/core/browser/account_tracker_service.h" | 37 #include "components/signin/core/browser/account_tracker_service.h" |
37 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 38 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
38 #include "components/signin/core/browser/signin_manager.h" | 39 #include "components/signin/core/browser/signin_manager.h" |
39 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/signin/core/browser/signin_manager.h" |
40 #include "components/sync_driver/data_type_manager.h" | 41 #include "components/sync_driver/data_type_manager.h" |
| 42 #include "components/sync_driver/data_type_manager_observer.h" |
41 #include "components/sync_driver/fake_data_type_controller.h" | 43 #include "components/sync_driver/fake_data_type_controller.h" |
42 #include "components/sync_driver/pref_names.h" | 44 #include "components/sync_driver/pref_names.h" |
43 #include "components/sync_driver/sync_prefs.h" | 45 #include "components/sync_driver/sync_prefs.h" |
| 46 #include "components/sync_driver/sync_service_observer.h" |
44 #include "components/version_info/version_info_values.h" | 47 #include "components/version_info/version_info_values.h" |
45 #include "content/public/test/test_browser_thread_bundle.h" | 48 #include "content/public/test/test_browser_thread_bundle.h" |
46 #include "google_apis/gaia/gaia_constants.h" | 49 #include "google_apis/gaia/gaia_constants.h" |
47 #include "testing/gmock/include/gmock/gmock.h" | 50 #include "testing/gmock/include/gmock/gmock.h" |
48 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
49 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
50 | 53 |
51 namespace content { | 54 namespace content { |
52 class BrowserContext; | 55 class BrowserContext; |
53 } | 56 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 268 } |
266 | 269 |
267 void CreateService(ProfileSyncServiceStartBehavior behavior) { | 270 void CreateService(ProfileSyncServiceStartBehavior behavior) { |
268 SigninManagerBase* signin = | 271 SigninManagerBase* signin = |
269 SigninManagerFactory::GetForProfile(profile_); | 272 SigninManagerFactory::GetForProfile(profile_); |
270 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); | 273 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); |
271 ProfileOAuth2TokenService* oauth2_token_service = | 274 ProfileOAuth2TokenService* oauth2_token_service = |
272 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 275 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
273 components_factory_ = new ProfileSyncComponentsFactoryMock(); | 276 components_factory_ = new ProfileSyncComponentsFactoryMock(); |
274 service_.reset(new ProfileSyncService( | 277 service_.reset(new ProfileSyncService( |
275 scoped_ptr<ProfileSyncComponentsFactory>(components_factory_), | 278 scoped_ptr<sync_driver::SyncApiComponentFactory>(components_factory_), |
276 profile_, | 279 profile_, |
277 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile_, | 280 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile_, |
278 signin)), | 281 signin)), |
279 oauth2_token_service, | 282 oauth2_token_service, |
280 behavior)); | 283 behavior)); |
281 service_->SetClearingBrowseringDataForTesting( | 284 service_->SetClearingBrowseringDataForTesting( |
282 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, | 285 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, |
283 base::Unretained(this))); | 286 base::Unretained(this))); |
284 service_->RegisterDataTypeController( | 287 service_->RegisterDataTypeController( |
285 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); | 288 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 350 |
348 void ExpectDataTypeManagerCreation( | 351 void ExpectDataTypeManagerCreation( |
349 int times, | 352 int times, |
350 const FakeDataTypeManager::ConfigureCalled& callback) { | 353 const FakeDataTypeManager::ConfigureCalled& callback) { |
351 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _)) | 354 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _)) |
352 .Times(times) | 355 .Times(times) |
353 .WillRepeatedly(ReturnNewDataTypeManager(callback)); | 356 .WillRepeatedly(ReturnNewDataTypeManager(callback)); |
354 } | 357 } |
355 | 358 |
356 void ExpectSyncBackendHostCreation(int times) { | 359 void ExpectSyncBackendHostCreation(int times) { |
357 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) | 360 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)) |
358 .Times(times) | 361 .Times(times) |
359 .WillRepeatedly(ReturnNewSyncBackendHostMock()); | 362 .WillRepeatedly(ReturnNewSyncBackendHostMock()); |
360 } | 363 } |
361 | 364 |
362 void ExpectSyncBackendHostCreationCollectDeleteDir( | 365 void ExpectSyncBackendHostCreationCollectDeleteDir( |
363 int times, std::vector<bool> *delete_dir_param) { | 366 int times, std::vector<bool> *delete_dir_param) { |
364 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) | 367 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)) |
365 .Times(times) | 368 .Times(times) |
366 .WillRepeatedly(ReturnNewMockHostCollectDeleteDirParam( | 369 .WillRepeatedly(ReturnNewMockHostCollectDeleteDirParam( |
367 delete_dir_param)); | 370 delete_dir_param)); |
368 } | 371 } |
369 | 372 |
370 void ExpectSyncBackendHostCreationCaptureClearServerData( | 373 void ExpectSyncBackendHostCreationCaptureClearServerData( |
371 syncer::SyncManager::ClearServerDataCallback* captured_callback) { | 374 syncer::SyncManager::ClearServerDataCallback* captured_callback) { |
372 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) | 375 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)) |
373 .Times(1) | 376 .Times(1) |
374 .WillOnce(ReturnNewMockHostCaptureClearServerData(captured_callback)); | 377 .WillOnce(ReturnNewMockHostCaptureClearServerData(captured_callback)); |
375 } | 378 } |
376 | 379 |
377 void PrepareDelayedInitSyncBackendHost() { | 380 void PrepareDelayedInitSyncBackendHost() { |
378 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)). | 381 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)). |
379 WillOnce(ReturnNewSyncBackendHostNoReturn()); | 382 WillOnce(ReturnNewSyncBackendHostNoReturn()); |
380 } | 383 } |
381 | 384 |
382 TestingProfile* profile() { | 385 TestingProfile* profile() { |
383 return profile_; | 386 return profile_; |
384 } | 387 } |
385 | 388 |
386 ProfileSyncService* service() { | 389 ProfileSyncService* service() { |
387 return service_.get(); | 390 return service_.get(); |
388 } | 391 } |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 EXPECT_FALSE(sync_prefs.IsPassphrasePrompted()); | 975 EXPECT_FALSE(sync_prefs.IsPassphrasePrompted()); |
973 | 976 |
974 // At this point further datatype startup request should have no effect. | 977 // At this point further datatype startup request should have no effect. |
975 sync_prefs.SetPassphrasePrompted(true); | 978 sync_prefs.SetPassphrasePrompted(true); |
976 TriggerDataTypeStartRequest(); | 979 TriggerDataTypeStartRequest(); |
977 EXPECT_TRUE(sync_prefs.IsPassphrasePrompted()); | 980 EXPECT_TRUE(sync_prefs.IsPassphrasePrompted()); |
978 } | 981 } |
979 | 982 |
980 } // namespace | 983 } // namespace |
981 } // namespace browser_sync | 984 } // namespace browser_sync |
OLD | NEW |