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

Unified Diff: components/autofill/core/browser/autofill_profile_unittest.cc

Issue 261993006: Modified to allow to preserve two-word string in first-name and last-name in autofill profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months 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
Index: components/autofill/core/browser/autofill_profile_unittest.cc
diff --git a/components/autofill/core/browser/autofill_profile_unittest.cc b/components/autofill/core/browser/autofill_profile_unittest.cc
index de550bd827bd869c9966a9a650fba85111e746db..e7b574a83d18dab4c3685e090f24985534323054 100644
--- a/components/autofill/core/browser/autofill_profile_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -898,4 +898,69 @@ TEST(AutofillProfileTest, FullAddress) {
EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
}
+TEST(AutofillProfileTest, OverwriteOrAppendNames) {
+ AutofillProfile a(base::GenerateGUID(), "https://www.example.com");
+ test::SetProfileInfo(&a,
+ "Marion",
+ "Mitchell",
+ "Morrison",
+ "marion@me.xyz",
+ "Fox",
+ "123 Zoo St.",
+ "unit 5",
+ "Hollywood",
+ "CA",
+ "91601",
+ "US",
+ "12345678910");
Ilya Sherman 2014/05/31 00:34:41 nit: Please only set the relevant fields, i.e. the
Pritam Nikam 2014/05/31 10:30:41 Done.
+
+ NameInfo name;
+ std::vector<NameInfo> names;
+ std::vector<base::string16> name_list;
+
+ a.GetRawMultiInfo(NAME_FULL, &name_list);
+ ASSERT_EQ(1U, name_list.size());
+
+ // Case 1: Identical full names
+ // Case 1A: Prefer with more info - 2 word last-name
+ // overwrite existing name as {first||last1 last2}
+ name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Marion"));
+ name.SetRawInfo(NAME_MIDDLE, base::string16());
+ name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Mitchell Morrison"));
+ names.push_back(name);
+
+ a.OverwriteOrAppendNames(names);
+ a.GetRawMultiInfo(NAME_FULL, &name_list);
+ ASSERT_EQ(1U, name_list.size());
+
+ // Case 1B: profile name with parsed tokens pased as first_, middle_ & last_
+ // Don't add to the list - {first|middle|last}
+ base::string16 full_name = name.GetRawInfo(NAME_FULL);
+ name.SetRawInfo(NAME_FULL, full_name);
+ names[0] = name;
+
+ a.OverwriteOrAppendNames(names);
+ a.GetRawMultiInfo(NAME_FULL, &name_list);
+ ASSERT_EQ(1U, name_list.size());
+
+ // Case 1C: Prefer with more info - 2 word first-name
+ // append as new name to the list - {first1 first2||last}
+ name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Marion Mitchell"));
+ name.SetRawInfo(NAME_MIDDLE, base::string16());
+ name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Morrison"));
+ names[0] = name;
+
+ a.OverwriteOrAppendNames(names);
+ a.GetRawMultiInfo(NAME_FULL, &name_list);
+ ASSERT_EQ(2U, name_list.size());
+
+ // Case 2: Unique names
+ // append name to the list
+ name.SetRawInfo(NAME_FULL, ASCIIToUTF16("Marion M. Morrison"));
+ names[0] = name;
+
+ a.OverwriteOrAppendNames(names);
+ a.GetRawMultiInfo(NAME_FULL, &name_list);
+ ASSERT_EQ(3U, name_list.size());
+}
Ilya Sherman 2014/05/31 00:34:41 This test code is somewhat fragile and hard to fol
Pritam Nikam 2014/05/31 10:30:41 Done.
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698