| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 673 |
| 674 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { | 674 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { |
| 675 std::vector<AutofillProfile*> profiles; | 675 std::vector<AutofillProfile*> profiles; |
| 676 std::vector<AutofillProfile> expected_profiles; | 676 std::vector<AutofillProfile> expected_profiles; |
| 677 // Owned by GetAutofillProfiles caller. | 677 // Owned by GetAutofillProfiles caller. |
| 678 AutofillProfile* profile0 = new AutofillProfile; | 678 AutofillProfile* profile0 = new AutofillProfile; |
| 679 autofill_test::SetProfileInfoWithGuid(profile0, | 679 autofill_test::SetProfileInfoWithGuid(profile0, |
| 680 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", | 680 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", |
| 681 "Mitchell", "Morrison", | 681 "Mitchell", "Morrison", |
| 682 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 682 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 683 "91601", "US", "12345678910", "01987654321"); | 683 "91601", "US", "12345678910"); |
| 684 profiles.push_back(profile0); | 684 profiles.push_back(profile0); |
| 685 expected_profiles.push_back(*profile0); | 685 expected_profiles.push_back(*profile0); |
| 686 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 686 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). |
| 687 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); | 687 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); |
| 688 EXPECT_CALL(*personal_data_manager_, Refresh()); | 688 EXPECT_CALL(*personal_data_manager_, Refresh()); |
| 689 SetIdleChangeProcessorExpectations(); | 689 SetIdleChangeProcessorExpectations(); |
| 690 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); | 690 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); |
| 691 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); | 691 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); |
| 692 ASSERT_TRUE(task.success()); | 692 ASSERT_TRUE(task.success()); |
| 693 std::vector<AutofillProfile> sync_profiles; | 693 std::vector<AutofillProfile> sync_profiles; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 ASSERT_EQ(1U, new_sync_entries.size()); | 783 ASSERT_EQ(1U, new_sync_entries.size()); |
| 784 EXPECT_TRUE(merged_entry == new_sync_entries[0]); | 784 EXPECT_TRUE(merged_entry == new_sync_entries[0]); |
| 785 } | 785 } |
| 786 | 786 |
| 787 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) { | 787 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) { |
| 788 AutofillProfile sync_profile; | 788 AutofillProfile sync_profile; |
| 789 autofill_test::SetProfileInfoWithGuid(&sync_profile, | 789 autofill_test::SetProfileInfoWithGuid(&sync_profile, |
| 790 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", | 790 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", |
| 791 "Mitchell", "Morrison", | 791 "Mitchell", "Morrison", |
| 792 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 792 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 793 "91601", "US", "12345678910", "01987654321"); | 793 "91601", "US", "12345678910"); |
| 794 | 794 |
| 795 AutofillProfile* native_profile = new AutofillProfile; | 795 AutofillProfile* native_profile = new AutofillProfile; |
| 796 autofill_test::SetProfileInfoWithGuid(native_profile, | 796 autofill_test::SetProfileInfoWithGuid(native_profile, |
| 797 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", "Alicia", "Saenz", | 797 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", "Alicia", "Saenz", |
| 798 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 798 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 799 "32801", "US", "19482937549", "13502849239"); | 799 "32801", "US", "19482937549"); |
| 800 | 800 |
| 801 std::vector<AutofillProfile*> native_profiles; | 801 std::vector<AutofillProfile*> native_profiles; |
| 802 native_profiles.push_back(native_profile); | 802 native_profiles.push_back(native_profile); |
| 803 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 803 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). |
| 804 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 804 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 805 | 805 |
| 806 std::vector<AutofillProfile> sync_profiles; | 806 std::vector<AutofillProfile> sync_profiles; |
| 807 sync_profiles.push_back(sync_profile); | 807 sync_profiles.push_back(sync_profile); |
| 808 AddAutofillTask<AutofillProfile> task(this, sync_profiles); | 808 AddAutofillTask<AutofillProfile> task(this, sync_profiles); |
| 809 | 809 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 820 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0])); | 820 EXPECT_EQ(0, sync_profile.Compare(new_sync_profiles[0])); |
| 821 } | 821 } |
| 822 | 822 |
| 823 TEST_F(ProfileSyncServiceAutofillTest, MergeProfileWithDifferentGuid) { | 823 TEST_F(ProfileSyncServiceAutofillTest, MergeProfileWithDifferentGuid) { |
| 824 AutofillProfile sync_profile; | 824 AutofillProfile sync_profile; |
| 825 | 825 |
| 826 autofill_test::SetProfileInfoWithGuid(&sync_profile, | 826 autofill_test::SetProfileInfoWithGuid(&sync_profile, |
| 827 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", | 827 "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", |
| 828 "Mitchell", "Morrison", | 828 "Mitchell", "Morrison", |
| 829 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 829 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 830 "91601", "US", "12345678910", "01987654321"); | 830 "91601", "US", "12345678910"); |
| 831 | 831 |
| 832 std::string native_guid = "EDC609ED-7EEE-4F27-B00C-423242A9C44B"; | 832 std::string native_guid = "EDC609ED-7EEE-4F27-B00C-423242A9C44B"; |
| 833 AutofillProfile* native_profile = new AutofillProfile; | 833 AutofillProfile* native_profile = new AutofillProfile; |
| 834 autofill_test::SetProfileInfoWithGuid(native_profile, | 834 autofill_test::SetProfileInfoWithGuid(native_profile, |
| 835 native_guid.c_str(), "Billing", | 835 native_guid.c_str(), "Billing", |
| 836 "Mitchell", "Morrison", | 836 "Mitchell", "Morrison", |
| 837 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 837 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 838 "91601", "US", "12345678910", "01987654321"); | 838 "91601", "US", "12345678910"); |
| 839 | 839 |
| 840 std::vector<AutofillProfile*> native_profiles; | 840 std::vector<AutofillProfile*> native_profiles; |
| 841 native_profiles.push_back(native_profile); | 841 native_profiles.push_back(native_profile); |
| 842 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 842 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). |
| 843 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 843 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 844 | 844 |
| 845 std::vector<AutofillProfile> sync_profiles; | 845 std::vector<AutofillProfile> sync_profiles; |
| 846 sync_profiles.push_back(sync_profile); | 846 sync_profiles.push_back(sync_profile); |
| 847 AddAutofillTask<AutofillProfile> task(this, sync_profiles); | 847 AddAutofillTask<AutofillProfile> task(this, sync_profiles); |
| 848 | 848 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 EXPECT_CALL(*personal_data_manager_, Refresh()); | 897 EXPECT_CALL(*personal_data_manager_, Refresh()); |
| 898 SetIdleChangeProcessorExpectations(); | 898 SetIdleChangeProcessorExpectations(); |
| 899 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); | 899 CreateRootTask task(this, syncable::AUTOFILL_PROFILE); |
| 900 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); | 900 StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); |
| 901 ASSERT_TRUE(task.success()); | 901 ASSERT_TRUE(task.success()); |
| 902 | 902 |
| 903 AutofillProfile added_profile; | 903 AutofillProfile added_profile; |
| 904 autofill_test::SetProfileInfoWithGuid(&added_profile, | 904 autofill_test::SetProfileInfoWithGuid(&added_profile, |
| 905 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", | 905 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", |
| 906 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 906 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 907 "32801", "US", "19482937549", "13502849239"); | 907 "32801", "US", "19482937549"); |
| 908 | 908 |
| 909 AutofillProfileChange change(AutofillProfileChange::ADD, | 909 AutofillProfileChange change(AutofillProfileChange::ADD, |
| 910 added_profile.guid(), &added_profile); | 910 added_profile.guid(), &added_profile); |
| 911 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); | 911 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); |
| 912 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 912 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 913 Source<WebDataService>(web_data_service_.get()), | 913 Source<WebDataService>(web_data_service_.get()), |
| 914 Details<AutofillProfileChange>(&change)); | 914 Details<AutofillProfileChange>(&change)); |
| 915 | 915 |
| 916 std::vector<AutofillProfile> new_sync_profiles; | 916 std::vector<AutofillProfile> new_sync_profiles; |
| 917 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 917 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 982 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, |
| 983 &new_sync_profiles)); | 983 &new_sync_profiles)); |
| 984 ASSERT_EQ(0U, new_sync_entries.size()); | 984 ASSERT_EQ(0U, new_sync_entries.size()); |
| 985 } | 985 } |
| 986 | 986 |
| 987 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { | 987 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { |
| 988 AutofillProfile sync_profile; | 988 AutofillProfile sync_profile; |
| 989 autofill_test::SetProfileInfoWithGuid(&sync_profile, | 989 autofill_test::SetProfileInfoWithGuid(&sync_profile, |
| 990 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz", | 990 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz", |
| 991 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 991 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 992 "32801", "US", "19482937549", "13502849239"); | 992 "32801", "US", "19482937549"); |
| 993 AutofillProfile* native_profile = new AutofillProfile; | 993 AutofillProfile* native_profile = new AutofillProfile; |
| 994 autofill_test::SetProfileInfoWithGuid(native_profile, | 994 autofill_test::SetProfileInfoWithGuid(native_profile, |
| 995 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz", | 995 "3BA5FA1B-1EC4-4BB3-9B57-EC92BE3C1A09", "Josephine", "Alicia", "Saenz", |
| 996 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 996 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 997 "32801", "US", "19482937549", "13502849239"); | 997 "32801", "US", "19482937549"); |
| 998 | 998 |
| 999 std::vector<AutofillProfile*> native_profiles; | 999 std::vector<AutofillProfile*> native_profiles; |
| 1000 native_profiles.push_back(native_profile); | 1000 native_profiles.push_back(native_profile); |
| 1001 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 1001 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). |
| 1002 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 1002 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 1003 | 1003 |
| 1004 std::vector<AutofillProfile> sync_profiles; | 1004 std::vector<AutofillProfile> sync_profiles; |
| 1005 sync_profiles.push_back(sync_profile); | 1005 sync_profiles.push_back(sync_profile); |
| 1006 AddAutofillTask<AutofillProfile> task(this, sync_profiles); | 1006 AddAutofillTask<AutofillProfile> task(this, sync_profiles); |
| 1007 EXPECT_CALL(*personal_data_manager_, Refresh()); | 1007 EXPECT_CALL(*personal_data_manager_, Refresh()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 std::vector<AutofillEntry> sync_entries; | 1091 std::vector<AutofillEntry> sync_entries; |
| 1092 std::vector<AutofillProfile> sync_profiles; | 1092 std::vector<AutofillProfile> sync_profiles; |
| 1093 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1093 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1094 EXPECT_EQ(3U, sync_entries.size()); | 1094 EXPECT_EQ(3U, sync_entries.size()); |
| 1095 EXPECT_EQ(0U, sync_profiles.size()); | 1095 EXPECT_EQ(0U, sync_profiles.size()); |
| 1096 for (size_t i = 0; i < sync_entries.size(); i++) { | 1096 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1097 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1097 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1098 << ", " << sync_entries[i].key().value(); | 1098 << ", " << sync_entries[i].key().value(); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| OLD | NEW |