diff --git a/components/autofill/core/browser/autofill_download_manager_unittest.cc b/components/autofill/core/browser/autofill_download_manager_unittest.cc index e72edf6232b84e..1a359d04b13bfd 100644 --- a/components/autofill/core/browser/autofill_download_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_download_manager_unittest.cc @@ -10,6 +10,7 @@ #include #include +#include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -363,7 +364,7 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Query) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(1100)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Get the retried request. fetcher = factory.GetFetcherByID(1); @@ -419,7 +420,7 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Upload) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(1100)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Check that it was a failure. EXPECT_EQ(AutofillDownloadManagerTest::REQUEST_UPLOAD_FAILED, diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc index 02e085b2752b17..d1122553bf70d7 100644 --- a/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/components/autofill/core/browser/personal_data_manager_unittest.cc @@ -19,6 +19,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/guid.h" #include "base/metrics/field_trial.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" #include "base/test/histogram_tester.h" @@ -179,7 +180,7 @@ class PersonalDataManagerTest : public testing::Test { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } void ResetProfiles() { @@ -213,7 +214,7 @@ class PersonalDataManagerTest : public testing::Test { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(1U, personal_data_->GetProfiles().size()); } @@ -283,7 +284,7 @@ class PersonalDataManagerTest : public testing::Test { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); } @@ -424,7 +425,7 @@ TEST_F(PersonalDataManagerTest, DontDuplicateServerProfile) { personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(1U, personal_data_->GetProfiles().size()); // Add profile with identical values. Duplicates should not get saved. @@ -440,7 +441,7 @@ TEST_F(PersonalDataManagerTest, DontDuplicateServerProfile) { personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Verify the non-addition. EXPECT_EQ(0U, personal_data_->web_profiles().size()); @@ -490,7 +491,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles; profiles.push_back(&profile0); @@ -506,7 +507,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); profiles.clear(); profiles.push_back(&profile0); @@ -542,7 +543,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector cards; cards.push_back(&credit_card0); @@ -558,7 +559,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); cards.clear(); cards.push_back(&credit_card0); @@ -620,7 +621,7 @@ TEST_F(PersonalDataManagerTest, UpdateUnverifiedProfilesAndCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& profiles1 = personal_data_->GetProfiles(); @@ -664,7 +665,7 @@ TEST_F(PersonalDataManagerTest, UpdateUnverifiedProfilesAndCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& profiles3 = personal_data_->GetProfiles(); @@ -698,7 +699,7 @@ TEST_F(PersonalDataManagerTest, RefuseToStoreFullCard) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(1U, personal_data_->GetCreditCards().size()); EXPECT_EQ(CreditCard::MASKED_SERVER_CARD, @@ -739,7 +740,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCards) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); @@ -765,7 +766,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCards) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); for (size_t i = 0; i < 3; ++i) EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); @@ -779,7 +780,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCards) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); for (size_t i = 0; i < 3; ++i) EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); @@ -813,7 +814,7 @@ TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles; profiles.push_back(&profile0); @@ -827,7 +828,7 @@ TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector cards; cards.push_back(&credit_card0); @@ -857,7 +858,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Verify that we've loaded the profiles from the web database. const std::vector& results2 = personal_data_->GetProfiles(); @@ -873,7 +874,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Make sure the two profiles have different GUIDs, both valid. const std::vector& results3 = personal_data_->GetProfiles(); @@ -979,7 +980,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles; profiles.push_back(&profile0); @@ -999,7 +1000,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); profiles.clear(); profiles.push_back(&profile0); @@ -1024,7 +1025,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results = personal_data_->GetProfiles(); ASSERT_EQ(1U, results.size()); @@ -1061,7 +1062,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1289,7 +1290,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1333,7 +1334,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MultilineAddress) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1374,7 +1375,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1412,7 +1413,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected2(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected2, "John", NULL, @@ -1473,7 +1474,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, "Washington", @@ -1551,7 +1552,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, "Washington", @@ -1635,7 +1636,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Only two are saved. AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); @@ -1690,7 +1691,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_SameProfileWithConflict) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", nullptr, "Washington", @@ -1738,7 +1739,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_SameProfileWithConflict) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results2 = personal_data_->GetProfiles(); @@ -1775,7 +1776,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MissingInfoInOld) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1813,7 +1814,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MissingInfoInOld) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results2 = personal_data_->GetProfiles(); @@ -1857,7 +1858,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MissingInfoInNew) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1896,7 +1897,7 @@ TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MissingInfoInNew) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results2 = personal_data_->GetProfiles(); @@ -1959,7 +1960,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Simulate a form submission with conflicting info. FormData form; @@ -1990,7 +1991,7 @@ TEST_F(PersonalDataManagerTest, // Wait for the refresh, which in this case is a no-op. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that no new profile is saved. const std::vector& results = personal_data_->GetProfiles(); @@ -2011,7 +2012,7 @@ TEST_F(PersonalDataManagerTest, // Wait for the refresh, which in this case is a no-op. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that no new profile is saved. const std::vector& results2 = personal_data_->GetProfiles(); @@ -2038,7 +2039,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_Valid) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", @@ -2098,7 +2099,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_MonthSelectInvalidText) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // See that the invalid option text was converted to the right value. CreditCard expected(base::GenerateGUID(), "https://www.example.com"); @@ -2125,7 +2126,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_TwoValidCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", @@ -2148,7 +2149,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_TwoValidCards) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected2, "", "5500000000000004", "02", "3999"); @@ -2187,7 +2188,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } // Tests that a credit card is not extracted because it matches a full server @@ -2230,7 +2231,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_SameCreditCardWithConflict) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, @@ -2254,7 +2255,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_SameCreditCardWithConflict) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that the newer information is saved. In this case the year is // updated to "3999". @@ -2282,7 +2283,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_ShouldReturnLocalCard) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, @@ -2309,7 +2310,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_ShouldReturnLocalCard) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that the newer information is saved. In this case the year is // updated to "3999". @@ -2337,7 +2338,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_EmptyCardWithConflict) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, @@ -2387,7 +2388,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_MissingInfoInNew) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, @@ -2457,7 +2458,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_MissingInfoInOld) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results1 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results1.size()); @@ -2478,7 +2479,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_MissingInfoInOld) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that the newer information is saved. In this case the year is // added to the existing credit card. @@ -2503,7 +2504,7 @@ TEST_F(PersonalDataManagerTest, ImportCreditCard_SameCardWithSeparators) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results1 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results1.size()); @@ -2546,7 +2547,7 @@ TEST_F(PersonalDataManagerTest, // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Simulate a form submission with conflicting expiration year. FormData form; @@ -2611,7 +2612,7 @@ TEST_F(PersonalDataManagerTest, ImportFormData_OneAddressOneCreditCard) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Test that the address has been saved. AutofillProfile expected_address(base::GenerateGUID(), @@ -2690,7 +2691,7 @@ TEST_F(PersonalDataManagerTest, ImportFormData_TwoAddressesOneCreditCard) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Test that both addresses have been saved. EXPECT_EQ(2U, personal_data_->GetProfiles().size()); @@ -2721,7 +2722,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithVerifiedData) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); AutofillProfile new_verified_profile = profile; new_verified_profile.set_guid(base::GenerateGUID()); @@ -2735,7 +2736,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithVerifiedData) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // The new profile should be merged into the existing one. const std::vector& results = personal_data_->GetProfiles(); @@ -2757,7 +2758,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CreditCard new_verified_card = credit_card; new_verified_card.set_guid(base::GenerateGUID()); @@ -2769,7 +2770,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Expect that the saved credit card is updated. const std::vector& results = personal_data_->GetCreditCards(); @@ -2796,7 +2797,7 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(15U, non_empty_types.size()); @@ -2835,7 +2836,7 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(19U, non_empty_types.size()); @@ -2869,7 +2870,7 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(29U, non_empty_types.size()); @@ -2990,7 +2991,7 @@ TEST_F(PersonalDataManagerTest, DefaultCountryCodeIsCached) { personal_data_->AddProfile(moose); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // The value is cached and doesn't change even after adding an address. EXPECT_EQ(default_country, personal_data_->GetDefaultCountryCodeForNewAddress()); @@ -3074,14 +3075,14 @@ TEST_F(PersonalDataManagerTest, UpdateLanguageCodeInProfile) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); profile.set_language_code("en"); personal_data_->UpdateProfile(profile); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); const std::vector& results = personal_data_->GetProfiles(); ASSERT_EQ(1U, results.size()); @@ -3296,7 +3297,7 @@ TEST_F(PersonalDataManagerTest, personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector suggestions = personal_data_->GetCreditCardSuggestions(AutofillType(CREDIT_CARD_NUMBER), @@ -3357,7 +3358,7 @@ TEST_F(PersonalDataManagerTest, personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector suggestions = personal_data_->GetCreditCardSuggestions( @@ -3405,7 +3406,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ExpiredCards) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); @@ -3446,7 +3447,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_NumberMissing) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(2U, personal_data_->GetCreditCards().size()); @@ -3506,7 +3507,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ServerDuplicates) { personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector suggestions = personal_data_->GetCreditCardSuggestions( @@ -3553,7 +3554,7 @@ TEST_F(PersonalDataManagerTest, personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector suggestions = personal_data_->GetCreditCardSuggestions( @@ -3570,7 +3571,7 @@ TEST_F(PersonalDataManagerTest, EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), @@ -3721,7 +3722,7 @@ TEST_F(PersonalDataManagerTest, RecordUseOf) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Notify the PDM that the profile and credit card were used. AutofillProfile* added_profile = @@ -3744,7 +3745,7 @@ TEST_F(PersonalDataManagerTest, RecordUseOf) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Verify usage stats are updated. added_profile = personal_data_->GetProfileByGUID(profile.guid()); @@ -3783,7 +3784,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCardUsageStats) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); @@ -3809,7 +3810,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCardUsageStats) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); for (size_t i = 0; i < 3; ++i) @@ -3832,7 +3833,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCardUsageStats) { personal_data_->RecordUseOf(server_cards.back()); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards()[0]->use_count()); @@ -3851,7 +3852,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCardUsageStats) { personal_data_->RecordUseOf(server_cards[1]); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards()[1]->use_count()); EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[1]->use_date()); @@ -3866,7 +3867,7 @@ TEST_F(PersonalDataManagerTest, UpdateServerCreditCardUsageStats) { personal_data_->RecordUseOf(server_cards[1]); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(3U, personal_data_->GetCreditCards()[1]->use_count()); EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[1]->use_date()); @@ -3924,7 +3925,7 @@ TEST_F(PersonalDataManagerTest, DontDuplicateServerCard) { personal_data_->Refresh(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // A valid credit card form. A user re-enters one of their masked cards. // We shouldn't offer to save. It's possible this is actually a different card @@ -4480,7 +4481,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MergedProfileValues) { personal_data_->AddProfile(profile3); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Make sure the 3 profiles were saved; EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -4494,7 +4495,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MergedProfileValues) { personal_data_->ApplyDedupingRoutine(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles = personal_data_->GetProfiles(); @@ -4573,7 +4574,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileFirst) { personal_data_->AddProfile(profile3); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -4587,7 +4588,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileFirst) { personal_data_->ApplyDedupingRoutine(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles = personal_data_->GetProfiles(); @@ -4645,7 +4646,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileLast) { personal_data_->AddProfile(profile3); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -4659,7 +4660,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileLast) { personal_data_->ApplyDedupingRoutine(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); std::vector profiles = personal_data_->GetProfiles(); @@ -4716,7 +4717,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleVerifiedProfiles) { personal_data_->AddProfile(profile3); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -4730,7 +4731,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleVerifiedProfiles) { personal_data_->ApplyDedupingRoutine(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Get the profiles, sorted by frecency to have a deterministic order. std::vector profiles = @@ -4792,7 +4793,7 @@ TEST_F(PersonalDataManagerTest, ApplyProfileUseDatesFix) { personal_data_->AddProfile(profile2); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Get a sorted list of profiles. |profile1| will be first and |profile2| will // be second. @@ -4813,7 +4814,7 @@ TEST_F(PersonalDataManagerTest, ApplyProfileUseDatesFix) { personal_data_->ApplyProfileUseDatesFix(); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Get a sorted list of profiles. saved_profiles = personal_data_->GetProfilesToSuggest(); @@ -4854,7 +4855,7 @@ TEST_F(PersonalDataManagerTest, ApplyProfileUseDatesFix_NotAppliedTwice) { EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // Get a sorted list of profiles. |profile1| will be first and |profile2| will // be second. diff --git a/components/autofill/core/browser/webdata/web_data_service_unittest.cc b/components/autofill/core/browser/webdata/web_data_service_unittest.cc index bfcafe166bc97d..ff255507e941ee 100644 --- a/components/autofill/core/browser/webdata/web_data_service_unittest.cc +++ b/components/autofill/core/browser/webdata/web_data_service_unittest.cc @@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string16.h" @@ -122,7 +123,7 @@ class WebDataServiceTest : public testing::Test { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); db_thread_.Stop(); } @@ -226,7 +227,7 @@ TEST_F(WebDataServiceAutofillTest, FormFillAdd) { name1_, base::string16(), limit, &consumer); // The message loop will exit when the consumer is called. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(1U, consumer.result().size()); @@ -303,7 +304,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileAdd) { // Check that it was added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(1U, consumer.result().size()); EXPECT_EQ(profile, *consumer.result()[0]); @@ -322,7 +323,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemove) { // Check that it was added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(1U, consumer.result().size()); EXPECT_EQ(profile, *consumer.result()[0]); @@ -341,7 +342,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemove) { // Check that it was removed. AutofillWebDataServiceConsumer > consumer2; WebDataServiceBase::Handle handle2 = wds_->GetAutofillProfiles(&consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, consumer2.handle()); ASSERT_EQ(0U, consumer2.result().size()); } @@ -366,7 +367,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { // Check that they were added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(2U, consumer.result().size()); EXPECT_EQ(profile2, *consumer.result()[0]); @@ -388,7 +389,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { // Check that the updates were made. AutofillWebDataServiceConsumer > consumer2; WebDataServiceBase::Handle handle2 = wds_->GetAutofillProfiles(&consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, consumer2.handle()); ASSERT_EQ(2U, consumer2.result().size()); EXPECT_EQ(profile2_changed, *consumer2.result()[0]); @@ -405,7 +406,7 @@ TEST_F(WebDataServiceAutofillTest, CreditAdd) { // Check that it was added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(1U, consumer.result().size()); EXPECT_EQ(card, *consumer.result()[0]); @@ -422,7 +423,7 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) { // Check that it was added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(1U, consumer.result().size()); EXPECT_EQ(credit_card, *consumer.result()[0]); @@ -435,7 +436,7 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) { // Check that it was removed. AutofillWebDataServiceConsumer > consumer2; WebDataServiceBase::Handle handle2 = wds_->GetCreditCards(&consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, consumer2.handle()); ASSERT_EQ(0U, consumer2.result().size()); } @@ -455,7 +456,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) { // Check that they got added. AutofillWebDataServiceConsumer > consumer; WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, consumer.handle()); ASSERT_EQ(2U, consumer.result().size()); EXPECT_EQ(card2, *consumer.result()[0]); @@ -471,7 +472,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) { // Check that the updates were made. AutofillWebDataServiceConsumer > consumer2; WebDataServiceBase::Handle handle2 = wds_->GetCreditCards(&consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, consumer2.handle()); ASSERT_EQ(2U, consumer2.result().size()); EXPECT_NE(card2, *consumer2.result()[0]); @@ -493,7 +494,7 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) { profile_consumer; WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&profile_consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, profile_consumer.handle()); ASSERT_EQ(1U, profile_consumer.result().size()); EXPECT_EQ(profile, *profile_consumer.result()[0]); @@ -507,7 +508,7 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) { // Check that it was added. AutofillWebDataServiceConsumer > card_consumer; handle = wds_->GetCreditCards(&card_consumer); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle, card_consumer.handle()); ASSERT_EQ(1U, card_consumer.result().size()); EXPECT_EQ(credit_card, *card_consumer.result()[0]); @@ -529,14 +530,14 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) { profile_consumer2; WebDataServiceBase::Handle handle2 = wds_->GetAutofillProfiles(&profile_consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, profile_consumer2.handle()); ASSERT_EQ(0U, profile_consumer2.result().size()); // Check that the credit card was removed. AutofillWebDataServiceConsumer > card_consumer2; handle2 = wds_->GetCreditCards(&card_consumer2); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(handle2, card_consumer2.handle()); ASSERT_EQ(0U, card_consumer2.result().size()); } diff --git a/components/bookmarks/browser/bookmark_expanded_state_tracker_unittest.cc b/components/bookmarks/browser/bookmark_expanded_state_tracker_unittest.cc index 2e343695b7d8cf..9890f27af0f588 100644 --- a/components/bookmarks/browser/bookmark_expanded_state_tracker_unittest.cc +++ b/components/bookmarks/browser/bookmark_expanded_state_tracker_unittest.cc @@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "components/bookmarks/browser/bookmark_model.h" @@ -54,7 +55,7 @@ void BookmarkExpandedStateTrackerTest::SetUp() { void BookmarkExpandedStateTrackerTest::TearDown() { model_.reset(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } // Various assertions for SetExpandedNodes. diff --git a/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc b/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc index 8e6245c283524b..a3d3bb256aec74 100644 --- a/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc +++ b/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "components/bookmarks/browser/bookmark_model.h" @@ -45,7 +46,7 @@ class ManagedBookmarksTrackerTest : public testing::Test { void TearDown() override { if (model_) model_->RemoveObserver(&observer_); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void CreateModel(bool is_supervised) { diff --git a/components/browser_sync/browser/profile_sync_service_typed_url_unittest.cc b/components/browser_sync/browser/profile_sync_service_typed_url_unittest.cc index a7aee5266b6a06..e77507b297a4a0 100644 --- a/components/browser_sync/browser/profile_sync_service_typed_url_unittest.cc +++ b/components/browser_sync/browser/profile_sync_service_typed_url_unittest.cc @@ -17,6 +17,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" +#include "base/run_loop.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread.h" @@ -305,7 +306,7 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest { FROM_HERE, task, base::Bind(&base::MessageLoop::QuitNow, base::Unretained(base::MessageLoop::current()))); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } void SendNotificationURLVisited(ui::PageTransition transition, diff --git a/components/devtools_http_handler/devtools_http_handler.cc b/components/devtools_http_handler/devtools_http_handler.cc index 89325284a9fd94..6d2f94cf03c1fc 100644 --- a/components/devtools_http_handler/devtools_http_handler.cc +++ b/components/devtools_http_handler/devtools_http_handler.cc @@ -178,11 +178,11 @@ void TerminateOnUI(base::Thread* thread, DCHECK_CURRENTLY_ON(BrowserThread::UI); if (server_wrapper) { DCHECK(thread); - thread->message_loop()->DeleteSoon(FROM_HERE, server_wrapper); + thread->task_runner()->DeleteSoon(FROM_HERE, server_wrapper); } if (socket_factory) { DCHECK(thread); - thread->message_loop()->DeleteSoon(FROM_HERE, socket_factory); + thread->task_runner()->DeleteSoon(FROM_HERE, socket_factory); } if (thread) { BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, thread); diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc index c29fd9e7a9a4e7..04963fb099de5f 100644 --- a/components/history/core/browser/history_backend.cc +++ b/components/history/core/browser/history_backend.cc @@ -20,6 +20,7 @@ #include "base/metrics/histogram_macros.h" #include "base/rand_util.h" #include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" @@ -227,7 +228,8 @@ HistoryBackend::~HistoryBackend() { if (!backend_destroy_task_.is_null()) { // Notify an interested party (typically a unit test) that we're done. DCHECK(backend_destroy_message_loop_); - backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_); + backend_destroy_message_loop_->task_runner()->PostTask( + FROM_HERE, backend_destroy_task_); } #if defined(OS_ANDROID) diff --git a/components/history/core/browser/history_querying_unittest.cc b/components/history/core/browser/history_querying_unittest.cc index b3bfbfbc63935a..b192f197975827 100644 --- a/components/history/core/browser/history_querying_unittest.cc +++ b/components/history/core/browser/history_querying_unittest.cc @@ -11,6 +11,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/task/cancelable_task_tracker.h" #include "components/history/core/browser/history_database_params.h" @@ -85,7 +86,7 @@ class HistoryQueryTest : public testing::Test { base::Unretained(this)), &tracker_); // Will go until ...Complete calls Quit. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); results->Swap(&last_query_results_); } @@ -185,7 +186,7 @@ class HistoryQueryTest : public testing::Test { base::MessageLoop::QuitWhenIdleClosure()); history_->Cleanup(); history_.reset(); - base::MessageLoop::current()->Run(); // Wait for the other thread. + base::RunLoop().Run(); // Wait for the other thread. } } diff --git a/components/history/core/browser/history_service.cc b/components/history/core/browser/history_service.cc index 6ed1bfda31fb1c..c7f0e7fb79faa9 100644 --- a/components/history/core/browser/history_service.cc +++ b/components/history/core/browser/history_service.cc @@ -848,7 +848,7 @@ void HistoryService::Cleanup() { closing_task.Reset(); HistoryBackend* raw_ptr = history_backend_.get(); history_backend_ = nullptr; - thread_->message_loop()->ReleaseSoon(FROM_HERE, raw_ptr); + thread_->task_runner()->ReleaseSoon(FROM_HERE, raw_ptr); } // Delete the thread, which joins with the background thread. We defensively diff --git a/components/history/core/browser/history_service_unittest.cc b/components/history/core/browser/history_service_unittest.cc index cdb6eb1d34a5e9..2f9b5ddc3a7275 100644 --- a/components/history/core/browser/history_service_unittest.cc +++ b/components/history/core/browser/history_service_unittest.cc @@ -26,6 +26,7 @@ #include "base/location.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" @@ -83,7 +84,7 @@ class HistoryServiceTest : public testing::Test { // test. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } void CleanupHistoryService() { @@ -99,7 +100,7 @@ class HistoryServiceTest : public testing::Test { // moving to the next test. Note: if this never terminates, somebody is // probably leaking a reference to the history backend, so it never calls // our destroy task. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } // Fills the query_url_row_ and query_url_visits_ structures with the @@ -111,7 +112,7 @@ class HistoryServiceTest : public testing::Test { true, base::Bind(&HistoryServiceTest::SaveURLAndQuit, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); // Will be exited in SaveURLAndQuit. + base::RunLoop().Run(); // Will be exited in SaveURLAndQuit. return query_url_success_; } @@ -138,7 +139,7 @@ class HistoryServiceTest : public testing::Test { base::Bind(&HistoryServiceTest::OnRedirectQueryComplete, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); // Will be exited in *QueryComplete. + base::RunLoop().Run(); // Will be exited in *QueryComplete. } // Callback for QueryRedirects. @@ -465,7 +466,7 @@ TEST_F(HistoryServiceTest, MostVisitedURLs) { base::Bind(&HistoryServiceTest::OnMostVisitedURLsAvailable, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(2U, most_visited_urls_.size()); EXPECT_EQ(url0, most_visited_urls_[0].url); @@ -482,7 +483,7 @@ TEST_F(HistoryServiceTest, MostVisitedURLs) { base::Bind(&HistoryServiceTest::OnMostVisitedURLsAvailable, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(3U, most_visited_urls_.size()); EXPECT_EQ(url0, most_visited_urls_[0].url); @@ -500,7 +501,7 @@ TEST_F(HistoryServiceTest, MostVisitedURLs) { base::Bind(&HistoryServiceTest::OnMostVisitedURLsAvailable, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(3U, most_visited_urls_.size()); EXPECT_EQ(url2, most_visited_urls_[0].url); @@ -518,7 +519,7 @@ TEST_F(HistoryServiceTest, MostVisitedURLs) { base::Bind(&HistoryServiceTest::OnMostVisitedURLsAvailable, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(3U, most_visited_urls_.size()); EXPECT_EQ(url1, most_visited_urls_[0].url); @@ -541,7 +542,7 @@ TEST_F(HistoryServiceTest, MostVisitedURLs) { base::Bind(&HistoryServiceTest::OnMostVisitedURLsAvailable, base::Unretained(this)), &tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_EQ(4U, most_visited_urls_.size()); EXPECT_EQ(url1, most_visited_urls_[0].url); @@ -600,7 +601,7 @@ TEST_F(HistoryServiceTest, HistoryDBTask) { // Run the message loop. When HistoryDBTaskImpl::DoneRunOnMainThread runs, // it will stop the message loop. If the test hangs here, it means // DoneRunOnMainThread isn't being invoked correctly. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); CleanupHistoryService(); // WARNING: history has now been deleted. history_service_.reset(); @@ -758,7 +759,7 @@ TEST_F(HistoryServiceTest, ProcessGlobalIdDeleteDirective) { base::Bind(&CheckDirectiveProcessingResult, base::Time::Now() + base::TimeDelta::FromSeconds(10), &change_processor, 2)); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(QueryURL(history_service_.get(), test_url)); ASSERT_EQ(5, query_url_row_.visit_count()); EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(1), @@ -842,7 +843,7 @@ TEST_F(HistoryServiceTest, ProcessTimeRangeDeleteDirective) { base::Bind(&CheckDirectiveProcessingResult, base::Time::Now() + base::TimeDelta::FromSeconds(10), &change_processor, 2)); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(QueryURL(history_service_.get(), test_url)); ASSERT_EQ(3, query_url_row_.visit_count()); EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(1), diff --git a/components/history/core/browser/top_sites_impl_unittest.cc b/components/history/core/browser/top_sites_impl_unittest.cc index 59819a074c266a..dc0715d493605a 100644 --- a/components/history/core/browser/top_sites_impl_unittest.cc +++ b/components/history/core/browser/top_sites_impl_unittest.cc @@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/task/cancelable_task_tracker.h" #include "build/build_config.h" @@ -91,7 +92,7 @@ class TopSitesQuerier { include_forced_urls); if (wait && start_number_of_callbacks == number_of_callbacks_) { waiting_ = true; - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } } @@ -179,7 +180,7 @@ class TopSitesImplTest : public HistoryUnitTestBase { history_service()->ScheduleDBTask( std::unique_ptr(new WaitForHistoryTask()), &history_tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } // Waits for top sites to finish processing a task. This is useful if you need @@ -188,7 +189,7 @@ class TopSitesImplTest : public HistoryUnitTestBase { top_sites()->backend_->DoEmptyRequest( base::Bind(&TopSitesImplTest::QuitCallback, base::Unretained(this)), &top_sites_tracker_); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } TopSitesImpl* top_sites() { return top_sites_impl_.get(); } @@ -325,7 +326,7 @@ class TopSitesImplTest : public HistoryUnitTestBase { top_sites_impl_ = nullptr; if (base::MessageLoop::current()) - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } } diff --git a/components/history/core/test/history_backend_db_base_test.cc b/components/history/core/test/history_backend_db_base_test.cc index 1b85745a29a103..9950fc76135744 100644 --- a/components/history/core/test/history_backend_db_base_test.cc +++ b/components/history/core/test/history_backend_db_base_test.cc @@ -6,6 +6,7 @@ #include "base/files/file_path.h" #include "base/location.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_task_runner_handle.h" @@ -80,7 +81,7 @@ void HistoryBackendDBBaseTest::TearDown() { // test. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } void HistoryBackendDBBaseTest::CreateBackendAndDatabase() { diff --git a/components/invalidation/impl/invalidation_notifier_unittest.cc b/components/invalidation/impl/invalidation_notifier_unittest.cc index 62ae4773dcba33..c2d4d1bef58f18 100644 --- a/components/invalidation/impl/invalidation_notifier_unittest.cc +++ b/components/invalidation/impl/invalidation_notifier_unittest.cc @@ -7,6 +7,7 @@ #include #include +#include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "components/invalidation/impl/fake_invalidation_handler.h" #include "components/invalidation/impl/fake_invalidation_state_tracker.h" @@ -57,13 +58,11 @@ class InvalidationNotifierTestDelegate { // another task, so they must be run in order to avoid leaking the inner // task. Stopping does not schedule any tasks, so it's both necessary and // sufficient to drain the task queue before stopping the notifier. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); invalidator_.reset(); } - void WaitForInvalidator() { - message_loop_.RunUntilIdle(); - } + void WaitForInvalidator() { base::RunLoop().RunUntilIdle(); } void TriggerOnInvalidatorStateChange(InvalidatorState state) { invalidator_->OnInvalidatorStateChange(state); diff --git a/components/invalidation/impl/non_blocking_invalidator_unittest.cc b/components/invalidation/impl/non_blocking_invalidator_unittest.cc index ea42c4aa352ea0..2aa6d6fadf73e2 100644 --- a/components/invalidation/impl/non_blocking_invalidator_unittest.cc +++ b/components/invalidation/impl/non_blocking_invalidator_unittest.cc @@ -63,7 +63,7 @@ class NonBlockingInvalidatorTestDelegate { invalidator_.reset(); request_context_getter_ = NULL; io_thread_.Stop(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void WaitForInvalidator() { diff --git a/components/invalidation/impl/sync_invalidation_listener_unittest.cc b/components/invalidation/impl/sync_invalidation_listener_unittest.cc index f1b03f7debffbc..3380bf7bc177d4 100644 --- a/components/invalidation/impl/sync_invalidation_listener_unittest.cc +++ b/components/invalidation/impl/sync_invalidation_listener_unittest.cc @@ -13,6 +13,7 @@ #include "base/compiler_specific.h" #include "base/memory/ptr_util.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/threading/thread_task_runner_handle.h" @@ -426,9 +427,7 @@ class SyncInvalidationListenerTest : public testing::Test { FlushPendingWrites(); } - void FlushPendingWrites() { - message_loop_.RunUntilIdle(); - } + void FlushPendingWrites() { base::RunLoop().RunUntilIdle(); } void EnableNotifications() { fake_push_client_->EnableNotifications(); diff --git a/components/invalidation/impl/sync_system_resources_unittest.cc b/components/invalidation/impl/sync_system_resources_unittest.cc index f6f240a2ed2bc8..76446c6c4b71d2 100644 --- a/components/invalidation/impl/sync_system_resources_unittest.cc +++ b/components/invalidation/impl/sync_system_resources_unittest.cc @@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "components/invalidation/impl/push_client_channel.h" #include "components/invalidation/impl/state_writer.h" #include "google/cacheinvalidation/include/types.h" @@ -135,7 +136,7 @@ TEST_F(SyncSystemResourcesTest, ScheduleImmediately) { EXPECT_CALL(mock_closure, Run()); sync_system_resources_.internal_scheduler()->Schedule( invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(SyncSystemResourcesTest, ScheduleOnListenerThread) { @@ -146,7 +147,7 @@ TEST_F(SyncSystemResourcesTest, ScheduleOnListenerThread) { invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); EXPECT_TRUE( sync_system_resources_.internal_scheduler()->IsRunningOnThread()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(SyncSystemResourcesTest, ScheduleWithZeroDelay) { @@ -155,7 +156,7 @@ TEST_F(SyncSystemResourcesTest, ScheduleWithZeroDelay) { EXPECT_CALL(mock_closure, Run()); sync_system_resources_.internal_scheduler()->Schedule( invalidation::TimeDelta::FromSeconds(0), mock_closure.CreateClosure()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } // TODO(akalin): Figure out how to test with a non-zero delay. @@ -171,7 +172,7 @@ TEST_F(SyncSystemResourcesTest, WriteState) { .WillOnce(SaveArg<0>(&results)); sync_system_resources_.storage()->WriteKey( std::string(), "state", mock_storage_callback.CreateCallback()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()), results); } diff --git a/components/nacl/loader/nacl_ipc_adapter_unittest.cc b/components/nacl/loader/nacl_ipc_adapter_unittest.cc index afd37389ca95d8..b89eb353dadaec 100644 --- a/components/nacl/loader/nacl_ipc_adapter_unittest.cc +++ b/components/nacl/loader/nacl_ipc_adapter_unittest.cc @@ -10,6 +10,7 @@ #include +#include "base/run_loop.h" #include "base/threading/platform_thread.h" #include "base/threading/simple_thread.h" #include "base/threading/thread_task_runner_handle.h" @@ -41,7 +42,7 @@ class NaClIPCAdapterTest : public testing::Test { // The adapter destructor has to post a task to destroy the Channel on the // IO thread. For the purposes of the test, we just need to make sure that // task gets run, or it will appear as a leak. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } protected: @@ -132,7 +133,7 @@ TEST_F(NaClIPCAdapterTest, SendRewriting) { // Check that the message came out the other end in the test sink // (messages are posted, so we have to pump). - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(1u, sink_->message_count()); const IPC::Message* msg = sink_->GetMessageAt(0); @@ -148,14 +149,14 @@ TEST_F(NaClIPCAdapterTest, SendRewriting) { EXPECT_EQ(first_chunk_size, result); // First partial send should not have made any messages. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0u, sink_->message_count()); // Second partial send should do the same. int second_chunk_size = 2; result = Send(&buf[first_chunk_size], second_chunk_size); EXPECT_EQ(second_chunk_size, result); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0u, sink_->message_count()); // Send the rest of the message in a third chunk. @@ -165,7 +166,7 @@ TEST_F(NaClIPCAdapterTest, SendRewriting) { EXPECT_EQ(third_chunk_size, result); // Last send should have generated one message. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(1u, sink_->message_count()); msg = sink_->GetMessageAt(0); EXPECT_EQ(sizeof(int), msg->payload_size()); @@ -248,7 +249,7 @@ TEST_F(NaClIPCAdapterTest, SendOverflow) { // Send too much data and make sure that the send fails. int result = Send(buf, big_buf_size); EXPECT_EQ(-1, result); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0u, sink_->message_count()); // Send too much data in two chunks and make sure that the send fails. @@ -257,13 +258,13 @@ TEST_F(NaClIPCAdapterTest, SendOverflow) { EXPECT_EQ(first_chunk_size, result); // First partial send should not have made any messages. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0u, sink_->message_count()); int second_chunk_size = big_buf_size - first_chunk_size; result = Send(&buf[first_chunk_size], second_chunk_size); EXPECT_EQ(-1, result); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0u, sink_->message_count()); } diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc index 2dfc2bbfdd6379..146b855f2e10ab 100644 --- a/components/nacl/loader/nacl_listener.cc +++ b/components/nacl/loader/nacl_listener.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/run_loop.h" #include "components/nacl/loader/nacl_listener.h" #include @@ -231,7 +232,7 @@ void NaClListener::Listen() { global->RegisterBrokerCommunicationChannel(channel_.get()); channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); main_loop_ = base::MessageLoop::current(); - main_loop_->Run(); + base::RunLoop().Run(); } bool NaClListener::OnMessageReceived(const IPC::Message& msg) { diff --git a/components/network_time/network_time_tracker.cc b/components/network_time/network_time_tracker.cc index 0e54d0e2465c3d..dc4ccbb56d3f49 100644 --- a/components/network_time/network_time_tracker.cc +++ b/components/network_time/network_time_tracker.cc @@ -14,6 +14,7 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/rand_util.h" +#include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/time/tick_clock.h" @@ -291,7 +292,7 @@ bool NetworkTimeTracker::QueryTimeServiceForTesting() { void NetworkTimeTracker::WaitForFetchForTesting(uint32_t nonce) { query_signer_->OverrideNonceForTesting(kKeyVersion, nonce); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } base::TimeDelta NetworkTimeTracker::GetTimerDelayForTesting() const { diff --git a/components/omnibox/browser/autocomplete_provider_unittest.cc b/components/omnibox/browser/autocomplete_provider_unittest.cc index a7de8a31a18720..a8e80a4dbbedad 100644 --- a/components/omnibox/browser/autocomplete_provider_unittest.cc +++ b/components/omnibox/browser/autocomplete_provider_unittest.cc @@ -14,6 +14,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" @@ -497,7 +498,7 @@ void AutocompleteProviderTest::RunQuery(const std::string& query, if (!controller_->done()) // The message loop will terminate when all autocomplete input has been // collected. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } void AutocompleteProviderTest::RunExactKeymatchTest( diff --git a/components/omnibox/browser/history_quick_provider_unittest.cc b/components/omnibox/browser/history_quick_provider_unittest.cc index 0a7dd7b725b64f..816f298d0d1352 100644 --- a/components/omnibox/browser/history_quick_provider_unittest.cc +++ b/components/omnibox/browser/history_quick_provider_unittest.cc @@ -17,6 +17,7 @@ #include "base/format_macros.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/sequenced_worker_pool_owner.h" @@ -323,7 +324,7 @@ void HistoryQuickProviderTest::TearDown() { // History index rebuild task is created from main thread during SetUp, // performed on DB thread and must be deleted on main thread. // Run main loop to process delete task, to prevent leaks. - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void HistoryQuickProviderTest::GetTestData(size_t* data_count, @@ -412,7 +413,7 @@ void HistoryQuickProviderTest::RunTestWithCursor( base::string16 expected_fill_into_edit, base::string16 expected_autocompletion) { SCOPED_TRACE(text); // Minimal hint to query being run. - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); AutocompleteInput input(text, cursor_position, std::string(), GURL(), metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, false, true, true, false, @@ -472,7 +473,7 @@ bool HistoryQuickProviderTest::GetURLProxy(const GURL& url) { &task_tracker); // Run the message loop until GetURLTask::DoneRunOnMainThread stops it. If // the test hangs, DoneRunOnMainThread isn't being invoked correctly. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); return result; } diff --git a/components/omnibox/browser/history_url_provider_unittest.cc b/components/omnibox/browser/history_url_provider_unittest.cc index 64c8232350e65d..c8b5a85b5a36e7 100644 --- a/components/omnibox/browser/history_url_provider_unittest.cc +++ b/components/omnibox/browser/history_url_provider_unittest.cc @@ -13,6 +13,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" @@ -328,7 +329,7 @@ void HistoryURLProviderTest::RunTest( *identified_input_type = input.type(); autocomplete_->Start(input, false); if (!autocomplete_->done()) - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); matches_ = autocomplete_->matches(); if (sort_matches_) { @@ -665,7 +666,7 @@ TEST_F(HistoryURLProviderTest, EmptyVisits) { int pandora_relevance = matches_[0].relevance; // Run the message loop. When |autocomplete_| finishes the loop is quit. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_TRUE(autocomplete_->done()); matches_ = autocomplete_->matches(); ASSERT_GT(matches_.size(), 0u); @@ -698,7 +699,7 @@ TEST_F(HistoryURLProviderTest, DontAutocompleteOnTrailingWhitespace) { TestSchemeClassifier()); autocomplete_->Start(input, false); if (!autocomplete_->done()) - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); // None of the matches should attempt to autocomplete. matches_ = autocomplete_->matches(); @@ -837,7 +838,7 @@ TEST_F(HistoryURLProviderTest, CrashDueToFixup) { true, false, TestSchemeClassifier()); autocomplete_->Start(input, false); if (!autocomplete_->done()) - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } } diff --git a/components/omnibox/browser/shortcuts_backend_unittest.cc b/components/omnibox/browser/shortcuts_backend_unittest.cc index abbd3dd4ea8359..ae35dd4ac9b55e 100644 --- a/components/omnibox/browser/shortcuts_backend_unittest.cc +++ b/components/omnibox/browser/shortcuts_backend_unittest.cc @@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread.h" @@ -145,7 +146,7 @@ void ShortcutsBackendTest::InitBackend() { ASSERT_FALSE(load_notified_); ASSERT_FALSE(backend_->initialized()); backend_->Init(); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_TRUE(load_notified_); EXPECT_TRUE(backend_->initialized()); } diff --git a/components/omnibox/browser/shortcuts_provider_unittest.cc b/components/omnibox/browser/shortcuts_provider_unittest.cc index 3c11e208d3f785..368aaa024ac8d2 100644 --- a/components/omnibox/browser/shortcuts_provider_unittest.cc +++ b/components/omnibox/browser/shortcuts_provider_unittest.cc @@ -18,6 +18,7 @@ #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/sequenced_worker_pool_owner.h" @@ -287,7 +288,7 @@ void ShortcutsProviderTest::SetUp() { void ShortcutsProviderTest::TearDown() { // Run all pending tasks or else some threads hold on to the message loop // and prevent it from being deleted. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); provider_ = NULL; } diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc index e6aace74e6b3e1..c2b44a4b05c3f2 100644 --- a/components/password_manager/core/browser/password_store_unittest.cc +++ b/components/password_manager/core/browser/password_store_unittest.cc @@ -391,7 +391,7 @@ TEST_F(PasswordStoreTest, RemoveLoginsCreatedBetweenCallbackIsCalled) { store->RemoveLoginsCreatedBetween( base::Time::FromDoubleT(0), base::Time::FromDoubleT(2), base::MessageLoop::current()->QuitWhenIdleClosure()); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); testing::Mock::VerifyAndClearExpectations(&mock_observer); store->RemoveObserver(&mock_observer); diff --git a/components/policy/core/common/async_policy_provider_unittest.cc b/components/policy/core/common/async_policy_provider_unittest.cc index 24d577b5772eda..aaf5e9c24d899e 100644 --- a/components/policy/core/common/async_policy_provider_unittest.cc +++ b/components/policy/core/common/async_policy_provider_unittest.cc @@ -9,6 +9,7 @@ #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/sequenced_task_runner.h" #include "base/values.h" #include "components/policy/core/common/async_policy_loader.h" @@ -111,7 +112,7 @@ void AsyncPolicyProviderTest::SetUp() { // Verify that the initial load is done synchronously: EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(loader_); EXPECT_CALL(*loader_, LastModificationTime()) @@ -123,7 +124,7 @@ void AsyncPolicyProviderTest::TearDown() { provider_->Shutdown(); provider_.reset(); } - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(AsyncPolicyProviderTest, RefreshPolicies) { @@ -135,7 +136,7 @@ TEST_F(AsyncPolicyProviderTest, RefreshPolicies) { provider_->AddObserver(&observer); EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1); provider_->RefreshPolicies(); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // The refreshed policies are now provided. EXPECT_TRUE(provider_->policies().Equals(refreshed_bundle)); provider_->RemoveObserver(&observer); @@ -159,7 +160,7 @@ TEST_F(AsyncPolicyProviderTest, RefreshPoliciesTwice) { Mock::VerifyAndClearExpectations(&observer); EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // The refreshed policies are now provided. EXPECT_TRUE(provider_->policies().Equals(refreshed_bundle)); Mock::VerifyAndClearExpectations(&observer); @@ -195,7 +196,7 @@ TEST_F(AsyncPolicyProviderTest, RefreshPoliciesDuringReload) { Mock::VerifyAndClearExpectations(&observer); EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // The refreshed policies are now provided, and the |reloaded_bundle| was // dropped. EXPECT_TRUE(provider_->policies().Equals(refreshed_bundle)); @@ -217,7 +218,7 @@ TEST_F(AsyncPolicyProviderTest, Shutdown) { EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); provider_->Shutdown(); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); provider_->RemoveObserver(&observer); diff --git a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc index 52b45fd210195f..6c0bebddc26a3c 100644 --- a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc +++ b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc @@ -12,6 +12,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/test/test_simple_task_runner.h" #include "build/build_config.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" @@ -67,7 +68,7 @@ class CloudPolicyRefreshSchedulerTest : public testing::Test { void NotifyIPAddressChanged() { net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } base::TimeDelta GetLastDelay() const { diff --git a/components/precache/core/fetcher_pool_unittest.cc b/components/precache/core/fetcher_pool_unittest.cc index a15388ed91ff01..09296a17d7a73a 100644 --- a/components/precache/core/fetcher_pool_unittest.cc +++ b/components/precache/core/fetcher_pool_unittest.cc @@ -13,6 +13,7 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "net/http/http_status_code.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_fetcher_delegate.h" @@ -62,7 +63,7 @@ TEST(FetcherPoolTest, AddDelete) { EXPECT_FALSE(pool.IsEmpty()); EXPECT_CALL(delegate, OnURLFetchComplete(url_fetcher_ptr)); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); pool.Delete(*url_fetcher_ptr); EXPECT_TRUE(pool.IsEmpty()); @@ -86,7 +87,7 @@ TEST(FetcherPoolTest, Delete) { EXPECT_TRUE(pool.IsEmpty()); EXPECT_CALL(delegate, OnURLFetchComplete(_)).Times(0); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST(FetcherPoolTest, ParallelURLFetchers) { @@ -116,7 +117,7 @@ TEST(FetcherPoolTest, ParallelURLFetchers) { pool.Delete(*fetcher); })); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(pool.IsEmpty()); EXPECT_TRUE(pool.IsAvailable()); @@ -139,7 +140,7 @@ TEST(FetcherPoolTest, DeleteAll) { pool.DeleteAll(); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(pool.IsEmpty()); EXPECT_TRUE(pool.IsAvailable()); @@ -208,7 +209,7 @@ TEST(FetcherPoolTest, ExampleUsage) { EXPECT_FALSE(pool.IsEmpty()); EXPECT_FALSE(pool.IsAvailable()); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(pool.IsEmpty()); EXPECT_TRUE(pool.IsAvailable()); diff --git a/components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc b/components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc index 6db88f8acc7a29..382f6346060167 100644 --- a/components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc +++ b/components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc @@ -9,6 +9,7 @@ #include "base/files/file_path.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" @@ -88,12 +89,12 @@ class PrefProxyConfigTrackerImplTest : public testing::Test { // SetProxyConfigServiceImpl triggers update of initial prefs proxy // config by tracker to chrome proxy config service, so flush all pending // tasks so that tests start fresh. - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } ~PrefProxyConfigTrackerImplTest() override { proxy_config_tracker_->DetachFromPrefService(); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); proxy_config_tracker_.reset(); proxy_config_service_.reset(); } @@ -119,7 +120,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, DynamicPrefOverrides) { pref_service_->SetManagedPref(proxy_config::prefs::kProxy, ProxyConfigDictionary::CreateFixedServers( "http://example.com:3128", std::string())); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); net::ProxyConfig actual_config; EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, @@ -133,7 +134,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, DynamicPrefOverrides) { pref_service_->SetManagedPref(proxy_config::prefs::kProxy, ProxyConfigDictionary::CreateAutoDetect()); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, proxy_config_service_->GetLatestProxyConfig(&actual_config)); @@ -159,7 +160,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Observers) { EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config2), CONFIG_VALID)).Times(1); delegate_service_->SetProxyConfig(config2, CONFIG_VALID); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); // Override configuration, this should trigger a notification. @@ -171,7 +172,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Observers) { pref_service_->SetManagedPref( proxy_config::prefs::kProxy, ProxyConfigDictionary::CreatePacScript(kFixedPacUrl, false)); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); // Since there are pref overrides, delegate changes should be ignored. @@ -180,14 +181,14 @@ TEST_F(PrefProxyConfigTrackerImplTest, Observers) { EXPECT_CALL(observer, OnProxyConfigChanged(_, _)).Times(0); fixed_config_.set_auto_detect(true); delegate_service_->SetProxyConfig(config3, CONFIG_VALID); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); // Clear the override should switch back to the fixed configuration. EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config3), CONFIG_VALID)).Times(1); pref_service_->RemoveManagedPref(proxy_config::prefs::kProxy); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); // Delegate service notifications should show up again. @@ -196,7 +197,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Observers) { EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config4), CONFIG_VALID)).Times(1); delegate_service_->SetProxyConfig(config4, CONFIG_VALID); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); proxy_config_service_->RemoveObserver(&observer); @@ -222,7 +223,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Fallback) { CONFIG_VALID)).Times(1); pref_service_->SetRecommendedPref(proxy_config::prefs::kProxy, ProxyConfigDictionary::CreateAutoDetect()); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); EXPECT_EQ(CONFIG_VALID, proxy_config_service_->GetLatestProxyConfig(&actual_config)); @@ -235,7 +236,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Fallback) { pref_service_->SetManagedPref( proxy_config::prefs::kProxy, ProxyConfigDictionary::CreatePacScript(kFixedPacUrl, false)); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); EXPECT_EQ(CONFIG_VALID, proxy_config_service_->GetLatestProxyConfig(&actual_config)); @@ -246,7 +247,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, Fallback) { OnProxyConfigChanged(ProxyConfigMatches(recommended_config), CONFIG_VALID)).Times(1); pref_service_->RemoveManagedPref(proxy_config::prefs::kProxy); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&observer); EXPECT_EQ(CONFIG_VALID, proxy_config_service_->GetLatestProxyConfig(&actual_config)); @@ -260,7 +261,7 @@ TEST_F(PrefProxyConfigTrackerImplTest, ExplicitSystemSettings) { ProxyConfigDictionary::CreateAutoDetect()); pref_service_->SetUserPref(proxy_config::prefs::kProxy, ProxyConfigDictionary::CreateSystem()); - loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // Test if we actually use the system setting, which is |kFixedPacUrl|. net::ProxyConfig actual_config; diff --git a/components/scheduler/base/task_queue_manager_unittest.cc b/components/scheduler/base/task_queue_manager_unittest.cc index 588fd1e365010d..39baad3518dfd0 100644 --- a/components/scheduler/base/task_queue_manager_unittest.cc +++ b/components/scheduler/base/task_queue_manager_unittest.cc @@ -115,7 +115,7 @@ void PostFromNestedRunloop(base::MessageLoop* message_loop, runner->PostNonNestableTask(FROM_HERE, pair.first); } } - message_loop->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void NopTask() {} @@ -1352,7 +1352,7 @@ void PostTestTasksFromNestedMessageLoop( base::Bind(&TestTask, 1, run_order)); // The following should never get executed. wake_up_runner->PostTask(FROM_HERE, base::Bind(&TestTask, 2, run_order)); - message_loop->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(TaskQueueManagerTest, DeferredNonNestableTaskDoesNotTriggerWakeUp) { @@ -1814,7 +1814,7 @@ void RunloopCurrentlyExecutingTaskQueueTestTask( pair.second->PostTask(FROM_HERE, pair.first); } - message_loop->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); task_sources->push_back(task_queue_manager->currently_executing_task_queue()); } } diff --git a/components/scheduler/renderer/webthread_impl_for_renderer_scheduler_unittest.cc b/components/scheduler/renderer/webthread_impl_for_renderer_scheduler_unittest.cc index 103f50d513b1a9..1d29f244f2f98b 100644 --- a/components/scheduler/renderer/webthread_impl_for_renderer_scheduler_unittest.cc +++ b/components/scheduler/renderer/webthread_impl_for_renderer_scheduler_unittest.cc @@ -83,7 +83,7 @@ TEST_F(WebThreadImplForRendererSchedulerTest, TestTaskObserver) { thread_->getWebTaskRunner()->postTask(blink::WebTraceLocation(), task.release()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); thread_->removeTaskObserver(&observer); } @@ -102,7 +102,7 @@ TEST_F(WebThreadImplForRendererSchedulerTest, TestWorkBatchWithOneTask) { thread_->getWebTaskRunner()->postTask(blink::WebTraceLocation(), task.release()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); thread_->removeTaskObserver(&observer); } @@ -128,7 +128,7 @@ TEST_F(WebThreadImplForRendererSchedulerTest, TestWorkBatchWithTwoTasks) { task1.release()); thread_->getWebTaskRunner()->postTask(blink::WebTraceLocation(), task2.release()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); thread_->removeTaskObserver(&observer); } @@ -161,7 +161,7 @@ TEST_F(WebThreadImplForRendererSchedulerTest, TestWorkBatchWithThreeTasks) { task2.release()); thread_->getWebTaskRunner()->postTask(blink::WebTraceLocation(), task3.release()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); thread_->removeTaskObserver(&observer); } @@ -206,7 +206,7 @@ TEST_F(WebThreadImplForRendererSchedulerTest, TestNestedRunLoop) { message_loop_.task_runner()->PostTask( FROM_HERE, base::Bind(&EnterRunLoop, base::Unretained(&message_loop_), base::Unretained(thread_.get()))); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); thread_->removeTaskObserver(&observer); } diff --git a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc index 33e67e4d7a1d90..9e5f896f95662b 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc +++ b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc @@ -13,6 +13,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/test/histogram_tester.h" @@ -226,7 +227,7 @@ TEST_F(GaiaCookieManagerServiceTest, MergeSessionRetried) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(1100)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); SimulateMergeSessionSuccess(&helper, "token"); DCHECK(!helper.is_running()); } @@ -250,7 +251,7 @@ TEST_F(GaiaCookieManagerServiceTest, MergeSessionRetriedTwice) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(1100)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); SimulateMergeSessionFailure(&helper, canceled()); DCHECK(helper.is_running()); // Next transient error incurs a retry after 3 seconds. @@ -259,7 +260,7 @@ TEST_F(GaiaCookieManagerServiceTest, MergeSessionRetriedTwice) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(3100)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); SimulateMergeSessionSuccess(&helper, "token"); DCHECK(!helper.is_running()); histograms.ExpectUniqueSample("OAuth2Login.MergeSessionRetry", diff --git a/components/ssl_config/ssl_config_service_manager_pref_unittest.cc b/components/ssl_config/ssl_config_service_manager_pref_unittest.cc index 07aaef88f48dbe..b5303f28e722e4 100644 --- a/components/ssl_config/ssl_config_service_manager_pref_unittest.cc +++ b/components/ssl_config/ssl_config_service_manager_pref_unittest.cc @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "components/prefs/testing_pref_service.h" @@ -71,7 +72,7 @@ TEST_F(SSLConfigServiceManagerPrefTest, GoodDisabledCipherSuites) { // Pump the message loop to notify the SSLConfigServiceManagerPref that the // preferences changed. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); SSLConfig config; config_service->GetSSLConfig(&config); @@ -109,7 +110,7 @@ TEST_F(SSLConfigServiceManagerPrefTest, BadDisabledCipherSuites) { // Pump the message loop to notify the SSLConfigServiceManagerPref that the // preferences changed. - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); SSLConfig config; config_service->GetSSLConfig(&config); diff --git a/components/storage_monitor/media_storage_util_unittest.cc b/components/storage_monitor/media_storage_util_unittest.cc index 5d760931456e3f..a63126465f9b4f 100644 --- a/components/storage_monitor/media_storage_util_unittest.cc +++ b/components/storage_monitor/media_storage_util_unittest.cc @@ -79,7 +79,7 @@ class MediaStorageUtilTest : public testing::Test { BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(&PostQuitToUIThread)); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); } private: diff --git a/components/storage_monitor/storage_monitor_unittest.cc b/components/storage_monitor/storage_monitor_unittest.cc index 9c2e89c64e084e..ef56ffeb515aa4 100644 --- a/components/storage_monitor/storage_monitor_unittest.cc +++ b/components/storage_monitor/storage_monitor_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" #include "components/storage_monitor/mock_removable_storage_observer.h" @@ -47,7 +48,7 @@ TEST(StorageMonitorTest, DeviceAttachDetachNotifications) { StorageInfo info(kDeviceId1, FILE_PATH_LITERAL("path"), base::string16(), base::string16(), base::string16(), 0); monitor.receiver()->ProcessAttach(info); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(kDeviceId1, observer1.last_attached().device_id()); EXPECT_EQ(FILE_PATH_LITERAL("path"), observer1.last_attached().location()); @@ -58,7 +59,7 @@ TEST(StorageMonitorTest, DeviceAttachDetachNotifications) { monitor.receiver()->ProcessDetach(kDeviceId1); monitor.receiver()->ProcessDetach(kDeviceId2); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(kDeviceId1, observer1.last_detached().device_id()); EXPECT_EQ(FILE_PATH_LITERAL("path"), observer1.last_detached().location()); @@ -93,7 +94,7 @@ TEST(StorageMonitorTest, GetAllAvailableStorageAttachDetach) { StorageInfo info1(kDeviceId1, kDevicePath1.value(), base::string16(), base::string16(), base::string16(), 0); monitor.receiver()->ProcessAttach(info1); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); std::vector devices = monitor.GetAllAvailableStorages(); ASSERT_EQ(1U, devices.size()); EXPECT_EQ(kDeviceId1, devices[0].device_id()); @@ -104,7 +105,7 @@ TEST(StorageMonitorTest, GetAllAvailableStorageAttachDetach) { StorageInfo info2(kDeviceId2, kDevicePath2.value(), base::string16(), base::string16(), base::string16(), 0); monitor.receiver()->ProcessAttach(info2); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); devices = monitor.GetAllAvailableStorages(); ASSERT_EQ(2U, devices.size()); EXPECT_EQ(kDeviceId1, devices[0].device_id()); @@ -113,14 +114,14 @@ TEST(StorageMonitorTest, GetAllAvailableStorageAttachDetach) { EXPECT_EQ(kDevicePath2.value(), devices[1].location()); monitor.receiver()->ProcessDetach(kDeviceId1); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); devices = monitor.GetAllAvailableStorages(); ASSERT_EQ(1U, devices.size()); EXPECT_EQ(kDeviceId2, devices[0].device_id()); EXPECT_EQ(kDevicePath2.value(), devices[0].location()); monitor.receiver()->ProcessDetach(kDeviceId2); - message_loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); devices = monitor.GetAllAvailableStorages(); EXPECT_EQ(0U, devices.size()); } diff --git a/components/sync_driver/glue/browser_thread_model_worker_unittest.cc b/components/sync_driver/glue/browser_thread_model_worker_unittest.cc index 7ad4df15a82108..f7d66709284371 100644 --- a/components/sync_driver/glue/browser_thread_model_worker_unittest.cc +++ b/components/sync_driver/glue/browser_thread_model_worker_unittest.cc @@ -9,6 +9,7 @@ #include "base/location.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" #include "base/threading/thread.h" @@ -50,8 +51,8 @@ class SyncBrowserThreadModelWorkerTest : public testing::Test { syncer::SyncerError DoWork() { EXPECT_TRUE(db_thread_.task_runner()->BelongsToCurrentThread()); timer_.Stop(); // Stop the failure timer so the test succeeds. - main_message_loop_.PostTask(FROM_HERE, - base::MessageLoop::QuitWhenIdleClosure()); + main_message_loop_.task_runner()->PostTask( + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); did_do_work_ = true; return syncer::SYNCER_OK; } @@ -60,8 +61,8 @@ class SyncBrowserThreadModelWorkerTest : public testing::Test { // DoWork is called first. void Timeout() { ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; - main_message_loop_.PostTask(FROM_HERE, - base::MessageLoop::QuitWhenIdleClosure()); + main_message_loop_.task_runner()->PostTask( + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); } protected: @@ -90,7 +91,7 @@ TEST_F(SyncBrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, factory()->GetWeakPtr())); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); EXPECT_TRUE(did_do_work()); } diff --git a/components/sync_driver/glue/sync_backend_host_impl.cc b/components/sync_driver/glue/sync_backend_host_impl.cc index bbe94286550f93..7f75372a47fb54 100644 --- a/components/sync_driver/glue/sync_backend_host_impl.cc +++ b/components/sync_driver/glue/sync_backend_host_impl.cc @@ -495,8 +495,8 @@ void SyncBackendHostImpl::GetModelSafeRoutingInfo( void SyncBackendHostImpl::FlushDirectory() const { DCHECK(initialized()); - registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE, - base::Bind(&SyncBackendHostCore::SaveChanges, core_)); + registrar_->sync_thread()->task_runner()->PostTask( + FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); } void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { diff --git a/components/sync_driver/glue/sync_backend_registrar_unittest.cc b/components/sync_driver/glue/sync_backend_registrar_unittest.cc index e004543daa9730..89ddfc85b09d0c 100644 --- a/components/sync_driver/glue/sync_backend_registrar_unittest.cc +++ b/components/sync_driver/glue/sync_backend_registrar_unittest.cc @@ -120,7 +120,7 @@ class SyncBackendRegistrarTest : public testing::Test { FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown, base::Unretained(registrar_.release()))); sync_thread_->WaitUntilThreadStarted(); - sync_thread_->message_loop()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void ExpectRoutingInfo( @@ -455,7 +455,7 @@ TEST_F(SyncBackendRegistrarShutdownTest, BlockingShutdown) { // The test verifies that the sync thread doesn't block because // of the blocked DB thread and can finish the shutdown. - sync_thread->message_loop()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); db_thread_lock_.Release(); diff --git a/components/sync_driver/glue/ui_model_worker_unittest.cc b/components/sync_driver/glue/ui_model_worker_unittest.cc index b33594bf7142d5..821bb8eaa13b67 100644 --- a/components/sync_driver/glue/ui_model_worker_unittest.cc +++ b/components/sync_driver/glue/ui_model_worker_unittest.cc @@ -12,6 +12,7 @@ #include "base/location.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" @@ -95,6 +96,6 @@ TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { // We are on the UI thread, so run our loop to process the // (hopefully) scheduled task from a SyncShare invocation. - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); syncer_thread()->Stop(); } diff --git a/components/test_runner/mock_screen_orientation_client.cc b/components/test_runner/mock_screen_orientation_client.cc index 1839281e0be812..dd432329282d3f 100644 --- a/components/test_runner/mock_screen_orientation_client.cc +++ b/components/test_runner/mock_screen_orientation_client.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" namespace test_runner { @@ -115,19 +116,15 @@ bool MockScreenOrientationClient::IsOrientationAllowedByCurrentLock( void MockScreenOrientationClient::lockOrientation( blink::WebScreenOrientationLockType orientation, blink::WebLockOrientationCallback* callback) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockScreenOrientationClient::UpdateLockSync, - base::Unretained(this), - orientation, - callback)); + base::MessageLoop::current()->task_runner()->PostTask( + FROM_HERE, base::Bind(&MockScreenOrientationClient::UpdateLockSync, + base::Unretained(this), orientation, callback)); } void MockScreenOrientationClient::unlockOrientation() { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockScreenOrientationClient::ResetLockSync, - base::Unretained(this))); + base::MessageLoop::current()->task_runner()->PostTask( + FROM_HERE, base::Bind(&MockScreenOrientationClient::ResetLockSync, + base::Unretained(this))); } void MockScreenOrientationClient::UpdateLockSync( diff --git a/components/tracing/child/child_trace_message_filter_unittest.cc b/components/tracing/child/child_trace_message_filter_unittest.cc index e2bd3d810bfe46..8a7ccec7e4e911 100644 --- a/components/tracing/child/child_trace_message_filter_unittest.cc +++ b/components/tracing/child/child_trace_message_filter_unittest.cc @@ -8,6 +8,7 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "components/tracing/common/tracing_messages.h" #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" @@ -56,7 +57,7 @@ TEST_F(ChildTraceMessageFilterTest, TestHistogramDoesNotTrigger) { OnSetUMACallback("foo1", 20000, 25000, true); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_FALSE(fake_sender_.last_message_); } @@ -66,7 +67,7 @@ TEST_F(ChildTraceMessageFilterTest, TestHistogramTriggers) { OnSetUMACallback("foo2", 1, 3, true); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(fake_sender_.last_message_); EXPECT_EQ(fake_sender_.last_message_->type(), @@ -78,7 +79,7 @@ TEST_F(ChildTraceMessageFilterTest, TestHistogramAborts) { OnSetUMACallback("foo3", 1, 3, false); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(fake_sender_.last_message_); EXPECT_EQ(fake_sender_.last_message_->type(), diff --git a/components/wallpaper/wallpaper_resizer_unittest.cc b/components/wallpaper/wallpaper_resizer_unittest.cc index 062039da48bf98..7d4fefb6bf40cf 100644 --- a/components/wallpaper/wallpaper_resizer_unittest.cc +++ b/components/wallpaper/wallpaper_resizer_unittest.cc @@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/test/sequenced_worker_pool_owner.h" #include "components/wallpaper/wallpaper_resizer_observer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -81,7 +82,7 @@ class WallpaperResizerTest : public testing::Test, return worker_pool_owner_.pool().get(); } - void WaitForResize() { message_loop_.Run(); } + void WaitForResize() { base::RunLoop().Run(); } void OnWallpaperResized() override { message_loop_.QuitWhenIdle(); } diff --git a/components/wifi/wifi_test.cc b/components/wifi/wifi_test.cc index b2d1def87513e2..b6cb8fdaad73e6 100644 --- a/components/wifi/wifi_test.cc +++ b/components/wifi/wifi_test.cc @@ -204,7 +204,7 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { wifi_service_->StartConnect(network_guid, &error); VLOG(0) << error; if (error.empty()) - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); return true; } } @@ -234,7 +234,7 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); wifi_service_->RequestNetworkScan(); - base::MessageLoop::current()->Run(); + base::RunLoop().Run(); return true; }