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

Unified Diff: chrome/browser/autofill/form_field_unittest.cc

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix for android CQ failure. Created 8 years 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: chrome/browser/autofill/form_field_unittest.cc
diff --git a/chrome/browser/autofill/form_field_unittest.cc b/chrome/browser/autofill/form_field_unittest.cc
index 16b51a0c83b3968afe91add1751578b1c6528946..8ab1127c458c139173c80defc9b1f6a326d5e656 100644
--- a/chrome/browser/autofill/form_field_unittest.cc
+++ b/chrome/browser/autofill/form_field_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_vector.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_field.h"
@@ -114,3 +115,32 @@ TEST(FormFieldTest, Match) {
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"),
FormField::MATCH_LABEL));
}
+
+// Test that we ignore checkable elements.
+TEST(FormFieldTest, ParseFormFields) {
+ ScopedVector<AutofillField> fields;
+ FormFieldData field_data;
+ field_data.form_control_type = "text";
+
+ field_data.label = ASCIIToUTF16("Address line1");
+ fields.push_back(new AutofillField(field_data, field_data.label));
+
+ field_data.is_checkable = true;
+ field_data.label = ASCIIToUTF16("Is PO Box");
+ fields.push_back(new AutofillField(field_data, field_data.label));
+
+ // reset is_checkable to false.
+ field_data.is_checkable = false;
+ field_data.label = ASCIIToUTF16("Address line2");
+ fields.push_back(new AutofillField(field_data, field_data.label));
+
+ FieldTypeMap field_type_map;
+ FormField::ParseFormFields(fields.get(), &field_type_map);
+ // Checkable element shouldn't interfere with inference of Address line2.
+ EXPECT_EQ(2U, field_type_map.size());
+
+ EXPECT_EQ(ADDRESS_HOME_LINE1,
+ field_type_map.find(ASCIIToUTF16("Address line1"))->second);
+ EXPECT_EQ(ADDRESS_HOME_LINE2,
+ field_type_map.find(ASCIIToUTF16("Address line2"))->second);
+}

Powered by Google App Engine
This is Rietveld 408576698