| Index: chrome/browser/safe_browsing/incident_reporting/incident_reporting_service_unittest.cc
|
| diff --git a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service_unittest.cc
|
| index 5808b21586c7c0b827ba3f8efcf6d24ac23b713b..6cd36508ccb7783494b42747f0605bf71c0a88d0 100644
|
| --- a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service_unittest.cc
|
| +++ b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service_unittest.cc
|
| @@ -19,7 +19,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/test/mock_entropy_provider.h"
|
| -#include "base/test/test_simple_task_runner.h"
|
| +#include "base/test/test_mock_time_task_runner.h"
|
| #include "base/threading/thread_local.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "build/build_config.h"
|
| @@ -192,7 +192,7 @@ class IncidentReportingServiceTest : public testing::Test {
|
| static const char kFakeExtensionId[];
|
|
|
| IncidentReportingServiceTest()
|
| - : task_runner_(new base::TestSimpleTaskRunner),
|
| + : task_runner_(new base::TestMockTimeTaskRunner),
|
| thread_task_runner_handle_(task_runner_),
|
| profile_manager_(TestingBrowserProcess::GetGlobal()),
|
| on_create_download_finder_action_(
|
| @@ -215,6 +215,13 @@ class IncidentReportingServiceTest : public testing::Test {
|
| ASSERT_TRUE(profile_manager_.SetUp());
|
| }
|
|
|
| + // Fast-forwards virtual time by one hour, causing all tasks with a remaining
|
| + // delay less than or equal to one hour to be executed. Having a one-hour
|
| + // delay prevents the base::Timer in extensions::QuotaService from kicking in.
|
| + void RunTasksForNextHour() {
|
| + task_runner_->FastForwardBy(base::TimeDelta::FromHours(1));
|
| + }
|
| +
|
| void SetFieldTrialAndCreateService(bool enabled) {
|
| field_trial_list_.reset(
|
| new base::FieldTrialList(new base::MockEntropyProvider()));
|
| @@ -339,7 +346,7 @@ class IncidentReportingServiceTest : public testing::Test {
|
| bool UploaderDestroyed() const { return uploader_destroyed_; }
|
| bool DelayedAnalysisRan() const { return delayed_analysis_ran_; }
|
|
|
| - scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
|
| + scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
|
| base::ThreadTaskRunnerHandle thread_task_runner_handle_;
|
| TestingProfileManager profile_manager_;
|
| std::unique_ptr<TestIncidentReportingService> instance_;
|
| @@ -623,8 +630,8 @@ TEST_F(IncidentReportingServiceTest, AddIncident) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that environment and extension collection took place.
|
| EXPECT_TRUE(HasCollectedEnvironmentAndExtensionData());
|
| @@ -653,8 +660,8 @@ TEST_F(IncidentReportingServiceTest, CoalesceIncidents) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_TWO_INCIDENTS, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that environment and extension collection took place.
|
| EXPECT_TRUE(HasCollectedEnvironmentAndExtensionData());
|
| @@ -682,8 +689,8 @@ TEST_F(IncidentReportingServiceTest, NoSafeBrowsing) {
|
| CreateProfile("profile1", SAFE_BROWSING_OPT_OUT,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no report upload took place.
|
| AssertNoUpload();
|
| @@ -702,8 +709,8 @@ TEST_F(IncidentReportingServiceTest, SafeBrowsingFieldTrial) {
|
| CreateProfile("profile1", SAFE_BROWSING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that environment collection took place.
|
| EXPECT_TRUE(HasCollectedEnvironmentAndExtensionData());
|
| @@ -733,8 +740,8 @@ TEST_F(IncidentReportingServiceTest, SafeBrowsingNoFieldTrial) {
|
| CreateProfile("profile1", SAFE_BROWSING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Downloads and environment data should have not been collected
|
| // (DownloadFinder will be created, but should be a no-op since no eligible
|
| @@ -759,8 +766,8 @@ TEST_F(IncidentReportingServiceTest, ExtendedReportingNoFieldTrial) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that environment collection took place.
|
| EXPECT_TRUE(HasCollectedEnvironmentAndExtensionData());
|
| @@ -794,8 +801,8 @@ TEST_F(IncidentReportingServiceTest, NoUploadBeforeExtendedReporting) {
|
| // Add a process-wide test incident.
|
| receiver->AddIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Downloads and environment data should have not been collected
|
| // (DownloadFinder will be created, but should be a no-op since no eligible
|
| @@ -816,8 +823,8 @@ TEST_F(IncidentReportingServiceTest, NoUploadBeforeExtendedReporting) {
|
| instance_->GetIncidentReceiver()->AddIncidentForProfile(
|
| profile, MakeTestIncident("squids"));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that environment collection took place.
|
| EXPECT_TRUE(HasCollectedEnvironmentAndExtensionData());
|
| @@ -844,8 +851,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadNoUpload) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that the download finder was run but that no report upload took
|
| // place.
|
| @@ -868,8 +875,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadPrunedIncidentOneUpload) {
|
| Profile* profile = CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Assert that no report upload took place.
|
| AssertNoUpload();
|
| @@ -881,8 +888,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadPrunedIncidentOneUpload) {
|
| instance_->GetIncidentReceiver()->AddIncidentForProfile(
|
| profile, MakeTestIncident("leeches"));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that an additional report upload took place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -902,8 +909,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadPrunedSameIncidentNoUpload) {
|
| Profile* profile = CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Assert that no report upload took place.
|
| AssertNoUpload();
|
| @@ -914,8 +921,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadPrunedSameIncidentNoUpload) {
|
| // Add the incident to the service again.
|
| AddTestIncident(profile);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no additional report upload took place.
|
| AssertNoUpload();
|
| @@ -935,8 +942,8 @@ TEST_F(IncidentReportingServiceTest, NoProfilesNoUpload) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that the download finder was run but that no report upload took
|
| // place.
|
| @@ -957,8 +964,8 @@ TEST_F(IncidentReportingServiceTest, OneIncidentOneUpload) {
|
| Profile* profile = CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that report upload took place and contained the incident and
|
| // environment data.
|
| @@ -967,8 +974,8 @@ TEST_F(IncidentReportingServiceTest, OneIncidentOneUpload) {
|
| // Add the incident to the service again.
|
| AddTestIncident(profile);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no additional report upload took place.
|
| AssertNoUpload();
|
| @@ -985,8 +992,8 @@ TEST_F(IncidentReportingServiceTest, TwoIncidentsTwoUploads) {
|
| Profile* profile = CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that report upload took place and contained the incident and
|
| // environment data.
|
| @@ -996,8 +1003,8 @@ TEST_F(IncidentReportingServiceTest, TwoIncidentsTwoUploads) {
|
| instance_->GetIncidentReceiver()->AddIncidentForProfile(
|
| profile, MakeTestIncident("leeches"));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that an additional report upload took place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1014,8 +1021,8 @@ TEST_F(IncidentReportingServiceTest, TwoProfilesTwoUploads) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that report upload took place and contained the incident and
|
| // environment data.
|
| @@ -1025,8 +1032,8 @@ TEST_F(IncidentReportingServiceTest, TwoProfilesTwoUploads) {
|
| CreateProfile("profile2", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_ADD_INCIDENT, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that a second report upload took place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1047,8 +1054,8 @@ TEST_F(IncidentReportingServiceTest, ProfileDestroyedDuringUpload) {
|
| // to delete the profile. This task will run before the upload finishes.
|
| DeleteProfileOnUpload(profile);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that report upload took place and contained the incident and
|
| // environment data.
|
| @@ -1068,8 +1075,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideNoProfileNoUpload) {
|
| // Add the test incident.
|
| AddTestIncident(NULL);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // No upload should have taken place.
|
| AssertNoUpload();
|
| @@ -1089,8 +1096,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideOneUpload) {
|
| // Add the test incident.
|
| AddTestIncident(NULL);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // An upload should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1098,8 +1105,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideOneUpload) {
|
| // Add the incident to the service again.
|
| AddTestIncident(NULL);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no additional report upload took place.
|
| AssertNoUpload();
|
| @@ -1121,8 +1128,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideTwoUploads) {
|
| instance_->GetIncidentReceiver());
|
| receiver->AddIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // An upload should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1130,8 +1137,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideTwoUploads) {
|
| // Add a variation on the incident to the service.
|
| receiver->AddIncidentForProcess(MakeTestIncident("leeches"));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that an additional report upload took place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1147,8 +1154,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideNoUploadAfterProfile) {
|
| // Add the test incident.
|
| AddTestIncident(NULL);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no report upload took place.
|
| AssertNoUpload();
|
| @@ -1157,8 +1164,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideNoUploadAfterProfile) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // No upload should have taken place.
|
| AssertNoUpload();
|
| @@ -1172,8 +1179,8 @@ TEST_F(IncidentReportingServiceTest, NoCollectionWithoutIncident) {
|
| // Register a callback.
|
| RegisterAnalysis(ON_DELAYED_ANALYSIS_NO_ACTION);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Confirm that the callback was not run.
|
| ASSERT_FALSE(DelayedAnalysisRan());
|
| @@ -1185,8 +1192,8 @@ TEST_F(IncidentReportingServiceTest, NoCollectionWithoutIncident) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Confirm that the callback was run.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1205,8 +1212,8 @@ TEST_F(IncidentReportingServiceTest, AnalysisAfterProfile) {
|
| // Register a callback.
|
| RegisterAnalysis(ON_DELAYED_ANALYSIS_NO_ACTION);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Not run yet.
|
| ASSERT_FALSE(DelayedAnalysisRan());
|
| @@ -1215,8 +1222,8 @@ TEST_F(IncidentReportingServiceTest, AnalysisAfterProfile) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // And now they have.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1236,8 +1243,8 @@ TEST_F(IncidentReportingServiceTest, AnalysisWhenRegisteredWithProfile) {
|
| // Register a callback.
|
| RegisterAnalysis(ON_DELAYED_ANALYSIS_NO_ACTION);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Confirm that the callbacks were run.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1257,8 +1264,8 @@ TEST_F(IncidentReportingServiceTest, DelayedAnalysisNoProfileNoUpload) {
|
| CreateProfile("profile1", SAFE_BROWSING_OPT_OUT,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // The callback should not have been run.
|
| ASSERT_FALSE(DelayedAnalysisRan());
|
| @@ -1281,8 +1288,8 @@ TEST_F(IncidentReportingServiceTest, DelayedAnalysisOneUpload) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // The callback should have been run.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1293,8 +1300,8 @@ TEST_F(IncidentReportingServiceTest, DelayedAnalysisOneUpload) {
|
| // Add the incident to the service again.
|
| AddTestIncident(NULL);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that no additional report upload took place.
|
| AssertNoUpload();
|
| @@ -1319,8 +1326,8 @@ TEST_F(IncidentReportingServiceTest, NoDownloadNoWaiting) {
|
| // Add an incident.
|
| AddTestIncident(profile);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Verify that the download finder was run but that no report upload took
|
| // place.
|
| @@ -1346,8 +1353,8 @@ TEST_F(IncidentReportingServiceTest, NonBinaryDownloadStillUploads) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Confirm that the callbacks were run.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1372,8 +1379,8 @@ TEST_F(IncidentReportingServiceTest, UploadsWithBothDownloadTypes) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, nullptr);
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // Confirm that the callbacks were run.
|
| ASSERT_TRUE(DelayedAnalysisRan());
|
| @@ -1408,8 +1415,8 @@ TEST_F(IncidentReportingServiceTest, CleanLegacyPruneState) {
|
| CreateProfile("profile1", EXTENDED_REPORTING_OPT_IN,
|
| ON_PROFILE_ADDITION_NO_ACTION, std::move(incidents_sent));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| const base::DictionaryValue* new_state =
|
| profile->GetPrefs()->GetDictionary(prefs::kSafeBrowsingIncidentsSent);
|
| @@ -1433,8 +1440,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideUploadClearUpload) {
|
| // Add the test incident.
|
| receiver->AddIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // An upload should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1442,8 +1449,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideUploadClearUpload) {
|
| // Clear incident data.
|
| receiver->ClearIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // No uploads should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(0);
|
| @@ -1451,8 +1458,8 @@ TEST_F(IncidentReportingServiceTest, ProcessWideUploadClearUpload) {
|
| // Add the incident to the service again.
|
| receiver->AddIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // An upload should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(1);
|
| @@ -1473,8 +1480,8 @@ TEST_F(IncidentReportingServiceTest, ClearProcessIncidentOnCleanState) {
|
| // Clear incident data.
|
| receiver->ClearIncidentForProcess(MakeTestIncident(nullptr));
|
|
|
| - // Let all tasks run.
|
| - task_runner_->RunUntilIdle();
|
| + // Run tasks scheduled for the next hour.
|
| + RunTasksForNextHour();
|
|
|
| // No uploads should have taken place.
|
| ExpectTestIncidentUploadWithBinaryDownload(0);
|
|
|