| Index: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
|
| diff --git a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
|
| index ad459dd348a70f0c577b9521b0bc231499e2df92..fe6d2cd0d9299766b7e3fee9dc7900fffa1eadc0 100644
|
| --- a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
|
| +++ b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
|
| @@ -7,12 +7,16 @@
|
| #include <string>
|
| #include <utility>
|
|
|
| +#include "base/base_switches.h"
|
| +#include "base/bind_helpers.h"
|
| #include "base/callback.h"
|
| +#include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/run_loop.h"
|
| #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.h"
|
| #include "chrome/browser/ssl/cert_report_helper.h"
|
| #include "chrome/browser/ssl/certificate_reporting_test_utils.h"
|
| #include "chrome/browser/ssl/security_state_tab_helper.h"
|
| @@ -24,6 +28,7 @@
|
| #include "components/captive_portal/captive_portal_detector.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "components/security_state/core/security_state.h"
|
| +#include "components/variations/variations_switches.h"
|
| #include "content/public/browser/interstitial_page.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| @@ -88,12 +93,20 @@ class CaptivePortalBlockingPageForTesting : public CaptivePortalBlockingPage {
|
| const std::string wifi_ssid_;
|
| };
|
|
|
| -class CaptivePortalBlockingPageTest
|
| - : public certificate_reporting_test_utils::CertificateReportingTest,
|
| - public InProcessBrowserTest {
|
| +class CaptivePortalBlockingPageTest : public InProcessBrowserTest {
|
| public:
|
| CaptivePortalBlockingPageTest() {}
|
|
|
| + void SetUpCommandLine(base::CommandLine* command_line) override {
|
| + command_line->AppendSwitchASCII(
|
| + switches::kForceFieldTrials,
|
| + "ReportCertificateErrors/ShowAndPossiblySend/");
|
| + // Setting the sending threshold to 1.0 ensures reporting is enabled.
|
| + command_line->AppendSwitchASCII(
|
| + variations::switches::kForceFieldTrialParams,
|
| + "ReportCertificateErrors.ShowAndPossiblySend:sendingThreshold/1.0");
|
| + }
|
| +
|
| void TestInterstitial(bool is_wifi_connection,
|
| const std::string& wifi_ssid,
|
| const GURL& login_url,
|
| @@ -203,13 +216,16 @@ void CaptivePortalBlockingPageTest::TestInterstitial(
|
|
|
| void CaptivePortalBlockingPageTest::TestCertReporting(
|
| certificate_reporting_test_utils::OptIn opt_in) {
|
| - ASSERT_NO_FATAL_FAILURE(SetUpMockReporter());
|
| -
|
| certificate_reporting_test_utils::SetCertReportingOptIn(browser(), opt_in);
|
| base::RunLoop run_loop;
|
| + certificate_reporting_test_utils::SSLCertReporterCallback reporter_callback(
|
| + &run_loop);
|
| +
|
| std::unique_ptr<SSLCertReporter> ssl_cert_reporter =
|
| - certificate_reporting_test_utils::SetUpMockSSLCertReporter(
|
| - &run_loop,
|
| + certificate_reporting_test_utils::CreateMockSSLCertReporter(
|
| + base::Bind(&certificate_reporting_test_utils::
|
| + SSLCertReporterCallback::ReportSent,
|
| + base::Unretained(&reporter_callback)),
|
| opt_in == certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN
|
| ? certificate_reporting_test_utils::CERT_REPORT_EXPECTED
|
| : certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED);
|
| @@ -219,7 +235,7 @@ void CaptivePortalBlockingPageTest::TestCertReporting(
|
| EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_NO,
|
| std::move(ssl_cert_reporter));
|
|
|
| - EXPECT_EQ(std::string(), GetLatestHostnameReported());
|
| + EXPECT_EQ(std::string(), reporter_callback.GetLatestHostnameReported());
|
|
|
| content::WebContents* tab =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| @@ -228,9 +244,10 @@ void CaptivePortalBlockingPageTest::TestCertReporting(
|
| if (opt_in == certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN) {
|
| // Check that the mock reporter received a request to send a report.
|
| run_loop.Run();
|
| - EXPECT_EQ(GURL(kBrokenSSL).host(), GetLatestHostnameReported());
|
| + EXPECT_EQ(GURL(kBrokenSSL).host(),
|
| + reporter_callback.GetLatestHostnameReported());
|
| } else {
|
| - EXPECT_EQ(std::string(), GetLatestHostnameReported());
|
| + EXPECT_EQ(std::string(), reporter_callback.GetLatestHostnameReported());
|
| }
|
| }
|
|
|
| @@ -303,16 +320,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest, CertReportingOptIn) {
|
| - // This test should only run if the Finch config is such that reports
|
| - // will be sent when opted in. This tests that a report *is* sent when
|
| - // the user opts in under such a Finch config, and the below test
|
| - // tests that a report *is not* sent when the user doesn't opt in
|
| - // (under any Finch config).
|
| - if (certificate_reporting_test_utils::GetReportExpectedFromFinch() ==
|
| - certificate_reporting_test_utils::CERT_REPORT_EXPECTED) {
|
| - TestCertReporting(
|
| - certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN);
|
| - }
|
| + TestCertReporting(
|
| + certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest, CertReportingOptOut) {
|
|
|