Index: chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc |
diff --git a/chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc b/chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc |
index dbe29ea07993c81bc20776e957c447b5c4255ade..37a9fc19bcd1429105cefc059d73bc4f93edbc85 100644 |
--- a/chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc |
+++ b/chrome/browser/safe_browsing/certificate_reporting_service_browsertest.cc |
@@ -37,6 +37,7 @@ |
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; |
@@ -84,6 +85,8 @@ class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { |
->SetServiceResetCallbackForTesting( |
base::Bind(&CertificateReportingServiceObserver::OnServiceReset, |
base::Unretained(&service_observer_))); |
+ |
+ event_histogram_tester_.reset(new EventHistogramTester()); |
InProcessBrowserTest::SetUpOnMainThread(); |
} |
@@ -102,6 +105,8 @@ class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { |
} else { |
histogram_tester_.ExpectTotalCount(kFailedReportHistogram, 0); |
} |
+ |
+ event_histogram_tester_.reset(); |
} |
void SetUpCommandLine(base::CommandLine* command_line) override { |
@@ -175,6 +180,10 @@ class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { |
browser()->profile()); |
} |
+ EventHistogramTester* event_histogram_tester() { |
+ return event_histogram_tester_.get(); |
+ } |
+ |
private: |
// Checks that the serialized reports in |received_reports| have the same |
// hostnames as |expected_hostnames|. |
@@ -200,6 +209,7 @@ class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { |
CertificateReportingServiceObserver service_observer_; |
base::HistogramTester histogram_tester_; |
+ std::unique_ptr<EventHistogramTester> event_histogram_tester_; |
DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceBrowserTest); |
}; |
@@ -216,6 +226,8 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
// Send a report. Test teardown checks for created and in-flight requests. If |
// a report was incorrectly sent, the test will fail. |
SendReport("no-report"); |
+ |
+ event_histogram_tester()->SetExpectedValues(0, 0, 0, 0); |
} |
// Tests that report send attempts are not cancelled when extended reporting is |
@@ -236,6 +248,10 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
SendReport("report0"); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Successful({{"report0", RetryStatus::NOT_RETRIED}})); |
+ |
+ // report0 was successfully submitted. |
+ event_histogram_tester()->SetExpectedValues( |
+ 1 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
// Tests that report send attempts are not cancelled when extended reporting is |
@@ -280,6 +296,12 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
// nothing should be sent this time. If any report is sent, test teardown |
// will catch it. |
SendPendingReports(); |
+ |
+ // report0 was submitted twice, failed once, succeeded once. |
+ // report1 was submitted twice, failed once, succeeded once. |
+ // report2 was submitted once, succeeded once. |
+ event_histogram_tester()->SetExpectedValues( |
+ 5 /* submitted */, 2 /* failed */, 3 /* successful */, 0 /* dropped */); |
} |
// Opting in then opting out of extended reporting should clear the pending |
@@ -305,6 +327,10 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
// Send pending reports. No reports should be observed during test teardown. |
SendPendingReports(); |
+ |
+ // report0 was submitted once and failed once. |
+ event_histogram_tester()->SetExpectedValues( |
+ 1 /* submitted */, 1 /* failed */, 0 /* successful */, 0 /* dropped */); |
} |
// Opting out, then in, then out of extended reporting should work as expected. |
@@ -344,6 +370,11 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
// Send pending reports. Nothing should be sent since there aren't any |
// pending reports. If any report is sent, test teardown will catch it. |
SendPendingReports(); |
+ |
+ // report0 was submitted once and failed once. |
+ // report1 was never submitted. |
+ event_histogram_tester()->SetExpectedValues( |
+ 1 /* submitted */, 1 /* failed */, 0 /* successful */, 0 /* dropped */); |
} |
// Disabling SafeBrowsing should clear pending reports queue in |
@@ -358,7 +389,7 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
test_helper()->SetFailureMode( |
certificate_reporting_test_utils::ReportSendingResult::REPORTS_FAIL); |
- // Send a delayed report. |
+ // Send a report. |
SendReport("report0"); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Failed({{"report0", RetryStatus::NOT_RETRIED}})); |
@@ -382,6 +413,11 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
SendPendingReports(); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Successful({{"report1", RetryStatus::RETRIED}})); |
+ |
+ // report0 was submitted once, failed once, then cleared. |
+ // report1 was submitted twice, failed once, succeeded once. |
+ event_histogram_tester()->SetExpectedValues( |
+ 3 /* submitted */, 2 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
// CertificateReportingService should ignore reports older than the report TTL. |
@@ -446,6 +482,12 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
// Send pending reports. report2 should be discarded since it's too old. No |
// other reports remain. If any report is sent, test teardown will catch it. |
SendPendingReports(); |
+ |
+ // report0 was submitted once, failed once, dropped once. |
+ // report1 was submitted twice, failed twice, dropped once. |
+ // report2 was submitted twice, failed twice, dropped once. |
+ event_histogram_tester()->SetExpectedValues( |
+ 5 /* submitted */, 5 /* failed */, 0 /* successful */, 3 /* dropped */); |
} |
// CertificateReportingService should drop old reports from its pending report |
@@ -520,6 +562,13 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
SendPendingReports(); |
test_helper()->WaitForRequestsDestroyed(ReportExpectation::Successful( |
{{"report2", RetryStatus::RETRIED}, {"report3", RetryStatus::RETRIED}})); |
+ |
+ // 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 */); |
} |
IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
@@ -543,6 +592,10 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
test_helper()->ResumeDelayedRequest(); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}})); |
+ |
+ // report0 was submitted once and succeeded once. |
+ event_histogram_tester()->SetExpectedValues( |
+ 1 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
// Same as above, but the service is shut down before resuming the delayed |
@@ -567,6 +620,10 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
test_helper()->ResumeDelayedRequest(); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}})); |
+ |
+ // report0 was submitted once and never completed since the service shut down. |
+ event_histogram_tester()->SetExpectedValues( |
+ 1 /* submitted */, 0 /* failed */, 0 /* successful */, 0 /* dropped */); |
} |
// Trigger a delayed report, then disable Safebrowsing. Certificate reporting |
@@ -607,6 +664,11 @@ IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, Delayed_Reset) { |
test_helper()->ResumeDelayedRequest(); |
test_helper()->WaitForRequestsDestroyed( |
ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
+ |
+ // report0 was submitted once and delayed, then cleared. |
+ // report1 was submitted once and delayed, then succeeded. |
+ event_histogram_tester()->SetExpectedValues( |
+ 2 /* submitted */, 0 /* failed */, 1 /* successful */, 0 /* dropped */); |
} |
} // namespace safe_browsing |