Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/autofill/personal_data_manager_unittest.cc

Issue 6877130: These changes *are* for review :) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 "State:", "state", "California", "text", &field); 882 "State:", "state", "California", "text", &field);
883 form1.fields.push_back(field); 883 form1.fields.push_back(field);
884 autofill_test::CreateTestFormField( 884 autofill_test::CreateTestFormField(
885 "Zip:", "zip", "94102", "text", &field); 885 "Zip:", "zip", "94102", "text", &field);
886 form1.fields.push_back(field); 886 form1.fields.push_back(field);
887 autofill_test::CreateTestFormField( 887 autofill_test::CreateTestFormField(
888 "Email:", "email", "theprez@gmail.com", "text", &field); 888 "Email:", "email", "theprez@gmail.com", "text", &field);
889 form1.fields.push_back(field); 889 form1.fields.push_back(field);
890 // Phone gets updated. 890 // Phone gets updated.
891 autofill_test::CreateTestFormField( 891 autofill_test::CreateTestFormField(
892 "Phone:", "phone", "4445556666", "text", &field); 892 "Phone:", "phone", "6505556666", "text", &field);
893 form1.fields.push_back(field); 893 form1.fields.push_back(field);
894 894
895 FormStructure form_structure1(form1); 895 FormStructure form_structure1(form1);
896 form_structure1.DetermineHeuristicTypes(); 896 form_structure1.DetermineHeuristicTypes();
897 const CreditCard* imported_credit_card; 897 const CreditCard* imported_credit_card;
898 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, 898 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
899 &imported_credit_card)); 899 &imported_credit_card));
900 ASSERT_FALSE(imported_credit_card); 900 ASSERT_FALSE(imported_credit_card);
901 901
902 // Verify that the web database has been updated and the notification sent. 902 // Verify that the web database has been updated and the notification sent.
903 EXPECT_CALL(personal_data_observer_, 903 EXPECT_CALL(personal_data_observer_,
904 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 904 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
905 MessageLoop::current()->Run(); 905 MessageLoop::current()->Run();
906 906
907 AutofillProfile expected; 907 AutofillProfile expected;
908 autofill_test::SetProfileInfo(&expected, "George", NULL, 908 autofill_test::SetProfileInfo(&expected, "George", NULL,
909 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", 909 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue",
910 "Suite A", "San Francisco", "California", "94102", NULL, "4445556666", 910 "Suite A", "San Francisco", "California", "94102", NULL, "4085556666",
911 NULL); 911 NULL);
912 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); 912 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles();
913 ASSERT_EQ(1U, results1.size()); 913 ASSERT_EQ(1U, results1.size());
914 EXPECT_EQ(0, expected.Compare(*results1[0])); 914 EXPECT_EQ(0, expected.Compare(*results1[0]));
915 915
916 // Now create an updated profile. 916 // Now create an updated profile.
917 FormData form2; 917 FormData form2;
918 autofill_test::CreateTestFormField( 918 autofill_test::CreateTestFormField(
919 "First name:", "first_name", "George", "text", &field); 919 "First name:", "first_name", "George", "text", &field);
920 form2.fields.push_back(field); 920 form2.fields.push_back(field);
(...skipping 17 matching lines...) Expand all
938 form2.fields.push_back(field); 938 form2.fields.push_back(field);
939 autofill_test::CreateTestFormField( 939 autofill_test::CreateTestFormField(
940 "Email:", "email", "theprez@gmail.com", "text", &field); 940 "Email:", "email", "theprez@gmail.com", "text", &field);
941 form2.fields.push_back(field); 941 form2.fields.push_back(field);
942 // Country gets added. 942 // Country gets added.
943 autofill_test::CreateTestFormField( 943 autofill_test::CreateTestFormField(
944 "Country:", "country", "USA", "text", &field); 944 "Country:", "country", "USA", "text", &field);
945 form2.fields.push_back(field); 945 form2.fields.push_back(field);
946 // Phone gets updated. 946 // Phone gets updated.
947 autofill_test::CreateTestFormField( 947 autofill_test::CreateTestFormField(
948 "Phone:", "phone", "1231231234", "text", &field); 948 "Phone:", "phone", "6502231234", "text", &field);
949 form2.fields.push_back(field); 949 form2.fields.push_back(field);
950 950
951 FormStructure form_structure2(form2); 951 FormStructure form_structure2(form2);
952 form_structure2.DetermineHeuristicTypes(); 952 form_structure2.DetermineHeuristicTypes();
953 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, 953 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
954 &imported_credit_card)); 954 &imported_credit_card));
955 ASSERT_FALSE(imported_credit_card); 955 ASSERT_FALSE(imported_credit_card);
956 956
957 // Verify that the web database has been updated and the notification sent. 957 // Verify that the web database has been updated and the notification sent.
958 EXPECT_CALL(personal_data_observer_, 958 EXPECT_CALL(personal_data_observer_,
959 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 959 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
960 MessageLoop::current()->Run(); 960 MessageLoop::current()->Run();
961 961
962 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); 962 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles();
963 963
964 // Add multi-valued phone number to expectation. Also, country gets added. 964 // Add multi-valued phone number to expectation. Also, country gets added.
965 std::vector<string16> values; 965 std::vector<string16> values;
966 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 966 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
967 values.push_back(ASCIIToUTF16("1231231234")); 967 values.push_back(ASCIIToUTF16("6502231234"));
968 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); 968 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
969 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); 969 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"));
970 ASSERT_EQ(1U, results2.size()); 970 ASSERT_EQ(1U, results2.size());
971 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); 971 EXPECT_EQ(0, expected.CompareMulti(*results2[0]));
972 } 972 }
973 973
974 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { 974 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
975 FormData form1; 975 FormData form1;
976 webkit_glue::FormField field; 976 webkit_glue::FormField field;
977 autofill_test::CreateTestFormField( 977 autofill_test::CreateTestFormField(
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 // Check that there are no available types with no profiles stored. 1625 // Check that there are no available types with no profiles stored.
1626 FieldTypeSet non_empty_types; 1626 FieldTypeSet non_empty_types;
1627 personal_data_->GetNonEmptyTypes(&non_empty_types); 1627 personal_data_->GetNonEmptyTypes(&non_empty_types);
1628 EXPECT_EQ(0U, non_empty_types.size()); 1628 EXPECT_EQ(0U, non_empty_types.size());
1629 1629
1630 // Test with one profile stored. 1630 // Test with one profile stored.
1631 AutofillProfile profile0; 1631 AutofillProfile profile0;
1632 autofill_test::SetProfileInfo(&profile0, 1632 autofill_test::SetProfileInfo(&profile0,
1633 "Marion", NULL, "Morrison", 1633 "Marion", NULL, "Morrison",
1634 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", 1634 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA",
1635 "91601", "US", "2345678910", NULL); 1635 "91601", "US", "14155678910", NULL);
1636 1636
1637 personal_data_->AddProfile(profile0); 1637 personal_data_->AddProfile(profile0);
1638 1638
1639 // Verify that the web database has been updated and the notification sent. 1639 // Verify that the web database has been updated and the notification sent.
1640 EXPECT_CALL(personal_data_observer_, 1640 EXPECT_CALL(personal_data_observer_,
1641 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 1641 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
1642 MessageLoop::current()->Run(); 1642 MessageLoop::current()->Run();
1643 1643
1644 personal_data_->GetNonEmptyTypes(&non_empty_types); 1644 personal_data_->GetNonEmptyTypes(&non_empty_types);
1645 EXPECT_EQ(13U, non_empty_types.size()); 1645 EXPECT_EQ(14U, non_empty_types.size());
1646 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); 1646 EXPECT_TRUE(non_empty_types.count(NAME_FIRST));
1647 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); 1647 EXPECT_TRUE(non_empty_types.count(NAME_LAST));
1648 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); 1648 EXPECT_TRUE(non_empty_types.count(NAME_FULL));
1649 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); 1649 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS));
1650 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); 1650 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1));
1651 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); 1651 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY));
1652 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); 1652 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE));
1653 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); 1653 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP));
1654 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); 1654 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY));
1655 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); 1655 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER));
1656 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE));
1656 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); 1657 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE));
1657 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); 1658 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER));
1658 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); 1659 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER));
1659 1660
1660 // Test with multiple profiles stored. 1661 // Test with multiple profiles stored.
1661 AutofillProfile profile1; 1662 AutofillProfile profile1;
1662 autofill_test::SetProfileInfo(&profile1, 1663 autofill_test::SetProfileInfo(&profile1,
1663 "Josephine", "Alicia", "Saenz", 1664 "Josephine", "Alicia", "Saenz",
1664 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", 1665 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801",
1665 "US", "19482937549", "13502849239"); 1666 "US", "16502937549", "14082849239");
1666 1667
1667 AutofillProfile profile2; 1668 AutofillProfile profile2;
1668 autofill_test::SetProfileInfo(&profile2, 1669 autofill_test::SetProfileInfo(&profile2,
1669 "Josephine", "Alicia", "Saenz", 1670 "Josephine", "Alicia", "Saenz",
1670 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1671 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
1671 "32801", "US", "19482937549", "13502849239"); 1672 "32801", "US", "16502937549", "14152849239");
1672 1673
1673 personal_data_->AddProfile(profile1); 1674 personal_data_->AddProfile(profile1);
1674 personal_data_->AddProfile(profile2); 1675 personal_data_->AddProfile(profile2);
1675 1676
1676 // Verify that the web database has been updated and the notification sent. 1677 // Verify that the web database has been updated and the notification sent.
1677 EXPECT_CALL(personal_data_observer_, 1678 EXPECT_CALL(personal_data_observer_,
1678 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 1679 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
1679 MessageLoop::current()->Run(); 1680 MessageLoop::current()->Run();
1680 1681
1681 personal_data_->GetNonEmptyTypes(&non_empty_types); 1682 personal_data_->GetNonEmptyTypes(&non_empty_types);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); 1743 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER));
1743 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); 1744 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER));
1744 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); 1745 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME));
1745 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); 1746 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER));
1746 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); 1747 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH));
1747 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); 1748 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR));
1748 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 1749 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR));
1749 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); 1750 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR));
1750 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); 1751 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR));
1751 } 1752 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_mac.mm ('k') | chrome/browser/autofill/phone_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698