diff options
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; |