| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 23 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 24 #include "chrome/browser/signin/signin_manager.h" | 24 #include "chrome/browser/signin/signin_manager.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/browser/signin/token_service_factory.h" | |
| 27 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 26 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
| 28 #include "chrome/browser/sync/fake_oauth2_token_service.h" | 27 #include "chrome/browser/sync/fake_oauth2_token_service.h" |
| 29 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" | 28 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" |
| 30 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" | 29 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" |
| 31 #include "chrome/browser/sync/glue/data_type_controller.h" | 30 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 32 #include "chrome/browser/sync/glue/generic_change_processor.h" | 31 #include "chrome/browser/sync/glue/generic_change_processor.h" |
| 33 #include "chrome/browser/sync/glue/shared_change_processor.h" | 32 #include "chrome/browser/sync/glue/shared_change_processor.h" |
| 34 #include "chrome/browser/sync/profile_sync_components_factory.h" | 33 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 35 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
| 36 #include "chrome/browser/sync/profile_sync_service_factory.h" | 35 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 : TokenWebData() { | 194 : TokenWebData() { |
| 196 } | 195 } |
| 197 | 196 |
| 198 virtual bool IsDatabaseLoaded() OVERRIDE { | 197 virtual bool IsDatabaseLoaded() OVERRIDE { |
| 199 return true; | 198 return true; |
| 200 } | 199 } |
| 201 | 200 |
| 202 virtual WebDataService::Handle GetAllTokens( | 201 virtual WebDataService::Handle GetAllTokens( |
| 203 WebDataServiceConsumer* consumer) OVERRIDE { | 202 WebDataServiceConsumer* consumer) OVERRIDE { |
| 204 // TODO(tim): It would be nice if WebDataService was injected on | 203 // TODO(tim): It would be nice if WebDataService was injected on |
| 205 // construction of TokenService rather than fetched by Initialize so that | 204 // construction of ProfileOAuth2TokenService rather than fetched by |
| 206 // this isn't necessary (we could pass a NULL service). We currently do | 205 // Initialize so that this isn't necessary (we could pass a NULL service). |
| 207 // return it via EXPECT_CALLs, but without depending on order-of- | 206 // We currently do return it via EXPECT_CALLs, but without depending on |
| 208 // initialization (which seems way more fragile) we can't tell which | 207 // order-of-initialization (which seems way more fragile) we can't tell |
| 209 // component is asking at what time, and some components in these Autofill | 208 // which component is asking at what time, and some components in these |
| 210 // tests require a WebDataService. | 209 // Autofill tests require a WebDataService. |
| 211 return 0; | 210 return 0; |
| 212 } | 211 } |
| 213 | 212 |
| 214 private: | 213 private: |
| 215 virtual ~TokenWebDataServiceFake() {} | 214 virtual ~TokenWebDataServiceFake() {} |
| 216 | 215 |
| 217 DISALLOW_COPY_AND_ASSIGN(TokenWebDataServiceFake); | 216 DISALLOW_COPY_AND_ASSIGN(TokenWebDataServiceFake); |
| 218 }; | 217 }; |
| 219 | 218 |
| 220 class WebDataServiceFake : public AutofillWebDataService { | 219 class WebDataServiceFake : public AutofillWebDataService { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 web_data_service_->SetDatabase(web_database_.get()); | 518 web_data_service_->SetDatabase(web_database_.get()); |
| 520 | 519 |
| 521 MockPersonalDataManagerService* personal_data_manager_service = | 520 MockPersonalDataManagerService* personal_data_manager_service = |
| 522 static_cast<MockPersonalDataManagerService*>( | 521 static_cast<MockPersonalDataManagerService*>( |
| 523 autofill::PersonalDataManagerFactory::GetInstance() | 522 autofill::PersonalDataManagerFactory::GetInstance() |
| 524 ->SetTestingFactoryAndUse( | 523 ->SetTestingFactoryAndUse( |
| 525 profile_.get(), MockPersonalDataManagerService::Build)); | 524 profile_.get(), MockPersonalDataManagerService::Build)); |
| 526 personal_data_manager_ = | 525 personal_data_manager_ = |
| 527 personal_data_manager_service->GetPersonalDataManager(); | 526 personal_data_manager_service->GetPersonalDataManager(); |
| 528 | 527 |
| 529 token_service_ = static_cast<TokenService*>( | |
| 530 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
| 531 profile_.get(), BuildTokenService)); | |
| 532 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); | 528 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); |
| 533 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); | 529 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); |
| 534 | 530 |
| 535 personal_data_manager_->Init(profile_.get(), | 531 personal_data_manager_->Init(profile_.get(), |
| 536 profile_->GetPrefs(), | 532 profile_->GetPrefs(), |
| 537 profile_->IsOffTheRecord()); | 533 profile_->IsOffTheRecord()); |
| 538 | 534 |
| 539 web_data_service_->StartSyncableService(); | 535 web_data_service_->StartSyncableService(); |
| 540 } | 536 } |
| 541 | 537 |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 std::vector<AutofillEntry> sync_entries; | 1403 std::vector<AutofillEntry> sync_entries; |
| 1408 std::vector<AutofillProfile> sync_profiles; | 1404 std::vector<AutofillProfile> sync_profiles; |
| 1409 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1405 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1410 EXPECT_EQ(3U, sync_entries.size()); | 1406 EXPECT_EQ(3U, sync_entries.size()); |
| 1411 EXPECT_EQ(0U, sync_profiles.size()); | 1407 EXPECT_EQ(0U, sync_profiles.size()); |
| 1412 for (size_t i = 0; i < sync_entries.size(); i++) { | 1408 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1413 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1409 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1414 << ", " << sync_entries[i].key().value(); | 1410 << ", " << sync_entries[i].key().value(); |
| 1415 } | 1411 } |
| 1416 } | 1412 } |
| OLD | NEW |