Index: chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc |
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc b/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc |
index 22d77a351ae5d4a10d4193597c9d61585e7e5d49..17335bb5cc613aa3042daa26f4099dfbafb47df6 100644 |
--- a/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc |
+++ b/chrome/browser/sync/profile_sync_components_factory_impl_unittest.cc |
@@ -8,9 +8,11 @@ |
#include "base/file_path.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop.h" |
+#include "base/synchronization/waitable_event.h" |
#include "chrome/browser/sync/glue/data_type_controller.h" |
#include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
#include "chrome/browser/sync/profile_sync_service.h" |
+#include "chrome/browser/webdata/web_data_service_factory.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/test/base/testing_profile.h" |
#include "content/test/test_browser_thread.h" |
@@ -22,14 +24,27 @@ using content::BrowserThread; |
class ProfileSyncComponentsFactoryImplTest : public testing::Test { |
protected: |
ProfileSyncComponentsFactoryImplTest() |
- : ui_thread_(BrowserThread::UI, &message_loop_) {} |
+ : ui_thread_(BrowserThread::UI, &message_loop_), |
+ db_thread_(BrowserThread::DB) {} |
- virtual void SetUp() { |
+ virtual void SetUp() OVERRIDE { |
+ db_thread_.Start(); |
profile_.reset(new TestingProfile()); |
FilePath program_path(FILE_PATH_LITERAL("chrome.exe")); |
command_line_.reset(new CommandLine(program_path)); |
} |
+ virtual void TearDown() OVERRIDE { |
+ profile_.reset(); |
+ // Schedule another task on the DB thread to notify us that it's safe to |
+ // carry on with the test. |
+ base::WaitableEvent done(false, false); |
+ BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
+ base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
+ done.Wait(); |
+ db_thread_.Stop(); |
+ } |
+ |
// Returns the collection of default datatypes. |
static std::vector<syncable::ModelType> DefaultDatatypes() { |
std::vector<syncable::ModelType> datatypes; |
@@ -78,6 +93,8 @@ class ProfileSyncComponentsFactoryImplTest : public testing::Test { |
void TestSwitchDisablesType(const char* cmd_switch, |
syncable::ModelType type) { |
command_line_->AppendSwitch(cmd_switch); |
+ WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_.get(), |
+ NULL); |
scoped_ptr<ProfileSyncService> pss( |
new ProfileSyncService( |
new ProfileSyncComponentsFactoryImpl(profile_.get(), |
@@ -94,11 +111,14 @@ class ProfileSyncComponentsFactoryImplTest : public testing::Test { |
MessageLoop message_loop_; |
content::TestBrowserThread ui_thread_; |
+ content::TestBrowserThread db_thread_; |
scoped_ptr<Profile> profile_; |
scoped_ptr<CommandLine> command_line_; |
}; |
TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { |
+ WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_.get(), |
+ NULL); |
scoped_ptr<ProfileSyncService> pss( |
new ProfileSyncService( |
new ProfileSyncComponentsFactoryImpl(profile_.get(), |