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

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

Issue 1392623002: [Autofill] Add metric for profile action on form submitted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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 59732c232291c4cf933ff1341ddc0fb70e599a25..b092feb7cedd932f7bbb49ba190721c0609e1a6a 100644
--- a/components/autofill/core/browser/autofill_profile_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -66,6 +66,14 @@ struct TestCase {
std::vector<NameParts> expected_result;
};
+void SetupTestProfile(AutofillProfile& profile) {
+ profile.set_guid(base::GenerateGUID());
+ profile.set_origin("Chrome settings");
+ test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison",
+ "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
+ "Hollywood", "CA", "91601", "US", "12345678910");
+}
+
} // namespace
// Tests different possibilities for summary string generation.
@@ -830,12 +838,9 @@ TEST(AutofillProfileTest, IsSubsetOf) {
EXPECT_FALSE(a->IsSubsetOf(*b, "en-US"));
}
-TEST(AutofillProfileTest, OverwriteWith) {
- 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");
+TEST(AutofillProfileTest, OverwriteWith_DifferentProfile) {
+ AutofillProfile a;
+ SetupTestProfile(a);
// Create an identical profile except that the new profile:
// (1) Has a different origin,
@@ -852,7 +857,7 @@ TEST(AutofillProfileTest, OverwriteWith) {
b.SetRawInfo(NAME_FULL, ASCIIToUTF16("Marion M. Morrison"));
b.set_language_code("en");
- a.OverwriteWith(b, "en-US");
+ EXPECT_TRUE(a.OverwriteWith(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
EXPECT_EQ(ASCIIToUTF16("area 51"), a.GetRawInfo(ADDRESS_HOME_LINE2));
EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME));
@@ -861,6 +866,37 @@ TEST(AutofillProfileTest, OverwriteWith) {
EXPECT_EQ("en", a.language_code());
}
+TEST(AutofillProfileTest, OverwriteWith_SameProfile) {
+ AutofillProfile a;
+ SetupTestProfile(a);
+
+ AutofillProfile b = a;
+ b.set_guid(base::GenerateGUID());
+ EXPECT_FALSE(a.OverwriteWith(b, "en-US"));
+}
+
+TEST(AutofillProfileTest, OverwriteWith_DifferentName) {
+ AutofillProfile a;
+ SetupTestProfile(a);
+
+ AutofillProfile b = a;
+ b.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Mario"));
+ EXPECT_TRUE(a.OverwriteWith(b, "en-US"));
+ base::string16 name_full = a.GetInfo(AutofillType(NAME_FULL), "en-US");
+ EXPECT_EQ(ASCIIToUTF16("Mario Mitchell Morrison"), name_full);
+}
+
+TEST(AutofillProfileTest, OverwriteWith_DifferentAddress) {
+ AutofillProfile a;
+ SetupTestProfile(a);
+
+ AutofillProfile b = a;
+ b.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Aquarium St."));
+ EXPECT_TRUE(a.OverwriteWith(b, "en-US"));
+ base::string16 address = a.GetRawInfo(ADDRESS_HOME_LINE1);
+ EXPECT_EQ(ASCIIToUTF16("123 Aquarium St."), address);
+}
+
TEST(AutofillProfileTest, AssignmentOperator) {
AutofillProfile a(base::GenerateGUID(), "https://www.example.com/");
test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison",
« no previous file with comments | « components/autofill/core/browser/autofill_profile.cc ('k') | components/autofill/core/browser/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698