Chromium Code Reviews| Index: chrome/browser/safe_browsing/incident_reporting_service_unittest.cc |
| diff --git a/chrome/browser/safe_browsing/incident_reporting_service_unittest.cc b/chrome/browser/safe_browsing/incident_reporting_service_unittest.cc |
| index 40dd948937885663ff6a2bc2cbb7ecc27fd57340..836c979c8bc2a5e2ef85c3d2bb5b9fd3f5fc621f 100644 |
| --- a/chrome/browser/safe_browsing/incident_reporting_service_unittest.cc |
| +++ b/chrome/browser/safe_browsing/incident_reporting_service_unittest.cc |
| @@ -138,7 +138,8 @@ class IncidentReportingServiceTest : public testing::Test { |
| return incident.Pass(); |
| } |
| - // Confirms that the test incident was uploaded by the service. |
| + // Confirms that the test incident was uploaded by the service, then clears |
| + // the instance for subsequent incidents. |
| void ExpectTestIncidentUploaded() { |
| ASSERT_TRUE(uploaded_report_); |
| ASSERT_EQ(1, uploaded_report_->incident_size()); |
| @@ -150,6 +151,8 @@ class IncidentReportingServiceTest : public testing::Test { |
| ASSERT_TRUE(uploaded_report_->environment().os().has_os_name()); |
| ASSERT_EQ(std::string(kFakeOsName), |
| uploaded_report_->environment().os().os_name()); |
| + |
| + uploaded_report_.reset(); |
| } |
| void ExpectNoUpload() { ASSERT_FALSE(uploaded_report_); } |
| @@ -274,6 +277,26 @@ TEST_F(IncidentReportingServiceTest, NoSafeBrowsing) { |
| ExpectNoUpload(); |
| } |
| +// Tests that an incident added after upload is not uploaded again. |
|
mattm
2014/06/19 21:43:11
Add a test of incident reported and uploaded for o
mattm
2014/06/19 21:43:11
Add a test of profile gets destroyed while upload
grt (UTC plus 2)
2014/06/20 03:24:10
Done (TwoProfilesTwoUploads).
grt (UTC plus 2)
2014/06/20 03:24:10
Done (ProfileDestroyedDuringUpload).
|
| +TEST_F(IncidentReportingServiceTest, OnlyOneUpload) { |
| + // Create the profile, thereby causing the test to begin. |
| + CreateProfileAndRunTest(true); |
| + |
| + // Verify that report upload took place and contained the incident and |
| + // environment data. |
| + ExpectTestIncidentUploaded(); |
| + |
| + // Add the incident to the service again. |
| + instance_->GetAddIncidentCallback(testing_profile_.get()) |
| + .Run(MakeTestIncident().Pass()); |
| + |
| + // Let all tasks run. |
| + task_runner_->RunUntilIdle(); |
| + |
| + // Verify that no additional report upload took place. |
| + ExpectNoUpload(); |
| +} |
| + |
| // Parallel uploads |
| // Shutdown during processing |
| // environment colection taking longer than incident delay timer |