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

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

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 370 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
371 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 371 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
372 return base::WeakPtr<syncer::SyncableService>(); 372 return base::WeakPtr<syncer::SyncableService>();
373 return AutofillProfileSyncableService::FromWebDataService(wds)->AsWeakPtr(); 373 return AutofillProfileSyncableService::FromWebDataService(wds)->AsWeakPtr();
374 } 374 }
375 375
376 class AbstractAutofillFactory { 376 class AbstractAutofillFactory {
377 public: 377 public:
378 virtual DataTypeController* CreateDataTypeController( 378 virtual DataTypeController* CreateDataTypeController(
379 ProfileSyncComponentsFactory* factory, 379 ProfileSyncComponentsFactory* factory,
380 ProfileMock* profile, 380 TestingProfile* profile,
381 ProfileSyncService* service) = 0; 381 ProfileSyncService* service) = 0;
382 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 382 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
383 ProfileSyncService* service, 383 ProfileSyncService* service,
384 AutofillWebDataService* wds, 384 AutofillWebDataService* wds,
385 DataTypeController* dtc) = 0; 385 DataTypeController* dtc) = 0;
386 virtual ~AbstractAutofillFactory() {} 386 virtual ~AbstractAutofillFactory() {}
387 }; 387 };
388 388
389 class AutofillEntryFactory : public AbstractAutofillFactory { 389 class AutofillEntryFactory : public AbstractAutofillFactory {
390 public: 390 public:
391 virtual browser_sync::DataTypeController* CreateDataTypeController( 391 virtual browser_sync::DataTypeController* CreateDataTypeController(
392 ProfileSyncComponentsFactory* factory, 392 ProfileSyncComponentsFactory* factory,
393 ProfileMock* profile, 393 TestingProfile* profile,
394 ProfileSyncService* service) OVERRIDE { 394 ProfileSyncService* service) OVERRIDE {
395 return new AutofillDataTypeController(factory, profile, service); 395 return new AutofillDataTypeController(factory, profile, service);
396 } 396 }
397 397
398 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 398 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
399 ProfileSyncService* service, 399 ProfileSyncService* service,
400 AutofillWebDataService* wds, 400 AutofillWebDataService* wds,
401 DataTypeController* dtc) OVERRIDE { 401 DataTypeController* dtc) OVERRIDE {
402 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 402 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
403 WillOnce(MakeGenericChangeProcessor()); 403 WillOnce(MakeGenericChangeProcessor());
404 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 404 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
405 WillOnce(MakeSharedChangeProcessor()); 405 WillOnce(MakeSharedChangeProcessor());
406 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)). 406 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)).
407 WillOnce(MakeAutocompleteSyncComponents(wds)); 407 WillOnce(MakeAutocompleteSyncComponents(wds));
408 } 408 }
409 }; 409 };
410 410
411 class AutofillProfileFactory : public AbstractAutofillFactory { 411 class AutofillProfileFactory : public AbstractAutofillFactory {
412 public: 412 public:
413 virtual browser_sync::DataTypeController* CreateDataTypeController( 413 virtual browser_sync::DataTypeController* CreateDataTypeController(
414 ProfileSyncComponentsFactory* factory, 414 ProfileSyncComponentsFactory* factory,
415 ProfileMock* profile, 415 TestingProfile* profile,
416 ProfileSyncService* service) OVERRIDE { 416 ProfileSyncService* service) OVERRIDE {
417 return new AutofillProfileDataTypeController(factory, profile, service); 417 return new AutofillProfileDataTypeController(factory, profile, service);
418 } 418 }
419 419
420 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 420 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
421 ProfileSyncService* service, 421 ProfileSyncService* service,
422 AutofillWebDataService* wds, 422 AutofillWebDataService* wds,
423 DataTypeController* dtc) OVERRIDE { 423 DataTypeController* dtc) OVERRIDE {
424 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 424 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
425 WillOnce(MakeGenericChangeProcessor()); 425 WillOnce(MakeGenericChangeProcessor());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } else if (type == syncer::AUTOFILL_PROFILE) { 496 } else if (type == syncer::AUTOFILL_PROFILE) {
497 return &profile_factory_; 497 return &profile_factory_;
498 } else { 498 } else {
499 NOTREACHED(); 499 NOTREACHED();
500 return NULL; 500 return NULL;
501 } 501 }
502 } 502 }
503 503
504 virtual void SetUp() OVERRIDE { 504 virtual void SetUp() OVERRIDE {
505 AbstractProfileSyncServiceTest::SetUp(); 505 AbstractProfileSyncServiceTest::SetUp();
506 profile_.reset(new ProfileMock()); 506 TestingProfile::Builder builder;
507 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
508 FakeOAuth2TokenService::BuildTokenService);
509 profile_ = builder.Build().Pass();
507 web_database_.reset(new WebDatabaseFake(&autofill_table_)); 510 web_database_.reset(new WebDatabaseFake(&autofill_table_));
508 MockWebDataServiceWrapper* wrapper = 511 MockWebDataServiceWrapper* wrapper =
509 static_cast<MockWebDataServiceWrapper*>( 512 static_cast<MockWebDataServiceWrapper*>(
510 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( 513 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
511 profile_.get(), BuildMockWebDataServiceWrapper)); 514 profile_.get(), BuildMockWebDataServiceWrapper));
512 web_data_service_ = 515 web_data_service_ =
513 static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get()); 516 static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get());
514 web_data_service_->SetDatabase(web_database_.get()); 517 web_data_service_->SetDatabase(web_database_.get());
515 518
516 MockPersonalDataManagerService* personal_data_manager_service = 519 MockPersonalDataManagerService* personal_data_manager_service =
517 static_cast<MockPersonalDataManagerService*>( 520 static_cast<MockPersonalDataManagerService*>(
518 autofill::PersonalDataManagerFactory::GetInstance() 521 autofill::PersonalDataManagerFactory::GetInstance()
519 ->SetTestingFactoryAndUse( 522 ->SetTestingFactoryAndUse(
520 profile_.get(), MockPersonalDataManagerService::Build)); 523 profile_.get(), MockPersonalDataManagerService::Build));
521 personal_data_manager_ = 524 personal_data_manager_ =
522 personal_data_manager_service->GetPersonalDataManager(); 525 personal_data_manager_service->GetPersonalDataManager();
523 526
524 token_service_ = static_cast<TokenService*>( 527 token_service_ = static_cast<TokenService*>(
525 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 528 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
526 profile_.get(), BuildTokenService)); 529 profile_.get(), BuildTokenService));
527 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
528 profile_.get(), FakeOAuth2TokenService::BuildTokenService);
529 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); 530 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1);
530 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); 531 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1);
531 532
532 personal_data_manager_->Init(profile_.get()); 533 personal_data_manager_->Init(profile_.get());
533 534
534 web_data_service_->StartSyncableService(); 535 web_data_service_->StartSyncableService();
535 } 536 }
536 537
537 virtual void TearDown() OVERRIDE { 538 virtual void TearDown() OVERRIDE {
538 // Note: The tear down order is important. 539 // Note: The tear down order is important.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 static AutofillEntry MakeAutofillEntry(const char* name, 751 static AutofillEntry MakeAutofillEntry(const char* name,
751 const char* value, 752 const char* value,
752 int time_shift) { 753 int time_shift) {
753 return MakeAutofillEntry(name, value, time_shift, -1); 754 return MakeAutofillEntry(name, value, time_shift, -1);
754 } 755 }
755 756
756 friend class AddAutofillHelper<AutofillEntry>; 757 friend class AddAutofillHelper<AutofillEntry>;
757 friend class AddAutofillHelper<AutofillProfile>; 758 friend class AddAutofillHelper<AutofillProfile>;
758 friend class FakeServerUpdater; 759 friend class FakeServerUpdater;
759 760
760 scoped_ptr<ProfileMock> profile_; 761 scoped_ptr<TestingProfile> profile_;
761 AutofillTableMock autofill_table_; 762 AutofillTableMock autofill_table_;
762 scoped_ptr<WebDatabaseFake> web_database_; 763 scoped_ptr<WebDatabaseFake> web_database_;
763 scoped_refptr<WebDataServiceFake> web_data_service_; 764 scoped_refptr<WebDataServiceFake> web_data_service_;
764 MockPersonalDataManager* personal_data_manager_; 765 MockPersonalDataManager* personal_data_manager_;
765 syncer::DataTypeAssociationStats association_stats_; 766 syncer::DataTypeAssociationStats association_stats_;
766 base::WeakPtrFactory<DataTypeDebugInfoListener> debug_ptr_factory_; 767 base::WeakPtrFactory<DataTypeDebugInfoListener> debug_ptr_factory_;
767 }; 768 };
768 769
769 template <class T> 770 template <class T>
770 class AddAutofillHelper { 771 class AddAutofillHelper {
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 std::vector<AutofillEntry> sync_entries; 1406 std::vector<AutofillEntry> sync_entries;
1406 std::vector<AutofillProfile> sync_profiles; 1407 std::vector<AutofillProfile> sync_profiles;
1407 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1408 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1408 EXPECT_EQ(3U, sync_entries.size()); 1409 EXPECT_EQ(3U, sync_entries.size());
1409 EXPECT_EQ(0U, sync_profiles.size()); 1410 EXPECT_EQ(0U, sync_profiles.size());
1410 for (size_t i = 0; i < sync_entries.size(); i++) { 1411 for (size_t i = 0; i < sync_entries.size(); i++) {
1411 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1412 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1412 << ", " << sync_entries[i].key().value(); 1413 << ", " << sync_entries[i].key().value();
1413 } 1414 }
1414 } 1415 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/ubertoken_fetcher_unittest.cc ('k') | chrome/browser/sync/profile_sync_service_password_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698