Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Unified Diff: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc

Issue 2578873003: Remove certificate reporting code from SafeBrowsing ping and ui managers (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/ui_manager.cc ('k') | chrome/browser/ssl/certificate_reporting_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/safe_browsing/ui_manager.cc ('k') | chrome/browser/ssl/certificate_reporting_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698