Index: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
index d8fc00b037fff5da458f896cbc15d0de997f7467..510b780bf3a6ebd5046b0cc30778dde0725e89bb 100644 |
--- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
+++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc |
@@ -14,6 +14,7 @@ |
#include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
#include "chrome/browser/sync/profile_sync_service_mock.h" |
#include "chrome/browser/webdata/web_data_service.h" |
+#include "chrome/browser/webdata/web_data_service_factory.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/test/base/profile_mock.h" |
#include "content/public/browser/notification_service.h" |
@@ -55,6 +56,8 @@ class FakeWebDataService : public WebDataService { |
return is_database_loaded_; |
} |
+ virtual void ShutdownOnUIThread() OVERRIDE {} |
+ |
private: |
DISALLOW_COPY_AND_ASSIGN(FakeWebDataService); |
@@ -80,10 +83,8 @@ class SyncAutofillDataTypeControllerTest : public testing::Test { |
CreateSharedChangeProcessor()). |
WillRepeatedly(Return(change_processor_.get())); |
- web_data_service_ = new FakeWebDataService(); |
- |
- EXPECT_CALL(profile_, GetWebDataService(_)). |
- WillRepeatedly(Return(web_data_service_.get())); |
+ WebDataServiceFactory::GetInstance()->SetTestingFactory( |
+ &profile_, BuildWebDataService); |
autofill_dtc_ = |
new AutofillDataTypeController(&profile_sync_factory_, |
@@ -100,10 +101,14 @@ class SyncAutofillDataTypeControllerTest : public testing::Test { |
virtual void TearDown() { |
autofill_dtc_ = NULL; |
- web_data_service_ = NULL; |
change_processor_ = NULL; |
} |
+ static scoped_refptr<RefcountedProfileKeyedService> |
+ BuildWebDataService(Profile* profile) { |
+ return new FakeWebDataService(); |
+ } |
+ |
protected: |
base::WeakPtrFactory<SyncAutofillDataTypeControllerTest> weak_ptr_factory_; |
MessageLoopForUI message_loop_; |
@@ -113,7 +118,6 @@ class SyncAutofillDataTypeControllerTest : public testing::Test { |
ProfileSyncComponentsFactoryMock profile_sync_factory_; |
ProfileSyncServiceMock service_; |
ProfileMock profile_; |
- scoped_refptr<FakeWebDataService> web_data_service_; |
scoped_refptr<AutofillDataTypeController> autofill_dtc_; |
// Stores arguments of most recent call of OnStartFinished(). |
@@ -125,7 +129,10 @@ class SyncAutofillDataTypeControllerTest : public testing::Test { |
// immediately try to start association and fail (due to missing DB |
// thread). |
TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) { |
- web_data_service_->LoadDatabase(); |
+ FakeWebDataService* web_db = |
+ static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile( |
+ &profile_, Profile::EXPLICIT_ACCESS).get()); |
+ web_db->LoadDatabase(); |
autofill_dtc_->Start( |
base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished, |
weak_ptr_factory_.GetWeakPtr())); |
@@ -148,7 +155,10 @@ TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) { |
EXPECT_FALSE(last_start_error_.IsSet()); |
EXPECT_EQ(DataTypeController::MODEL_STARTING, autofill_dtc_->state()); |
- web_data_service_->LoadDatabase(); |
+ FakeWebDataService* web_db = |
+ static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile( |
+ &profile_, Profile::EXPLICIT_ACCESS).get()); |
+ web_db->LoadDatabase(); |
EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_); |
EXPECT_TRUE(last_start_error_.IsSet()); |