| 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 <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) | 841 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) |
| 842 .WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); | 842 .WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); |
| 843 SetIdleChangeProcessorExpectations(); | 843 SetIdleChangeProcessorExpectations(); |
| 844 CreateRootHelper create_root(this, AUTOFILL); | 844 CreateRootHelper create_root(this, AUTOFILL); |
| 845 EXPECT_CALL(personal_data_manager(), Refresh()); | 845 EXPECT_CALL(personal_data_manager(), Refresh()); |
| 846 StartSyncService(create_root.callback(), false, AUTOFILL); | 846 StartSyncService(create_root.callback(), false, AUTOFILL); |
| 847 ASSERT_TRUE(create_root.success()); | 847 ASSERT_TRUE(create_root.success()); |
| 848 std::vector<AutofillEntry> sync_entries; | 848 std::vector<AutofillEntry> sync_entries; |
| 849 std::vector<AutofillProfile> sync_profiles; | 849 std::vector<AutofillProfile> sync_profiles; |
| 850 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 850 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 851 ASSERT_EQ(1U, entries.size()); | 851 ASSERT_EQ(1U, sync_entries.size()); |
| 852 EXPECT_TRUE(entries[0] == sync_entries[0]); | 852 EXPECT_EQ(entries[0], sync_entries[0]); |
| 853 EXPECT_EQ(0U, sync_profiles.size()); | 853 EXPECT_EQ(0U, sync_profiles.size()); |
| 854 } | 854 } |
| 855 | 855 |
| 856 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { | 856 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { |
| 857 std::vector<std::unique_ptr<AutofillProfile>> profiles; | 857 std::vector<std::unique_ptr<AutofillProfile>> profiles; |
| 858 std::vector<AutofillProfile> expected_profiles; | 858 std::vector<AutofillProfile> expected_profiles; |
| 859 std::unique_ptr<AutofillProfile> profile0 = | 859 std::unique_ptr<AutofillProfile> profile0 = |
| 860 base::MakeUnique<AutofillProfile>(); | 860 base::MakeUnique<AutofillProfile>(); |
| 861 autofill::test::SetProfileInfoWithGuid( | 861 autofill::test::SetProfileInfoWithGuid( |
| 862 profile0.get(), "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", | 862 profile0.get(), "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 expected_entries.insert(native_entry); | 924 expected_entries.insert(native_entry); |
| 925 expected_entries.insert(sync_entry); | 925 expected_entries.insert(sync_entry); |
| 926 | 926 |
| 927 std::vector<AutofillEntry> new_sync_entries; | 927 std::vector<AutofillEntry> new_sync_entries; |
| 928 std::vector<AutofillProfile> new_sync_profiles; | 928 std::vector<AutofillProfile> new_sync_profiles; |
| 929 ASSERT_TRUE( | 929 ASSERT_TRUE( |
| 930 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); | 930 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); |
| 931 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(), | 931 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(), |
| 932 new_sync_entries.end()); | 932 new_sync_entries.end()); |
| 933 | 933 |
| 934 EXPECT_TRUE(expected_entries == new_sync_entries_set); | 934 EXPECT_EQ(expected_entries, new_sync_entries_set); |
| 935 } | 935 } |
| 936 | 936 |
| 937 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeEntry) { | 937 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeEntry) { |
| 938 AutofillEntry native_entry(MakeAutofillEntry("merge", "entry", 1)); | 938 AutofillEntry native_entry(MakeAutofillEntry("merge", "entry", 1)); |
| 939 AutofillEntry sync_entry(MakeAutofillEntry("merge", "entry", 2)); | 939 AutofillEntry sync_entry(MakeAutofillEntry("merge", "entry", 2)); |
| 940 AutofillEntry merged_entry(MakeAutofillEntry("merge", "entry", 1, 2)); | 940 AutofillEntry merged_entry(MakeAutofillEntry("merge", "entry", 1, 2)); |
| 941 | 941 |
| 942 std::vector<AutofillEntry> native_entries; | 942 std::vector<AutofillEntry> native_entries; |
| 943 native_entries.push_back(native_entry); | 943 native_entries.push_back(native_entry); |
| 944 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) | 944 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) |
| 945 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); | 945 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); |
| 946 | 946 |
| 947 std::vector<AutofillEntry> sync_entries; | 947 std::vector<AutofillEntry> sync_entries; |
| 948 sync_entries.push_back(sync_entry); | 948 sync_entries.push_back(sync_entry); |
| 949 AddAutofillHelper<AutofillEntry> add_autofill(this, sync_entries); | 949 AddAutofillHelper<AutofillEntry> add_autofill(this, sync_entries); |
| 950 | 950 |
| 951 EXPECT_CALL(autofill_table(), | 951 EXPECT_CALL(autofill_table(), |
| 952 UpdateAutofillEntries(ElementsAre(merged_entry))) | 952 UpdateAutofillEntries(ElementsAre(merged_entry))) |
| 953 .WillOnce(Return(true)); | 953 .WillOnce(Return(true)); |
| 954 EXPECT_CALL(personal_data_manager(), Refresh()); | 954 EXPECT_CALL(personal_data_manager(), Refresh()); |
| 955 StartSyncService(add_autofill.callback(), false, AUTOFILL); | 955 StartSyncService(add_autofill.callback(), false, AUTOFILL); |
| 956 ASSERT_TRUE(add_autofill.success()); | 956 ASSERT_TRUE(add_autofill.success()); |
| 957 | 957 |
| 958 std::vector<AutofillEntry> new_sync_entries; | 958 std::vector<AutofillEntry> new_sync_entries; |
| 959 std::vector<AutofillProfile> new_sync_profiles; | 959 std::vector<AutofillProfile> new_sync_profiles; |
| 960 ASSERT_TRUE( | 960 ASSERT_TRUE( |
| 961 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); | 961 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); |
| 962 ASSERT_EQ(1U, new_sync_entries.size()); | 962 ASSERT_EQ(1U, new_sync_entries.size()); |
| 963 EXPECT_TRUE(merged_entry == new_sync_entries[0]); | 963 EXPECT_EQ(merged_entry, new_sync_entries[0]); |
| 964 } | 964 } |
| 965 | 965 |
| 966 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) { | 966 TEST_F(ProfileSyncServiceAutofillTest, HasNativeHasSyncMergeProfile) { |
| 967 AutofillProfile sync_profile; | 967 AutofillProfile sync_profile; |
| 968 autofill::test::SetProfileInfoWithGuid( | 968 autofill::test::SetProfileInfoWithGuid( |
| 969 &sync_profile, "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", | 969 &sync_profile, "23355099-1170-4B71-8ED4-144470CC9EBE", "Billing", |
| 970 "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", | 970 "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", |
| 971 "unit 5", "Hollywood", "CA", "91601", "US", "12345678910"); | 971 "unit 5", "Hollywood", "CA", "91601", "US", "12345678910"); |
| 972 | 972 |
| 973 std::unique_ptr<AutofillProfile> native_profile = | 973 std::unique_ptr<AutofillProfile> native_profile = |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 AutofillChangeList changes; | 1319 AutofillChangeList changes; |
| 1320 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); | 1320 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); |
| 1321 | 1321 |
| 1322 web_data_service()->OnAutofillEntriesChanged(changes); | 1322 web_data_service()->OnAutofillEntriesChanged(changes); |
| 1323 | 1323 |
| 1324 std::vector<AutofillEntry> new_sync_entries; | 1324 std::vector<AutofillEntry> new_sync_entries; |
| 1325 std::vector<AutofillProfile> new_sync_profiles; | 1325 std::vector<AutofillProfile> new_sync_profiles; |
| 1326 ASSERT_TRUE( | 1326 ASSERT_TRUE( |
| 1327 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); | 1327 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); |
| 1328 ASSERT_EQ(1U, new_sync_entries.size()); | 1328 ASSERT_EQ(1U, new_sync_entries.size()); |
| 1329 EXPECT_TRUE(added_entry == new_sync_entries[0]); | 1329 EXPECT_EQ(added_entry, new_sync_entries[0]); |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { | 1332 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { |
| 1333 EXPECT_CALL(autofill_table(), GetAutofillProfiles(_)).WillOnce(Return(true)); | 1333 EXPECT_CALL(autofill_table(), GetAutofillProfiles(_)).WillOnce(Return(true)); |
| 1334 EXPECT_CALL(personal_data_manager(), Refresh()); | 1334 EXPECT_CALL(personal_data_manager(), Refresh()); |
| 1335 SetIdleChangeProcessorExpectations(); | 1335 SetIdleChangeProcessorExpectations(); |
| 1336 CreateRootHelper create_root(this, AUTOFILL_PROFILE); | 1336 CreateRootHelper create_root(this, AUTOFILL_PROFILE); |
| 1337 StartSyncService(create_root.callback(), false, AUTOFILL_PROFILE); | 1337 StartSyncService(create_root.callback(), false, AUTOFILL_PROFILE); |
| 1338 ASSERT_TRUE(create_root.success()); | 1338 ASSERT_TRUE(create_root.success()); |
| 1339 | 1339 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 AutofillChangeList changes; | 1376 AutofillChangeList changes; |
| 1377 changes.push_back( | 1377 changes.push_back( |
| 1378 AutofillChange(AutofillChange::UPDATE, updated_entry.key())); | 1378 AutofillChange(AutofillChange::UPDATE, updated_entry.key())); |
| 1379 web_data_service()->OnAutofillEntriesChanged(changes); | 1379 web_data_service()->OnAutofillEntriesChanged(changes); |
| 1380 | 1380 |
| 1381 std::vector<AutofillEntry> new_sync_entries; | 1381 std::vector<AutofillEntry> new_sync_entries; |
| 1382 std::vector<AutofillProfile> new_sync_profiles; | 1382 std::vector<AutofillProfile> new_sync_profiles; |
| 1383 ASSERT_TRUE( | 1383 ASSERT_TRUE( |
| 1384 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); | 1384 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles)); |
| 1385 ASSERT_EQ(1U, new_sync_entries.size()); | 1385 ASSERT_EQ(1U, new_sync_entries.size()); |
| 1386 EXPECT_TRUE(updated_entry == new_sync_entries[0]); | 1386 EXPECT_EQ(updated_entry, new_sync_entries[0]); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { | 1389 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { |
| 1390 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); | 1390 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); |
| 1391 std::vector<AutofillEntry> original_entries; | 1391 std::vector<AutofillEntry> original_entries; |
| 1392 original_entries.push_back(original_entry); | 1392 original_entries.push_back(original_entry); |
| 1393 | 1393 |
| 1394 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) | 1394 EXPECT_CALL(autofill_table(), GetAllAutofillEntries(_)) |
| 1395 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); | 1395 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); |
| 1396 EXPECT_CALL(personal_data_manager(), Refresh()); | 1396 EXPECT_CALL(personal_data_manager(), Refresh()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1500 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1501 EXPECT_EQ(3U, sync_entries.size()); | 1501 EXPECT_EQ(3U, sync_entries.size()); |
| 1502 EXPECT_EQ(0U, sync_profiles.size()); | 1502 EXPECT_EQ(0U, sync_profiles.size()); |
| 1503 for (size_t i = 0; i < sync_entries.size(); i++) { | 1503 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1504 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() << ", " | 1504 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() << ", " |
| 1505 << sync_entries[i].key().value(); | 1505 << sync_entries[i].key().value(); |
| 1506 } | 1506 } |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 } // namespace browser_sync | 1509 } // namespace browser_sync |
| OLD | NEW |