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

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

Issue 2104363004: Remove remaining calls to deprecated MessageLoop methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab 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/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 4934 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 4945
4946 personal_data_->AddProfile(Homer1); 4946 personal_data_->AddProfile(Homer1);
4947 personal_data_->AddProfile(Homer2); 4947 personal_data_->AddProfile(Homer2);
4948 personal_data_->AddProfile(Homer3); 4948 personal_data_->AddProfile(Homer3);
4949 personal_data_->AddProfile(Homer4); 4949 personal_data_->AddProfile(Homer4);
4950 personal_data_->AddProfile(Marge1); 4950 personal_data_->AddProfile(Marge1);
4951 personal_data_->AddProfile(Marge2); 4951 personal_data_->AddProfile(Marge2);
4952 personal_data_->AddProfile(Barney); 4952 personal_data_->AddProfile(Barney);
4953 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 4953 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
4954 .WillOnce(QuitMainMessageLoop()); 4954 .WillOnce(QuitMainMessageLoop());
4955 base::MessageLoop::current()->Run(); 4955 base::RunLoop().Run();
4956 4956
4957 // Make sure the 7 profiles were saved; 4957 // Make sure the 7 profiles were saved;
4958 EXPECT_EQ(7U, personal_data_->GetProfiles().size()); 4958 EXPECT_EQ(7U, personal_data_->GetProfiles().size());
4959 4959
4960 // Enable the profile cleanup now. Otherwise it would be triggered by the 4960 // Enable the profile cleanup now. Otherwise it would be triggered by the
4961 // calls to AddProfile. 4961 // calls to AddProfile.
4962 EnableAutofillProfileCleanup(); 4962 EnableAutofillProfileCleanup();
4963 4963
4964 base::HistogramTester histogram_tester; 4964 base::HistogramTester histogram_tester;
4965 4965
4966 // |Homer1| should get merged into |Homer2| which should then be merged into 4966 // |Homer1| should get merged into |Homer2| which should then be merged into
4967 // |Homer3|. |Marge2| should be discarded in favor of |Marge1| which is 4967 // |Homer3|. |Marge2| should be discarded in favor of |Marge1| which is
4968 // verified. |Homer4| and |Barney| should not be deduped at all. 4968 // verified. |Homer4| and |Barney| should not be deduped at all.
4969 personal_data_->ApplyDedupingRoutine(); 4969 personal_data_->ApplyDedupingRoutine();
4970 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 4970 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
4971 .WillOnce(QuitMainMessageLoop()); 4971 .WillOnce(QuitMainMessageLoop());
4972 base::MessageLoop::current()->Run(); 4972 base::RunLoop().Run();
4973 4973
4974 // Get the profiles, sorted by frecency to have a deterministic order. 4974 // Get the profiles, sorted by frecency to have a deterministic order.
4975 std::vector<AutofillProfile*> profiles = 4975 std::vector<AutofillProfile*> profiles =
4976 personal_data_->GetProfilesToSuggest(); 4976 personal_data_->GetProfilesToSuggest();
4977 4977
4978 // The 2 duplicates Homer home profiles with the higher frecency and the 4978 // The 2 duplicates Homer home profiles with the higher frecency and the
4979 // unverified Marge profile should have been deduped. 4979 // unverified Marge profile should have been deduped.
4980 ASSERT_EQ(4U, profiles.size()); 4980 ASSERT_EQ(4U, profiles.size());
4981 // 7 profiles were considered for dedupe. 4981 // 7 profiles were considered for dedupe.
4982 histogram_tester.ExpectUniqueSample( 4982 histogram_tester.ExpectUniqueSample(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5035 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com"); 5035 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com");
5036 test::SetProfileInfo(&profile2, "Homer", "J", "Simpson", 5036 test::SetProfileInfo(&profile2, "Homer", "J", "Simpson",
5037 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.", 5037 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.",
5038 "", "Springfield", "IL", "91601", "", ""); 5038 "", "Springfield", "IL", "91601", "", "");
5039 5039
5040 personal_data_->AddProfile(profile1); 5040 personal_data_->AddProfile(profile1);
5041 personal_data_->AddProfile(profile2); 5041 personal_data_->AddProfile(profile2);
5042 5042
5043 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 5043 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
5044 .WillOnce(QuitMainMessageLoop()); 5044 .WillOnce(QuitMainMessageLoop());
5045 base::MessageLoop::current()->Run(); 5045 base::RunLoop().Run();
5046 5046
5047 // Make sure both profiles were saved. 5047 // Make sure both profiles were saved.
5048 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); 5048 EXPECT_EQ(2U, personal_data_->GetProfiles().size());
5049 5049
5050 // The deduping routine should not be run. 5050 // The deduping routine should not be run.
5051 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); 5051 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine());
5052 5052
5053 // Both profiles should still be present. 5053 // Both profiles should still be present.
5054 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); 5054 EXPECT_EQ(2U, personal_data_->GetProfiles().size());
5055 } 5055 }
(...skipping 10 matching lines...) Expand all
5066 // Create a similar profile. 5066 // Create a similar profile.
5067 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com"); 5067 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com");
5068 test::SetProfileInfo(&profile2, "Homer", "J", "Simpson", 5068 test::SetProfileInfo(&profile2, "Homer", "J", "Simpson",
5069 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.", 5069 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.",
5070 "", "Springfield", "IL", "91601", "", ""); 5070 "", "Springfield", "IL", "91601", "", "");
5071 5071
5072 personal_data_->AddProfile(profile1); 5072 personal_data_->AddProfile(profile1);
5073 personal_data_->AddProfile(profile2); 5073 personal_data_->AddProfile(profile2);
5074 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 5074 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
5075 .WillOnce(QuitMainMessageLoop()); 5075 .WillOnce(QuitMainMessageLoop());
5076 base::MessageLoop::current()->Run(); 5076 base::RunLoop().Run();
5077 5077
5078 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); 5078 EXPECT_EQ(2U, personal_data_->GetProfiles().size());
5079 5079
5080 // Enable the profile cleanup now. Otherwise it would be triggered by the 5080 // Enable the profile cleanup now. Otherwise it would be triggered by the
5081 // calls to AddProfile. 5081 // calls to AddProfile.
5082 EnableAutofillProfileCleanup(); 5082 EnableAutofillProfileCleanup();
5083 5083
5084 // The deduping routine should be run a first time. 5084 // The deduping routine should be run a first time.
5085 EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); 5085 EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
5086 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 5086 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
5087 .WillOnce(QuitMainMessageLoop()); 5087 .WillOnce(QuitMainMessageLoop());
5088 base::MessageLoop::current()->Run(); 5088 base::RunLoop().Run();
5089 5089
5090 std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles(); 5090 std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles();
5091 5091
5092 // The profiles should have been deduped 5092 // The profiles should have been deduped
5093 EXPECT_EQ(1U, profiles.size()); 5093 EXPECT_EQ(1U, profiles.size());
5094 5094
5095 // Add another duplicate profile. 5095 // Add another duplicate profile.
5096 AutofillProfile profile3(base::GenerateGUID(), "https://www.example.com"); 5096 AutofillProfile profile3(base::GenerateGUID(), "https://www.example.com");
5097 test::SetProfileInfo(&profile3, "Homer", "J", "Simpson", 5097 test::SetProfileInfo(&profile3, "Homer", "J", "Simpson",
5098 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.", 5098 "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace.",
5099 "", "Springfield", "IL", "91601", "", ""); 5099 "", "Springfield", "IL", "91601", "", "");
5100 5100
5101 // Disable the profile cleanup before adding |profile3|. 5101 // Disable the profile cleanup before adding |profile3|.
5102 base::FeatureList::ClearInstanceForTesting(); 5102 base::FeatureList::ClearInstanceForTesting();
5103 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 5103 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
5104 base::FeatureList::SetInstance(std::move(feature_list)); 5104 base::FeatureList::SetInstance(std::move(feature_list));
5105 5105
5106 personal_data_->AddProfile(profile3); 5106 personal_data_->AddProfile(profile3);
5107 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 5107 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
5108 .WillOnce(QuitMainMessageLoop()); 5108 .WillOnce(QuitMainMessageLoop());
5109 base::MessageLoop::current()->Run(); 5109 base::RunLoop().Run();
5110 5110
5111 // Make sure |profile3| was saved. 5111 // Make sure |profile3| was saved.
5112 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); 5112 EXPECT_EQ(2U, personal_data_->GetProfiles().size());
5113 5113
5114 // Re-enable the profile cleanup now that the profile was added. 5114 // Re-enable the profile cleanup now that the profile was added.
5115 EnableAutofillProfileCleanup(); 5115 EnableAutofillProfileCleanup();
5116 5116
5117 // The deduping routine should not be run. 5117 // The deduping routine should not be run.
5118 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine()); 5118 EXPECT_FALSE(personal_data_->ApplyDedupingRoutine());
5119 5119
5120 // The two duplicate profiles should still be present. 5120 // The two duplicate profiles should still be present.
5121 EXPECT_EQ(2U, personal_data_->GetProfiles().size()); 5121 EXPECT_EQ(2U, personal_data_->GetProfiles().size());
5122 } 5122 }
5123 5123
5124 } // namespace autofill 5124 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/server/chromedriver_server.cc ('k') | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698