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

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

Issue 1943853003: [Autofill] Sort existing profiles by frecency before trying to merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 4143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 base::Time::Now() - saved_profiles.front()->modification_date()); 4154 base::Time::Now() - saved_profiles.front()->modification_date());
4155 EXPECT_GT(base::TimeDelta::FromMilliseconds(500), 4155 EXPECT_GT(base::TimeDelta::FromMilliseconds(500),
4156 base::Time::Now() - saved_profiles.front()->use_date()); 4156 base::Time::Now() - saved_profiles.front()->use_date());
4157 } 4157 }
4158 4158
4159 // Erase the profiles for the next test. 4159 // Erase the profiles for the next test.
4160 ResetProfiles(); 4160 ResetProfiles();
4161 } 4161 }
4162 } 4162 }
4163 4163
4164 // Tests that MergeProfile tries to merge the imported profile into the
4165 // existing profile in decreasing order of frecency.
4166 TEST_F(PersonalDataManagerTest, MergeProfile_Frecency) {
4167 // Create two very similar profiles except with different company names.
4168 AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com");
4169 test::SetProfileInfo(&profile1, "Homer", "Jay", "Simpson",
4170 "homer.simpson@abc.com", "SNP", "742 Evergreen Terrace",
4171 "", "Springfield", "IL", "91601", "US", "12345678910");
4172 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com");
4173 test::SetProfileInfo(&profile2, "Homer", "Jay", "Simpson",
4174 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace",
4175 "", "Springfield", "IL", "91601", "US", "12345678910");
4176
4177 // Give the "Fox" profile a bigger frecency score.
4178 profile2.set_use_count(15);
4179
4180 // Create the |existing_profiles| vector.
4181 std::vector<AutofillProfile*> existing_profiles;
4182 existing_profiles.push_back(&profile1);
4183 existing_profiles.push_back(&profile2);
4184
4185 // Create a new imported profile with no company name.
4186 AutofillProfile imported_profile(base::GenerateGUID(),
4187 "https://www.example.com");
4188 test::SetProfileInfo(&imported_profile, "Homer", "Jay", "Simpson",
4189 "homer.simpson@abc.com", "", "742 Evergreen Terrace", "",
4190 "Springfield", "IL", "91601", "US", "12345678910");
4191
4192 // Merge the imported profile into the existing profiles.
4193 std::vector<AutofillProfile> profiles;
4194 std::string guid = personal_data_->MergeProfile(
4195 imported_profile, existing_profiles, "US-EN", &profiles);
4196
4197 // The new profile should be merged into the "fox" profile.
4198 EXPECT_EQ(profile2.guid(), guid);
4199 }
4200
4164 } // namespace autofill 4201 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698