| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 5 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 CertificateReportingServiceFactory::GetInstance() | 83 CertificateReportingServiceFactory::GetInstance() |
| 84 ->SetServiceResetCallbackForTesting( | 84 ->SetServiceResetCallbackForTesting( |
| 85 base::Bind(&CertificateReportingServiceObserver::OnServiceReset, | 85 base::Bind(&CertificateReportingServiceObserver::OnServiceReset, |
| 86 base::Unretained(&service_observer_))); | 86 base::Unretained(&service_observer_))); |
| 87 InProcessBrowserTest::SetUpOnMainThread(); | 87 InProcessBrowserTest::SetUpOnMainThread(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void TearDownOnMainThread() override { | 90 void TearDownOnMainThread() override { |
| 91 test_helper()->ExpectNoRequests(service()); | 91 test_helper()->ExpectNoRequests(service()); |
| 92 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 92 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 93 base::Bind(&CleanUpOnIOThread)); | 93 base::BindOnce(&CleanUpOnIOThread)); |
| 94 EXPECT_GE(num_expected_failed_report_, 0) | 94 EXPECT_GE(num_expected_failed_report_, 0) |
| 95 << "Don't forget to set expected failed report count."; | 95 << "Don't forget to set expected failed report count."; |
| 96 // Check the histogram as the last thing. This makes sure no in-flight | 96 // Check the histogram as the last thing. This makes sure no in-flight |
| 97 // report is missed. | 97 // report is missed. |
| 98 if (num_expected_failed_report_ != 0) { | 98 if (num_expected_failed_report_ != 0) { |
| 99 histogram_tester_.ExpectUniqueSample(kFailedReportHistogram, | 99 histogram_tester_.ExpectUniqueSample(kFailedReportHistogram, |
| 100 -net::ERR_SSL_PROTOCOL_ERROR, | 100 -net::ERR_SSL_PROTOCOL_ERROR, |
| 101 num_expected_failed_report_); | 101 num_expected_failed_report_); |
| 102 } else { | 102 } else { |
| 103 histogram_tester_.ExpectTotalCount(kFailedReportHistogram, 0); | 103 histogram_tester_.ExpectTotalCount(kFailedReportHistogram, 0); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 test_helper()->WaitForRequestsCreated( | 603 test_helper()->WaitForRequestsCreated( |
| 604 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 604 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
| 605 | 605 |
| 606 // Resume the delayed report and wait for it to complete. | 606 // Resume the delayed report and wait for it to complete. |
| 607 test_helper()->ResumeDelayedRequest(); | 607 test_helper()->ResumeDelayedRequest(); |
| 608 test_helper()->WaitForRequestsDestroyed( | 608 test_helper()->WaitForRequestsDestroyed( |
| 609 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 609 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
| 610 } | 610 } |
| 611 | 611 |
| 612 } // namespace safe_browsing | 612 } // namespace safe_browsing |
| OLD | NEW |