Commit 516413c9 authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Add new credit card field

This change adds the non-padded month for credit card expiry to deal
with forms where the month is "1" for January (instead of "01").

Bug: b/168227057
Change-Id: Ibf030936e638ea5df57fe8e3da36fe6cf06589ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461314
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#815568}
parent 04ada830
......@@ -133,6 +133,14 @@ std::map<std::string, std::string> CreateAutofillMappings<autofill::CreditCard>(
AutofillFormatProto::CREDIT_CARD_NUMBER_LAST_FOUR_DIGITS))] =
last_four_digits;
}
int month;
if (base::StringToInt(
credit_card.GetInfo(autofill::CREDIT_CARD_EXP_MONTH, locale),
&month)) {
mappings[base::NumberToString(static_cast<int>(
AutofillFormatProto::CREDIT_CARD_NON_PADDED_EXP_MONTH))] =
base::NumberToString(month);
}
return mappings;
}
......
......@@ -108,6 +108,11 @@ TEST(FieldFormatterTest, CreditCard) {
EXPECT_EQ(*FormatString("${-2} ${-5}",
CreateAutofillMappings(credit_card, "en-US")),
"visa Visa");
// CREDIT_CARD_NON_PADDED_EXP_MONTH
EXPECT_EQ(
*FormatString("${-7}", CreateAutofillMappings(credit_card, "en-US")),
"1");
}
TEST(FieldFormatterTest, SpecialCases) {
......@@ -189,6 +194,7 @@ TEST(FieldFormatterTest, AddsAllProfileFields) {
TEST(FieldFormatterTest, AddsAllCreditCardFields) {
std::map<std::string, std::string> expected_values = {
{"-7", "8"},
{"-5", "Visa"},
{"-4", "1111"},
{"-2", "visa"},
......
......@@ -199,6 +199,7 @@ message AutofillFormatProto {
CREDIT_CARD_NETWORK_FOR_DISPLAY = -5;
// Currently only US states are supported. The state name is in lower case.
ADDRESS_HOME_STATE_NAME = -6;
CREDIT_CARD_NON_PADDED_EXP_MONTH = -7;
}
// The format string to use. May contain one or multiple "${key}"
// placeholders, where the key is an integer corresponding to
......
......@@ -431,6 +431,7 @@ enum KeyboardValueFillStrategy {
SIMULATE_KEY_PRESSES_SELECT_VALUE = 3;
}
// Note: On multiple matches, the first one will be selected.
enum DropdownSelectStrategy {
UNSPECIFIED_SELECT_STRATEGY = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment