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

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

Issue 853523004: Autofill: Set requirements for number of recognized fields in an autofillable form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug, adjust tests Created 5 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/form_structure_unittest.cc
diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
index 4ad21eb3c2c86dbe2efbdf02560d778ea57ce570..5b3ec57203678baa06c4f2e22611badb05e0ab5d 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -111,8 +111,8 @@ TEST(FormStructureTest, AutofillCount) {
// Add a field with should_autocomplete=false. This should not be considered a
// fillable field.
- field.label = ASCIIToUTF16("address1");
- field.name = ASCIIToUTF16("address1");
+ field.label = ASCIIToUTF16("city");
+ field.name = ASCIIToUTF16("city");
field.form_control_type = "text";
field.should_autocomplete = false;
form.fields.push_back(field);
@@ -1068,10 +1068,14 @@ TEST(FormStructureTest, SurplusAddressLinesIgnored) {
field.name = ASCIIToUTF16("billing.address.addressLine4");
form.fields.push_back(field);
+ field.label = ASCIIToUTF16("City");
+ field.name = ASCIIToUTF16("billing.address.city");
+ form.fields.push_back(field);
+
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes();
- ASSERT_EQ(4U, form_structure->field_count());
- ASSERT_EQ(3U, form_structure->autofill_count());
+ ASSERT_EQ(5U, form_structure->field_count());
+ EXPECT_EQ(4U, form_structure->autofill_count());
// Address Line 1.
EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
@@ -1330,6 +1334,10 @@ TEST(FormStructureTest, HeuristicsInfernoCC) {
field.name = ASCIIToUTF16("billing_address");
form.fields.push_back(field);
+ field.label = ASCIIToUTF16("City");
+ field.name = ASCIIToUTF16("city");
+ form.fields.push_back(field);
+
field.label = ASCIIToUTF16("Card Number");
field.name = ASCIIToUTF16("card_number");
form.fields.push_back(field);
@@ -1347,20 +1355,22 @@ TEST(FormStructureTest, HeuristicsInfernoCC) {
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
- ASSERT_EQ(5U, form_structure->field_count());
- EXPECT_EQ(5U, form_structure->autofill_count());
+ ASSERT_EQ(6U, form_structure->field_count());
+ EXPECT_EQ(6U, form_structure->autofill_count());
// Name on Card.
EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type());
// Address.
EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type());
+ // City.
+ EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type());
// Card Number.
- EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type());
+ EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(3)->heuristic_type());
// Expiration Date.
- EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(3)->heuristic_type());
+ EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(4)->heuristic_type());
// Expiration Year.
EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR,
- form_structure->field(4)->heuristic_type());
+ form_structure->field(5)->heuristic_type());
}
TEST(FormStructureTest, CVCCodeClash) {
@@ -2420,6 +2430,8 @@ TEST(FormStructureTest, ParseQueryResponse) {
FormStructure::ParseQueryResponse(response, forms.get());
+ ASSERT_GE(forms[0]->field_count(), 2U);
+ ASSERT_GE(forms[1]->field_count(), 2U);
EXPECT_EQ(7, forms[0]->field(0)->server_type());
EXPECT_EQ(30, forms[0]->field(1)->server_type());
EXPECT_EQ(9, forms[1]->field(0)->server_type());
@@ -2455,6 +2467,7 @@ TEST(FormStructureTest, ParseQueryResponseAuthorDefinedTypes) {
FormStructure::ParseQueryResponse(response, forms.get());
+ ASSERT_GE(forms[0]->field_count(), 2U);
EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type());
EXPECT_EQ(76, forms[0]->field(1)->server_type());
}

Powered by Google App Engine
This is Rietveld 408576698