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

Side by Side Diff: components/autofill/core/browser/autofill_field_unittest.cc

Issue 2041863003: [Autofill] Fix the trucating of expiration year inputs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « components/autofill/core/browser/autofill_field.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_field.h" 5 #include "components/autofill/core/browser/autofill_field.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // A field predicted as a 4 digits expiration year should fill the last 2 360 // A field predicted as a 4 digits expiration year should fill the last 2
361 // digits of the expiration year if the field has a max length of 2. 361 // digits of the expiration year if the field has a max length of 2.
362 {HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 2, "2023", "23"}, 362 {HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 2, "2023", "23"},
363 // A field predicted as a 4 digits expiration year should fill the last 363 // A field predicted as a 4 digits expiration year should fill the last
364 // digit of the expiration year if the field has a max length of 1. 364 // digit of the expiration year if the field has a max length of 1.
365 {HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 1, "2023", "3"}, 365 {HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 1, "2023", "3"},
366 }; 366 };
367 367
368 for (TestCase test_case : test_cases) { 368 for (TestCase test_case : test_cases) {
369 AutofillField field; 369 AutofillField field;
370 field.form_control_type = "input"; 370 field.form_control_type = "text";
371 field.SetHtmlType(test_case.field_type, HtmlFieldMode()); 371 field.SetHtmlType(test_case.field_type, HtmlFieldMode());
372 field.max_length = test_case.field_max_length; 372 field.max_length = test_case.field_max_length;
373 373
374 AutofillField::FillFormField(field, ASCIIToUTF16(test_case.value_to_fill), 374 AutofillField::FillFormField(field, ASCIIToUTF16(test_case.value_to_fill),
375 "en-US", "en-US", &field); 375 "en-US", "en-US", &field);
376 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); 376 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
377 } 377 }
378 } 378 }
379 379
380 TEST_F(AutofillFieldTest, FillSelectControlByValue) { 380 TEST_F(AutofillFieldTest, FillSelectControlByValue) {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 bool has_filled = AutofillField::FillFormField( 944 bool has_filled = AutofillField::FillFormField(
945 field, ASCIIToUTF16(test_case.value_to_fill), "en-US", "en-US", &field); 945 field, ASCIIToUTF16(test_case.value_to_fill), "en-US", "en-US", &field);
946 946
947 EXPECT_EQ(test_case.should_fill, has_filled); 947 EXPECT_EQ(test_case.should_fill, has_filled);
948 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); 948 EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
949 } 949 }
950 } 950 }
951 951
952 } // namespace 952 } // namespace
953 } // namespace autofill 953 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_field.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698