| OLD | NEW |
| 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 <list> | 10 #include <list> |
| (...skipping 5266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5277 // Make sure both profiles were saved. | 5277 // Make sure both profiles were saved. |
| 5278 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); | 5278 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); |
| 5279 | 5279 |
| 5280 // The deduping routine should not be run. | 5280 // The deduping routine should not be run. |
| 5281 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); | 5281 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); |
| 5282 | 5282 |
| 5283 // Both profiles should still be present. | 5283 // Both profiles should still be present. |
| 5284 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); | 5284 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); |
| 5285 } | 5285 } |
| 5286 | 5286 |
| 5287 TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_NopIfZeroProfiles) { |
| 5288 EXPECT_TRUE(personal_data_->GetProfiles().empty()); |
| 5289 EnableAutofillProfileCleanup(); |
| 5290 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); |
| 5291 } |
| 5292 |
| 5293 TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_NopIfOneProfile) { |
| 5294 // Create a profile to dedupe. |
| 5295 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); |
| 5296 test::SetProfileInfo(&profile, "Homer", "J", "Simpson", |
| 5297 "homer.simpson@abc.com", "", "742. Evergreen Terrace", |
| 5298 "", "Springfield", "IL", "91601", "US", ""); |
| 5299 |
| 5300 personal_data_->AddProfile(profile); |
| 5301 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
| 5302 .WillOnce(QuitMainMessageLoop()); |
| 5303 base::RunLoop().Run(); |
| 5304 |
| 5305 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); |
| 5306 |
| 5307 // Enable the profile cleanup now. Otherwise it would be triggered by the |
| 5308 // calls to AddProfile. |
| 5309 EnableAutofillProfileCleanup(); |
| 5310 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); |
| 5311 } |
| 5312 |
| 5313 |
| 5287 // Tests that ApplyDedupingRoutine is not run a second time on the same major | 5314 // Tests that ApplyDedupingRoutine is not run a second time on the same major |
| 5288 // version. | 5315 // version. |
| 5289 TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_OncePerVersion) { | 5316 TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_OncePerVersion) { |
| 5290 // Create a profile to dedupe. | 5317 // Create a profile to dedupe. |
| 5291 AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com"); | 5318 AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com"); |
| 5292 test::SetProfileInfo(&profile1, "Homer", "J", "Simpson", | 5319 test::SetProfileInfo(&profile1, "Homer", "J", "Simpson", |
| 5293 "homer.simpson@abc.com", "", "742. Evergreen Terrace", | 5320 "homer.simpson@abc.com", "", "742. Evergreen Terrace", |
| 5294 "", "Springfield", "IL", "91601", "US", ""); | 5321 "", "Springfield", "IL", "91601", "US", ""); |
| 5295 | 5322 |
| 5296 // Create a similar profile. | 5323 // Create a similar profile. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5343 EnableAutofillProfileCleanup(); | 5370 EnableAutofillProfileCleanup(); |
| 5344 | 5371 |
| 5345 // The deduping routine should not be run. | 5372 // The deduping routine should not be run. |
| 5346 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); | 5373 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); |
| 5347 | 5374 |
| 5348 // The two duplicate profiles should still be present. | 5375 // The two duplicate profiles should still be present. |
| 5349 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); | 5376 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); |
| 5350 } | 5377 } |
| 5351 | 5378 |
| 5352 } // namespace autofill | 5379 } // namespace autofill |
| OLD | NEW |