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

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

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
Patch Set: Created 6 years, 2 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 fa10822aa1c0210ac82fb724c0bd9faad825953d..78b4eeed133436e94995873e49c90aaa493bda31 100644
--- a/components/autofill/core/browser/autofill_field_unittest.cc
+++ b/components/autofill/core/browser/autofill_field_unittest.cc
@@ -622,5 +622,29 @@ TEST(AutofillFieldTest, FillCreditCardNumberWithUnequalSizeSplits) {
EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value);
}
+TEST(AutofillFieldTest, GetCreditCardNumberValue) {
+ std::string card_number("5187654321098765");
+ std::string expectations[] = {"5187", "6543", "2109", "8765"};
+ 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.
+ int max_lengths[] = {4, 4, 4, 4};
+
+ for (size_t i = 0; i < total_spilts; ++i) {
+ AutofillField cc_number_part;
+ cc_number_part.set_heuristic_type(CREDIT_CARD_NUMBER);
+ cc_number_part.max_length = max_lengths[i];
+ cc_number_part.set_credit_card_number_offset(4 * i);
+
+ // Retrive the value for |cc_number_part|.
+ base::string16 actual = AutofillField::GetCreditCardNumberValue(
+ cc_number_part, ASCIIToUTF16(card_number));
+
+ // 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.
+ actual = actual.substr(0, max_lengths[i]);
+
+ // Verify for expected results.
+ EXPECT_EQ(ASCIIToUTF16(expectations[i]), actual);
+ }
+}
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.
+
} // namespace
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698