Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ssl / certificate_reporting_test_utils.h
blob81d3d91925a2ffff47f9fee5d91420ecbc16af3c
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_
6 #define CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_
8 #include <string>
10 #include "chrome/browser/net/certificate_error_reporter.h"
11 #include "chrome/test/base/in_process_browser_test.h"
13 class Browser;
14 class GURL;
15 class SSLCertReporter;
17 namespace net {
18 class URLRequestContext;
21 namespace certificate_reporting_test_utils {
23 enum OptIn { EXTENDED_REPORTING_OPT_IN, EXTENDED_REPORTING_DO_NOT_OPT_IN };
25 enum ExpectReport { CERT_REPORT_EXPECTED, CERT_REPORT_NOT_EXPECTED };
27 // A test class that tracks the latest hostname for which a certificate
28 // report would have been sent over the network.
29 class CertificateReportingTest : public InProcessBrowserTest {
30 public:
31 // Set up the mock reporter that keeps track of certificate reports
32 // that the safe browsing service sends.
33 void SetUpMockReporter();
35 protected:
36 // Get the latest hostname for which a certificate report was
37 // sent. SetUpMockReporter() must have been called before this.
38 const std::string& GetLatestHostnameReported() const;
40 private:
41 class MockReporter;
42 MockReporter* reporter_;
45 // Sets the browser preference to enable or disable extended reporting.
46 void SetCertReportingOptIn(Browser* browser, OptIn opt_in);
48 // Sets up a mock SSLCertReporter and return a pointer to it, which will
49 // be owned by the caller. The mock SSLCertReporter will call
50 // |run_loop|'s QuitClosure when a report is sent. It also checks that a
51 // report is sent or not sent according to |expect_report|.
52 scoped_ptr<SSLCertReporter> SetUpMockSSLCertReporter(
53 base::RunLoop* run_loop,
54 ExpectReport expect_report);
56 // Returns whether a report should be expected (due to the Finch config)
57 // if the user opts in.
58 ExpectReport GetReportExpectedFromFinch();
60 } // namespace certificate_reporting_test_utils
62 #endif // CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_