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_
10 #include "chrome/test/base/in_process_browser_test.h"
14 class SSLCertReporter
;
17 class URLRequestContext
;
20 namespace certificate_reporting_test_utils
{
22 enum OptIn
{ EXTENDED_REPORTING_OPT_IN
, EXTENDED_REPORTING_DO_NOT_OPT_IN
};
24 enum ExpectReport
{ CERT_REPORT_EXPECTED
, CERT_REPORT_NOT_EXPECTED
};
26 // A test class that tracks the latest hostname for which a certificate
27 // report would have been sent over the network.
28 class CertificateReportingTest
: public InProcessBrowserTest
{
30 // Set up the mock reporter that keeps track of certificate reports
31 // that the safe browsing service sends.
32 void SetUpMockReporter();
35 // Get the latest hostname for which a certificate report was
36 // sent. SetUpMockReporter() must have been called before this.
37 const std::string
& GetLatestHostnameReported() const;
41 MockReporter
* reporter_
;
44 // Sets the browser preference to enable or disable extended reporting.
45 void SetCertReportingOptIn(Browser
* browser
, OptIn opt_in
);
47 // Sets up a mock SSLCertReporter and return a pointer to it, which will
48 // be owned by the caller. The mock SSLCertReporter will call
49 // |run_loop|'s QuitClosure when a report is sent. It also checks that a
50 // report is sent or not sent according to |expect_report|.
51 scoped_ptr
<SSLCertReporter
> SetUpMockSSLCertReporter(
52 base::RunLoop
* run_loop
,
53 ExpectReport expect_report
);
55 // Returns whether a report should be expected (due to the Finch config)
56 // if the user opts in.
57 ExpectReport
GetReportExpectedFromFinch();
59 } // namespace certificate_reporting_test_utils
61 #endif // CHROME_BROWSER_SSL_CERTIFICATE_REPORTING_TEST_UTILS_H_