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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 24 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
25 #include "chrome/browser/prefs/pref_service_syncable.h" | 25 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 26 #include "chrome/browser/signin/account_tracker_service_factory.h" |
26 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 27 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
27 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 28 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
29 #include "chrome/browser/signin/signin_manager_factory.h" | 30 #include "chrome/browser/signin/signin_manager_factory.h" |
30 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 31 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
31 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" | 32 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" |
32 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" | 33 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" |
33 #include "chrome/browser/sync/profile_sync_components_factory.h" | 34 #include "chrome/browser/sync/profile_sync_components_factory.h" |
34 #include "chrome/browser/sync/profile_sync_service.h" | 35 #include "chrome/browser/sync/profile_sync_service.h" |
35 #include "chrome/browser/sync/profile_sync_service_factory.h" | 36 #include "chrome/browser/sync/profile_sync_service_factory.h" |
36 #include "chrome/browser/sync/profile_sync_test_util.h" | 37 #include "chrome/browser/sync/profile_sync_test_util.h" |
37 #include "chrome/browser/sync/test_profile_sync_service.h" | 38 #include "chrome/browser/sync/test_profile_sync_service.h" |
38 #include "chrome/browser/webdata/web_data_service_factory.h" | 39 #include "chrome/browser/webdata/web_data_service_factory.h" |
39 #include "chrome/test/base/testing_browser_process.h" | 40 #include "chrome/test/base/testing_browser_process.h" |
40 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
41 #include "chrome/test/base/testing_profile_manager.h" | 42 #include "chrome/test/base/testing_profile_manager.h" |
42 #include "components/autofill/core/browser/autofill_test_utils.h" | 43 #include "components/autofill/core/browser/autofill_test_utils.h" |
43 #include "components/autofill/core/browser/personal_data_manager.h" | 44 #include "components/autofill/core/browser/personal_data_manager.h" |
44 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 45 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
45 #include "components/autofill/core/browser/webdata/autofill_change.h" | 46 #include "components/autofill/core/browser/webdata/autofill_change.h" |
46 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 47 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
47 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 48 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
48 #include "components/autofill/core/browser/webdata/autofill_table.h" | 49 #include "components/autofill/core/browser/webdata/autofill_table.h" |
49 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 50 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 51 #include "components/signin/core/browser/account_tracker_service.h" |
50 #include "components/signin/core/browser/signin_manager.h" | 52 #include "components/signin/core/browser/signin_manager.h" |
51 #include "components/sync_driver/data_type_controller.h" | 53 #include "components/sync_driver/data_type_controller.h" |
52 #include "components/webdata/common/web_database.h" | 54 #include "components/webdata/common/web_database.h" |
53 #include "components/webdata_services/web_data_service_test_util.h" | 55 #include "components/webdata_services/web_data_service_test_util.h" |
54 #include "content/public/test/test_browser_thread.h" | 56 #include "content/public/test/test_browser_thread.h" |
55 #include "google_apis/gaia/gaia_constants.h" | 57 #include "google_apis/gaia/gaia_constants.h" |
56 #include "sync/internal_api/public/base/model_type.h" | 58 #include "sync/internal_api/public/base/model_type.h" |
57 #include "sync/internal_api/public/data_type_debug_info_listener.h" | 59 #include "sync/internal_api/public/data_type_debug_info_listener.h" |
58 #include "sync/internal_api/public/read_node.h" | 60 #include "sync/internal_api/public/read_node.h" |
59 #include "sync/internal_api/public/read_transaction.h" | 61 #include "sync/internal_api/public/read_transaction.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 ->SetTestingFactoryAndUse(profile_, | 492 ->SetTestingFactoryAndUse(profile_, |
491 MockPersonalDataManager::Build)); | 493 MockPersonalDataManager::Build)); |
492 | 494 |
493 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); | 495 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); |
494 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); | 496 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); |
495 | 497 |
496 personal_data_manager_->Init( | 498 personal_data_manager_->Init( |
497 WebDataServiceFactory::GetAutofillWebDataForProfile( | 499 WebDataServiceFactory::GetAutofillWebDataForProfile( |
498 profile_, ServiceAccessType::EXPLICIT_ACCESS), | 500 profile_, ServiceAccessType::EXPLICIT_ACCESS), |
499 profile_->GetPrefs(), | 501 profile_->GetPrefs(), |
| 502 AccountTrackerServiceFactory::GetForProfile(profile_), |
500 profile_->IsOffTheRecord()); | 503 profile_->IsOffTheRecord()); |
501 | 504 |
502 web_data_service_->StartSyncableService(); | 505 web_data_service_->StartSyncableService(); |
503 | 506 |
504 // When UpdateAutofillEntries() is called with an empty list, the return | 507 // When UpdateAutofillEntries() is called with an empty list, the return |
505 // value should be |true|, rather than the default of |false|. | 508 // value should be |true|, rather than the default of |false|. |
506 std::vector<AutofillEntry> empty; | 509 std::vector<AutofillEntry> empty; |
507 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(empty)) | 510 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(empty)) |
508 .WillRepeatedly(Return(true)); | 511 .WillRepeatedly(Return(true)); |
509 } | 512 } |
(...skipping 17 matching lines...) Expand all Loading... |
527 if (node.InitTypeRoot(type) != syncer::BaseNode::INIT_OK) | 530 if (node.InitTypeRoot(type) != syncer::BaseNode::INIT_OK) |
528 return 0; | 531 return 0; |
529 return node.GetTotalNodeCount() - 1; | 532 return node.GetTotalNodeCount() - 1; |
530 } | 533 } |
531 | 534 |
532 void StartSyncService(const base::Closure& callback, | 535 void StartSyncService(const base::Closure& callback, |
533 bool will_fail_association, | 536 bool will_fail_association, |
534 syncer::ModelType type) { | 537 syncer::ModelType type) { |
535 AbstractAutofillFactory* factory = GetFactory(type); | 538 AbstractAutofillFactory* factory = GetFactory(type); |
536 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); | 539 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); |
537 signin->SetAuthenticatedUsername("test_user@gmail.com"); | 540 const std::string account_id = "test_user@gmail.com"; |
| 541 signin->SetAuthenticatedAccountInfo(account_id, account_id); |
538 sync_service_ = TestProfileSyncService::BuildAutoStartAsyncInit(profile_, | 542 sync_service_ = TestProfileSyncService::BuildAutoStartAsyncInit(profile_, |
539 callback); | 543 callback); |
540 | 544 |
541 ProfileSyncComponentsFactoryMock* components = | 545 ProfileSyncComponentsFactoryMock* components = |
542 sync_service_->components_factory_mock(); | 546 sync_service_->components_factory_mock(); |
543 DataTypeController* data_type_controller = | 547 DataTypeController* data_type_controller = |
544 factory->CreateDataTypeController(components, profile_, sync_service_); | 548 factory->CreateDataTypeController(components, profile_, sync_service_); |
545 factory->SetExpectation(components, | 549 factory->SetExpectation(components, |
546 sync_service_, | 550 sync_service_, |
547 web_data_service_.get(), | 551 web_data_service_.get(), |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 std::vector<AutofillEntry> sync_entries; | 1374 std::vector<AutofillEntry> sync_entries; |
1371 std::vector<AutofillProfile> sync_profiles; | 1375 std::vector<AutofillProfile> sync_profiles; |
1372 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1376 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1373 EXPECT_EQ(3U, sync_entries.size()); | 1377 EXPECT_EQ(3U, sync_entries.size()); |
1374 EXPECT_EQ(0U, sync_profiles.size()); | 1378 EXPECT_EQ(0U, sync_profiles.size()); |
1375 for (size_t i = 0; i < sync_entries.size(); i++) { | 1379 for (size_t i = 0; i < sync_entries.size(); i++) { |
1376 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1380 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1377 << ", " << sync_entries[i].key().value(); | 1381 << ", " << sync_entries[i].key().value(); |
1378 } | 1382 } |
1379 } | 1383 } |
OLD | NEW |