diff options
author | ramankk@chromium.org <ramankk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 10:08:45 +0000 |
---|---|---|
committer | ramankk@chromium.org <ramankk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 10:08:45 +0000 |
commit | b32c7e7452dd53a9907083ae6a09523400197419 (patch) | |
tree | 41d272ec478ea77374ce7d06ae088c30f236383f /chrome/browser/autofill/form_field_unittest.cc | |
parent | 8f3119100192dff88fb3e4e563a4852349c00e7b (diff) | |
download | chromium_src-b32c7e7452dd53a9907083ae6a09523400197419.zip chromium_src-b32c7e7452dd53a9907083ae6a09523400197419.tar.gz chromium_src-b32c7e7452dd53a9907083ae6a09523400197419.tar.bz2 |
Add support for autofilling radio buttons and checkboxes.
Autofill server is equiped with provision to say a field type as
FIELD_WITH_DEFAULT_VALUE and specify what value to use by default it
client wants to fill it. For radio buttons, if the default value
specified by the autofill server is same as its value, Chrome checks that
input element.
all changes are behind switch.
BUG=157636
Review URL: https://chromiumcodereview.appspot.com/11415221
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/form_field_unittest.cc')
-rw-r--r-- | chrome/browser/autofill/form_field_unittest.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/autofill/form_field_unittest.cc b/chrome/browser/autofill/form_field_unittest.cc index 16b51a0..8ab1127 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); +} |