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 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); | 1753 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); |
1754 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); | 1754 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); |
1755 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); | 1755 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); |
1756 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); | 1756 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); |
1757 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); | 1757 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); |
1758 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); | 1758 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); |
1759 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1759 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
1760 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); | 1760 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); |
1761 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); | 1761 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); |
1762 } | 1762 } |
| 1763 |
| 1764 TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { |
| 1765 FormData form1; |
| 1766 webkit_glue::FormField field; |
| 1767 autofill_test::CreateTestFormField( |
| 1768 "First name:", "first_name", "George", "text", &field); |
| 1769 form1.fields.push_back(field); |
| 1770 autofill_test::CreateTestFormField( |
| 1771 "Last name:", "last_name", "Washington", "text", &field); |
| 1772 form1.fields.push_back(field); |
| 1773 autofill_test::CreateTestFormField( |
| 1774 "Email:", "email", "theprez@gmail.com", "text", &field); |
| 1775 form1.fields.push_back(field); |
| 1776 autofill_test::CreateTestFormField( |
| 1777 "Address:", "address1", "21 Laussat St", "text", &field); |
| 1778 form1.fields.push_back(field); |
| 1779 autofill_test::CreateTestFormField( |
| 1780 "City:", "city", "San Francisco", "text", &field); |
| 1781 form1.fields.push_back(field); |
| 1782 autofill_test::CreateTestFormField( |
| 1783 "State:", "state", "California", "text", &field); |
| 1784 form1.fields.push_back(field); |
| 1785 autofill_test::CreateTestFormField( |
| 1786 "Zip:", "zip", "94102", "text", &field); |
| 1787 form1.fields.push_back(field); |
| 1788 autofill_test::CreateTestFormField( |
| 1789 "Phone number:", "phone_number", "817-555-6789", "text", &field); |
| 1790 form1.fields.push_back(field); |
| 1791 |
| 1792 FormStructure form_structure1(form1); |
| 1793 form_structure1.DetermineHeuristicTypes(); |
| 1794 const CreditCard* imported_credit_card; |
| 1795 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
| 1796 &imported_credit_card)); |
| 1797 ASSERT_FALSE(imported_credit_card); |
| 1798 |
| 1799 // Verify that the web database has been updated and the notification sent. |
| 1800 EXPECT_CALL(personal_data_observer_, |
| 1801 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1802 MessageLoop::current()->Run(); |
| 1803 |
| 1804 AutofillProfile expected; |
| 1805 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 1806 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
| 1807 "San Francisco", "California", "94102", NULL, "817-555-6789", NULL); |
| 1808 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 1809 ASSERT_EQ(1U, results1.size()); |
| 1810 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 1811 |
| 1812 // Upper-case the first name and change the phone number. |
| 1813 FormData form2; |
| 1814 autofill_test::CreateTestFormField( |
| 1815 "First name:", "first_name", "GEORGE", "text", &field); |
| 1816 form2.fields.push_back(field); |
| 1817 autofill_test::CreateTestFormField( |
| 1818 "Last name:", "last_name", "Washington", "text", &field); |
| 1819 form2.fields.push_back(field); |
| 1820 autofill_test::CreateTestFormField( |
| 1821 "Email:", "email", "theprez@gmail.com", "text", &field); |
| 1822 form2.fields.push_back(field); |
| 1823 autofill_test::CreateTestFormField( |
| 1824 "Address:", "address1", "21 Laussat St", "text", &field); |
| 1825 form2.fields.push_back(field); |
| 1826 autofill_test::CreateTestFormField( |
| 1827 "City:", "city", "San Francisco", "text", &field); |
| 1828 form2.fields.push_back(field); |
| 1829 autofill_test::CreateTestFormField( |
| 1830 "State:", "state", "California", "text", &field); |
| 1831 form2.fields.push_back(field); |
| 1832 autofill_test::CreateTestFormField( |
| 1833 "Zip:", "zip", "94102", "text", &field); |
| 1834 form2.fields.push_back(field); |
| 1835 autofill_test::CreateTestFormField( |
| 1836 "Phone number:", "phone_number", "214-555-1234", "text", &field); |
| 1837 form2.fields.push_back(field); |
| 1838 |
| 1839 FormStructure form_structure2(form2); |
| 1840 form_structure2.DetermineHeuristicTypes(); |
| 1841 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
| 1842 &imported_credit_card)); |
| 1843 ASSERT_FALSE(imported_credit_card); |
| 1844 |
| 1845 // Verify that the web database has been updated and the notification sent. |
| 1846 EXPECT_CALL(personal_data_observer_, |
| 1847 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1848 MessageLoop::current()->Run(); |
| 1849 |
| 1850 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| 1851 |
| 1852 // Modify expected to include multi-valued fields. |
| 1853 std::vector<string16> values; |
| 1854 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); |
| 1855 values.push_back(ASCIIToUTF16("214-555-1234")); |
| 1856 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); |
| 1857 |
| 1858 ASSERT_EQ(1U, results2.size()); |
| 1859 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); |
| 1860 } |
OLD | NEW |