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

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

Issue 11635039: [Autofill] Update unit tests to use country codes when setting raw address info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 profile1.SetRawInfo(ADDRESS_HOME_LINE1, 901 profile1.SetRawInfo(ADDRESS_HOME_LINE1,
902 WideToUTF16(L"\uad6d\uc815\uc6d0\xb7\uac80\ucc30, " 902 WideToUTF16(L"\uad6d\uc815\uc6d0\xb7\uac80\ucc30, "
903 L"\ub178\ubb34\ud604\uc815\ubd80 " 903 L"\ub178\ubb34\ud604\uc815\ubd80 "
904 L"\ub300\ubd81\uc811\ucd09 \ub2f4\ub2f9 " 904 L"\ub300\ubd81\uc811\ucd09 \ub2f4\ub2f9 "
905 L"\uc778\uc0ac\ub4e4 \uc870\uc0ac")); 905 L"\uc778\uc0ac\ub4e4 \uc870\uc0ac"));
906 profile1.SetRawInfo(ADDRESS_HOME_CITY, 906 profile1.SetRawInfo(ADDRESS_HOME_CITY,
907 WideToUTF16(L"\u653f\u5e9c\u4e0d\u6392\u9664\u7acb\u6cd5" 907 WideToUTF16(L"\u653f\u5e9c\u4e0d\u6392\u9664\u7acb\u6cd5"
908 L"\u898f\u7ba1\u5c0e\u904a")); 908 L"\u898f\u7ba1\u5c0e\u904a"));
909 profile1.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"YOHO_54676")); 909 profile1.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"YOHO_54676"));
910 profile1.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"861088828000")); 910 profile1.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"861088828000"));
911 profile1.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"India")); 911 profile1.SetInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"India"), "en-US");
912 profiles.push_back(profile1); 912 profiles.push_back(profile1);
913 913
914 AutofillProfile profile2; 914 AutofillProfile profile2;
915 profile2.SetRawInfo(NAME_FIRST, 915 profile2.SetRawInfo(NAME_FIRST,
916 WideToUTF16(L"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a " 916 WideToUTF16(L"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a "
917 L"\u677e\u9690\u9547\u4ead\u67ab\u516c" 917 L"\u677e\u9690\u9547\u4ead\u67ab\u516c"
918 L"\u8def1915\u53f7")); 918 L"\u8def1915\u53f7"));
919 profile2.SetRawInfo(NAME_LAST, WideToUTF16(L"aguantó")); 919 profile2.SetRawInfo(NAME_LAST, WideToUTF16(L"aguantó"));
920 profile2.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"HOME 94043")); 920 profile2.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"HOME 94043"));
921 profiles.push_back(profile2); 921 profiles.push_back(profile2);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 AutofillProfile profile7; 968 AutofillProfile profile7;
969 profile7.SetRawInfo(NAME_FIRST, WideToUTF16(L"&$%$$$ TESTO *&*&^&^& MOKO")); 969 profile7.SetRawInfo(NAME_FIRST, WideToUTF16(L"&$%$$$ TESTO *&*&^&^& MOKO"));
970 profile7.SetRawInfo(NAME_MIDDLE, WideToUTF16(L"WOHOOOO$$$$$$$$****")); 970 profile7.SetRawInfo(NAME_MIDDLE, WideToUTF16(L"WOHOOOO$$$$$$$$****"));
971 profile7.SetRawInfo(EMAIL_ADDRESS, WideToUTF16(L"yuvu@example.com")); 971 profile7.SetRawInfo(EMAIL_ADDRESS, WideToUTF16(L"yuvu@example.com"));
972 profile7.SetRawInfo(ADDRESS_HOME_LINE1, 972 profile7.SetRawInfo(ADDRESS_HOME_LINE1,
973 WideToUTF16(L"34544, anderson ST.(120230)")); 973 WideToUTF16(L"34544, anderson ST.(120230)"));
974 profile7.SetRawInfo(ADDRESS_HOME_CITY, WideToUTF16(L"Sunnyvale")); 974 profile7.SetRawInfo(ADDRESS_HOME_CITY, WideToUTF16(L"Sunnyvale"));
975 profile7.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA")); 975 profile7.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA"));
976 profile7.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"94086")); 976 profile7.SetRawInfo(ADDRESS_HOME_ZIP, WideToUTF16(L"94086"));
977 profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"15466784565")); 977 profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, WideToUTF16(L"15466784565"));
978 profile7.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"United States")); 978 profile7.SetInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"United States"),
979 "en-US");
979 profiles.push_back(profile7); 980 profiles.push_back(profile7);
980 981
981 SetProfiles(&profiles); 982 SetProfiles(&profiles);
982 ASSERT_EQ(profiles.size(), personal_data_manager()->GetProfiles().size()); 983 ASSERT_EQ(profiles.size(), personal_data_manager()->GetProfiles().size());
983 for (size_t i = 0; i < profiles.size(); ++i) 984 for (size_t i = 0; i < profiles.size(); ++i)
984 ASSERT_EQ(profiles[i], *personal_data_manager()->GetProfiles()[i]); 985 ASSERT_EQ(profiles[i], *personal_data_manager()->GetProfiles()[i]);
985 986
986 std::vector<CreditCard> cards; 987 std::vector<CreditCard> cards;
987 CreditCard card1; 988 CreditCard card1;
988 card1.SetRawInfo(CREDIT_CARD_NAME, 989 card1.SetRawInfo(CREDIT_CARD_NAME,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 // information entered into the prefs UI is not validated or rejected except for 1040 // information entered into the prefs UI is not validated or rejected except for
1040 // duplicates. 1041 // duplicates.
1041 // TODO(isherman): rewrite as WebUI test? 1042 // TODO(isherman): rewrite as WebUI test?
1042 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) { 1043 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) {
1043 // First try profiles with invalid ZIP input. 1044 // First try profiles with invalid ZIP input.
1044 AutofillProfile without_invalid; 1045 AutofillProfile without_invalid;
1045 without_invalid.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Will")); 1046 without_invalid.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Will"));
1046 without_invalid.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Sunnyvale")); 1047 without_invalid.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Sunnyvale"));
1047 without_invalid.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); 1048 without_invalid.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
1048 without_invalid.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("my_zip")); 1049 without_invalid.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("my_zip"));
1049 without_invalid.SetRawInfo(ADDRESS_HOME_COUNTRY, 1050 without_invalid.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"),
1050 ASCIIToUTF16("United States")); 1051 "en-US");
1051 1052
1052 AutofillProfile with_invalid = without_invalid; 1053 AutofillProfile with_invalid = without_invalid;
1053 with_invalid.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, 1054 with_invalid.SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
1054 ASCIIToUTF16("Invalid_Phone_Number")); 1055 ASCIIToUTF16("Invalid_Phone_Number"));
1055 SetProfile(with_invalid); 1056 SetProfile(with_invalid);
1056 1057
1057 ASSERT_EQ(1u, personal_data_manager()->GetProfiles().size()); 1058 ASSERT_EQ(1u, personal_data_manager()->GetProfiles().size());
1058 AutofillProfile profile = *personal_data_manager()->GetProfiles()[0]; 1059 AutofillProfile profile = *personal_data_manager()->GetProfiles()[0];
1059 ASSERT_NE(without_invalid.GetRawInfo(PHONE_HOME_WHOLE_NUMBER), 1060 ASSERT_NE(without_invalid.GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
1060 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1061 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 base::IntToString(base::RandInt(0, 10000)) + " " + 1485 base::IntToString(base::RandInt(0, 10000)) + " " +
1485 streets[base::RandInt(0, streets.size() - 1)]); 1486 streets[base::RandInt(0, streets.size() - 1)]);
1486 string16 city = ASCIIToUTF16(cities[base::RandInt(0, cities.size() - 1)]); 1487 string16 city = ASCIIToUTF16(cities[base::RandInt(0, cities.size() - 1)]);
1487 string16 zip(base::IntToString16(base::RandInt(0, 10000))); 1488 string16 zip(base::IntToString16(base::RandInt(0, 10000)));
1488 profile.SetRawInfo(NAME_FIRST, name); 1489 profile.SetRawInfo(NAME_FIRST, name);
1489 profile.SetRawInfo(EMAIL_ADDRESS, email); 1490 profile.SetRawInfo(EMAIL_ADDRESS, email);
1490 profile.SetRawInfo(ADDRESS_HOME_LINE1, street); 1491 profile.SetRawInfo(ADDRESS_HOME_LINE1, street);
1491 profile.SetRawInfo(ADDRESS_HOME_CITY, city); 1492 profile.SetRawInfo(ADDRESS_HOME_CITY, city);
1492 profile.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA")); 1493 profile.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA"));
1493 profile.SetRawInfo(ADDRESS_HOME_ZIP, zip); 1494 profile.SetRawInfo(ADDRESS_HOME_ZIP, zip);
1494 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"United States")); 1495 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"US"));
1495 profiles.push_back(profile); 1496 profiles.push_back(profile);
1496 } 1497 }
1497 SetProfiles(&profiles); 1498 SetProfiles(&profiles);
1498 // TODO(isherman): once we're sure this test doesn't timeout on any bots, this 1499 // TODO(isherman): once we're sure this test doesn't timeout on any bots, this
1499 // can be removd. 1500 // can be removd.
1500 LOG(INFO) << "Created " << kNumProfiles << " profiles in " << 1501 LOG(INFO) << "Created " << kNumProfiles << " profiles in " <<
1501 (base::Time::Now() - start_time).InSeconds() << " seconds."; 1502 (base::Time::Now() - start_time).InSeconds() << " seconds.";
1502 1503
1503 GURL url = test_server()->GetURL( 1504 GURL url = test_server()->GetURL(
1504 "files/autofill/latency_after_submit_test.html"); 1505 "files/autofill/latency_after_submit_test.html");
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 // TODO(isherman): this looks redundant, consider removing. 1595 // TODO(isherman): this looks redundant, consider removing.
1595 // DISABLED: http://crbug.com/150084 1596 // DISABLED: http://crbug.com/150084
1596 IN_PROC_BROWSER_TEST_F(AutofillTest, 1597 IN_PROC_BROWSER_TEST_F(AutofillTest,
1597 DISABLED_MergeAggregatedDuplicatedProfiles) { 1598 DISABLED_MergeAggregatedDuplicatedProfiles) {
1598 int num_of_profiles = 1599 int num_of_profiles =
1599 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); 1600 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt");
1600 1601
1601 ASSERT_GT(num_of_profiles, 1602 ASSERT_GT(num_of_profiles,
1602 static_cast<int>(personal_data_manager()->GetProfiles().size())); 1603 static_cast<int>(personal_data_manager()->GetProfiles().size()));
1603 } 1604 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/address_unittest.cc ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698