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

Side by Side Diff: components/autofill/core/browser/autofill_profile_unittest.cc

Issue 2164143002: Use the max use count on autofill profile merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better documentation Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 873 }
874 874
875 TEST(AutofillProfileTest, MergeDataFrom_SameProfile) { 875 TEST(AutofillProfileTest, MergeDataFrom_SameProfile) {
876 AutofillProfile a; 876 AutofillProfile a;
877 SetupTestProfile(a); 877 SetupTestProfile(a);
878 878
879 // The profile has no full name yet. Merge will add it. 879 // The profile has no full name yet. Merge will add it.
880 AutofillProfile b = a; 880 AutofillProfile b = a;
881 b.set_guid(base::GenerateGUID()); 881 b.set_guid(base::GenerateGUID());
882 EXPECT_TRUE(a.MergeDataFrom(b, "en-US")); 882 EXPECT_TRUE(a.MergeDataFrom(b, "en-US"));
883 EXPECT_EQ(2u, a.use_count()); 883 EXPECT_EQ(1u, a.use_count());
884 884
885 // Now the profile is fully populated. Merging it again has no effect (except 885 // Now the profile is fully populated. Merging it again has no effect (except
886 // for usage statistics). 886 // for usage statistics).
887 AutofillProfile c = a; 887 AutofillProfile c = a;
888 c.set_guid(base::GenerateGUID()); 888 c.set_guid(base::GenerateGUID());
889 c.set_use_count(3); 889 c.set_use_count(3);
890 EXPECT_FALSE(a.MergeDataFrom(c, "en-US")); 890 EXPECT_FALSE(a.MergeDataFrom(c, "en-US"));
891 EXPECT_EQ(5u, a.use_count()); 891 EXPECT_EQ(3u, a.use_count());
892 } 892 }
893 893
894 TEST(AutofillProfileTest, OverwriteName_AddNameFull) { 894 TEST(AutofillProfileTest, OverwriteName_AddNameFull) {
895 AutofillProfile a; 895 AutofillProfile a;
896 896
897 a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion")); 897 a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
898 a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell")); 898 a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
899 a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison")); 899 a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
900 900
901 AutofillProfile b = a; 901 AutofillProfile b = a;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 // The first, middle and last names should be kept and name full should be 1226 // The first, middle and last names should be kept and name full should be
1227 // added. 1227 // added.
1228 EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST)); 1228 EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
1229 EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE)); 1229 EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
1230 EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST)); 1230 EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
1231 EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"), 1231 EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"),
1232 a.GetRawInfo(NAME_FULL)); 1232 a.GetRawInfo(NAME_FULL));
1233 } 1233 }
1234 1234
1235 } // namespace autofill 1235 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698