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

Unified Diff: components/autofill/core/browser/autofill_field_unittest.cc

Issue 1639563002: [Autofill] Fill from the last digits when filling a phone number with a maximum length. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_field_unittest.cc
diff --git a/components/autofill/core/browser/autofill_field_unittest.cc b/components/autofill/core/browser/autofill_field_unittest.cc
index 10b1d96ce6a146dbce193be0fdc2343e90afba12..b339e62894393ccbde7df3a58746b2562f9ec682 100644
--- a/components/autofill/core/browser/autofill_field_unittest.cc
+++ b/components/autofill/core/browser/autofill_field_unittest.cc
@@ -273,7 +273,7 @@ TEST(AutofillFieldTest, FillPhoneNumber) {
field, ASCIIToUTF16("5551234"), "en-US", "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("555"), field.value);
- // Now reset the type, and set a max-length instead.
+ // Now reset the type, and set a max-length the size of a suffix.
field.SetHtmlType(HTML_TYPE_UNSPECIFIED, HtmlFieldMode());
field.set_heuristic_type(PHONE_HOME_NUMBER);
field.max_length = 4;
@@ -282,6 +282,17 @@ TEST(AutofillFieldTest, FillPhoneNumber) {
AutofillField::FillFormField(
field, ASCIIToUTF16("5551234"), "en-US", "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("1234"), field.value);
+
+ // Now reset the type, and set a max-length of 10.
+ field.SetHtmlType(HTML_TYPE_UNSPECIFIED, HtmlFieldMode());
Mathieu 2016/01/26 14:43:02 HTML_TYPE_TEL? https://code.google.com/p/chromiu
sebsg 2016/01/26 23:56:26 Done.
+ field.set_heuristic_type(PHONE_HOME_WHOLE_NUMBER);
+ field.max_length = 10;
+
+ // Fill with a whole phone number including country code. The number should
+ // fill without the country code.
+ AutofillField::FillFormField(field, ASCIIToUTF16("15141254578"), "en-US",
+ "en-US", &field);
+ EXPECT_EQ(ASCIIToUTF16("5141254578"), field.value);
}
TEST(AutofillFieldTest, FillSelectControlByValue) {

Powered by Google App Engine
This is Rietveld 408576698