diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 21:37:14 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 21:37:14 +0000 |
commit | 4c21758a04827937155a4f5f4f6c0175894e9acd (patch) | |
tree | 5c8f179369cb54d7de1f7d6f6a4254a13cb69e17 /chrome/browser | |
parent | cd1454e93e232cdbd0569f363d5020e6c750dc35 (diff) | |
download | chromium_src-4c21758a04827937155a4f5f4f6c0175894e9acd.zip chromium_src-4c21758a04827937155a4f5f4f6c0175894e9acd.tar.gz chromium_src-4c21758a04827937155a4f5f4f6c0175894e9acd.tar.bz2 |
Folded TestingProfileSyncService class into TestProfileSyncService.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/2064002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 39 insertions, 48 deletions
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc index ee5c4c2..7679732 100644 --- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc @@ -26,6 +26,7 @@ #include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" #include "chrome/browser/sync/syncable/directory_manager.h" +#include "chrome/browser/sync/test_profile_sync_service.h" #include "chrome/browser/webdata/autofill_change.h" #include "chrome/browser/webdata/autofill_entry.h" #include "chrome/browser/webdata/web_database.h" @@ -95,7 +96,8 @@ class WebDatabaseMock : public WebDatabase { class WebDataServiceFake : public WebDataService { public: - WebDataServiceFake(WebDatabase* web_database) : web_database_(web_database) {} + explicit WebDataServiceFake(WebDatabase* web_database) + : web_database_(web_database) {} virtual bool IsDatabaseLoaded() { return true; } @@ -152,7 +154,7 @@ class ProfileSyncServiceAutofillTest : public testing::Test { void StartSyncService(Task* task) { if (!service_.get()) { service_.reset( - new TestingProfileSyncService(&factory_, &profile_, false)); + new TestProfileSyncService(&factory_, &profile_, false, false)); service_->AddObserver(&observer_); AutofillDataTypeController* data_type_controller = new AutofillDataTypeController(&factory_, @@ -311,7 +313,7 @@ class ProfileSyncServiceAutofillTest : public testing::Test { ChromeThread db_thread_; scoped_refptr<ThreadNotificationService> notification_service_; - scoped_ptr<TestingProfileSyncService> service_; + scoped_ptr<TestProfileSyncService> service_; ProfileMock profile_; ProfileSyncFactoryMock factory_; ProfileSyncServiceObserverMock observer_; diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index 0c3bd2d..3b0f68d 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -50,7 +50,8 @@ class ProfileSyncServicePreferenceTest : public testing::Test { if (!service_.get()) { service_.reset(new TestProfileSyncService(&factory_, profile_.get(), - false)); + false, + true)); // Register the preference data type. model_associator_ = diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index ad51f7d..f8f4e7a 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -50,7 +50,8 @@ class ProfileSyncServiceStartupTest : public testing::Test { } virtual void SetUp() { - service_.reset(new TestProfileSyncService(&factory_, &profile_, false)); + service_.reset(new TestProfileSyncService(&factory_, &profile_, + false, true)); service_->AddObserver(&observer_); } @@ -137,7 +138,8 @@ class ProfileSyncServiceStartupBootstrapTest virtual ~ProfileSyncServiceStartupBootstrapTest() {} virtual void SetUp() { - service_.reset(new TestProfileSyncService(&factory_, &profile_, true)); + service_.reset(new TestProfileSyncService(&factory_, &profile_, + true, true)); service_->AddObserver(&observer_); } }; diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc index 2872cf6..6194c6a 100644 --- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc @@ -25,6 +25,7 @@ #include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" #include "chrome/browser/sync/syncable/directory_manager.h" +#include "chrome/browser/sync/test_profile_sync_service.h" #include "chrome/common/notification_service.h" #include "chrome/test/profile_mock.h" #include "chrome/test/sync/engine/test_id_factory.h" @@ -152,7 +153,7 @@ class ProfileSyncServiceTypedUrlTest : public testing::Test { void StartSyncService(Task* task) { if (!service_.get()) { service_.reset( - new TestingProfileSyncService(&factory_, &profile_, false)); + new TestProfileSyncService(&factory_, &profile_, false, false)); service_->AddObserver(&observer_); TypedUrlDataTypeController* data_type_controller = new TypedUrlDataTypeController(&factory_, @@ -297,7 +298,7 @@ class ProfileSyncServiceTypedUrlTest : public testing::Test { Thread history_thread_; scoped_refptr<ThreadNotificationService> notification_service_; - scoped_ptr<TestingProfileSyncService> service_; + scoped_ptr<TestProfileSyncService> service_; ProfileMock profile_; ProfileSyncFactoryMock factory_; SyncBackendHostMock backend_mock_; diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index 7bd90c0..cb4da3c 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -232,7 +232,7 @@ class ProfileSyncServiceTest : public testing::Test { if (!service_.get()) { service_.reset(new TestProfileSyncService(&factory_, profile_.get(), - false)); + false, true)); // Register the bookmark data type. model_associator_ = new TestBookmarkModelAssociator(service_.get()); @@ -445,7 +445,8 @@ TEST_F(ProfileSyncServiceTest, InitialState) { } TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { - service_.reset(new TestProfileSyncService(&factory_, profile_.get(), false)); + service_.reset(new TestProfileSyncService(&factory_, profile_.get(), + false, true)); EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). WillOnce(MakeDataTypeManager(&backend_mock_)); EXPECT_CALL(factory_, CreateBookmarkSyncComponents(_, _)).Times(0); @@ -1326,7 +1327,8 @@ TEST_F(ProfileSyncServiceTestWithData, MAYBE_TestStartupWithOldSyncData) { LoadBookmarkModel(LOAD_FROM_STORAGE, SAVE_TO_STORAGE); if (!service_.get()) { service_.reset( - new TestProfileSyncService(&factory_, profile_.get(), false)); + new TestProfileSyncService(&factory_, profile_.get(), + false, true)); profile_->GetPrefs()->SetBoolean(prefs::kSyncHasSetupCompleted, false); model_associator_ = new TestBookmarkModelAssociator(service_.get()); diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h index eeedc2d..4dbc1cc 100644 --- a/chrome/browser/sync/profile_sync_test_util.h +++ b/chrome/browser/sync/profile_sync_test_util.h @@ -118,35 +118,6 @@ class ProfileSyncServiceObserverMock : public ProfileSyncServiceObserver { MOCK_METHOD0(OnStateChanged, void()); }; -class TestingProfileSyncService : public ProfileSyncService { - public: - explicit TestingProfileSyncService(ProfileSyncFactory* factory, - Profile* profile, - bool bootstrap_sync_authentication) - : ProfileSyncService(factory, profile, bootstrap_sync_authentication) { - RegisterPreferences(); - SetSyncSetupCompleted(); - } - virtual ~TestingProfileSyncService() { - } - - virtual void InitializeBackend(bool delete_sync_data_folder) { - browser_sync::TestHttpBridgeFactory* factory = - new browser_sync::TestHttpBridgeFactory(); - browser_sync::TestHttpBridgeFactory* factory2 = - new browser_sync::TestHttpBridgeFactory(); - backend()->InitializeForTestMode(L"testuser", factory, factory2, - delete_sync_data_folder, browser_sync::kDefaultNotificationMethod); - } - - private: - // When testing under ChromiumOS, this method must not return an empty - // value value in order for the profile sync service to start. - virtual std::string GetLsidForAuthBootstraping() { - return "foo"; - } -}; - class ThreadNotificationService : public base::RefCountedThreadSafe<ThreadNotificationService> { public: diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h index 9efd5d2..d8c7a1e 100644 --- a/chrome/browser/sync/test_profile_sync_service.h +++ b/chrome/browser/sync/test_profile_sync_service.h @@ -17,8 +17,11 @@ class TestProfileSyncService : public ProfileSyncService { public: explicit TestProfileSyncService(ProfileSyncFactory* factory, Profile* profile, - bool bootstrap_sync_authentication) - : ProfileSyncService(factory, profile, bootstrap_sync_authentication) { + bool bootstrap_sync_authentication, + bool synchronous_backend_initialization) + : ProfileSyncService(factory, profile, bootstrap_sync_authentication), + synchronous_backend_initialization_( + synchronous_backend_initialization) { RegisterPreferences(); SetSyncSetupCompleted(); } @@ -32,16 +35,23 @@ class TestProfileSyncService : public ProfileSyncService { new browser_sync::TestHttpBridgeFactory(); backend()->InitializeForTestMode(L"testuser", factory, factory2, delete_sync_data_folder, browser_sync::kDefaultNotificationMethod); - // The SyncBackend posts a task to the current loop when initialization - // completes. - MessageLoop::current()->Run(); - // Initialization is synchronous for test mode, so we should be good to go. - DCHECK(sync_initialized()); + // TODO(akalin): Figure out a better way to do this. + if (synchronous_backend_initialization_) { + // The SyncBackend posts a task to the current loop when + // initialization completes. + MessageLoop::current()->Run(); + // Initialization is synchronous for test mode, so we should be + // good to go. + DCHECK(sync_initialized()); + } } virtual void OnBackendInitialized() { ProfileSyncService::OnBackendInitialized(); - MessageLoop::current()->Quit(); + // TODO(akalin): Figure out a better way to do this. + if (synchronous_backend_initialization_) { + MessageLoop::current()->Quit(); + } } private: @@ -50,6 +60,8 @@ class TestProfileSyncService : public ProfileSyncService { virtual std::string GetLsidForAuthBootstraping() { return "foo"; } + + bool synchronous_backend_initialization_; }; #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |