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

Unified Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 12897009: Autofill Webdata Split TRY ONLY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try again Created 7 years, 9 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/profile_sync_service_autofill_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index f82ba9608cb31dd2e43cb3b9747f0845012265f5..af128fd80b522810ab8bb1959bd487b3e2918ad5 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -40,7 +40,7 @@
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/autofill_table.h"
-#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/browser/webdata/autofill_web_data_service_impl.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/browser/webdata/web_data_service_test_util.h"
#include "chrome/browser/webdata/web_database.h"
@@ -144,10 +144,40 @@ syncer::ModelType GetModelType<AutofillProfile>() {
return syncer::AUTOFILL_PROFILE;
}
-class WebDataServiceFake : public WebDataService {
+class TokenWebDataServiceFake : public WebDataService {
+ public:
+ TokenWebDataServiceFake()
+ : WebDataService() {
+ }
+
+ virtual bool IsDatabaseLoaded() OVERRIDE {
+ return true;
+ }
+
+ virtual WebDataService::Handle GetAllTokens(
+ WebDataServiceConsumer* consumer) OVERRIDE {
+ // TODO(tim): It would be nice if WebDataService was injected on
+ // construction of TokenService rather than fetched by Initialize so that
+ // this isn't necessary (we could pass a NULL service). We currently do
+ // return it via EXPECT_CALLs, but without depending on order-of-
+ // initialization (which seems way more fragile) we can't tell which
+ // component is asking at what time, and some components in these Autofill
+ // tests require a WebDataService.
+ return 0;
+ }
+
+ private:
+ virtual ~TokenWebDataServiceFake() {}
+
+ DISALLOW_COPY_AND_ASSIGN(TokenWebDataServiceFake);
+};
+
+class WebDataServiceFake : public AutofillWebDataServiceImpl {
public:
WebDataServiceFake()
- : web_database_(NULL),
+ : AutofillWebDataServiceImpl(
+ NULL, WebDataServiceBase::ProfileErrorCallback()),
+ web_database_(NULL),
syncable_service_created_or_destroyed_(false, false) {
}
@@ -181,18 +211,6 @@ class WebDataServiceFake : public WebDataService {
return web_database_;
}
- virtual WebDataService::Handle GetAllTokens(
- WebDataServiceConsumer* consumer) OVERRIDE {
- // TODO(tim): It would be nice if WebDataService was injected on
- // construction of TokenService rather than fetched by Initialize so that
- // this isn't necessary (we could pass a NULL service). We currently do
- // return it via EXPECT_CALLs, but without depending on order-of-
- // initialization (which seems way more fragile) we can't tell which
- // component is asking at what time, and some components in these Autofill
- // tests require a WebDataService.
- return 0;
- }
-
virtual void ShutdownOnUIThread() OVERRIDE {}
private:
@@ -215,10 +233,14 @@ class WebDataServiceFake : public WebDataService {
WebDatabase* web_database_;
WaitableEvent syncable_service_created_or_destroyed_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebDataServiceFake);
};
ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) {
- return new MockWebDataServiceWrapper(new WebDataServiceFake());
+ return new MockWebDataServiceWrapper(
+ new TokenWebDataServiceFake(),
+ new WebDataServiceFake());
}
ACTION_P(MakeAutocompleteSyncComponents, wds) {
@@ -265,7 +287,7 @@ class AbstractAutofillFactory {
ProfileSyncService* service) = 0;
virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
ProfileSyncService* service,
- WebDataService* wds,
+ AutofillWebDataService* wds,
DataTypeController* dtc) = 0;
virtual ~AbstractAutofillFactory() {}
};
@@ -281,7 +303,7 @@ class AutofillEntryFactory : public AbstractAutofillFactory {
virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
ProfileSyncService* service,
- WebDataService* wds,
+ AutofillWebDataService* wds,
DataTypeController* dtc) OVERRIDE {
EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
WillOnce(MakeGenericChangeProcessor());
@@ -303,7 +325,7 @@ class AutofillProfileFactory : public AbstractAutofillFactory {
virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
ProfileSyncService* service,
- WebDataService* wds,
+ AutofillWebDataService* wds,
DataTypeController* dtc) OVERRIDE {
EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
WillOnce(MakeGenericChangeProcessor());
@@ -387,7 +409,7 @@ class ProfileSyncServiceAutofillTest
WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), BuildMockWebDataServiceWrapper));
web_data_service_ =
- static_cast<WebDataServiceFake*>(wrapper->GetWebData().get());
+ static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get());
web_data_service_->SetDatabase(web_database_.get());
MockPersonalDataManagerService* personal_data_manager_service =
@@ -466,7 +488,6 @@ class ProfileSyncServiceAutofillTest
sync_service_->RegisterDataTypeController(data_type_controller);
sync_service_->Initialize();
MessageLoop::current()->Run();
-
// It's possible this test triggered an unrecoverable error, in which case
// we can't get the sync count.
if (sync_service_->ShouldPushChanges()) {
@@ -1110,7 +1131,8 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddEntry) {
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
db_thread_.DeprecatedGetThreadObject()));
notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
- content::Source<WebDataService>(web_data_service_.get()),
+ content::Source<AutofillWebDataService>(
+ web_data_service_.get()),
content::Details<AutofillChangeList>(&changes));
std::vector<AutofillEntry> new_sync_entries;
@@ -1140,7 +1162,8 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
db_thread_.DeprecatedGetThreadObject()));
notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
- content::Source<WebDataService>(web_data_service_.get()),
+ content::Source<AutofillWebDataService>(
+ web_data_service_.get()),
content::Details<AutofillProfileChange>(&change));
std::vector<AutofillProfile> new_sync_profiles;
@@ -1174,7 +1197,8 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) {
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
db_thread_.DeprecatedGetThreadObject()));
notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
- content::Source<WebDataService>(web_data_service_.get()),
+ content::Source<AutofillWebDataService>(
+ web_data_service_.get()),
content::Details<AutofillChangeList>(&changes));
std::vector<AutofillEntry> new_sync_entries;
@@ -1204,7 +1228,8 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) {
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
db_thread_.DeprecatedGetThreadObject()));
notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
- content::Source<WebDataService>(web_data_service_.get()),
+ content::Source<AutofillWebDataService>(
+ web_data_service_.get()),
content::Details<AutofillChangeList>(&changes));
std::vector<AutofillEntry> new_sync_entries;
@@ -1243,7 +1268,8 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) {
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
db_thread_.DeprecatedGetThreadObject()));
notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
- content::Source<WebDataService>(web_data_service_.get()),
+ content::Source<AutofillWebDataService>(
+ web_data_service_.get()),
content::Details<AutofillProfileChange>(&change));
std::vector<AutofillProfile> new_sync_profiles;
« no previous file with comments | « chrome/browser/sync/profile_sync_components_factory_impl.cc ('k') | chrome/browser/sync/test/integration/autofill_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698