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

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

Issue 8184001: The AutofillProfileSyncableService's lifetime should be managed by the WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure that destruction occurs on the DB thread Created 9 years, 2 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
11 #include "base/bind.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop.h" 16 #include "base/message_loop.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
18 #include "base/task.h" 19 #include "base/task.h"
19 #include "base/time.h" 20 #include "base/time.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/browser/browser_thread.h" 54 #include "content/browser/browser_thread.h"
54 #include "content/common/notification_source.h" 55 #include "content/common/notification_source.h"
55 #include "testing/gmock/include/gmock/gmock.h" 56 #include "testing/gmock/include/gmock/gmock.h"
56 57
57 using base::Time; 58 using base::Time;
58 using base::WaitableEvent; 59 using base::WaitableEvent;
59 using browser_sync::AutofillChangeProcessor; 60 using browser_sync::AutofillChangeProcessor;
60 using browser_sync::AutofillDataTypeController; 61 using browser_sync::AutofillDataTypeController;
61 using browser_sync::AutofillModelAssociator; 62 using browser_sync::AutofillModelAssociator;
62 using browser_sync::AutofillProfileDataTypeController; 63 using browser_sync::AutofillProfileDataTypeController;
63 using browser_sync::AutofillProfileSyncableService;
64 using browser_sync::DataTypeController; 64 using browser_sync::DataTypeController;
65 using browser_sync::GenericChangeProcessor; 65 using browser_sync::GenericChangeProcessor;
66 using browser_sync::SyncableServiceAdapter; 66 using browser_sync::SyncableServiceAdapter;
67 using browser_sync::GROUP_DB; 67 using browser_sync::GROUP_DB;
68 using browser_sync::kAutofillTag; 68 using browser_sync::kAutofillTag;
69 using browser_sync::SyncBackendHostForProfileSyncTest; 69 using browser_sync::SyncBackendHostForProfileSyncTest;
70 using browser_sync::UnrecoverableErrorHandler; 70 using browser_sync::UnrecoverableErrorHandler;
71 using syncable::CREATE_NEW_UPDATE_ITEM; 71 using syncable::CREATE_NEW_UPDATE_ITEM;
72 using syncable::AUTOFILL; 72 using syncable::AUTOFILL;
73 using syncable::BASE_VERSION; 73 using syncable::BASE_VERSION;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 service->profile(), dtc); 177 service->profile(), dtc);
178 return ProfileSyncFactory::SyncComponents(model_associator, 178 return ProfileSyncFactory::SyncComponents(model_associator,
179 change_processor); 179 change_processor);
180 } 180 }
181 181
182 ACTION_P3(MakeAutofillProfileSyncComponents, service, wd, dtc) { 182 ACTION_P3(MakeAutofillProfileSyncComponents, service, wd, dtc) {
183 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 183 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
184 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 184 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
185 return ProfileSyncFactory::SyncComponents(NULL, NULL); 185 return ProfileSyncFactory::SyncComponents(NULL, NULL);
186 AutofillProfileSyncableService* sync_service = 186 AutofillProfileSyncableService* sync_service =
187 new AutofillProfileSyncableService(wd, service->profile()); 187 wd->GetAutofillTable()->GetSyncableService(wd, service->profile());
188 sync_api::UserShare* user_share = service->GetUserShare(); 188 sync_api::UserShare* user_share = service->GetUserShare();
189 GenericChangeProcessor* change_processor = 189 GenericChangeProcessor* change_processor =
190 new GenericChangeProcessor(sync_service, dtc, user_share); 190 new GenericChangeProcessor(sync_service, dtc, user_share);
191 SyncableServiceAdapter* sync_service_adapter = 191 SyncableServiceAdapter* sync_service_adapter =
192 new SyncableServiceAdapter(syncable::AUTOFILL_PROFILE, 192 new SyncableServiceAdapter(syncable::AUTOFILL_PROFILE,
193 sync_service, 193 sync_service,
194 change_processor); 194 change_processor);
195 return ProfileSyncFactory::SyncComponents(sync_service_adapter, 195 return ProfileSyncFactory::SyncComponents(sync_service_adapter,
196 change_processor); 196 change_processor);
197 } 197 }
(...skipping 10 matching lines...) Expand all
208 DataTypeController* dtc) = 0; 208 DataTypeController* dtc) = 0;
209 virtual ~AbstractAutofillFactory() {} 209 virtual ~AbstractAutofillFactory() {}
210 }; 210 };
211 211
212 class AutofillEntryFactory : public AbstractAutofillFactory { 212 class AutofillEntryFactory : public AbstractAutofillFactory {
213 public: 213 public:
214 browser_sync::AutofillDataTypeController* CreateDataTypeController( 214 browser_sync::AutofillDataTypeController* CreateDataTypeController(
215 ProfileSyncFactory* factory, 215 ProfileSyncFactory* factory,
216 ProfileMock* profile, 216 ProfileMock* profile,
217 ProfileSyncService* service) { 217 ProfileSyncService* service) {
218 return new AutofillDataTypeController(factory, 218 return new AutofillDataTypeController(factory, profile);
219 profile);
220 } 219 }
221 220
222 void SetExpectation(ProfileSyncFactoryMock* factory, 221 void SetExpectation(ProfileSyncFactoryMock* factory,
223 ProfileSyncService* service, 222 ProfileSyncService* service,
224 WebDatabase* wd, 223 WebDatabase* wd,
225 DataTypeController* dtc) { 224 DataTypeController* dtc) {
226 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_)). 225 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_)).
227 WillOnce(MakeAutofillSyncComponents(service, wd, dtc)); 226 WillOnce(MakeAutofillSyncComponents(service, wd, dtc));
228 } 227 }
229 }; 228 };
230 229
231 class AutofillProfileFactory : public AbstractAutofillFactory { 230 class AutofillProfileFactory : public AbstractAutofillFactory {
232 public: 231 public:
233 browser_sync::AutofillDataTypeController* CreateDataTypeController( 232 browser_sync::AutofillDataTypeController* CreateDataTypeController(
234 ProfileSyncFactory* factory, 233 ProfileSyncFactory* factory,
235 ProfileMock* profile, 234 ProfileMock* profile,
236 ProfileSyncService* service) { 235 ProfileSyncService* service) {
237 return new AutofillProfileDataTypeController(factory, 236 return new AutofillProfileDataTypeController(factory, profile);
238 profile);
239 } 237 }
240 238
241 void SetExpectation(ProfileSyncFactoryMock* factory, 239 void SetExpectation(ProfileSyncFactoryMock* factory,
242 ProfileSyncService* service, 240 ProfileSyncService* service,
243 WebDatabase* wd, 241 WebDatabase* wd,
244 DataTypeController* dtc) { 242 DataTypeController* dtc) {
245 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_)). 243 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_)).
246 WillOnce(MakeAutofillProfileSyncComponents(service, wd, dtc)); 244 WillOnce(MakeAutofillProfileSyncComponents(service, wd, dtc));
247 } 245 }
248 }; 246 };
249 247
250 class PersonalDataManagerMock: public PersonalDataManager { 248 class PersonalDataManagerMock: public PersonalDataManager {
251 public: 249 public:
252 static ProfileKeyedService* Build(Profile* profile) { 250 static ProfileKeyedService* Build(Profile* profile) {
253 return new PersonalDataManagerMock; 251 return new PersonalDataManagerMock;
254 } 252 }
255 253
256 MOCK_CONST_METHOD0(IsDataLoaded, bool()); 254 MOCK_CONST_METHOD0(IsDataLoaded, bool());
257 MOCK_METHOD0(LoadProfiles, void()); 255 MOCK_METHOD0(LoadProfiles, void());
258 MOCK_METHOD0(LoadCreditCards, void()); 256 MOCK_METHOD0(LoadCreditCards, void());
259 MOCK_METHOD0(Refresh, void()); 257 MOCK_METHOD0(Refresh, void());
260 }; 258 };
261 template <class T> class AddAutofillTask; 259 template <class T> class AddAutofillTask;
262 260
263 class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest { 261 class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
264 protected: 262 protected:
265 ProfileSyncServiceAutofillTest() {} 263 ProfileSyncServiceAutofillTest()
264 : autofill_table_created_or_destroyed_(false, false) {
265 }
266 266
267 AutofillProfileFactory profile_factory_; 267 AutofillProfileFactory profile_factory_;
268 AutofillEntryFactory entry_factory_; 268 AutofillEntryFactory entry_factory_;
269 269
270 AbstractAutofillFactory* GetFactory(syncable::ModelType type) { 270 AbstractAutofillFactory* GetFactory(syncable::ModelType type) {
271 if (type == syncable::AUTOFILL) { 271 if (type == syncable::AUTOFILL) {
272 return &entry_factory_; 272 return &entry_factory_;
273 } else if (type == syncable::AUTOFILL_PROFILE) { 273 } else if (type == syncable::AUTOFILL_PROFILE) {
274 return &profile_factory_; 274 return &profile_factory_;
275 } else { 275 } else {
276 NOTREACHED(); 276 NOTREACHED();
277 return NULL; 277 return NULL;
278 } 278 }
279 } 279 }
280 280
281 virtual void SetUp() { 281 virtual void SetUp() {
282 AbstractProfileSyncServiceTest::SetUp(); 282 AbstractProfileSyncServiceTest::SetUp();
283 profile_.CreateRequestContext(); 283 profile_.CreateRequestContext();
284 web_database_.reset(new WebDatabaseFake(&autofill_table_)); 284
285 // The |autofill_table_| must be constructed on the DB thread.
286 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
287 base::Bind(&ProfileSyncServiceAutofillTest::CreateAutofillTable,
288 base::Unretained(this)));
289 ASSERT_TRUE(autofill_table_created_or_destroyed_.Wait());
290
291 web_database_.reset(new WebDatabaseFake(autofill_table_.get()));
285 web_data_service_ = new WebDataServiceFake(web_database_.get()); 292 web_data_service_ = new WebDataServiceFake(web_database_.get());
286 personal_data_manager_ = static_cast<PersonalDataManagerMock*>( 293 personal_data_manager_ = static_cast<PersonalDataManagerMock*>(
287 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( 294 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse(
288 &profile_, PersonalDataManagerMock::Build)); 295 &profile_, PersonalDataManagerMock::Build));
289 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); 296 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1);
290 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); 297 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1);
291 EXPECT_CALL(profile_, GetWebDataService(_)). 298 EXPECT_CALL(profile_, GetWebDataService(_)).
292 // TokenService::Initialize 299 // TokenService::Initialize
293 // AutofillDataTypeController::StartModels() 300 // AutofillDataTypeController::StartModels()
294 // In some tests: 301 // In some tests:
295 // AutofillProfileSyncableService::AutofillProfileSyncableService() 302 // AutofillProfileSyncableService::AutofillProfileSyncableService()
296 WillRepeatedly(Return(web_data_service_.get())); 303 WillRepeatedly(Return(web_data_service_.get()));
297 personal_data_manager_->Init(&profile_); 304 personal_data_manager_->Init(&profile_);
298 305
299 notification_service_ = new ThreadNotificationService(&db_thread_); 306 notification_service_ = new ThreadNotificationService(&db_thread_);
300 notification_service_->Init(); 307 notification_service_->Init();
301 } 308 }
302 309
303 virtual void TearDown() { 310 virtual void TearDown() {
304 service_.reset(); 311 service_.reset();
305 notification_service_->TearDown(); 312 notification_service_->TearDown();
313
314 // The |autofill_table_| must be destroyed on the DB thread.
315 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
316 base::Bind(&ProfileSyncServiceAutofillTest::DestroyAutofillTable,
317 base::Unretained(this)));
318 ASSERT_TRUE(autofill_table_created_or_destroyed_.Wait());
319
306 profile_.ResetRequestContext(); 320 profile_.ResetRequestContext();
307 AbstractProfileSyncServiceTest::TearDown(); 321 AbstractProfileSyncServiceTest::TearDown();
308 } 322 }
309 323
324 void CreateAutofillTable() {
325 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
326 autofill_table_.reset(new AutofillTableMock);
327 autofill_table_created_or_destroyed_.Signal();
328 }
329
330 void DestroyAutofillTable() {
331 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
332 autofill_table_.reset();
333 autofill_table_created_or_destroyed_.Signal();
334 }
335
310 void StartSyncService(Task* task, 336 void StartSyncService(Task* task,
311 bool will_fail_association, 337 bool will_fail_association,
312 syncable::ModelType type) { 338 syncable::ModelType type) {
313 AbstractAutofillFactory* factory = GetFactory(type); 339 AbstractAutofillFactory* factory = GetFactory(type);
314 service_.reset( 340 service_.reset(
315 new TestProfileSyncService(&factory_, &profile_, "test_user", false, 341 new TestProfileSyncService(&factory_, &profile_, "test_user", false,
316 task)); 342 task));
317 EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly( 343 EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly(
318 Return(service_.get())); 344 Return(service_.get()));
319 AutofillDataTypeController* data_type_controller = 345 AutofillDataTypeController* data_type_controller =
320 factory->CreateDataTypeController(&factory_, 346 factory->CreateDataTypeController(&factory_,
321 &profile_, 347 &profile_,
322 service_.get()); 348 service_.get());
323 SyncBackendHostForProfileSyncTest:: 349 SyncBackendHostForProfileSyncTest::
324 SetDefaultExpectationsForWorkerCreation(&profile_); 350 SetDefaultExpectationsForWorkerCreation(&profile_);
325 351
326 factory->SetExpectation(&factory_, 352 factory->SetExpectation(&factory_,
327 service_.get(), 353 service_.get(),
328 web_database_.get(), 354 web_database_.get(),
329 data_type_controller); 355 data_type_controller);
330 356
331 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). 357 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)).
332 WillOnce(ReturnNewDataTypeManager()); 358 WillOnce(ReturnNewDataTypeManager());
333 359
334 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). 360 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()).
335 WillRepeatedly(Return(true)); 361 WillRepeatedly(Return(true));
336 362
337 // We need tokens to get the tests going 363 // We need tokens to get the tests going
338 token_service_->IssueAuthTokenForTest( 364 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token");
339 GaiaConstants::kSyncService, "token");
340 365
341 EXPECT_CALL(profile_, GetTokenService()). 366 EXPECT_CALL(profile_, GetTokenService()).
342 WillRepeatedly(Return(token_service_.get())); 367 WillRepeatedly(Return(token_service_.get()));
343 368
344 service_->RegisterDataTypeController(data_type_controller); 369 service_->RegisterDataTypeController(data_type_controller);
345 service_->Initialize(); 370 service_->Initialize();
346 MessageLoop::current()->Run(); 371 MessageLoop::current()->Run();
347 } 372 }
348 373
349 bool AddAutofillSyncNode(const AutofillEntry& entry) { 374 bool AddAutofillSyncNode(const AutofillEntry& entry) {
350 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); 375 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
351 sync_api::ReadNode autofill_root(&trans); 376 sync_api::ReadNode autofill_root(&trans);
352 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillTag)) 377 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillTag))
353 return false; 378 return false;
354 379
355 sync_api::WriteNode node(&trans); 380 sync_api::WriteNode node(&trans);
356 std::string tag = AutofillModelAssociator::KeyToTag(entry.key().name(), 381 std::string tag = AutofillModelAssociator::KeyToTag(entry.key().name(),
357 entry.key().value()); 382 entry.key().value());
358 if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag)) 383 if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag))
359 return false; 384 return false;
360 385
361 AutofillChangeProcessor::WriteAutofillEntry(entry, &node); 386 AutofillChangeProcessor::WriteAutofillEntry(entry, &node);
362 return true; 387 return true;
363 } 388 }
364 389
365 bool AddAutofillSyncNode(const AutofillProfile& profile) { 390 bool AddAutofillSyncNode(const AutofillProfile& profile) {
366 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); 391 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
367 sync_api::ReadNode autofill_root(&trans); 392 sync_api::ReadNode autofill_root(&trans);
368 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillProfileTag)) 393 if (!autofill_root.InitByTagLookup(kAutofillProfileTag))
369 return false; 394 return false;
370 sync_api::WriteNode node(&trans); 395 sync_api::WriteNode node(&trans);
371 std::string tag = profile.guid(); 396 std::string tag = profile.guid();
372 if (!node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE, 397 if (!node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE,
373 autofill_root, tag)) 398 autofill_root, tag))
374 return false; 399 return false;
375 sync_pb::EntitySpecifics specifics; 400 sync_pb::EntitySpecifics specifics;
376 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); 401 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics);
377 sync_pb::AutofillProfileSpecifics* profile_specifics = 402 sync_pb::AutofillProfileSpecifics* profile_specifics =
378 specifics.MutableExtension(sync_pb::autofill_profile); 403 specifics.MutableExtension(sync_pb::autofill_profile);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 439 }
415 child_id = child_node.GetSuccessorId(); 440 child_id = child_node.GetSuccessorId();
416 } 441 }
417 return true; 442 return true;
418 } 443 }
419 444
420 bool GetAutofillProfilesFromSyncDBUnderProfileNode( 445 bool GetAutofillProfilesFromSyncDBUnderProfileNode(
421 std::vector<AutofillProfile>* profiles) { 446 std::vector<AutofillProfile>* profiles) {
422 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare()); 447 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare());
423 sync_api::ReadNode autofill_root(&trans); 448 sync_api::ReadNode autofill_root(&trans);
424 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillProfileTag)) 449 if (!autofill_root.InitByTagLookup(kAutofillProfileTag))
425 return false; 450 return false;
426 451
427 int64 child_id = autofill_root.GetFirstChildId(); 452 int64 child_id = autofill_root.GetFirstChildId();
428 while (child_id != sync_api::kInvalidId) { 453 while (child_id != sync_api::kInvalidId) {
429 sync_api::ReadNode child_node(&trans); 454 sync_api::ReadNode child_node(&trans);
430 if (!child_node.InitByIdLookup(child_id)) 455 if (!child_node.InitByIdLookup(child_id))
431 return false; 456 return false;
432 457
433 const sync_pb::AutofillProfileSpecifics& autofill( 458 const sync_pb::AutofillProfileSpecifics& autofill(
434 child_node.GetAutofillProfileSpecifics()); 459 child_node.GetAutofillProfileSpecifics());
435 AutofillProfile p; 460 AutofillProfile p;
436 p.set_guid(autofill.guid()); 461 p.set_guid(autofill.guid());
437 AutofillProfileSyncableService::OverwriteProfileWithServerData( 462 AutofillProfileSyncableService::OverwriteProfileWithServerData(
438 autofill, &p); 463 autofill, &p);
439 profiles->push_back(p); 464 profiles->push_back(p);
440 child_id = child_node.GetSuccessorId(); 465 child_id = child_node.GetSuccessorId();
441 } 466 }
442 return true; 467 return true;
443 } 468 }
444 469
445 void SetIdleChangeProcessorExpectations() { 470 void SetIdleChangeProcessorExpectations() {
446 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); 471 EXPECT_CALL(*autofill_table_, RemoveFormElement(_, _)).Times(0);
447 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); 472 EXPECT_CALL(*autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0);
448 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); 473 EXPECT_CALL(*autofill_table_, UpdateAutofillEntries(_)).Times(0);
449 } 474 }
450 475
451 static AutofillEntry MakeAutofillEntry(const char* name, 476 static AutofillEntry MakeAutofillEntry(const char* name,
452 const char* value, 477 const char* value,
453 time_t timestamp0, 478 time_t timestamp0,
454 time_t timestamp1) { 479 time_t timestamp1) {
455 std::vector<Time> timestamps; 480 std::vector<Time> timestamps;
456 if (timestamp0 > 0) 481 if (timestamp0 > 0)
457 timestamps.push_back(Time::FromTimeT(timestamp0)); 482 timestamps.push_back(Time::FromTimeT(timestamp0));
458 if (timestamp1 > 0) 483 if (timestamp1 > 0)
459 timestamps.push_back(Time::FromTimeT(timestamp1)); 484 timestamps.push_back(Time::FromTimeT(timestamp1));
460 return AutofillEntry( 485 return AutofillEntry(
461 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps); 486 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps);
462 } 487 }
463 488
464 static AutofillEntry MakeAutofillEntry(const char* name, 489 static AutofillEntry MakeAutofillEntry(const char* name,
465 const char* value, 490 const char* value,
466 time_t timestamp) { 491 time_t timestamp) {
467 return MakeAutofillEntry(name, value, timestamp, -1); 492 return MakeAutofillEntry(name, value, timestamp, -1);
468 } 493 }
469 494
470 friend class AddAutofillTask<AutofillEntry>; 495 friend class AddAutofillTask<AutofillEntry>;
471 friend class AddAutofillTask<AutofillProfile>; 496 friend class AddAutofillTask<AutofillProfile>;
472 friend class FakeServerUpdater; 497 friend class FakeServerUpdater;
473 498
474 scoped_refptr<ThreadNotificationService> notification_service_; 499 scoped_refptr<ThreadNotificationService> notification_service_;
475 500
476 ProfileMock profile_; 501 ProfileMock profile_;
477 AutofillTableMock autofill_table_; 502 scoped_ptr<AutofillTableMock> autofill_table_;
503 WaitableEvent autofill_table_created_or_destroyed_;
478 scoped_ptr<WebDatabaseFake> web_database_; 504 scoped_ptr<WebDatabaseFake> web_database_;
479 scoped_refptr<WebDataService> web_data_service_; 505 scoped_refptr<WebDataService> web_data_service_;
480 PersonalDataManagerMock* personal_data_manager_; 506 PersonalDataManagerMock* personal_data_manager_;
481 }; 507 };
482 508
483 template <class T> 509 template <class T>
484 class AddAutofillTask : public Task { 510 class AddAutofillTask : public Task {
485 public: 511 public:
486 AddAutofillTask(ProfileSyncServiceAutofillTest* test, 512 AddAutofillTask(ProfileSyncServiceAutofillTest* test,
487 const std::vector<T>& entries) 513 const std::vector<T>& entries)
488 : test_(test), entries_(entries), success_(false) { 514 : test_(test), entries_(entries), success_(false) {
489 } 515 }
490 516
491 virtual void Run() { 517 virtual void Run() {
492 if (!test_->CreateRoot(GetModelType<T>())) 518 if (!test_->CreateRoot(GetModelType<T>()))
493 return; 519 return;
494 for (size_t i = 0; i < entries_.size(); ++i) { 520 for (size_t i = 0; i < entries_.size(); ++i) {
495 if (!test_->AddAutofillSyncNode(entries_[i])) 521 if (!test_->AddAutofillSyncNode(entries_[i]))
496 return; 522 return;
497 } 523 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // TODO(skrul): Test processing of cloud changes. 659 // TODO(skrul): Test processing of cloud changes.
634 // TODO(tim): Add autofill data type controller test, and a case to cover 660 // TODO(tim): Add autofill data type controller test, and a case to cover
635 // waiting for the PersonalDataManager. 661 // waiting for the PersonalDataManager.
636 TEST_F(ProfileSyncServiceAutofillTest, FailModelAssociation) { 662 TEST_F(ProfileSyncServiceAutofillTest, FailModelAssociation) {
637 // Don't create the root autofill node so startup fails. 663 // Don't create the root autofill node so startup fails.
638 StartSyncService(NULL, true, syncable::AUTOFILL); 664 StartSyncService(NULL, true, syncable::AUTOFILL);
639 EXPECT_TRUE(service_->unrecoverable_error_detected()); 665 EXPECT_TRUE(service_->unrecoverable_error_detected());
640 } 666 }
641 667
642 TEST_F(ProfileSyncServiceAutofillTest, EmptyNativeEmptySync) { 668 TEST_F(ProfileSyncServiceAutofillTest, EmptyNativeEmptySync) {
643 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 669 EXPECT_CALL(*autofill_table_,
644 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 670 GetAllAutofillEntries(_)).WillOnce(Return(true));
671 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
645 SetIdleChangeProcessorExpectations(); 672 SetIdleChangeProcessorExpectations();
646 CreateRootTask task(this, syncable::AUTOFILL); 673 CreateRootTask task(this, syncable::AUTOFILL);
647 EXPECT_CALL(*personal_data_manager_, Refresh()); 674 EXPECT_CALL(*personal_data_manager_, Refresh());
648 StartSyncService(&task, false, syncable::AUTOFILL); 675 StartSyncService(&task, false, syncable::AUTOFILL);
649 ASSERT_TRUE(task.success()); 676 ASSERT_TRUE(task.success());
650 std::vector<AutofillEntry> sync_entries; 677 std::vector<AutofillEntry> sync_entries;
651 std::vector<AutofillProfile> sync_profiles; 678 std::vector<AutofillProfile> sync_profiles;
652 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 679 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
653 EXPECT_EQ(0U, sync_entries.size()); 680 EXPECT_EQ(0U, sync_entries.size());
654 EXPECT_EQ(0U, sync_profiles.size()); 681 EXPECT_EQ(0U, sync_profiles.size());
655 } 682 }
656 683
657 TEST_F(ProfileSyncServiceAutofillTest, HasNativeEntriesEmptySync) { 684 TEST_F(ProfileSyncServiceAutofillTest, HasNativeEntriesEmptySync) {
658 std::vector<AutofillEntry> entries; 685 std::vector<AutofillEntry> entries;
659 entries.push_back(MakeAutofillEntry("foo", "bar", 1)); 686 entries.push_back(MakeAutofillEntry("foo", "bar", 1));
660 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 687 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
661 WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); 688 WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true)));
662 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 689 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
663 SetIdleChangeProcessorExpectations(); 690 SetIdleChangeProcessorExpectations();
664 CreateRootTask task(this, syncable::AUTOFILL); 691 CreateRootTask task(this, syncable::AUTOFILL);
665 EXPECT_CALL(*personal_data_manager_, Refresh()); 692 EXPECT_CALL(*personal_data_manager_, Refresh());
666 StartSyncService(&task, false, syncable::AUTOFILL); 693 StartSyncService(&task, false, syncable::AUTOFILL);
667 ASSERT_TRUE(task.success()); 694 ASSERT_TRUE(task.success());
668 std::vector<AutofillEntry> sync_entries; 695 std::vector<AutofillEntry> sync_entries;
669 std::vector<AutofillProfile> sync_profiles; 696 std::vector<AutofillProfile> sync_profiles;
670 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 697 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
671 ASSERT_EQ(1U, entries.size()); 698 ASSERT_EQ(1U, entries.size());
672 EXPECT_TRUE(entries[0] == sync_entries[0]); 699 EXPECT_TRUE(entries[0] == sync_entries[0]);
673 EXPECT_EQ(0U, sync_profiles.size()); 700 EXPECT_EQ(0U, sync_profiles.size());
674 } 701 }
675 702
676 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { 703 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) {
677 std::vector<AutofillProfile*> profiles; 704 std::vector<AutofillProfile*> profiles;
678 std::vector<AutofillProfile> expected_profiles; 705 std::vector<AutofillProfile> expected_profiles;
679 // Owned by GetAutofillProfiles caller. 706 // Owned by GetAutofillProfiles caller.
680 AutofillProfile* profile0 = new AutofillProfile; 707 AutofillProfile* profile0 = new AutofillProfile;
681 autofill_test::SetProfileInfoWithGuid(profile0, 708 autofill_test::SetProfileInfoWithGuid(profile0,
682 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", 709 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing",
683 "Mitchell", "Morrison", 710 "Mitchell", "Morrison",
684 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 711 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
685 "91601", "US", "12345678910"); 712 "91601", "US", "12345678910");
686 profiles.push_back(profile0); 713 profiles.push_back(profile0);
687 expected_profiles.push_back(*profile0); 714 expected_profiles.push_back(*profile0);
688 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). 715 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).
689 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); 716 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true)));
690 EXPECT_CALL(*personal_data_manager_, Refresh()); 717 EXPECT_CALL(*personal_data_manager_, Refresh());
691 SetIdleChangeProcessorExpectations(); 718 SetIdleChangeProcessorExpectations();
692 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); 719 CreateRootTask task(this, syncable::AUTOFILL_PROFILE);
693 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); 720 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE);
694 ASSERT_TRUE(task.success()); 721 ASSERT_TRUE(task.success());
695 std::vector<AutofillProfile> sync_profiles; 722 std::vector<AutofillProfile> sync_profiles;
696 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(&sync_profiles)); 723 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(&sync_profiles));
697 EXPECT_EQ(1U, sync_profiles.size()); 724 EXPECT_EQ(1U, sync_profiles.size());
698 EXPECT_EQ(0, expected_profiles[0].Compare(sync_profiles[0])); 725 EXPECT_EQ(0, expected_profiles[0].Compare(sync_profiles[0]));
699 } 726 }
700 727
701 TEST_F(ProfileSyncServiceAutofillTest, HasNativeWithDuplicatesEmptySync) { 728 TEST_F(ProfileSyncServiceAutofillTest, HasNativeWithDuplicatesEmptySync) {
702 // There is buggy autofill code that allows duplicate name/value 729 // There is buggy autofill code that allows duplicate name/value
703 // pairs to exist in the database with separate pair_ids. 730 // pairs to exist in the database with separate pair_ids.
704 std::vector<AutofillEntry> entries; 731 std::vector<AutofillEntry> entries;
705 entries.push_back(MakeAutofillEntry("foo", "bar", 1)); 732 entries.push_back(MakeAutofillEntry("foo", "bar", 1));
706 entries.push_back(MakeAutofillEntry("dup", "", 2)); 733 entries.push_back(MakeAutofillEntry("dup", "", 2));
707 entries.push_back(MakeAutofillEntry("dup", "", 3)); 734 entries.push_back(MakeAutofillEntry("dup", "", 3));
708 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 735 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
709 WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); 736 WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true)));
710 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 737 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
711 SetIdleChangeProcessorExpectations(); 738 SetIdleChangeProcessorExpectations();
712 CreateRootTask task(this, syncable::AUTOFILL); 739 CreateRootTask task(this, syncable::AUTOFILL);
713 EXPECT_CALL(*personal_data_manager_, Refresh()); 740 EXPECT_CALL(*personal_data_manager_, Refresh());
714 StartSyncService(&task, false, syncable::AUTOFILL); 741 StartSyncService(&task, false, syncable::AUTOFILL);
715 ASSERT_TRUE(task.success()); 742 ASSERT_TRUE(task.success());
716 std::vector<AutofillEntry> sync_entries; 743 std::vector<AutofillEntry> sync_entries;
717 std::vector<AutofillProfile> sync_profiles; 744 std::vector<AutofillProfile> sync_profiles;
718 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 745 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
719 EXPECT_EQ(2U, sync_entries.size()); 746 EXPECT_EQ(2U, sync_entries.size());
720 } 747 }
721 748
722 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncNoMerge) { 749 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncNoMerge) {
723 AutofillEntry native_entry(MakeAutofillEntry("native", "entry", 1)); 750 AutofillEntry native_entry(MakeAutofillEntry("native", "entry", 1));
724 AutofillEntry sync_entry(MakeAutofillEntry("sync", "entry", 2)); 751 AutofillEntry sync_entry(MakeAutofillEntry("sync", "entry", 2));
725 752
726 std::vector<AutofillEntry> native_entries; 753 std::vector<AutofillEntry> native_entries;
727 native_entries.push_back(native_entry); 754 native_entries.push_back(native_entry);
728 755
729 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 756 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
730 WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 757 WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true)));
731 758
732 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 759 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
733 760
734 std::vector<AutofillEntry> sync_entries; 761 std::vector<AutofillEntry> sync_entries;
735 sync_entries.push_back(sync_entry); 762 sync_entries.push_back(sync_entry);
736 763
737 AddAutofillTask<AutofillEntry> task(this, sync_entries); 764 AddAutofillTask<AutofillEntry> task(this, sync_entries);
738 765
739 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(ElementsAre(sync_entry))). 766 EXPECT_CALL(*autofill_table_, UpdateAutofillEntries(ElementsAre(sync_entry))).
740 WillOnce(Return(true)); 767 WillOnce(Return(true));
741 768
742 EXPECT_CALL(*personal_data_manager_, Refresh()); 769 EXPECT_CALL(*personal_data_manager_, Refresh());
743 StartSyncService(&task, false, syncable::AUTOFILL); 770 StartSyncService(&task, false, syncable::AUTOFILL);
744 ASSERT_TRUE(task.success()); 771 ASSERT_TRUE(task.success());
745 772
746 std::set<AutofillEntry> expected_entries; 773 std::set<AutofillEntry> expected_entries;
747 expected_entries.insert(native_entry); 774 expected_entries.insert(native_entry);
748 expected_entries.insert(sync_entry); 775 expected_entries.insert(sync_entry);
749 776
750 std::vector<AutofillEntry> new_sync_entries; 777 std::vector<AutofillEntry> new_sync_entries;
751 std::vector<AutofillProfile> new_sync_profiles; 778 std::vector<AutofillProfile> new_sync_profiles;
752 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 779 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
753 &new_sync_profiles)); 780 &new_sync_profiles));
754 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(), 781 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(),
755 new_sync_entries.end()); 782 new_sync_entries.end());
756 783
757 EXPECT_TRUE(expected_entries == new_sync_entries_set); 784 EXPECT_TRUE(expected_entries == new_sync_entries_set);
758 } 785 }
759 786
760 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeEntry) { 787 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeEntry) {
761 AutofillEntry native_entry(MakeAutofillEntry("merge", "entry", 1)); 788 AutofillEntry native_entry(MakeAutofillEntry("merge", "entry", 1));
762 AutofillEntry sync_entry(MakeAutofillEntry("merge", "entry", 2)); 789 AutofillEntry sync_entry(MakeAutofillEntry("merge", "entry", 2));
763 AutofillEntry merged_entry(MakeAutofillEntry("merge", "entry", 1, 2)); 790 AutofillEntry merged_entry(MakeAutofillEntry("merge", "entry", 1, 2));
764 791
765 std::vector<AutofillEntry> native_entries; 792 std::vector<AutofillEntry> native_entries;
766 native_entries.push_back(native_entry); 793 native_entries.push_back(native_entry);
767 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 794 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
768 WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 795 WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true)));
769 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 796 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
770 797
771 std::vector<AutofillEntry> sync_entries; 798 std::vector<AutofillEntry> sync_entries;
772 sync_entries.push_back(sync_entry); 799 sync_entries.push_back(sync_entry);
773 AddAutofillTask<AutofillEntry> task(this, sync_entries); 800 AddAutofillTask<AutofillEntry> task(this, sync_entries);
774 801
775 EXPECT_CALL(autofill_table_, 802 EXPECT_CALL(*autofill_table_,
776 UpdateAutofillEntries(ElementsAre(merged_entry))).WillOnce(Return(true)); 803 UpdateAutofillEntries(ElementsAre(merged_entry))).WillOnce(Return(true));
777 EXPECT_CALL(*personal_data_manager_, Refresh()); 804 EXPECT_CALL(*personal_data_manager_, Refresh());
778 StartSyncService(&task, false, syncable::AUTOFILL); 805 StartSyncService(&task, false, syncable::AUTOFILL);
779 ASSERT_TRUE(task.success()); 806 ASSERT_TRUE(task.success());
780 807
781 std::vector<AutofillEntry> new_sync_entries; 808 std::vector<AutofillEntry> new_sync_entries;
782 std::vector<AutofillProfile> new_sync_profiles; 809 std::vector<AutofillProfile> new_sync_profiles;
783 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 810 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
784 &new_sync_profiles)); 811 &new_sync_profiles));
785 ASSERT_EQ(1U, new_sync_entries.size()); 812 ASSERT_EQ(1U, new_sync_entries.size());
786 EXPECT_TRUE(merged_entry == new_sync_entries[0]); 813 EXPECT_TRUE(merged_entry == new_sync_entries[0]);
787 } 814 }
788 815
789 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) { 816 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) {
790 AutofillProfile sync_profile; 817 AutofillProfile sync_profile;
791 autofill_test::SetProfileInfoWithGuid(&sync_profile, 818 autofill_test::SetProfileInfoWithGuid(&sync_profile,
792 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", 819 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing",
793 "Mitchell", "Morrison", 820 "Mitchell", "Morrison",
794 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 821 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
795 "91601", "US", "12345678910"); 822 "91601", "US", "12345678910");
796 823
797 AutofillProfile* native_profile = new AutofillProfile; 824 AutofillProfile* native_profile = new AutofillProfile;
798 autofill_test::SetProfileInfoWithGuid(native_profile, 825 autofill_test::SetProfileInfoWithGuid(native_profile,
799 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", "Alicia", "Saenz", 826 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", "Alicia", "Saenz",
800 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 827 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
801 "32801", "US", "19482937549"); 828 "32801", "US", "19482937549");
802 829
803 std::vector<AutofillProfile*> native_profiles; 830 std::vector<AutofillProfile*> native_profiles;
804 native_profiles.push_back(native_profile); 831 native_profiles.push_back(native_profile);
805 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). 832 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).
806 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); 833 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true)));
807 834
808 std::vector<AutofillProfile> sync_profiles; 835 std::vector<AutofillProfile> sync_profiles;
809 sync_profiles.push_back(sync_profile); 836 sync_profiles.push_back(sync_profile);
810 AddAutofillTask<AutofillProfile> task(this, sync_profiles); 837 AddAutofillTask<AutofillProfile> task(this, sync_profiles);
811 838
812 EXPECT_CALL(autofill_table_, UpdateAutofillProfile(_)). 839 EXPECT_CALL(*autofill_table_, UpdateAutofillProfile(_)).
813 WillOnce(Return(true)); 840 WillOnce(Return(true));
814 EXPECT_CALL(*personal_data_manager_, Refresh()); 841 EXPECT_CALL(*personal_data_manager_, Refresh());
815 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); 842 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE);
816 ASSERT_TRUE(task.success()); 843 ASSERT_TRUE(task.success());
817 844
818 std::vector<AutofillProfile> new_sync_profiles; 845 std::vector<AutofillProfile> new_sync_profiles;
819 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 846 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
820 &new_sync_profiles)); 847 &new_sync_profiles));
821 ASSERT_EQ(1U, new_sync_profiles.size()); 848 ASSERT_EQ(1U, new_sync_profiles.size());
822 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0])); 849 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0]));
(...skipping 11 matching lines...) Expand all
834 std::string native_guid = "EDC609ED-7EEE-4F27-B00C-423242A9C44B"; 861 std::string native_guid = "EDC609ED-7EEE-4F27-B00C-423242A9C44B";
835 AutofillProfile* native_profile = new AutofillProfile; 862 AutofillProfile* native_profile = new AutofillProfile;
836 autofill_test::SetProfileInfoWithGuid(native_profile, 863 autofill_test::SetProfileInfoWithGuid(native_profile,
837 native_guid.c_str(), "Billing", 864 native_guid.c_str(), "Billing",
838 "Mitchell", "Morrison", 865 "Mitchell", "Morrison",
839 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 866 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
840 "91601", "US", "12345678910"); 867 "91601", "US", "12345678910");
841 868
842 std::vector<AutofillProfile*> native_profiles; 869 std::vector<AutofillProfile*> native_profiles;
843 native_profiles.push_back(native_profile); 870 native_profiles.push_back(native_profile);
844 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). 871 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).
845 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); 872 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true)));
846 873
847 std::vector<AutofillProfile> sync_profiles; 874 std::vector<AutofillProfile> sync_profiles;
848 sync_profiles.push_back(sync_profile); 875 sync_profiles.push_back(sync_profile);
849 AddAutofillTask<AutofillProfile> task(this, sync_profiles); 876 AddAutofillTask<AutofillProfile> task(this, sync_profiles);
850 877
851 EXPECT_CALL(autofill_table_, AddAutofillProfile(_)). 878 EXPECT_CALL(*autofill_table_, AddAutofillProfile(_)).
852 WillOnce(Return(true)); 879 WillOnce(Return(true));
853 EXPECT_CALL(autofill_table_, RemoveAutofillProfile(native_guid)). 880 EXPECT_CALL(*autofill_table_, RemoveAutofillProfile(native_guid)).
854 WillOnce(Return(true)); 881 WillOnce(Return(true));
855 EXPECT_CALL(*personal_data_manager_, Refresh()); 882 EXPECT_CALL(*personal_data_manager_, Refresh());
856 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); 883 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE);
857 ASSERT_TRUE(task.success()); 884 ASSERT_TRUE(task.success());
858 885
859 std::vector<AutofillProfile> new_sync_profiles; 886 std::vector<AutofillProfile> new_sync_profiles;
860 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 887 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
861 &new_sync_profiles)); 888 &new_sync_profiles));
862 ASSERT_EQ(1U, new_sync_profiles.size()); 889 ASSERT_EQ(1U, new_sync_profiles.size());
863 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0])); 890 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0]));
864 EXPECT_EQ(sync_profile.guid(), new_sync_profiles[0].guid()); 891 EXPECT_EQ(sync_profile.guid(), new_sync_profiles[0].guid());
865 } 892 }
866 893
867 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddEntry) { 894 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddEntry) {
868 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 895 EXPECT_CALL(*autofill_table_,
869 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 896 GetAllAutofillEntries(_)).WillOnce(Return(true));
897 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
870 EXPECT_CALL(*personal_data_manager_, Refresh()); 898 EXPECT_CALL(*personal_data_manager_, Refresh());
871 SetIdleChangeProcessorExpectations(); 899 SetIdleChangeProcessorExpectations();
872 CreateRootTask task(this, syncable::AUTOFILL); 900 CreateRootTask task(this, syncable::AUTOFILL);
873 StartSyncService(&task, false, syncable::AUTOFILL); 901 StartSyncService(&task, false, syncable::AUTOFILL);
874 ASSERT_TRUE(task.success()); 902 ASSERT_TRUE(task.success());
875 903
876 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1)); 904 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1));
877 std::vector<base::Time> timestamps(added_entry.timestamps()); 905 std::vector<base::Time> timestamps(added_entry.timestamps());
878 906
879 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 907 EXPECT_CALL(*autofill_table_, GetAutofillTimestamps(_, _, _)).
880 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 908 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
881 909
882 AutofillChangeList changes; 910 AutofillChangeList changes;
883 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); 911 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key()));
884 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); 912 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
885 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 913 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
886 Source<WebDataService>(web_data_service_.get()), 914 Source<WebDataService>(web_data_service_.get()),
887 Details<AutofillChangeList>(&changes)); 915 Details<AutofillChangeList>(&changes));
888 916
889 std::vector<AutofillEntry> new_sync_entries; 917 std::vector<AutofillEntry> new_sync_entries;
890 std::vector<AutofillProfile> new_sync_profiles; 918 std::vector<AutofillProfile> new_sync_profiles;
891 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 919 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
892 &new_sync_profiles)); 920 &new_sync_profiles));
893 ASSERT_EQ(1U, new_sync_entries.size()); 921 ASSERT_EQ(1U, new_sync_entries.size());
894 EXPECT_TRUE(added_entry == new_sync_entries[0]); 922 EXPECT_TRUE(added_entry == new_sync_entries[0]);
895 } 923 }
896 924
897 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { 925 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
898 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 926 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
899 EXPECT_CALL(*personal_data_manager_, Refresh()); 927 EXPECT_CALL(*personal_data_manager_, Refresh());
900 SetIdleChangeProcessorExpectations(); 928 SetIdleChangeProcessorExpectations();
901 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); 929 CreateRootTask task(this, syncable::AUTOFILL_PROFILE);
902 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); 930 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE);
903 ASSERT_TRUE(task.success()); 931 ASSERT_TRUE(task.success());
904 932
905 AutofillProfile added_profile; 933 AutofillProfile added_profile;
906 autofill_test::SetProfileInfoWithGuid(&added_profile, 934 autofill_test::SetProfileInfoWithGuid(&added_profile,
907 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", 935 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz",
908 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 936 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
(...skipping 11 matching lines...) Expand all
920 &new_sync_profiles)); 948 &new_sync_profiles));
921 ASSERT_EQ(1U, new_sync_profiles.size()); 949 ASSERT_EQ(1U, new_sync_profiles.size());
922 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); 950 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0]));
923 } 951 }
924 952
925 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { 953 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) {
926 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); 954 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1));
927 std::vector<AutofillEntry> original_entries; 955 std::vector<AutofillEntry> original_entries;
928 original_entries.push_back(original_entry); 956 original_entries.push_back(original_entry);
929 957
930 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 958 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
931 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 959 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
932 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 960 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
933 EXPECT_CALL(*personal_data_manager_, Refresh()); 961 EXPECT_CALL(*personal_data_manager_, Refresh());
934 CreateRootTask task(this, syncable::AUTOFILL); 962 CreateRootTask task(this, syncable::AUTOFILL);
935 StartSyncService(&task, false, syncable::AUTOFILL); 963 StartSyncService(&task, false, syncable::AUTOFILL);
936 ASSERT_TRUE(task.success()); 964 ASSERT_TRUE(task.success());
937 965
938 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2)); 966 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2));
939 std::vector<base::Time> timestamps(updated_entry.timestamps()); 967 std::vector<base::Time> timestamps(updated_entry.timestamps());
940 968
941 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 969 EXPECT_CALL(*autofill_table_, GetAutofillTimestamps(_, _, _)).
942 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 970 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
943 971
944 AutofillChangeList changes; 972 AutofillChangeList changes;
945 changes.push_back(AutofillChange(AutofillChange::UPDATE, 973 changes.push_back(AutofillChange(AutofillChange::UPDATE,
946 updated_entry.key())); 974 updated_entry.key()));
947 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); 975 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
948 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 976 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
949 Source<WebDataService>(web_data_service_.get()), 977 Source<WebDataService>(web_data_service_.get()),
950 Details<AutofillChangeList>(&changes)); 978 Details<AutofillChangeList>(&changes));
951 979
952 std::vector<AutofillEntry> new_sync_entries; 980 std::vector<AutofillEntry> new_sync_entries;
953 std::vector<AutofillProfile> new_sync_profiles; 981 std::vector<AutofillProfile> new_sync_profiles;
954 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 982 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
955 &new_sync_profiles)); 983 &new_sync_profiles));
956 ASSERT_EQ(1U, new_sync_entries.size()); 984 ASSERT_EQ(1U, new_sync_entries.size());
957 EXPECT_TRUE(updated_entry == new_sync_entries[0]); 985 EXPECT_TRUE(updated_entry == new_sync_entries[0]);
958 } 986 }
959 987
960 988
961 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { 989 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) {
962 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); 990 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1));
963 std::vector<AutofillEntry> original_entries; 991 std::vector<AutofillEntry> original_entries;
964 original_entries.push_back(original_entry); 992 original_entries.push_back(original_entry);
965 993
966 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 994 EXPECT_CALL(*autofill_table_, GetAllAutofillEntries(_)).
967 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 995 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
968 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 996 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
969 EXPECT_CALL(*personal_data_manager_, Refresh()); 997 EXPECT_CALL(*personal_data_manager_, Refresh());
970 CreateRootTask task(this, syncable::AUTOFILL); 998 CreateRootTask task(this, syncable::AUTOFILL);
971 StartSyncService(&task, false, syncable::AUTOFILL); 999 StartSyncService(&task, false, syncable::AUTOFILL);
972 ASSERT_TRUE(task.success()); 1000 ASSERT_TRUE(task.success());
973 1001
974 AutofillChangeList changes; 1002 AutofillChangeList changes;
975 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1003 changes.push_back(AutofillChange(AutofillChange::REMOVE,
976 original_entry.key())); 1004 original_entry.key()));
977 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); 1005 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
978 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1006 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
(...skipping 14 matching lines...) Expand all
993 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1021 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
994 "32801", "US", "19482937549"); 1022 "32801", "US", "19482937549");
995 AutofillProfile* native_profile = new AutofillProfile; 1023 AutofillProfile* native_profile = new AutofillProfile;
996 autofill_test::SetProfileInfoWithGuid(native_profile, 1024 autofill_test::SetProfileInfoWithGuid(native_profile,
997 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz", 1025 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz",
998 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1026 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
999 "32801", "US", "19482937549"); 1027 "32801", "US", "19482937549");
1000 1028
1001 std::vector<AutofillProfile*> native_profiles; 1029 std::vector<AutofillProfile*> native_profiles;
1002 native_profiles.push_back(native_profile); 1030 native_profiles.push_back(native_profile);
1003 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). 1031 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).
1004 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); 1032 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true)));
1005 1033
1006 std::vector<AutofillProfile> sync_profiles; 1034 std::vector<AutofillProfile> sync_profiles;
1007 sync_profiles.push_back(sync_profile); 1035 sync_profiles.push_back(sync_profile);
1008 AddAutofillTask<AutofillProfile> task(this, sync_profiles); 1036 AddAutofillTask<AutofillProfile> task(this, sync_profiles);
1009 EXPECT_CALL(*personal_data_manager_, Refresh()); 1037 EXPECT_CALL(*personal_data_manager_, Refresh());
1010 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); 1038 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE);
1011 ASSERT_TRUE(task.success()); 1039 ASSERT_TRUE(task.success());
1012 1040
1013 AutofillProfileChange change(AutofillProfileChange::REMOVE, 1041 AutofillProfileChange change(AutofillProfileChange::REMOVE,
1014 sync_profile.guid(), NULL); 1042 sync_profile.guid(), NULL);
1015 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); 1043 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_));
1016 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1044 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1017 Source<WebDataService>(web_data_service_.get()), 1045 Source<WebDataService>(web_data_service_.get()),
1018 Details<AutofillProfileChange>(&change)); 1046 Details<AutofillProfileChange>(&change));
1019 1047
1020 std::vector<AutofillProfile> new_sync_profiles; 1048 std::vector<AutofillProfile> new_sync_profiles;
1021 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1049 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1022 &new_sync_profiles)); 1050 &new_sync_profiles));
1023 ASSERT_EQ(0U, new_sync_profiles.size()); 1051 ASSERT_EQ(0U, new_sync_profiles.size());
1024 } 1052 }
1025 1053
1026 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeError) { 1054 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeError) {
1027 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 1055 EXPECT_CALL(*autofill_table_,
1028 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 1056 GetAllAutofillEntries(_)).WillOnce(Return(true));
1057 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
1029 EXPECT_CALL(*personal_data_manager_, Refresh()); 1058 EXPECT_CALL(*personal_data_manager_, Refresh());
1030 CreateRootTask task(this, syncable::AUTOFILL); 1059 CreateRootTask task(this, syncable::AUTOFILL);
1031 StartSyncService(&task, false, syncable::AUTOFILL); 1060 StartSyncService(&task, false, syncable::AUTOFILL);
1032 ASSERT_TRUE(task.success()); 1061 ASSERT_TRUE(task.success());
1033 1062
1034 // Inject an evil entry into the sync db to conflict with the same 1063 // Inject an evil entry into the sync db to conflict with the same
1035 // entry added by the user. 1064 // entry added by the user.
1036 AutofillEntry evil_entry(MakeAutofillEntry("evil", "entry", 1)); 1065 AutofillEntry evil_entry(MakeAutofillEntry("evil", "entry", 1));
1037 ASSERT_TRUE(AddAutofillSyncNode(evil_entry)); 1066 ASSERT_TRUE(AddAutofillSyncNode(evil_entry));
1038 1067
(...skipping 13 matching lines...) Expand all
1052 EXPECT_TRUE(service_->unrecoverable_error_detected()); 1081 EXPECT_TRUE(service_->unrecoverable_error_detected());
1053 1082
1054 // Ensure future autofill notifications don't crash. 1083 // Ensure future autofill notifications don't crash.
1055 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1084 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1056 Source<WebDataService>(web_data_service_.get()), 1085 Source<WebDataService>(web_data_service_.get()),
1057 Details<AutofillChangeList>(&changes)); 1086 Details<AutofillChangeList>(&changes));
1058 } 1087 }
1059 1088
1060 // Crashy, http://crbug.com/57884 1089 // Crashy, http://crbug.com/57884
1061 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { 1090 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) {
1062 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); 1091 EXPECT_CALL(*autofill_table_,
1063 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 1092 GetAllAutofillEntries(_)).WillOnce(Return(true));
1064 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). 1093 EXPECT_CALL(*autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
1094 EXPECT_CALL(*autofill_table_, UpdateAutofillEntries(_)).
1065 WillRepeatedly(Return(true)); 1095 WillRepeatedly(Return(true));
1066 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); 1096 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3);
1067 CreateRootTask task(this, syncable::AUTOFILL); 1097 CreateRootTask task(this, syncable::AUTOFILL);
1068 StartSyncService(&task, false, syncable::AUTOFILL); 1098 StartSyncService(&task, false, syncable::AUTOFILL);
1069 ASSERT_TRUE(task.success()); 1099 ASSERT_TRUE(task.success());
1070 1100
1071 // (true, false) means we have to reset after |Signal|, init to unsignaled. 1101 // (true, false) means we have to reset after |Signal|, init to unsignaled.
1072 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); 1102 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false));
1073 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); 1103 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false));
1074 scoped_refptr<FakeServerUpdater> updater(new FakeServerUpdater( 1104 scoped_refptr<FakeServerUpdater> updater(new FakeServerUpdater(
(...skipping 18 matching lines...) Expand all
1093 std::vector<AutofillEntry> sync_entries; 1123 std::vector<AutofillEntry> sync_entries;
1094 std::vector<AutofillProfile> sync_profiles; 1124 std::vector<AutofillProfile> sync_profiles;
1095 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1125 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1096 EXPECT_EQ(3U, sync_entries.size()); 1126 EXPECT_EQ(3U, sync_entries.size());
1097 EXPECT_EQ(0U, sync_profiles.size()); 1127 EXPECT_EQ(0U, sync_profiles.size());
1098 for (size_t i = 0; i < sync_entries.size(); i++) { 1128 for (size_t i = 0; i < sync_entries.size(); i++) {
1099 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1129 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1100 << ", " << sync_entries[i].key().value(); 1130 << ", " << sync_entries[i].key().value();
1101 } 1131 }
1102 } 1132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698