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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/signin/signin_manager_factory.h" | 32 #include "chrome/browser/signin/signin_manager_factory.h" |
33 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 33 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
34 #include "chrome/browser/sync/profile_sync_service_factory.h" | 34 #include "chrome/browser/sync/profile_sync_service_factory.h" |
35 #include "chrome/browser/sync/profile_sync_test_util.h" | 35 #include "chrome/browser/sync/profile_sync_test_util.h" |
36 #include "chrome/browser/sync/test_profile_sync_service.h" | 36 #include "chrome/browser/sync/test_profile_sync_service.h" |
37 #include "chrome/browser/web_data_service_factory.h" | 37 #include "chrome/browser/web_data_service_factory.h" |
38 #include "chrome/test/base/testing_browser_process.h" | 38 #include "chrome/test/base/testing_browser_process.h" |
39 #include "chrome/test/base/testing_profile.h" | 39 #include "chrome/test/base/testing_profile.h" |
40 #include "chrome/test/base/testing_profile_manager.h" | 40 #include "chrome/test/base/testing_profile_manager.h" |
41 #include "components/autofill/core/browser/autofill_test_utils.h" | 41 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 42 #include "components/autofill/core/browser/country_names.h" |
42 #include "components/autofill/core/browser/personal_data_manager.h" | 43 #include "components/autofill/core/browser/personal_data_manager.h" |
43 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 44 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
44 #include "components/autofill/core/browser/webdata/autofill_change.h" | 45 #include "components/autofill/core/browser/webdata/autofill_change.h" |
45 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" | 46 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.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_data_type_co
ntroller.h" | 48 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" |
48 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 49 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
49 #include "components/autofill/core/browser/webdata/autofill_table.h" | 50 #include "components/autofill/core/browser/webdata/autofill_table.h" |
50 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 51 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
51 #include "components/browser_sync/browser/profile_sync_service.h" | 52 #include "components/browser_sync/browser/profile_sync_service.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 void OnDataTypeConfigureComplete(const std::vector< | 423 void OnDataTypeConfigureComplete(const std::vector< |
423 syncer::DataTypeConfigurationStats>& configuration_stats) override { | 424 syncer::DataTypeConfigurationStats>& configuration_stats) override { |
424 ASSERT_EQ(1u, configuration_stats.size()); | 425 ASSERT_EQ(1u, configuration_stats.size()); |
425 association_stats_ = configuration_stats[0].association_stats; | 426 association_stats_ = configuration_stats[0].association_stats; |
426 } | 427 } |
427 | 428 |
428 protected: | 429 protected: |
429 ProfileSyncServiceAutofillTest() | 430 ProfileSyncServiceAutofillTest() |
430 : profile_manager_(TestingBrowserProcess::GetGlobal()), | 431 : profile_manager_(TestingBrowserProcess::GetGlobal()), |
431 debug_ptr_factory_(this) { | 432 debug_ptr_factory_(this) { |
| 433 autofill::CountryNames::SetLocaleString("en-US"); |
432 } | 434 } |
| 435 |
433 ~ProfileSyncServiceAutofillTest() override {} | 436 ~ProfileSyncServiceAutofillTest() override {} |
434 | 437 |
435 void SetUp() override { | 438 void SetUp() override { |
436 AbstractProfileSyncServiceTest::SetUp(); | 439 AbstractProfileSyncServiceTest::SetUp(); |
437 ASSERT_TRUE(profile_manager_.SetUp()); | 440 ASSERT_TRUE(profile_manager_.SetUp()); |
438 TestingProfile::TestingFactories testing_factories; | 441 TestingProfile::TestingFactories testing_factories; |
439 testing_factories.push_back(std::make_pair( | 442 testing_factories.push_back(std::make_pair( |
440 ProfileOAuth2TokenServiceFactory::GetInstance(), | 443 ProfileOAuth2TokenServiceFactory::GetInstance(), |
441 BuildAutoIssuingFakeProfileOAuth2TokenService)); | 444 BuildAutoIssuingFakeProfileOAuth2TokenService)); |
442 profile_ = profile_manager_.CreateTestingProfile( | 445 profile_ = profile_manager_.CreateTestingProfile( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 for (int i = 0; i < timestamps_count; ++i) { | 603 for (int i = 0; i < timestamps_count; ++i) { |
601 timestamps.push_back(Time::FromInternalValue( | 604 timestamps.push_back(Time::FromInternalValue( |
602 autofill.usage_timestamp(i))); | 605 autofill.usage_timestamp(i))); |
603 } | 606 } |
604 entries->push_back( | 607 entries->push_back( |
605 AutofillEntry(key, timestamps.front(), timestamps.back())); | 608 AutofillEntry(key, timestamps.front(), timestamps.back())); |
606 } else if (autofill.has_profile()) { | 609 } else if (autofill.has_profile()) { |
607 AutofillProfile p; | 610 AutofillProfile p; |
608 p.set_guid(autofill.profile().guid()); | 611 p.set_guid(autofill.profile().guid()); |
609 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 612 AutofillProfileSyncableService::OverwriteProfileWithServerData( |
610 autofill.profile(), &p, "en-US"); | 613 autofill.profile(), &p); |
611 profiles->push_back(p); | 614 profiles->push_back(p); |
612 } | 615 } |
613 child_id = child_node.GetSuccessorId(); | 616 child_id = child_node.GetSuccessorId(); |
614 } | 617 } |
615 return true; | 618 return true; |
616 } | 619 } |
617 | 620 |
618 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 621 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
619 std::vector<AutofillProfile>* profiles) { | 622 std::vector<AutofillProfile>* profiles) { |
620 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 623 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
621 syncer::ReadNode autofill_root(&trans); | 624 syncer::ReadNode autofill_root(&trans); |
622 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { | 625 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { |
623 return false; | 626 return false; |
624 } | 627 } |
625 | 628 |
626 int64_t child_id = autofill_root.GetFirstChildId(); | 629 int64_t child_id = autofill_root.GetFirstChildId(); |
627 while (child_id != syncer::kInvalidId) { | 630 while (child_id != syncer::kInvalidId) { |
628 syncer::ReadNode child_node(&trans); | 631 syncer::ReadNode child_node(&trans); |
629 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 632 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
630 return false; | 633 return false; |
631 | 634 |
632 const sync_pb::AutofillProfileSpecifics& autofill( | 635 const sync_pb::AutofillProfileSpecifics& autofill( |
633 child_node.GetEntitySpecifics().autofill_profile()); | 636 child_node.GetEntitySpecifics().autofill_profile()); |
634 AutofillProfile p; | 637 AutofillProfile p; |
635 p.set_guid(autofill.guid()); | 638 p.set_guid(autofill.guid()); |
636 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 639 AutofillProfileSyncableService::OverwriteProfileWithServerData(autofill, |
637 autofill, &p, "en-US"); | 640 &p); |
638 profiles->push_back(p); | 641 profiles->push_back(p); |
639 child_id = child_node.GetSuccessorId(); | 642 child_id = child_node.GetSuccessorId(); |
640 } | 643 } |
641 return true; | 644 return true; |
642 } | 645 } |
643 | 646 |
644 void SetIdleChangeProcessorExpectations() { | 647 void SetIdleChangeProcessorExpectations() { |
645 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); | 648 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); |
646 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _, _)).Times(0); | 649 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _, _)).Times(0); |
647 | 650 |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 std::vector<AutofillEntry> sync_entries; | 1310 std::vector<AutofillEntry> sync_entries; |
1308 std::vector<AutofillProfile> sync_profiles; | 1311 std::vector<AutofillProfile> sync_profiles; |
1309 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1312 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1310 EXPECT_EQ(3U, sync_entries.size()); | 1313 EXPECT_EQ(3U, sync_entries.size()); |
1311 EXPECT_EQ(0U, sync_profiles.size()); | 1314 EXPECT_EQ(0U, sync_profiles.size()); |
1312 for (size_t i = 0; i < sync_entries.size(); i++) { | 1315 for (size_t i = 0; i < sync_entries.size(); i++) { |
1313 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1316 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1314 << ", " << sync_entries[i].key().value(); | 1317 << ", " << sync_entries[i].key().value(); |
1315 } | 1318 } |
1316 } | 1319 } |
OLD | NEW |