| 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 nullptr; | 137 nullptr; |
| 138 | 138 |
| 139 ReportSendingResult expected_report_result_; | 139 ReportSendingResult expected_report_result_; |
| 140 mutable base::WeakPtrFactory<CertReportJobInterceptor> weak_factory_; | 140 mutable base::WeakPtrFactory<CertReportJobInterceptor> weak_factory_; |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(CertReportJobInterceptor); | 142 DISALLOW_COPY_AND_ASSIGN(CertReportJobInterceptor); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 class CertificateReportingServiceTestBase { | 145 class CertificateReportingServiceTestBase { |
| 146 public: | 146 public: |
| 147 enum ObservedReportEvent { |
| 148 // No event should be observed. This can happen when hanging report requests |
| 149 // are allowed to complete. |
| 150 EXPECT_NONE, |
| 151 // Indicates that the send attempt is completed. |
| 152 EXPECT_SEND_ATTEMPT_COMPLETED, |
| 153 // Indicates that the send attempt is cancelled (e.g. extended reporting was |
| 154 // not opted in). |
| 155 EXPECT_SEND_ATTEMPT_CANCELLED, |
| 156 // Expect the service to be reset. |
| 157 EXPECT_SERVICE_RESET, |
| 158 }; |
| 159 |
| 147 CertificateReportingServiceTestBase(); | 160 CertificateReportingServiceTestBase(); |
| 148 virtual ~CertificateReportingServiceTestBase(); | 161 virtual ~CertificateReportingServiceTestBase(); |
| 149 | 162 |
| 150 // Changes the behavior of report uploads to fail, succeed or hang. | 163 // Changes the behavior of report uploads to fail, succeed or hang. |
| 151 void SetFailureMode(certificate_reporting_test_utils::ReportSendingResult | 164 void SetFailureMode(certificate_reporting_test_utils::ReportSendingResult |
| 152 expected_report_result); | 165 expected_report_result); |
| 153 | 166 |
| 154 // Resumes delayed report request. Failure mode should be REPORTS_DELAY when | 167 // Resumes delayed report request. Failure mode should be REPORTS_DELAY when |
| 155 // calling this method. | 168 // calling this method. |
| 156 void ResumeDelayedRequest(); | 169 void ResumeDelayedRequest(); |
| 157 | 170 |
| 171 void CheckExpectedResults(const ReportEventObserver& observer, |
| 172 ObservedReportEvent expected_observed_event, |
| 173 const std::set<int>& expected_successful_report_ids, |
| 174 const std::set<int>& expected_failed_report_ids); |
| 175 |
| 158 protected: | 176 protected: |
| 159 void SetUpInterceptor(); | 177 void SetUpInterceptor(); |
| 160 | 178 |
| 161 private: | 179 private: |
| 162 certificate_reporting_test_utils::CertReportJobInterceptor* | 180 certificate_reporting_test_utils::CertReportJobInterceptor* |
| 163 url_request_interceptor_; | 181 url_request_interceptor_; |
| 164 | 182 |
| 165 DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceTestBase); | 183 DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceTestBase); |
| 166 }; | 184 }; |
| 167 | 185 |
| 168 } // namespace certificate_reporting_test_utils | 186 } // namespace certificate_reporting_test_utils |
| 169 | 187 |
| 170 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS
_H_ | 188 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS
_H_ |
| OLD | NEW |