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

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 12695015: Split Autofill webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Convert all Autofill/Sync clients of WDS to using AutofillWDS 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/sync/profile_sync_components_factory.h" 33 #include "chrome/browser/sync/profile_sync_components_factory.h"
34 #include "chrome/browser/sync/profile_sync_service.h" 34 #include "chrome/browser/sync/profile_sync_service.h"
35 #include "chrome/browser/sync/profile_sync_service_factory.h" 35 #include "chrome/browser/sync/profile_sync_service_factory.h"
36 #include "chrome/browser/sync/profile_sync_test_util.h" 36 #include "chrome/browser/sync/profile_sync_test_util.h"
37 #include "chrome/browser/sync/test_profile_sync_service.h" 37 #include "chrome/browser/sync/test_profile_sync_service.h"
38 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 38 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
39 #include "chrome/browser/webdata/autofill_change.h" 39 #include "chrome/browser/webdata/autofill_change.h"
40 #include "chrome/browser/webdata/autofill_entry.h" 40 #include "chrome/browser/webdata/autofill_entry.h"
41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
42 #include "chrome/browser/webdata/autofill_table.h" 42 #include "chrome/browser/webdata/autofill_table.h"
43 #include "chrome/browser/webdata/web_data_service.h" 43 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
44 #include "chrome/browser/webdata/web_data_service_factory.h" 44 #include "chrome/browser/webdata/web_data_service_factory.h"
45 #include "chrome/browser/webdata/web_data_service_test_util.h" 45 #include "chrome/browser/webdata/web_data_service_test_util.h"
46 #include "chrome/browser/webdata/web_database.h" 46 #include "chrome/browser/webdata/web_database.h"
47 #include "chrome/common/chrome_notification_types.h" 47 #include "chrome/common/chrome_notification_types.h"
48 #include "components/autofill/browser/autofill_common_test.h" 48 #include "components/autofill/browser/autofill_common_test.h"
49 #include "components/autofill/browser/personal_data_manager.h" 49 #include "components/autofill/browser/personal_data_manager.h"
50 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
51 #include "content/public/test/test_browser_thread.h" 51 #include "content/public/test/test_browser_thread.h"
52 #include "google_apis/gaia/gaia_constants.h" 52 #include "google_apis/gaia/gaia_constants.h"
53 #include "sync/internal_api/public/base/model_type.h" 53 #include "sync/internal_api/public/base/model_type.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 template<> 137 template<>
138 syncer::ModelType GetModelType<AutofillEntry>() { 138 syncer::ModelType GetModelType<AutofillEntry>() {
139 return syncer::AUTOFILL; 139 return syncer::AUTOFILL;
140 } 140 }
141 141
142 template<> 142 template<>
143 syncer::ModelType GetModelType<AutofillProfile>() { 143 syncer::ModelType GetModelType<AutofillProfile>() {
144 return syncer::AUTOFILL_PROFILE; 144 return syncer::AUTOFILL_PROFILE;
145 } 145 }
146 146
147 class WebDataServiceFake : public WebDataService { 147 class TokenWebDataServiceFake : public WebDataService {
148 public:
149 TokenWebDataServiceFake()
150 : WebDataService() {
151 }
152
153 virtual WebDataService::Handle GetAllTokens(
154 WebDataServiceConsumer* consumer) OVERRIDE {
155 // TODO(tim): It would be nice if WebDataService was injected on
156 // construction of TokenService rather than fetched by Initialize so that
157 // this isn't necessary (we could pass a NULL service). We currently do
158 // return it via EXPECT_CALLs, but without depending on order-of-
159 // initialization (which seems way more fragile) we can't tell which
160 // component is asking at what time, and some components in these Autofill
161 // tests require a WebDataService.
162 return 0;
163 }
164
165 };
166
167 class WebDataServiceFake : public AutofillWebDataServiceImpl {
148 public: 168 public:
149 WebDataServiceFake() 169 WebDataServiceFake()
150 : web_database_(NULL), 170 : AutofillWebDataServiceImpl(
171 NULL, WebDataServiceBase::ProfileErrorCallback()),
172 web_database_(NULL),
151 syncable_service_created_or_destroyed_(false, false) { 173 syncable_service_created_or_destroyed_(false, false) {
152 } 174 }
153 175
154 void SetDatabase(WebDatabase* web_database) { 176 void SetDatabase(WebDatabase* web_database) {
155 web_database_ = web_database; 177 web_database_ = web_database;
156 } 178 }
157 179
158 void StartSyncableService() { 180 void StartSyncableService() {
159 // The |autofill_profile_syncable_service_| must be constructed on the DB 181 // The |autofill_profile_syncable_service_| must be constructed on the DB
160 // thread. 182 // thread.
(...skipping 13 matching lines...) Expand all
174 } 196 }
175 197
176 virtual bool IsDatabaseLoaded() OVERRIDE { 198 virtual bool IsDatabaseLoaded() OVERRIDE {
177 return true; 199 return true;
178 } 200 }
179 201
180 virtual WebDatabase* GetDatabase() OVERRIDE { 202 virtual WebDatabase* GetDatabase() OVERRIDE {
181 return web_database_; 203 return web_database_;
182 } 204 }
183 205
184 virtual WebDataService::Handle GetAllTokens(
185 WebDataServiceConsumer* consumer) OVERRIDE {
186 // TODO(tim): It would be nice if WebDataService was injected on
187 // construction of TokenService rather than fetched by Initialize so that
188 // this isn't necessary (we could pass a NULL service). We currently do
189 // return it via EXPECT_CALLs, but without depending on order-of-
190 // initialization (which seems way more fragile) we can't tell which
191 // component is asking at what time, and some components in these Autofill
192 // tests require a WebDataService.
193 return 0;
194 }
195
196 virtual void ShutdownOnUIThread() OVERRIDE {} 206 virtual void ShutdownOnUIThread() OVERRIDE {}
197 207
198 private: 208 private:
199 virtual ~WebDataServiceFake() {} 209 virtual ~WebDataServiceFake() {}
200 210
201 void CreateSyncableService() { 211 void CreateSyncableService() {
202 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 212 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
203 // These services are deleted in DestroySyncableService(). 213 // These services are deleted in DestroySyncableService().
204 AutocompleteSyncableService::CreateForWebDataService(this); 214 AutocompleteSyncableService::CreateForWebDataService(this);
205 AutofillProfileSyncableService::CreateForWebDataService(this); 215 AutofillProfileSyncableService::CreateForWebDataService(this);
206 syncable_service_created_or_destroyed_.Signal(); 216 syncable_service_created_or_destroyed_.Signal();
207 } 217 }
208 218
209 void DestroySyncableService() { 219 void DestroySyncableService() {
210 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 220 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
211 WebDataServiceBase::ShutdownOnDBThread(); 221 WebDataServiceBase::ShutdownOnDBThread();
212 syncable_service_created_or_destroyed_.Signal(); 222 syncable_service_created_or_destroyed_.Signal();
213 } 223 }
214 224
215 WebDatabase* web_database_; 225 WebDatabase* web_database_;
216 226
217 WaitableEvent syncable_service_created_or_destroyed_; 227 WaitableEvent syncable_service_created_or_destroyed_;
218 }; 228 };
219 229
220 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) { 230 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) {
221 return new MockWebDataServiceWrapper(new WebDataServiceFake()); 231 return new MockWebDataServiceWrapper(
232 new TokenWebDataServiceFake(),
233 new WebDataServiceFake());
222 } 234 }
223 235
224 ACTION_P(MakeAutocompleteSyncComponents, wds) { 236 ACTION_P(MakeAutocompleteSyncComponents, wds) {
225 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 237 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
226 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 238 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
227 return base::WeakPtr<syncer::SyncableService>(); 239 return base::WeakPtr<syncer::SyncableService>();
228 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr(); 240 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr();
229 } 241 }
230 242
231 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { 243 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) {
(...skipping 26 matching lines...) Expand all
258 } 270 }
259 271
260 class AbstractAutofillFactory { 272 class AbstractAutofillFactory {
261 public: 273 public:
262 virtual DataTypeController* CreateDataTypeController( 274 virtual DataTypeController* CreateDataTypeController(
263 ProfileSyncComponentsFactory* factory, 275 ProfileSyncComponentsFactory* factory,
264 ProfileMock* profile, 276 ProfileMock* profile,
265 ProfileSyncService* service) = 0; 277 ProfileSyncService* service) = 0;
266 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 278 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
267 ProfileSyncService* service, 279 ProfileSyncService* service,
268 WebDataService* wds, 280 AutofillWebDataService* wds,
269 DataTypeController* dtc) = 0; 281 DataTypeController* dtc) = 0;
270 virtual ~AbstractAutofillFactory() {} 282 virtual ~AbstractAutofillFactory() {}
271 }; 283 };
272 284
273 class AutofillEntryFactory : public AbstractAutofillFactory { 285 class AutofillEntryFactory : public AbstractAutofillFactory {
274 public: 286 public:
275 virtual browser_sync::DataTypeController* CreateDataTypeController( 287 virtual browser_sync::DataTypeController* CreateDataTypeController(
276 ProfileSyncComponentsFactory* factory, 288 ProfileSyncComponentsFactory* factory,
277 ProfileMock* profile, 289 ProfileMock* profile,
278 ProfileSyncService* service) OVERRIDE { 290 ProfileSyncService* service) OVERRIDE {
279 return new AutofillDataTypeController(factory, profile, service); 291 return new AutofillDataTypeController(factory, profile, service);
280 } 292 }
281 293
282 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 294 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
283 ProfileSyncService* service, 295 ProfileSyncService* service,
284 WebDataService* wds, 296 AutofillWebDataService* wds,
285 DataTypeController* dtc) OVERRIDE { 297 DataTypeController* dtc) OVERRIDE {
286 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 298 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
287 WillOnce(MakeGenericChangeProcessor()); 299 WillOnce(MakeGenericChangeProcessor());
288 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 300 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
289 WillOnce(MakeSharedChangeProcessor()); 301 WillOnce(MakeSharedChangeProcessor());
290 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)). 302 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)).
291 WillOnce(MakeAutocompleteSyncComponents(wds)); 303 WillOnce(MakeAutocompleteSyncComponents(wds));
292 } 304 }
293 }; 305 };
294 306
295 class AutofillProfileFactory : public AbstractAutofillFactory { 307 class AutofillProfileFactory : public AbstractAutofillFactory {
296 public: 308 public:
297 virtual browser_sync::DataTypeController* CreateDataTypeController( 309 virtual browser_sync::DataTypeController* CreateDataTypeController(
298 ProfileSyncComponentsFactory* factory, 310 ProfileSyncComponentsFactory* factory,
299 ProfileMock* profile, 311 ProfileMock* profile,
300 ProfileSyncService* service) OVERRIDE { 312 ProfileSyncService* service) OVERRIDE {
301 return new AutofillProfileDataTypeController(factory, profile, service); 313 return new AutofillProfileDataTypeController(factory, profile, service);
302 } 314 }
303 315
304 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 316 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
305 ProfileSyncService* service, 317 ProfileSyncService* service,
306 WebDataService* wds, 318 AutofillWebDataService* wds,
307 DataTypeController* dtc) OVERRIDE { 319 DataTypeController* dtc) OVERRIDE {
308 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 320 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
309 WillOnce(MakeGenericChangeProcessor()); 321 WillOnce(MakeGenericChangeProcessor());
310 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 322 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
311 WillOnce(MakeSharedChangeProcessor()); 323 WillOnce(MakeSharedChangeProcessor());
312 EXPECT_CALL(*factory, 324 EXPECT_CALL(*factory,
313 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)). 325 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)).
314 WillOnce(MakeAutofillProfileSyncComponents(wds)); 326 WillOnce(MakeAutofillProfileSyncComponents(wds));
315 } 327 }
316 }; 328 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 virtual void SetUp() OVERRIDE { 392 virtual void SetUp() OVERRIDE {
381 AbstractProfileSyncServiceTest::SetUp(); 393 AbstractProfileSyncServiceTest::SetUp();
382 profile_.reset(new ProfileMock()); 394 profile_.reset(new ProfileMock());
383 profile_->CreateRequestContext(); 395 profile_->CreateRequestContext();
384 web_database_.reset(new WebDatabaseFake(&autofill_table_)); 396 web_database_.reset(new WebDatabaseFake(&autofill_table_));
385 MockWebDataServiceWrapper* wrapper = 397 MockWebDataServiceWrapper* wrapper =
386 static_cast<MockWebDataServiceWrapper*>( 398 static_cast<MockWebDataServiceWrapper*>(
387 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( 399 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
388 profile_.get(), BuildMockWebDataServiceWrapper)); 400 profile_.get(), BuildMockWebDataServiceWrapper));
389 web_data_service_ = 401 web_data_service_ =
390 static_cast<WebDataServiceFake*>(wrapper->GetWebData().get()); 402 static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get());
391 web_data_service_->SetDatabase(web_database_.get()); 403 web_data_service_->SetDatabase(web_database_.get());
392 404
393 MockPersonalDataManagerService* personal_data_manager_service = 405 MockPersonalDataManagerService* personal_data_manager_service =
394 static_cast<MockPersonalDataManagerService*>( 406 static_cast<MockPersonalDataManagerService*>(
395 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( 407 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse(
396 profile_.get(), MockPersonalDataManagerService::Build)); 408 profile_.get(), MockPersonalDataManagerService::Build));
397 personal_data_manager_ = 409 personal_data_manager_ =
398 personal_data_manager_service->GetPersonalDataManager(); 410 personal_data_manager_service->GetPersonalDataManager();
399 411
400 token_service_ = static_cast<TokenService*>( 412 token_service_ = static_cast<TokenService*>(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 471
460 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). 472 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()).
461 WillRepeatedly(Return(true)); 473 WillRepeatedly(Return(true));
462 474
463 // We need tokens to get the tests going 475 // We need tokens to get the tests going
464 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token"); 476 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token");
465 477
466 sync_service_->RegisterDataTypeController(data_type_controller); 478 sync_service_->RegisterDataTypeController(data_type_controller);
467 sync_service_->Initialize(); 479 sync_service_->Initialize();
468 MessageLoop::current()->Run(); 480 MessageLoop::current()->Run();
469
470 // It's possible this test triggered an unrecoverable error, in which case 481 // It's possible this test triggered an unrecoverable error, in which case
471 // we can't get the sync count. 482 // we can't get the sync count.
472 if (sync_service_->ShouldPushChanges()) { 483 if (sync_service_->ShouldPushChanges()) {
473 EXPECT_EQ(GetSyncCount(type), 484 EXPECT_EQ(GetSyncCount(type),
474 association_stats_.num_sync_items_after_association); 485 association_stats_.num_sync_items_after_association);
475 } 486 }
476 EXPECT_EQ(association_stats_.num_sync_items_after_association, 487 EXPECT_EQ(association_stats_.num_sync_items_after_association,
477 association_stats_.num_sync_items_before_association + 488 association_stats_.num_sync_items_before_association +
478 association_stats_.num_sync_items_added - 489 association_stats_.num_sync_items_added -
479 association_stats_.num_sync_items_deleted); 490 association_stats_.num_sync_items_deleted);
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 std::vector<base::Time> timestamps(added_entry.timestamps()); 1114 std::vector<base::Time> timestamps(added_entry.timestamps());
1104 1115
1105 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1116 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1106 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1117 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1107 1118
1108 AutofillChangeList changes; 1119 AutofillChangeList changes;
1109 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); 1120 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key()));
1110 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1121 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1111 db_thread_.DeprecatedGetThreadObject())); 1122 db_thread_.DeprecatedGetThreadObject()));
1112 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1123 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1113 content::Source<WebDataService>(web_data_service_.get()), 1124 content::Source<AutofillWebDataService>(
1125 web_data_service_.get()),
1114 content::Details<AutofillChangeList>(&changes)); 1126 content::Details<AutofillChangeList>(&changes));
1115 1127
1116 std::vector<AutofillEntry> new_sync_entries; 1128 std::vector<AutofillEntry> new_sync_entries;
1117 std::vector<AutofillProfile> new_sync_profiles; 1129 std::vector<AutofillProfile> new_sync_profiles;
1118 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1130 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1119 &new_sync_profiles)); 1131 &new_sync_profiles));
1120 ASSERT_EQ(1U, new_sync_entries.size()); 1132 ASSERT_EQ(1U, new_sync_entries.size());
1121 EXPECT_TRUE(added_entry == new_sync_entries[0]); 1133 EXPECT_TRUE(added_entry == new_sync_entries[0]);
1122 } 1134 }
1123 1135
1124 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { 1136 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
1125 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 1137 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
1126 EXPECT_CALL(*personal_data_manager_, Refresh()); 1138 EXPECT_CALL(*personal_data_manager_, Refresh());
1127 SetIdleChangeProcessorExpectations(); 1139 SetIdleChangeProcessorExpectations();
1128 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE); 1140 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE);
1129 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE); 1141 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE);
1130 ASSERT_TRUE(create_root.success()); 1142 ASSERT_TRUE(create_root.success());
1131 1143
1132 AutofillProfile added_profile; 1144 AutofillProfile added_profile;
1133 autofill_test::SetProfileInfoWithGuid(&added_profile, 1145 autofill_test::SetProfileInfoWithGuid(&added_profile,
1134 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", 1146 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz",
1135 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1147 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
1136 "32801", "US", "19482937549"); 1148 "32801", "US", "19482937549");
1137 1149
1138 AutofillProfileChange change(AutofillProfileChange::ADD, 1150 AutofillProfileChange change(AutofillProfileChange::ADD,
1139 added_profile.guid(), &added_profile); 1151 added_profile.guid(), &added_profile);
1140 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1152 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1141 db_thread_.DeprecatedGetThreadObject())); 1153 db_thread_.DeprecatedGetThreadObject()));
1142 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1154 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1143 content::Source<WebDataService>(web_data_service_.get()), 1155 content::Source<AutofillWebDataService>(
1156 web_data_service_.get()),
1144 content::Details<AutofillProfileChange>(&change)); 1157 content::Details<AutofillProfileChange>(&change));
1145 1158
1146 std::vector<AutofillProfile> new_sync_profiles; 1159 std::vector<AutofillProfile> new_sync_profiles;
1147 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1160 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1148 &new_sync_profiles)); 1161 &new_sync_profiles));
1149 ASSERT_EQ(1U, new_sync_profiles.size()); 1162 ASSERT_EQ(1U, new_sync_profiles.size());
1150 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); 1163 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0]));
1151 } 1164 }
1152 1165
1153 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { 1166 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) {
(...skipping 13 matching lines...) Expand all
1167 1180
1168 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1181 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1169 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1182 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1170 1183
1171 AutofillChangeList changes; 1184 AutofillChangeList changes;
1172 changes.push_back(AutofillChange(AutofillChange::UPDATE, 1185 changes.push_back(AutofillChange(AutofillChange::UPDATE,
1173 updated_entry.key())); 1186 updated_entry.key()));
1174 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1187 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1175 db_thread_.DeprecatedGetThreadObject())); 1188 db_thread_.DeprecatedGetThreadObject()));
1176 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1189 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1177 content::Source<WebDataService>(web_data_service_.get()), 1190 content::Source<AutofillWebDataService>(
1191 web_data_service_.get()),
1178 content::Details<AutofillChangeList>(&changes)); 1192 content::Details<AutofillChangeList>(&changes));
1179 1193
1180 std::vector<AutofillEntry> new_sync_entries; 1194 std::vector<AutofillEntry> new_sync_entries;
1181 std::vector<AutofillProfile> new_sync_profiles; 1195 std::vector<AutofillProfile> new_sync_profiles;
1182 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1196 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1183 &new_sync_profiles)); 1197 &new_sync_profiles));
1184 ASSERT_EQ(1U, new_sync_entries.size()); 1198 ASSERT_EQ(1U, new_sync_entries.size());
1185 EXPECT_TRUE(updated_entry == new_sync_entries[0]); 1199 EXPECT_TRUE(updated_entry == new_sync_entries[0]);
1186 } 1200 }
1187 1201
1188 1202
1189 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { 1203 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) {
1190 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); 1204 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1));
1191 std::vector<AutofillEntry> original_entries; 1205 std::vector<AutofillEntry> original_entries;
1192 original_entries.push_back(original_entry); 1206 original_entries.push_back(original_entry);
1193 1207
1194 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 1208 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).
1195 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 1209 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
1196 EXPECT_CALL(*personal_data_manager_, Refresh()); 1210 EXPECT_CALL(*personal_data_manager_, Refresh());
1197 CreateRootHelper create_root(this, syncer::AUTOFILL); 1211 CreateRootHelper create_root(this, syncer::AUTOFILL);
1198 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); 1212 StartSyncService(create_root.callback(), false, syncer::AUTOFILL);
1199 ASSERT_TRUE(create_root.success()); 1213 ASSERT_TRUE(create_root.success());
1200 1214
1201 AutofillChangeList changes; 1215 AutofillChangeList changes;
1202 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1216 changes.push_back(AutofillChange(AutofillChange::REMOVE,
1203 original_entry.key())); 1217 original_entry.key()));
1204 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1218 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1205 db_thread_.DeprecatedGetThreadObject())); 1219 db_thread_.DeprecatedGetThreadObject()));
1206 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1220 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1207 content::Source<WebDataService>(web_data_service_.get()), 1221 content::Source<AutofillWebDataService>(
1222 web_data_service_.get()),
1208 content::Details<AutofillChangeList>(&changes)); 1223 content::Details<AutofillChangeList>(&changes));
1209 1224
1210 std::vector<AutofillEntry> new_sync_entries; 1225 std::vector<AutofillEntry> new_sync_entries;
1211 std::vector<AutofillProfile> new_sync_profiles; 1226 std::vector<AutofillProfile> new_sync_profiles;
1212 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1227 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1213 &new_sync_profiles)); 1228 &new_sync_profiles));
1214 ASSERT_EQ(0U, new_sync_entries.size()); 1229 ASSERT_EQ(0U, new_sync_entries.size());
1215 } 1230 }
1216 1231
1217 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { 1232 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) {
(...skipping 18 matching lines...) Expand all
1236 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); 1251 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles);
1237 EXPECT_CALL(*personal_data_manager_, Refresh()); 1252 EXPECT_CALL(*personal_data_manager_, Refresh());
1238 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); 1253 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE);
1239 ASSERT_TRUE(add_autofill.success()); 1254 ASSERT_TRUE(add_autofill.success());
1240 1255
1241 AutofillProfileChange change(AutofillProfileChange::REMOVE, 1256 AutofillProfileChange change(AutofillProfileChange::REMOVE,
1242 sync_profile.guid(), NULL); 1257 sync_profile.guid(), NULL);
1243 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1258 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1244 db_thread_.DeprecatedGetThreadObject())); 1259 db_thread_.DeprecatedGetThreadObject()));
1245 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1260 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1246 content::Source<WebDataService>(web_data_service_.get()), 1261 content::Source<AutofillWebDataService>(
1262 web_data_service_.get()),
1247 content::Details<AutofillProfileChange>(&change)); 1263 content::Details<AutofillProfileChange>(&change));
1248 1264
1249 std::vector<AutofillProfile> new_sync_profiles; 1265 std::vector<AutofillProfile> new_sync_profiles;
1250 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1266 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1251 &new_sync_profiles)); 1267 &new_sync_profiles));
1252 ASSERT_EQ(0U, new_sync_profiles.size()); 1268 ASSERT_EQ(0U, new_sync_profiles.size());
1253 } 1269 }
1254 1270
1255 // http://crbug.com/57884 1271 // http://crbug.com/57884
1256 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { 1272 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 std::vector<AutofillEntry> sync_entries; 1309 std::vector<AutofillEntry> sync_entries;
1294 std::vector<AutofillProfile> sync_profiles; 1310 std::vector<AutofillProfile> sync_profiles;
1295 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1311 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1296 EXPECT_EQ(3U, sync_entries.size()); 1312 EXPECT_EQ(3U, sync_entries.size());
1297 EXPECT_EQ(0U, sync_profiles.size()); 1313 EXPECT_EQ(0U, sync_profiles.size());
1298 for (size_t i = 0; i < sync_entries.size(); i++) { 1314 for (size_t i = 0; i < sync_entries.size(); i++) {
1299 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1315 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1300 << ", " << sync_entries[i].key().value(); 1316 << ", " << sync_entries[i].key().value();
1301 } 1317 }
1302 } 1318 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698