summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/form_structure_unittest.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 20:55:36 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 20:55:36 +0000
commitc8ccbfcbdaa3b2c62ca4ca63dae2db344345ab9d (patch)
treec61c21e0c2e022980d0ae0b01078d035b679d76c /chrome/browser/autofill/form_structure_unittest.cc
parentbd72c7906210755e2bbad86faaeeb59fb48e5b86 (diff)
downloadchromium_src-c8ccbfcbdaa3b2c62ca4ca63dae2db344345ab9d.zip
chromium_src-c8ccbfcbdaa3b2c62ca4ca63dae2db344345ab9d.tar.gz
chromium_src-c8ccbfcbdaa3b2c62ca4ca63dae2db344345ab9d.tar.bz2
AutoFill: Try to parse a third address line and discard it if it exists.
BUG=38327 TEST=FormManagerTest.ThreeAddressLines Review URL: http://codereview.chromium.org/1746004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/form_structure_unittest.cc')
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index 8230364..52f440d 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -667,4 +667,55 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(6)->heuristic_type());
}
+TEST(FormStructureTest, ThreeAddressLines) {
+ scoped_ptr<FormStructure> form_structure;
+ FormData form;
+
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
+ ASCIIToUTF16("Address"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
+ ASCIIToUTF16("Address"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
+ ASCIIToUTF16("Address"),
+ string16(),
+ ASCIIToUTF16("text")));
+ form_structure.reset(new FormStructure(form));
+ EXPECT_TRUE(form_structure->IsAutoFillable());
+
+ // Check that heuristics are initialized as UNKNOWN_TYPE.
+ std::vector<AutoFillField*>::const_iterator iter;
+ size_t i;
+ for (iter = form_structure->begin(), i = 0;
+ iter != form_structure->end();
+ ++iter, ++i) {
+ // Expect last element to be NULL.
+ if (i == form_structure->field_count()) {
+ ASSERT_EQ(static_cast<AutoFillField*>(NULL), *iter);
+ } else {
+ ASSERT_NE(static_cast<AutoFillField*>(NULL), *iter);
+ EXPECT_EQ(UNKNOWN_TYPE, (*iter)->heuristic_type());
+ }
+ }
+
+ // Compute heuristic types.
+ form_structure->GetHeuristicAutoFillTypes();
+ ASSERT_EQ(3U, form_structure->field_count());
+
+ // Check that heuristics are no longer UNKNOWN_TYPE.
+ // Address Line 1.
+ EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
+ // Address Line 2.
+ EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
+ // Address Line 3.
+ EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type());
+}
+
} // namespace