| 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 4193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4204 FormStructure form_structure2(form2); | 4204 FormStructure form_structure2(form2); |
| 4205 form_structure2.DetermineHeuristicTypes(); | 4205 form_structure2.DetermineHeuristicTypes(); |
| 4206 std::unique_ptr<CreditCard> imported_credit_card2; | 4206 std::unique_ptr<CreditCard> imported_credit_card2; |
| 4207 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, false, | 4207 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, false, |
| 4208 &imported_credit_card2)); | 4208 &imported_credit_card2)); |
| 4209 EXPECT_FALSE(imported_credit_card2); | 4209 EXPECT_FALSE(imported_credit_card2); |
| 4210 } | 4210 } |
| 4211 | 4211 |
| 4212 // Tests the SaveImportedProfile method with different profiles to make sure the | 4212 // Tests the SaveImportedProfile method with different profiles to make sure the |
| 4213 // merge logic works correctly. | 4213 // merge logic works correctly. |
| 4214 TEST_F(PersonalDataManagerTest, SaveImportedProfile) { | 4214 // Flaky on TSan, see crbug.com/686226. |
| 4215 #if defined(THREAD_SANITIZER) |
| 4216 #define MAYBE_SaveImportedProfile DISABLED_SaveImportedProfile |
| 4217 #else |
| 4218 #define MAYBE_SaveImportedProfile SaveImportedProfile |
| 4219 #endif |
| 4220 |
| 4221 TEST_F(PersonalDataManagerTest, MAYBE_SaveImportedProfile) { |
| 4215 typedef struct { | 4222 typedef struct { |
| 4216 autofill::ServerFieldType field_type; | 4223 autofill::ServerFieldType field_type; |
| 4217 std::string field_value; | 4224 std::string field_value; |
| 4218 } ProfileField; | 4225 } ProfileField; |
| 4219 | 4226 |
| 4220 typedef std::vector<ProfileField> ProfileFields; | 4227 typedef std::vector<ProfileField> ProfileFields; |
| 4221 | 4228 |
| 4222 typedef struct { | 4229 typedef struct { |
| 4223 // Each test starts with a default pre-existing profile and applies these | 4230 // Each test starts with a default pre-existing profile and applies these |
| 4224 // changes to it. | 4231 // changes to it. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4561 std::vector<AutofillProfile> profiles; | 4568 std::vector<AutofillProfile> profiles; |
| 4562 std::string guid = personal_data_->MergeProfile( | 4569 std::string guid = personal_data_->MergeProfile( |
| 4563 imported_profile, &existing_profiles, "US-EN", &profiles); | 4570 imported_profile, &existing_profiles, "US-EN", &profiles); |
| 4564 | 4571 |
| 4565 // The new profile should be merged into the "fox" profile. | 4572 // The new profile should be merged into the "fox" profile. |
| 4566 EXPECT_EQ(profile2->guid(), guid); | 4573 EXPECT_EQ(profile2->guid(), guid); |
| 4567 } | 4574 } |
| 4568 | 4575 |
| 4569 // Tests that MergeProfile produces a merged profile with the expected usage | 4576 // Tests that MergeProfile produces a merged profile with the expected usage |
| 4570 // statistics. | 4577 // statistics. |
| 4571 TEST_F(PersonalDataManagerTest, MergeProfile_UsageStats) { | 4578 // Flaky on TSan, see crbug.com/686226. |
| 4579 #if defined(THREAD_SANITIZER) |
| 4580 #define MAYBE_MergeProfile_UsageStats DISABLED_MergeProfile_UsageStats |
| 4581 #else |
| 4582 #define MAYBE_MergeProfile_UsageStats MergeProfile_UsageStats |
| 4583 #endif |
| 4584 |
| 4585 TEST_F(PersonalDataManagerTest, MAYBE_MergeProfile_UsageStats) { |
| 4572 // Create an initial profile with a use count of 10, an old use date and an | 4586 // Create an initial profile with a use count of 10, an old use date and an |
| 4573 // old modification date of 4 days ago. | 4587 // old modification date of 4 days ago. |
| 4574 AutofillProfile* profile = | 4588 AutofillProfile* profile = |
| 4575 new AutofillProfile(base::GenerateGUID(), "https://www.example.com"); | 4589 new AutofillProfile(base::GenerateGUID(), "https://www.example.com"); |
| 4576 test::SetProfileInfo(profile, "Homer", "Jay", "Simpson", | 4590 test::SetProfileInfo(profile, "Homer", "Jay", "Simpson", |
| 4577 "homer.simpson@abc.com", "SNP", "742 Evergreen Terrace", | 4591 "homer.simpson@abc.com", "SNP", "742 Evergreen Terrace", |
| 4578 "", "Springfield", "IL", "91601", "US", "12345678910"); | 4592 "", "Springfield", "IL", "91601", "US", "12345678910"); |
| 4579 profile->set_use_count(4U); | 4593 profile->set_use_count(4U); |
| 4580 profile->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(4)); | 4594 profile->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(4)); |
| 4581 profile->set_modification_date(base::Time::Now() - | 4595 profile->set_modification_date(base::Time::Now() - |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5641 EnableAutofillProfileCleanup(); | 5655 EnableAutofillProfileCleanup(); |
| 5642 | 5656 |
| 5643 // The deduping routine should not be run. | 5657 // The deduping routine should not be run. |
| 5644 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); | 5658 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); |
| 5645 | 5659 |
| 5646 // The two duplicate profiles should still be present. | 5660 // The two duplicate profiles should still be present. |
| 5647 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); | 5661 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); |
| 5648 } | 5662 } |
| 5649 | 5663 |
| 5650 } // namespace autofill | 5664 } // namespace autofill |
| OLD | NEW |