 Chromium Code Reviews
 Chromium Code Reviews Issue 622773002:
  [Autofill] Autofill fails to show suggestions for credit card split across fields.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 622773002:
  [Autofill] Autofill fails to show suggestions for credit card split across fields.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 "components/autofill/core/browser/autofill_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" | 
| 6 | 6 | 
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" | 
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" | 
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" | 
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" | 
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 AutofillField::FillFormField(cc_number_full, | 615 AutofillField::FillFormField(cc_number_full, | 
| 616 ASCIIToUTF16(test.card_number_), | 616 ASCIIToUTF16(test.card_number_), | 
| 617 "en-US", | 617 "en-US", | 
| 618 "en-US", | 618 "en-US", | 
| 619 &cc_number_full); | 619 &cc_number_full); | 
| 620 | 620 | 
| 621 // Verify for expected results. | 621 // Verify for expected results. | 
| 622 EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value); | 622 EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value); | 
| 623 } | 623 } | 
| 624 | 624 | 
| 625 TEST(AutofillFieldTest, GetCreditCardNumberValue) { | |
| 626 std::string card_number("5187654321098765"); | |
| 627 std::string expectations[] = {"5187", "6543", "2109", "8765"}; | |
| 628 size_t total_spilts = 4; | |
| 
Ilya Sherman
2014/10/13 23:33:37
nit: Please use the arraysize macro to compute thi
 
Pritam Nikam
2014/10/15 09:12:11
Done.
 | |
| 629 int max_lengths[] = {4, 4, 4, 4}; | |
| 630 | |
| 631 for (size_t i = 0; i < total_spilts; ++i) { | |
| 632 AutofillField cc_number_part; | |
| 633 cc_number_part.set_heuristic_type(CREDIT_CARD_NUMBER); | |
| 634 cc_number_part.max_length = max_lengths[i]; | |
| 635 cc_number_part.set_credit_card_number_offset(4 * i); | |
| 636 | |
| 637 // Retrive the value for |cc_number_part|. | |
| 638 base::string16 actual = AutofillField::GetCreditCardNumberValue( | |
| 639 cc_number_part, ASCIIToUTF16(card_number)); | |
| 640 | |
| 641 // Enforce the field's |max_length| constrain. | |
| 
Ilya Sherman
2014/10/13 23:33:37
nit: "constrain" -> "constraint".  Also, please me
 
Pritam Nikam
2014/10/15 09:12:10
Done.
 | |
| 642 actual = actual.substr(0, max_lengths[i]); | |
| 643 | |
| 644 // Verify for expected results. | |
| 645 EXPECT_EQ(ASCIIToUTF16(expectations[i]), actual); | |
| 646 } | |
| 647 } | |
| 
Ilya Sherman
2014/10/13 23:33:37
Please also test the behavior if the offset is equ
 
Pritam Nikam
2014/10/15 09:12:10
Done.
 | |
| 648 | |
| 625 } // namespace | 649 } // namespace | 
| 626 } // namespace autofill | 650 } // namespace autofill | 
| OLD | NEW |