| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autofill_field.h" | 8 #include "components/autofill/core/browser/autofill_field.h" |
| 9 #include "components/autofill/core/browser/autofill_scanner.h" | 9 #include "components/autofill/core/browser/autofill_scanner.h" |
| 10 #include "components/autofill/core/browser/credit_card_field.h" | 10 #include "components/autofill/core/browser/credit_card_field.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 ASSERT_TRUE( | 340 ASSERT_TRUE( |
| 341 field_type_map_.find(ASCIIToUTF16("number1")) != field_type_map_.end()); | 341 field_type_map_.find(ASCIIToUTF16("number1")) != field_type_map_.end()); |
| 342 EXPECT_EQ(CREDIT_CARD_NUMBER, | 342 EXPECT_EQ(CREDIT_CARD_NUMBER, |
| 343 field_type_map_[ASCIIToUTF16("number1")]); | 343 field_type_map_[ASCIIToUTF16("number1")]); |
| 344 ASSERT_TRUE( | 344 ASSERT_TRUE( |
| 345 field_type_map_.find(ASCIIToUTF16("date2")) != field_type_map_.end()); | 345 field_type_map_.find(ASCIIToUTF16("date2")) != field_type_map_.end()); |
| 346 EXPECT_EQ(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, | 346 EXPECT_EQ(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, |
| 347 field_type_map_[ASCIIToUTF16("date2")]); | 347 field_type_map_[ASCIIToUTF16("date2")]); |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Verify that heuristics <input name="ccyear" maxlength="2"/> considers |
| 351 // *maxlength* attribute while parsing 2 Digit expiration year. |
| 352 TEST_F(CreditCardFieldTest, ParseCreditCardExpYear_2DigitMaxLength) { |
| 353 FormFieldData field; |
| 354 field.form_control_type = "text"; |
| 355 |
| 356 field.label = ASCIIToUTF16("Card Number"); |
| 357 field.name = ASCIIToUTF16("card_number"); |
| 358 list_.push_back(new AutofillField(field, ASCIIToUTF16("number"))); |
| 359 |
| 360 field.label = ASCIIToUTF16("Expiration Date"); |
| 361 field.name = ASCIIToUTF16("ccmonth"); |
| 362 list_.push_back(new AutofillField(field, ASCIIToUTF16("month"))); |
| 363 |
| 364 field.name = ASCIIToUTF16("ccyear"); |
| 365 field.max_length = 2; |
| 366 list_.push_back(new AutofillField(field, ASCIIToUTF16("year"))); |
| 367 |
| 368 Parse(); |
| 369 ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); |
| 370 EXPECT_TRUE(ClassifyField()); |
| 371 ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("number")) != |
| 372 field_type_map_.end()); |
| 373 EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number")]); |
| 374 ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("month")) != |
| 375 field_type_map_.end()); |
| 376 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month")]); |
| 377 ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("year")) != |
| 378 field_type_map_.end()); |
| 379 EXPECT_EQ(CREDIT_CARD_EXP_2_DIGIT_YEAR, |
| 380 field_type_map_[ASCIIToUTF16("year")]); |
| 381 } |
| 382 |
| 350 } // namespace autofill | 383 } // namespace autofill |
| OLD | NEW |