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

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: More unit tests 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
« no previous file with comments | « chrome/browser/autofill/form_field.cc ('k') | chrome/browser/autofill/form_structure.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..55175900e76e53522fd8e22c095ea1bd256d8b53 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,35 @@ TEST(FormFieldTest, Match) {
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"),
FormField::MATCH_LABEL));
}
+
+AutofillField* BuildTestField(const std::string& name) {
Ilya Sherman 2012/12/18 02:05:11 nit: Please rename the parameter to |label|, since
+ FormFieldData field_data;
+ field_data.label = ASCIIToUTF16(name);
+ field_data.name = ASCIIToUTF16("name");
+ field_data.value = ASCIIToUTF16("value");
+ field_data.form_control_type = "text";
+ field_data.is_focusable = true;
+ field_data.autocomplete_attribute = "on";
+ field_data.should_autocomplete = true;
+ return new AutofillField(field_data, field_data.label);
Ilya Sherman 2012/12/18 02:05:11 You should pretty much never return a raw pointer
+}
Ilya Sherman 2012/12/18 02:05:11 nit: Please move this function definition into an
+
+// Test that we ignore checkable elements.
+TEST(FormFieldTest, ParseFormFields) {
+ ScopedVector<AutofillField> fields;
+ fields.push_back(BuildTestField("Address line1"));
+ AutofillField* checkable_field = BuildTestField("Is PO box");
+ checkable_field->is_checkable = true;
+ fields.push_back(checkable_field);
+ fields.push_back(BuildTestField("Address line2"));
+
+ 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);
+}
« no previous file with comments | « chrome/browser/autofill/form_field.cc ('k') | chrome/browser/autofill/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698