| 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/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 16 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
| 17 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 17 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 18 #include "chrome/browser/signin/account_tracker_service_factory.h" | 18 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 22 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
| 23 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 23 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
| 24 #include "chrome/browser/sync/profile_sync_service.h" |
| 24 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 25 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/sync_util.h" | 28 #include "chrome/common/sync_util.h" |
| 28 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
| 29 #include "chrome/test/base/testing_browser_process.h" | 30 #include "chrome/test/base/testing_browser_process.h" |
| 30 #include "chrome/test/base/testing_pref_service_syncable.h" | 31 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 32 #include "chrome/test/base/testing_profile_manager.h" | 33 #include "chrome/test/base/testing_profile_manager.h" |
| 33 #include "components/invalidation/impl/profile_invalidation_provider.h" | 34 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 34 #include "components/invalidation/public/invalidation_service.h" | 35 #include "components/invalidation/public/invalidation_service.h" |
| 35 #include "components/signin/core/browser/account_tracker_service.h" | 36 #include "components/signin/core/browser/account_tracker_service.h" |
| 36 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 37 #include "components/signin/core/browser/signin_manager.h" | 38 #include "components/signin/core/browser/signin_manager.h" |
| 38 #include "components/signin/core/browser/signin_manager.h" | 39 #include "components/signin/core/browser/signin_manager.h" |
| 39 #include "components/sync_driver/data_type_manager.h" | 40 #include "components/sync_driver/data_type_manager.h" |
| 41 #include "components/sync_driver/data_type_manager_observer.h" |
| 40 #include "components/sync_driver/fake_data_type_controller.h" | 42 #include "components/sync_driver/fake_data_type_controller.h" |
| 41 #include "components/sync_driver/pref_names.h" | 43 #include "components/sync_driver/pref_names.h" |
| 42 #include "components/sync_driver/sync_prefs.h" | 44 #include "components/sync_driver/sync_prefs.h" |
| 45 #include "components/sync_driver/sync_service_observer.h" |
| 43 #include "components/version_info/version_info_values.h" | 46 #include "components/version_info/version_info_values.h" |
| 44 #include "content/public/test/test_browser_thread_bundle.h" | 47 #include "content/public/test/test_browser_thread_bundle.h" |
| 45 #include "google_apis/gaia/gaia_constants.h" | 48 #include "google_apis/gaia/gaia_constants.h" |
| 46 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
| 47 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
| 48 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| 49 | 52 |
| 50 namespace content { | 53 namespace content { |
| 51 class BrowserContext; | 54 class BrowserContext; |
| 52 } | 55 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 235 } |
| 233 | 236 |
| 234 void CreateService(ProfileSyncServiceStartBehavior behavior) { | 237 void CreateService(ProfileSyncServiceStartBehavior behavior) { |
| 235 SigninManagerBase* signin = | 238 SigninManagerBase* signin = |
| 236 SigninManagerFactory::GetForProfile(profile_); | 239 SigninManagerFactory::GetForProfile(profile_); |
| 237 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); | 240 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); |
| 238 ProfileOAuth2TokenService* oauth2_token_service = | 241 ProfileOAuth2TokenService* oauth2_token_service = |
| 239 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 242 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 240 components_factory_ = new ProfileSyncComponentsFactoryMock(); | 243 components_factory_ = new ProfileSyncComponentsFactoryMock(); |
| 241 service_.reset(new ProfileSyncService( | 244 service_.reset(new ProfileSyncService( |
| 242 scoped_ptr<ProfileSyncComponentsFactory>(components_factory_), | 245 scoped_ptr<sync_driver::SyncApiComponentFactory>(components_factory_), |
| 243 profile_, | 246 profile_, |
| 244 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile_, | 247 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile_, |
| 245 signin)), | 248 signin)), |
| 246 oauth2_token_service, | 249 oauth2_token_service, |
| 247 behavior)); | 250 behavior)); |
| 248 service_->SetClearingBrowseringDataForTesting( | 251 service_->SetClearingBrowseringDataForTesting( |
| 249 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, | 252 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, |
| 250 base::Unretained(this))); | 253 base::Unretained(this))); |
| 251 service_->RegisterDataTypeController( | 254 service_->RegisterDataTypeController( |
| 252 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); | 255 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 service_->OnDataTypeRequestsSyncStartup(syncer::BOOKMARKS); | 292 service_->OnDataTypeRequestsSyncStartup(syncer::BOOKMARKS); |
| 290 } | 293 } |
| 291 | 294 |
| 292 void ExpectDataTypeManagerCreation(int times) { | 295 void ExpectDataTypeManagerCreation(int times) { |
| 293 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _)) | 296 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _)) |
| 294 .Times(times) | 297 .Times(times) |
| 295 .WillRepeatedly(ReturnNewDataTypeManager()); | 298 .WillRepeatedly(ReturnNewDataTypeManager()); |
| 296 } | 299 } |
| 297 | 300 |
| 298 void ExpectSyncBackendHostCreation(int times) { | 301 void ExpectSyncBackendHostCreation(int times) { |
| 299 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) | 302 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)) |
| 300 .Times(times) | 303 .Times(times) |
| 301 .WillRepeatedly(ReturnNewSyncBackendHostMock()); | 304 .WillRepeatedly(ReturnNewSyncBackendHostMock()); |
| 302 } | 305 } |
| 303 | 306 |
| 304 void ExpectSyncBackendHostCreationCollectDeleteDir( | 307 void ExpectSyncBackendHostCreationCollectDeleteDir( |
| 305 int times, std::vector<bool> *delete_dir_param) { | 308 int times, std::vector<bool> *delete_dir_param) { |
| 306 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) | 309 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)) |
| 307 .Times(times) | 310 .Times(times) |
| 308 .WillRepeatedly(ReturnNewMockHostCollectDeleteDirParam( | 311 .WillRepeatedly(ReturnNewMockHostCollectDeleteDirParam( |
| 309 delete_dir_param)); | 312 delete_dir_param)); |
| 310 } | 313 } |
| 311 | 314 |
| 312 void PrepareDelayedInitSyncBackendHost() { | 315 void PrepareDelayedInitSyncBackendHost() { |
| 313 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)). | 316 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _)). |
| 314 WillOnce(ReturnNewSyncBackendHostNoReturn()); | 317 WillOnce(ReturnNewSyncBackendHostNoReturn()); |
| 315 } | 318 } |
| 316 | 319 |
| 317 TestingProfile* profile() { | 320 TestingProfile* profile() { |
| 318 return profile_; | 321 return profile_; |
| 319 } | 322 } |
| 320 | 323 |
| 321 ProfileSyncService* service() { | 324 ProfileSyncService* service() { |
| 322 return service_.get(); | 325 return service_.get(); |
| 323 } | 326 } |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 EXPECT_FALSE(sync_prefs.IsPassphrasePrompted()); | 774 EXPECT_FALSE(sync_prefs.IsPassphrasePrompted()); |
| 772 | 775 |
| 773 // At this point further datatype startup request should have no effect. | 776 // At this point further datatype startup request should have no effect. |
| 774 sync_prefs.SetPassphrasePrompted(true); | 777 sync_prefs.SetPassphrasePrompted(true); |
| 775 TriggerDataTypeStartRequest(); | 778 TriggerDataTypeStartRequest(); |
| 776 EXPECT_TRUE(sync_prefs.IsPassphrasePrompted()); | 779 EXPECT_TRUE(sync_prefs.IsPassphrasePrompted()); |
| 777 } | 780 } |
| 778 | 781 |
| 779 } // namespace | 782 } // namespace |
| 780 } // namespace browser_sync | 783 } // namespace browser_sync |
| OLD | NEW |