| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 "State:", "state", "California", "text", &field); | 1024 "State:", "state", "California", "text", &field); |
| 1025 form1.fields.push_back(field); | 1025 form1.fields.push_back(field); |
| 1026 autofill_test::CreateTestFormField( | 1026 autofill_test::CreateTestFormField( |
| 1027 "Zip:", "zip", "94102", "text", &field); | 1027 "Zip:", "zip", "94102", "text", &field); |
| 1028 form1.fields.push_back(field); | 1028 form1.fields.push_back(field); |
| 1029 autofill_test::CreateTestFormField( | 1029 autofill_test::CreateTestFormField( |
| 1030 "Email:", "email", "theprez@gmail.com", "text", &field); | 1030 "Email:", "email", "theprez@gmail.com", "text", &field); |
| 1031 form1.fields.push_back(field); | 1031 form1.fields.push_back(field); |
| 1032 // Phone gets updated. | 1032 // Phone gets updated. |
| 1033 autofill_test::CreateTestFormField( | 1033 autofill_test::CreateTestFormField( |
| 1034 "Phone:", "phone", "4445556666", "text", &field); | 1034 "Phone:", "phone", "6505556666", "text", &field); |
| 1035 form1.fields.push_back(field); | 1035 form1.fields.push_back(field); |
| 1036 | 1036 |
| 1037 FormStructure form_structure1(form1); | 1037 FormStructure form_structure1(form1); |
| 1038 form_structure1.DetermineHeuristicTypes(); | 1038 form_structure1.DetermineHeuristicTypes(); |
| 1039 const CreditCard* imported_credit_card; | 1039 const CreditCard* imported_credit_card; |
| 1040 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1040 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
| 1041 &imported_credit_card)); | 1041 &imported_credit_card)); |
| 1042 ASSERT_FALSE(imported_credit_card); | 1042 ASSERT_FALSE(imported_credit_card); |
| 1043 | 1043 |
| 1044 // Wait for the refresh. | 1044 // Wait for the refresh. |
| 1045 EXPECT_CALL(personal_data_observer_, | 1045 EXPECT_CALL(personal_data_observer_, |
| 1046 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); | 1046 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
| 1047 | 1047 |
| 1048 MessageLoop::current()->Run(); | 1048 MessageLoop::current()->Run(); |
| 1049 | 1049 |
| 1050 AutofillProfile expected; | 1050 AutofillProfile expected; |
| 1051 autofill_test::SetProfileInfo(&expected, "George", NULL, | 1051 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 1052 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", | 1052 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", |
| 1053 "Suite A", "San Francisco", "California", "94102", NULL, "4445556666", | 1053 "Suite A", "San Francisco", "California", "94102", NULL, "4085556666", |
| 1054 NULL); | 1054 NULL); |
| 1055 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 1055 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 1056 ASSERT_EQ(1U, results1.size()); | 1056 ASSERT_EQ(1U, results1.size()); |
| 1057 EXPECT_EQ(0, expected.Compare(*results1[0])); | 1057 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 1058 | 1058 |
| 1059 // Now create an updated profile. | 1059 // Now create an updated profile. |
| 1060 FormData form2; | 1060 FormData form2; |
| 1061 autofill_test::CreateTestFormField( | 1061 autofill_test::CreateTestFormField( |
| 1062 "First name:", "first_name", "George", "text", &field); | 1062 "First name:", "first_name", "George", "text", &field); |
| 1063 form2.fields.push_back(field); | 1063 form2.fields.push_back(field); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1081 form2.fields.push_back(field); | 1081 form2.fields.push_back(field); |
| 1082 autofill_test::CreateTestFormField( | 1082 autofill_test::CreateTestFormField( |
| 1083 "Email:", "email", "theprez@gmail.com", "text", &field); | 1083 "Email:", "email", "theprez@gmail.com", "text", &field); |
| 1084 form2.fields.push_back(field); | 1084 form2.fields.push_back(field); |
| 1085 // Country gets added. | 1085 // Country gets added. |
| 1086 autofill_test::CreateTestFormField( | 1086 autofill_test::CreateTestFormField( |
| 1087 "Country:", "country", "USA", "text", &field); | 1087 "Country:", "country", "USA", "text", &field); |
| 1088 form2.fields.push_back(field); | 1088 form2.fields.push_back(field); |
| 1089 // Phone gets updated. | 1089 // Phone gets updated. |
| 1090 autofill_test::CreateTestFormField( | 1090 autofill_test::CreateTestFormField( |
| 1091 "Phone:", "phone", "1231231234", "text", &field); | 1091 "Phone:", "phone", "6502231234", "text", &field); |
| 1092 form2.fields.push_back(field); | 1092 form2.fields.push_back(field); |
| 1093 | 1093 |
| 1094 FormStructure form_structure2(form2); | 1094 FormStructure form_structure2(form2); |
| 1095 form_structure2.DetermineHeuristicTypes(); | 1095 form_structure2.DetermineHeuristicTypes(); |
| 1096 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1096 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
| 1097 &imported_credit_card)); | 1097 &imported_credit_card)); |
| 1098 ASSERT_FALSE(imported_credit_card); | 1098 ASSERT_FALSE(imported_credit_card); |
| 1099 | 1099 |
| 1100 // Wait for the refresh. | 1100 // Wait for the refresh. |
| 1101 EXPECT_CALL(personal_data_observer_, | 1101 EXPECT_CALL(personal_data_observer_, |
| 1102 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); | 1102 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
| 1103 | 1103 |
| 1104 MessageLoop::current()->Run(); | 1104 MessageLoop::current()->Run(); |
| 1105 | 1105 |
| 1106 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 1106 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| 1107 | 1107 |
| 1108 // Add multi-valued phone number to expectation. Also, country gets added. | 1108 // Add multi-valued phone number to expectation. Also, country gets added. |
| 1109 std::vector<string16> values; | 1109 std::vector<string16> values; |
| 1110 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 1110 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
| 1111 values.push_back(ASCIIToUTF16("1231231234")); | 1111 values.push_back(ASCIIToUTF16("6502231234")); |
| 1112 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); | 1112 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); |
| 1113 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); | 1113 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); |
| 1114 ASSERT_EQ(1U, results2.size()); | 1114 ASSERT_EQ(1U, results2.size()); |
| 1115 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); | 1115 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { | 1118 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { |
| 1119 FormData form1; | 1119 FormData form1; |
| 1120 webkit_glue::FormField field; | 1120 webkit_glue::FormField field; |
| 1121 autofill_test::CreateTestFormField( | 1121 autofill_test::CreateTestFormField( |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 // Check that there are no available types with no profiles stored. | 1792 // Check that there are no available types with no profiles stored. |
| 1793 FieldTypeSet non_empty_types; | 1793 FieldTypeSet non_empty_types; |
| 1794 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1794 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1795 EXPECT_EQ(0U, non_empty_types.size()); | 1795 EXPECT_EQ(0U, non_empty_types.size()); |
| 1796 | 1796 |
| 1797 // Test with one profile stored. | 1797 // Test with one profile stored. |
| 1798 AutofillProfile profile0; | 1798 AutofillProfile profile0; |
| 1799 autofill_test::SetProfileInfo(&profile0, | 1799 autofill_test::SetProfileInfo(&profile0, |
| 1800 "Marion", NULL, "Morrison", | 1800 "Marion", NULL, "Morrison", |
| 1801 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", | 1801 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", |
| 1802 "91601", "US", "2345678910", NULL); | 1802 "91601", "US", "14155678910", NULL); |
| 1803 | 1803 |
| 1804 std::vector<AutofillProfile> profiles; | 1804 std::vector<AutofillProfile> profiles; |
| 1805 profiles.push_back(profile0); | 1805 profiles.push_back(profile0); |
| 1806 personal_data_->SetProfiles(&profiles); | 1806 personal_data_->SetProfiles(&profiles); |
| 1807 | 1807 |
| 1808 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1808 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1809 EXPECT_EQ(13U, non_empty_types.size()); | 1809 EXPECT_EQ(14U, non_empty_types.size()); |
| 1810 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); | 1810 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); |
| 1811 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); | 1811 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); |
| 1812 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); | 1812 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); |
| 1813 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); | 1813 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); |
| 1814 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); | 1814 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); |
| 1815 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); | 1815 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); |
| 1816 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); | 1816 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); |
| 1817 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); | 1817 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); |
| 1818 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); | 1818 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); |
| 1819 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); | 1819 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); |
| 1820 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); |
| 1820 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); | 1821 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); |
| 1821 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); | 1822 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); |
| 1822 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); | 1823 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); |
| 1823 | 1824 |
| 1824 // Test with multiple profiles stored. | 1825 // Test with multiple profiles stored. |
| 1825 AutofillProfile profile1; | 1826 AutofillProfile profile1; |
| 1826 autofill_test::SetProfileInfo(&profile1, | 1827 autofill_test::SetProfileInfo(&profile1, |
| 1827 "Josephine", "Alicia", "Saenz", | 1828 "Josephine", "Alicia", "Saenz", |
| 1828 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", | 1829 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
| 1829 "US", "19482937549", "13502849239"); | 1830 "US", "16502937549", "14082849239"); |
| 1830 | 1831 |
| 1831 AutofillProfile profile2; | 1832 AutofillProfile profile2; |
| 1832 autofill_test::SetProfileInfo(&profile2, | 1833 autofill_test::SetProfileInfo(&profile2, |
| 1833 "Josephine", "Alicia", "Saenz", | 1834 "Josephine", "Alicia", "Saenz", |
| 1834 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 1835 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 1835 "32801", "US", "19482937549", "13502849239"); | 1836 "32801", "US", "16502937549", "14152849239"); |
| 1836 | 1837 |
| 1837 profiles.push_back(profile1); | 1838 profiles.push_back(profile1); |
| 1838 profiles.push_back(profile2); | 1839 profiles.push_back(profile2); |
| 1839 personal_data_->SetProfiles(&profiles); | 1840 personal_data_->SetProfiles(&profiles); |
| 1840 | 1841 |
| 1841 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1842 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1842 EXPECT_EQ(23U, non_empty_types.size()); | 1843 EXPECT_EQ(23U, non_empty_types.size()); |
| 1843 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); | 1844 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); |
| 1844 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); | 1845 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); |
| 1845 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); | 1846 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); | 1901 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); |
| 1901 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); | 1902 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); |
| 1902 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); | 1903 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); |
| 1903 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); | 1904 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); |
| 1904 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); | 1905 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); |
| 1905 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); | 1906 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); |
| 1906 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1907 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 1907 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); | 1908 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); |
| 1908 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); | 1909 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); |
| 1909 } | 1910 } |
| OLD | NEW |