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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile 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..f9b520a73ba4adb9244d69a72f21c044b8c6817b 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);
@@ -66,6 +69,7 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
SyncAutofillDataTypeControllerTest()
: weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
ui_thread_(BrowserThread::UI, &message_loop_),
+ db_thread_(BrowserThread::DB),
last_start_result_(DataTypeController::OK) {}
virtual ~SyncAutofillDataTypeControllerTest() {}
@@ -80,10 +84,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,20 +102,24 @@ 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_;
content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread db_thread_;
scoped_refptr<NiceMock<SharedChangeProcessorMock> > change_processor_;
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 +131,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 +157,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