summaryrefslogtreecommitdiffstats
path: root/components/autofill/browser/personal_data_manager_unittest.cc
diff options
context:
space:
mode:
authorjimblackler@chromium.org <jimblackler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 12:35:42 +0000
committerjimblackler@chromium.org <jimblackler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 12:35:42 +0000
commita36215aa2ae4ccdee4a577b4668dfa391d1ced0c (patch)
tree01e99ceb16a0aa81fc64cd7463381283a9979103 /components/autofill/browser/personal_data_manager_unittest.cc
parentc9132eaa3f2eb391284e1b64af353c84947893b7 (diff)
downloadchromium_src-a36215aa2ae4ccdee4a577b4668dfa391d1ced0c.zip
chromium_src-a36215aa2ae4ccdee4a577b4668dfa391d1ced0c.tar.gz
chromium_src-a36215aa2ae4ccdee4a577b4668dfa391d1ced0c.tar.bz2
Rules for Autofill profile import relaxed where appropriate for most countries worldwide
Specifically, adapt PersonalDataManager::IsMinimumAddress to use the rules from the Android Address Widget project https://code.google.com/p/libaddressinput/source/browse/trunk/src/com/android/i18n/addressinput/RegionDataConstants.java?spec=svn117&r=117 regarding minimum address elements (Address Line 1, City, State, Zip) for each locality. BUG=http://crbug.com/224567 TEST=PersonalDataManager.ImportFormMinimumAddressUSA, PersonalDataManager.ImportFormMinimumAddressGB, PersonalDataManager.ImportFormMinimumAddressGI Review URL: https://chromiumcodereview.appspot.com/13375023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/autofill/browser/personal_data_manager_unittest.cc')
-rw-r--r--components/autofill/browser/personal_data_manager_unittest.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/components/autofill/browser/personal_data_manager_unittest.cc b/components/autofill/browser/personal_data_manager_unittest.cc
index 740c9f8..ac3a40f 100644
--- a/components/autofill/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/browser/personal_data_manager_unittest.cc
@@ -605,6 +605,90 @@ TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) {
ASSERT_EQ(0U, credit_cards.size());
}
+TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressUSA) {
+ // United States addresses must specifiy one address line, a city, state and
+ // zip code.
+ FormData form;
+ FormFieldData field;
+ autofill_test::CreateTestFormField(
+ "Name:", "name", "Barack Obama", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Address:", "address", "1600 Pennsylvania Avenue", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "City:", "city", "Washington", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "State:", "state", "DC", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Zip:", "zip", "20500", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Country:", "country", "USA", "text", &field);
+ form.fields.push_back(field);
+ FormStructure form_structure(form, std::string());
+ form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ const CreditCard* imported_credit_card;
+ EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
+ &imported_credit_card));
+ const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles();
+ ASSERT_EQ(1U, profiles.size());
+}
+
+TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGB) {
+ // British addresses do not require a state/province as the county is usually
+ // not requested on forms.
+ FormData form;
+ FormFieldData field;
+ autofill_test::CreateTestFormField(
+ "Name:", "name", "David Cameron", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Address:", "address", "10 Downing Street", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "City:", "city", "London", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Postcode:", "postcode", "SW1A 2AA", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Country:", "country", "United Kingdom", "text", &field);
+ form.fields.push_back(field);
+ FormStructure form_structure(form, std::string());
+ form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ const CreditCard* imported_credit_card;
+ EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
+ &imported_credit_card));
+ const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles();
+ ASSERT_EQ(1U, profiles.size());
+}
+
+TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGI) {
+ // Gibraltar has the most minimal set of requirements for a valid address.
+ // There are no cities or provinces and no postal/zip code system.
+ FormData form;
+ FormFieldData field;
+ autofill_test::CreateTestFormField(
+ "Name:", "name", "Sir Adrian Johns", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Address:", "address", "The Convent, Main Street", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Country:", "country", "Gibraltar", "text", &field);
+ form.fields.push_back(field);
+ FormStructure form_structure(form, std::string());
+ form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ const CreditCard* imported_credit_card;
+ EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
+ &imported_credit_card));
+ const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles();
+ ASSERT_EQ(1U, profiles.size());
+}
+
TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) {
FormData form;
FormFieldData field;