Index: chrome/browser/safe_browsing/certificate_reporting_service_unittest.cc |
diff --git a/chrome/browser/safe_browsing/certificate_reporting_service_unittest.cc b/chrome/browser/safe_browsing/certificate_reporting_service_unittest.cc |
index d224a65a98b8b85b60cb5008a90503fc43e3a846..724edb52dd9a4a0ff9d368c7d8758276222edfad 100644 |
--- a/chrome/browser/safe_browsing/certificate_reporting_service_unittest.cc |
+++ b/chrome/browser/safe_browsing/certificate_reporting_service_unittest.cc |
@@ -36,7 +36,6 @@ |
using certificate_reporting_test_utils::CertificateReportingServiceTestHelper; |
using certificate_reporting_test_utils::CertificateReportingServiceObserver; |
-using certificate_reporting_test_utils::EventHistogramTester; |
using certificate_reporting_test_utils::ReportExpectation; |
using certificate_reporting_test_utils::RetryStatus; |
@@ -120,8 +119,6 @@ class ReportHistogramTestHelper { |
} // namespace |
TEST(CertificateReportingServiceReportListTest, BoundedReportList) { |
- EventHistogramTester event_histogram_tester; |
- |
// Create a report list with maximum of 2 items. |
CertificateReportingService::BoundedReportList list(2 /* max_size */); |
EXPECT_EQ(0u, list.items().size()); |
@@ -157,9 +154,6 @@ TEST(CertificateReportingServiceReportListTest, BoundedReportList) { |
EXPECT_EQ(2u, list.items().size()); |
EXPECT_EQ("report3_zero_minutes_old", list.items()[0].serialized_report); |
EXPECT_EQ("report2_five_minutes_old", list.items()[1].serialized_report); |
- |
- event_histogram_tester.SetExpectedValues(0 /* submitted */, 0 /* failed */, |
- 0 /* successful */, 2 /* dropped */); |
} |
class CertificateReportingServiceReporterOnIOThreadTest |
@@ -173,16 +167,13 @@ class CertificateReportingServiceReporterOnIOThreadTest |
new net::TestURLRequestContextGetter(message_loop_->task_runner()); |
net::URLRequestFailedJob::AddUrlHandler(); |
net::URLRequestMockDataJob::AddUrlHandler(); |
- |
- event_histogram_tester_.reset(new EventHistogramTester()); |
} |
void TearDown() override { |
ClearURLHandlers(); |
- // Check histograms as the last thing. This makes sure no in-flight report |
- // is missed. |
+ // Check the histogram as the last thing. This makes sure no in-flight |
+ // report is missed. |
histogram_test_helper_.CheckHistogram(); |
- event_histogram_tester_.reset(); |
} |
protected: |
@@ -194,21 +185,12 @@ class CertificateReportingServiceReporterOnIOThreadTest |
histogram_test_helper_.SetExpectedFailedReportCount(count); |
} |
- EventHistogramTester* event_histogram_tester() { |
- return event_histogram_tester_.get(); |
- } |
- |
private: |
std::unique_ptr<base::MessageLoopForIO> message_loop_; |
std::unique_ptr<content::TestBrowserThread> io_thread_; |
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
ReportHistogramTestHelper histogram_test_helper_; |
- // Histogram tester for reporting events. This is a member instead of a local |
- // so that we can check the histogram after the test teardown. At that point |
- // all in flight reports should be completed or deleted because |
- // of CleanUpOnIOThread(). |
- std::unique_ptr<EventHistogramTester> event_histogram_tester_; |
}; |
TEST_F(CertificateReportingServiceReporterOnIOThreadTest, |
@@ -298,12 +280,6 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest, |
EXPECT_EQ(1u, reporter.inflight_report_count_for_testing()); |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(0u, list->items().size()); |
- |
- // report1 was submitted once, failed once, dropped once. |
- // report2 was submitted twice, failed twice, dropped once. |
- // report3 was submitted four times, failed thrice, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 7 /* submitted */, 6 /* failed */, 1 /* successful */, 2 /* dropped */); |
} |
// Same as above, but retries are disabled. |
@@ -353,10 +329,6 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest, |
reporter.SendPending(); |
base::RunLoop().RunUntilIdle(); |
ASSERT_EQ(0u, list->items().size()); |
- |
- // report1 and report2 were both submitted once, failed once. |
- event_histogram_tester()->SetExpectedValues( |
- 2 /* submitted */, 2 /* failed */, 0 /* successful */, 0 /* dropped */); |
} |
class CertificateReportingServiceTest : public ::testing::Test { |
@@ -392,8 +364,6 @@ class CertificateReportingServiceTest : public ::testing::Test { |
base::Bind(&CertificateReportingServiceObserver::OnServiceReset, |
base::Unretained(&service_observer_)))); |
service_observer_.WaitForReset(); |
- |
- event_histogram_tester_.reset(new EventHistogramTester()); |
} |
void TearDown() override { |
@@ -413,7 +383,6 @@ class CertificateReportingServiceTest : public ::testing::Test { |
WaitForIOThread(); |
histogram_test_helper_.CheckHistogram(); |
- event_histogram_tester_.reset(); |
} |
protected: |
@@ -456,10 +425,6 @@ class CertificateReportingServiceTest : public ::testing::Test { |
CertificateReportingServiceTestHelper* test_helper() { return &test_helper_; } |
- EventHistogramTester* event_histogram_tester() { |
- return event_histogram_tester_.get(); |
- } |
- |
private: |
void SetUpURLRequestContextOnIOThread() { |
std::unique_ptr<net::TestURLRequestContext> url_request_context( |
@@ -488,8 +453,6 @@ class CertificateReportingServiceTest : public ::testing::Test { |
CertificateReportingServiceTestHelper test_helper_; |
ReportHistogramTestHelper histogram_test_helper_; |
CertificateReportingServiceObserver service_observer_; |
- |
- std::unique_ptr<EventHistogramTester> event_histogram_tester_; |
}; |
TEST_F(CertificateReportingServiceTest, SendSuccessful) { |
@@ -504,10 +467,6 @@ TEST_F(CertificateReportingServiceTest, SendSuccessful) { |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Successful({{"report0", RetryStatus::NOT_RETRIED}, |
{"report1", RetryStatus::NOT_RETRIED}})); |
- |
- // report0 and report1 were both submitted once, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 2 /* submitted */, 0 /* failed */, 2 /* successful */, 0 /* dropped */); |
} |
TEST_F(CertificateReportingServiceTest, SendFailure) { |
@@ -543,11 +502,6 @@ TEST_F(CertificateReportingServiceTest, SendFailure) { |
service()->SendPending(); |
test_helper()->WaitForRequestsDestroyed(ReportExpectation::Successful( |
{{"report0", RetryStatus::RETRIED}, {"report1", RetryStatus::RETRIED}})); |
- |
- // report0 and report1 were both submitted thrice, failed twice, succeeded |
- // once. report2 was submitted once, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 7 /* submitted */, 4 /* failed */, 3 /* successful */, 0 /* dropped */); |
} |
TEST_F(CertificateReportingServiceTest, Disabled_ShouldNotSend) { |
@@ -570,10 +524,6 @@ TEST_F(CertificateReportingServiceTest, Disabled_ShouldNotSend) { |
service()->Send(MakeReport("report1")); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Successful({{"report1", RetryStatus::NOT_RETRIED}})); |
- |
- // report0 was never sent. report1 was submitted once, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 1 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
TEST_F(CertificateReportingServiceTest, Disabled_ShouldClearPendingReports) { |
@@ -599,10 +549,6 @@ TEST_F(CertificateReportingServiceTest, Disabled_ShouldClearPendingReports) { |
// Sending with empty queue has no effect. |
service()->SendPending(); |
- |
- // report0 was submitted once, failed once. |
- event_histogram_tester()->SetExpectedValues( |
- 1 /* submitted */, 1 /* failed */, 0 /* successful */, 0 /* dropped */); |
} |
TEST_F(CertificateReportingServiceTest, DontSendOldReports) { |
@@ -650,13 +596,6 @@ TEST_F(CertificateReportingServiceTest, DontSendOldReports) { |
// Send pending reports. report2 should be discarded since it's too old. No |
// other reports remain. |
service()->SendPending(); |
- |
- // report0 was submitted once, failed once, dropped once. |
- // report1 was submitted twice, failed twice, dropped once. |
- // report2 was submitted twice, failed twice, dropped once. |
- // Need to wait for SendPending() to complete. |
- event_histogram_tester()->SetExpectedValues( |
- 5 /* submitted */, 5 /* failed */, 0 /* successful */, 3 /* dropped */); |
} |
TEST_F(CertificateReportingServiceTest, DiscardOldReports) { |
@@ -715,13 +654,6 @@ TEST_F(CertificateReportingServiceTest, DiscardOldReports) { |
// Do a final send. No reports should be sent. |
service()->SendPending(); |
- |
- // report0 was submitted once, failed once, dropped once. |
- // report1 was submitted twice, failed twice, dropped once. |
- // report2 was submitted thrice, failed twice, succeeded once. |
- // report3 was submitted thrice, failed twice, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 9 /* submitted */, 7 /* failed */, 2 /* successful */, 2 /* dropped */); |
} |
// A delayed report should successfully upload when it's resumed. |
@@ -740,10 +672,6 @@ TEST_F(CertificateReportingServiceTest, Delayed_Resumed) { |
test_helper()->ResumeDelayedRequest(); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}})); |
- |
- // report0 was submitted once, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 1 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
// Delayed reports should cleaned when the service is reset. |
@@ -779,9 +707,4 @@ TEST_F(CertificateReportingServiceTest, Delayed_Reset) { |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}, |
{"report1", RetryStatus::NOT_RETRIED}})); |
- |
- // report0 was submitted once, but neither failed nor succeeded because the |
- // report queue was cleared. report1 was submitted once, succeeded once. |
- event_histogram_tester()->SetExpectedValues( |
- 2 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |