diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 05:19:04 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 05:19:04 +0000 |
commit | 351e326d2e335db14f44edfc7bc69aa37133dd92 (patch) | |
tree | 25ae8d1bb23081dfd7aa077c16209cc0c5077673 /chrome/browser/autofill | |
parent | 44820ba4336b5acfd238ef2bcb61b7b2dc647228 (diff) | |
download | chromium_src-351e326d2e335db14f44edfc7bc69aa37133dd92.zip chromium_src-351e326d2e335db14f44edfc7bc69aa37133dd92.tar.gz chromium_src-351e326d2e335db14f44edfc7bc69aa37133dd92.tar.bz2 |
Don't use empty fields as distinguishing fields for autofill.
BUG=66953
TEST=unit_tests --gtest_filter=AutoFillProfileTest.CreateInferredLabelsSkipsEmptyFields
Review URL: http://codereview.chromium.org/5848002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_profile.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_profile_unittest.cc | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc index f1889c0..f60e640 100644 --- a/chrome/browser/autofill/autofill_profile.cc +++ b/chrome/browser/autofill/autofill_profile.cc @@ -297,7 +297,7 @@ void AutoFillProfile::CreateInferredLabels( fields.push_back(fields_to_use[i]); } else if (added_fields < minimal_fields_shown && exclude_field != fields_to_use[i] && - !label_iterator->first.empty()) { + !tested_fields[i].count(string16())) { fields.push_back(fields_to_use[i]); first_non_empty_fields.push_back(fields_to_use[i]); ++added_fields; diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc index 7958eae..670105d 100644 --- a/chrome/browser/autofill/autofill_profile_unittest.cc +++ b/chrome/browser/autofill/autofill_profile_unittest.cc @@ -4,6 +4,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" +#include "base/scoped_vector.h" #include "base/stl_util-inl.h" #include "base/string16.h" #include "base/utf_string_conversions.h" @@ -392,6 +393,31 @@ TEST(AutoFillProfileTest, CreateInferredLabels) { STLDeleteContainerPointers(profiles.begin(), profiles.end()); } +// Make sure that empty fields are not treated as distinguishing fields. +TEST(AutoFillProfileTest, CreateInferredLabelsSkipsEmptyFields) { + ScopedVector<AutoFillProfile> profiles; + profiles.push_back(new AutoFillProfile); + autofill_test::SetProfileInfo(profiles[0], + "", "John", "", "Doe", "doe@example.com", + "Gogole", "", "", "", "", "", "", "", ""); + profiles.push_back(new AutoFillProfile); + autofill_test::SetProfileInfo(profiles[1], + "", "John", "", "Doe", "doe@example.com", + "Ggoole", "", "", "", "", "", "", "", ""); + profiles.push_back(new AutoFillProfile); + autofill_test::SetProfileInfo(profiles[2], + "", "John", "", "Doe", "john.doe@example.com", + "Goolge", "", "", "", "", "", "", "", ""); + + std::vector<string16> labels; + AutoFillProfile::CreateInferredLabels(&profiles.get(), &labels, 3, + UNKNOWN_TYPE, NULL); + ASSERT_EQ(3U, labels.size()); + EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); + EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]); + EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]); +} + TEST(AutoFillProfileTest, IsSubsetOf) { scoped_ptr<AutoFillProfile> a, b; |