summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-09 01:24:54 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-09 01:24:54 +0000
commitab6a23916c03e980118ba4c3fd64da744d6716f5 (patch)
tree17026b02f1419cb936a024994fe7e892d5823a11
parent6bdec590995846cfbb6a879778befe3b1e5af8b6 (diff)
downloadchromium_src-ab6a23916c03e980118ba4c3fd64da744d6716f5.zip
chromium_src-ab6a23916c03e980118ba4c3fd64da744d6716f5.tar.gz
chromium_src-ab6a23916c03e980118ba4c3fd64da744d6716f5.tar.bz2
rAc: support street-address.
BUG=330084 Review URL: https://codereview.chromium.org/111853012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243724 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_common.cc10
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc70
-rw-r--r--components/autofill/content/browser/wallet/wallet_address.cc12
-rw-r--r--components/autofill/content/browser/wallet/wallet_address_unittest.cc2
4 files changed, 86 insertions, 8 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_common.cc b/chrome/browser/ui/autofill/autofill_dialog_common.cc
index 81cc600..7c4db15 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_common.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_common.cc
@@ -42,8 +42,14 @@ bool InputTypeMatchesFieldType(const DetailInput& input,
// Check the groups to distinguish billing types from shipping ones.
AutofillType input_type = AutofillType(input.type);
- return input_type.GetStorableType() == server_type &&
- input_type.group() == field_type.group();
+ if (input_type.group() != field_type.group())
+ return false;
+
+ // Street address (all lines) is matched to the first input address line.
+ if (server_type == ADDRESS_HOME_STREET_ADDRESS)
+ return input_type.GetStorableType() == ADDRESS_HOME_LINE1;
+
+ return input_type.GetStorableType() == server_type;
}
// Returns true if |input| in the given |section| should be used for a
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index cb32ae2..f6ed642 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -1208,6 +1208,76 @@ TEST_F(AutofillDialogControllerTest, BillingVsShippingPhoneNumber) {
form_structure()->field(0)->value);
}
+// Similar to the above, but tests that street-address (i.e. all lines of the
+// street address) is successfully filled for both shipping and billing
+// sections.
+TEST_F(AutofillDialogControllerTest, BillingVsShippingStreetAddress) {
+ FormFieldData shipping_address;
+ shipping_address.autocomplete_attribute = "shipping street-address";
+ FormFieldData billing_address;
+ billing_address.autocomplete_attribute = "billing street-address";
+ FormFieldData shipping_address_textarea;
+ shipping_address_textarea.autocomplete_attribute = "shipping street-address";
+ shipping_address_textarea.form_control_type = "textarea";
+ FormFieldData billing_address_textarea;
+ billing_address_textarea.autocomplete_attribute = "billing street-address";
+ billing_address_textarea.form_control_type = "textarea";
+
+ FormData form_data;
+ form_data.fields.push_back(shipping_address);
+ form_data.fields.push_back(billing_address);
+ form_data.fields.push_back(shipping_address_textarea);
+ form_data.fields.push_back(billing_address_textarea);
+ SetUpControllerWithFormData(form_data);
+
+ SwitchToAutofill();
+
+ // The profile that will be chosen for the shipping section.
+ AutofillProfile shipping_profile(test::GetVerifiedProfile());
+ // The profile that will be chosen for the billing section.
+ AutofillProfile billing_profile(test::GetVerifiedProfile2());
+ CreditCard credit_card(test::GetVerifiedCreditCard());
+ controller()->GetTestingManager()->AddTestingProfile(&shipping_profile);
+ controller()->GetTestingManager()->AddTestingProfile(&billing_profile);
+ controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
+ ui::MenuModel* billing_model =
+ controller()->MenuModelForSection(SECTION_BILLING);
+ billing_model->ActivatedAt(1);
+
+ controller()->OnAccept();
+ ASSERT_EQ(4U, form_structure()->field_count());
+ EXPECT_EQ(ADDRESS_HOME_STREET_ADDRESS,
+ form_structure()->field(0)->Type().GetStorableType());
+ EXPECT_EQ(ADDRESS_HOME, form_structure()->field(0)->Type().group());
+ EXPECT_EQ(ADDRESS_HOME_STREET_ADDRESS,
+ form_structure()->field(1)->Type().GetStorableType());
+ EXPECT_EQ(ADDRESS_BILLING, form_structure()->field(1)->Type().group());
+ // Inexact matching; single-line inputs get the address data concatenated but
+ // separated by commas.
+ EXPECT_TRUE(StartsWith(form_structure()->field(0)->value,
+ shipping_profile.GetRawInfo(ADDRESS_HOME_LINE1),
+ true));
+ EXPECT_TRUE(EndsWith(form_structure()->field(0)->value,
+ shipping_profile.GetRawInfo(ADDRESS_HOME_LINE2),
+ true));
+ EXPECT_TRUE(StartsWith(form_structure()->field(1)->value,
+ billing_profile.GetRawInfo(ADDRESS_HOME_LINE1),
+ true));
+ EXPECT_TRUE(EndsWith(form_structure()->field(1)->value,
+ billing_profile.GetRawInfo(ADDRESS_HOME_LINE2),
+ true));
+ // The textareas should be an exact match.
+ EXPECT_EQ(shipping_profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
+ form_structure()->field(2)->value);
+ EXPECT_EQ(billing_profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
+ form_structure()->field(3)->value);
+
+ EXPECT_NE(form_structure()->field(1)->value,
+ form_structure()->field(0)->value);
+ EXPECT_NE(form_structure()->field(3)->value,
+ form_structure()->field(2)->value);
+}
+
TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) {
for (size_t i = 0; i < 2; ++i) {
SCOPED_TRACE(testing::Message() << "Case " << i);
diff --git a/components/autofill/content/browser/wallet/wallet_address.cc b/components/autofill/content/browser/wallet/wallet_address.cc
index 000b616..bc22a60 100644
--- a/components/autofill/content/browser/wallet/wallet_address.cc
+++ b/components/autofill/content/browser/wallet/wallet_address.cc
@@ -280,17 +280,19 @@ base::string16 Address::GetInfo(const AutofillType& type,
if (type.html_type() == HTML_TYPE_COUNTRY_CODE) {
DCHECK(IsStringASCII(country_name_code()));
return base::ASCIIToUTF16(country_name_code());
- } else if (type.html_type() == HTML_TYPE_STREET_ADDRESS) {
- base::string16 address = address_line_1();
- if (!address_line_2().empty())
- address += base::ASCIIToUTF16(", ") + address_line_2();
- return address;
}
switch (type.GetStorableType()) {
case NAME_FULL:
return recipient_name();
+ case ADDRESS_HOME_STREET_ADDRESS: {
+ base::string16 address = address_line_1();
+ if (!address_line_2().empty())
+ address += base::ASCIIToUTF16("\n") + address_line_2();
+ return address;
+ }
+
case ADDRESS_HOME_LINE1:
return address_line_1();
diff --git a/components/autofill/content/browser/wallet/wallet_address_unittest.cc b/components/autofill/content/browser/wallet/wallet_address_unittest.cc
index 11f6125..8a206bd 100644
--- a/components/autofill/content/browser/wallet/wallet_address_unittest.cc
+++ b/components/autofill/content/browser/wallet/wallet_address_unittest.cc
@@ -448,7 +448,7 @@ TEST_F(WalletAddressTest, GetStreetAddress) {
ASCIIToUTF16("phone_number"),
"id1");
AutofillType type = AutofillType(HTML_TYPE_STREET_ADDRESS, HTML_MODE_NONE);
- EXPECT_EQ(ASCIIToUTF16("address_line_1, address_line_2"),
+ EXPECT_EQ(ASCIIToUTF16("address_line_1\naddress_line_2"),
address1.GetInfo(type, "en-US"));
// Address has only line 1.