OLD | NEW |
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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 static_cast<MockPersonalDataManagerService*>( | 518 static_cast<MockPersonalDataManagerService*>( |
519 autofill::PersonalDataManagerFactory::GetInstance() | 519 autofill::PersonalDataManagerFactory::GetInstance() |
520 ->SetTestingFactoryAndUse( | 520 ->SetTestingFactoryAndUse( |
521 profile_.get(), MockPersonalDataManagerService::Build)); | 521 profile_.get(), MockPersonalDataManagerService::Build)); |
522 personal_data_manager_ = | 522 personal_data_manager_ = |
523 personal_data_manager_service->GetPersonalDataManager(); | 523 personal_data_manager_service->GetPersonalDataManager(); |
524 | 524 |
525 token_service_ = static_cast<TokenService*>( | 525 token_service_ = static_cast<TokenService*>( |
526 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 526 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
527 profile_.get(), BuildTokenService)); | 527 profile_.get(), BuildTokenService)); |
| 528 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
| 529 profile_.get(), FakeOAuth2TokenService::BuildTokenService); |
528 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); | 530 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); |
529 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); | 531 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); |
530 | 532 |
531 personal_data_manager_->Init(profile_.get()); | 533 personal_data_manager_->Init(profile_.get()); |
532 | 534 |
533 web_data_service_->StartSyncableService(); | 535 web_data_service_->StartSyncableService(); |
534 } | 536 } |
535 | 537 |
536 virtual void TearDown() OVERRIDE { | 538 virtual void TearDown() OVERRIDE { |
537 // Note: The tear down order is important. | 539 // Note: The tear down order is important. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 data_type_controller); | 583 data_type_controller); |
582 | 584 |
583 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)). | 585 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)). |
584 WillOnce(ReturnNewDataTypeManagerWithDebugListener( | 586 WillOnce(ReturnNewDataTypeManagerWithDebugListener( |
585 syncer::MakeWeakHandle(debug_ptr_factory_.GetWeakPtr()))); | 587 syncer::MakeWeakHandle(debug_ptr_factory_.GetWeakPtr()))); |
586 | 588 |
587 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). | 589 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). |
588 WillRepeatedly(Return(true)); | 590 WillRepeatedly(Return(true)); |
589 | 591 |
590 // We need tokens to get the tests going | 592 // We need tokens to get the tests going |
591 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token"); | 593 token_service_->IssueAuthTokenForTest( |
| 594 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); |
| 595 token_service_->IssueAuthTokenForTest( |
| 596 GaiaConstants::kSyncService, "token"); |
592 | 597 |
593 sync_service_->RegisterDataTypeController(data_type_controller); | 598 sync_service_->RegisterDataTypeController(data_type_controller); |
594 sync_service_->Initialize(); | 599 sync_service_->Initialize(); |
595 base::MessageLoop::current()->Run(); | 600 base::MessageLoop::current()->Run(); |
596 | 601 |
597 // It's possible this test triggered an unrecoverable error, in which case | 602 // It's possible this test triggered an unrecoverable error, in which case |
598 // we can't get the sync count. | 603 // we can't get the sync count. |
599 if (sync_service_->ShouldPushChanges()) { | 604 if (sync_service_->ShouldPushChanges()) { |
600 EXPECT_EQ(GetSyncCount(type), | 605 EXPECT_EQ(GetSyncCount(type), |
601 association_stats_.num_sync_items_after_association); | 606 association_stats_.num_sync_items_after_association); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 | 933 |
929 std::set<string16> values_set; | 934 std::set<string16> values_set; |
930 for (size_t i = 0; i < values1.size(); ++i) | 935 for (size_t i = 0; i < values1.size(); ++i) |
931 values_set.insert(values1[i]); | 936 values_set.insert(values1[i]); |
932 for (size_t i = 0; i < values2.size(); ++i) | 937 for (size_t i = 0; i < values2.size(); ++i) |
933 if (values_set.find(values2[i]) == values_set.end()) | 938 if (values_set.find(values2[i]) == values_set.end()) |
934 return false; | 939 return false; |
935 return true; | 940 return true; |
936 } | 941 } |
937 | 942 |
938 }; | 943 } // namespace |
939 | 944 |
940 // TODO(skrul): Test abort startup. | 945 // TODO(skrul): Test abort startup. |
941 // TODO(skrul): Test processing of cloud changes. | 946 // TODO(skrul): Test processing of cloud changes. |
942 // TODO(tim): Add autofill data type controller test, and a case to cover | 947 // TODO(tim): Add autofill data type controller test, and a case to cover |
943 // waiting for the PersonalDataManager. | 948 // waiting for the PersonalDataManager. |
944 TEST_F(ProfileSyncServiceAutofillTest, FailModelAssociation) { | 949 TEST_F(ProfileSyncServiceAutofillTest, FailModelAssociation) { |
945 // Don't create the root autofill node so startup fails. | 950 // Don't create the root autofill node so startup fails. |
946 StartSyncService(base::Closure(), true, syncer::AUTOFILL); | 951 StartSyncService(base::Closure(), true, syncer::AUTOFILL); |
947 EXPECT_TRUE(sync_service_->HasUnrecoverableError()); | 952 EXPECT_TRUE(sync_service_->HasUnrecoverableError()); |
948 } | 953 } |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 std::vector<AutofillEntry> sync_entries; | 1407 std::vector<AutofillEntry> sync_entries; |
1403 std::vector<AutofillProfile> sync_profiles; | 1408 std::vector<AutofillProfile> sync_profiles; |
1404 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1409 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1405 EXPECT_EQ(3U, sync_entries.size()); | 1410 EXPECT_EQ(3U, sync_entries.size()); |
1406 EXPECT_EQ(0U, sync_profiles.size()); | 1411 EXPECT_EQ(0U, sync_profiles.size()); |
1407 for (size_t i = 0; i < sync_entries.size(); i++) { | 1412 for (size_t i = 0; i < sync_entries.size(); i++) { |
1408 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1413 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1409 << ", " << sync_entries[i].key().value(); | 1414 << ", " << sync_entries[i].key().value(); |
1410 } | 1415 } |
1411 } | 1416 } |
OLD | NEW |