Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698