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 <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/test/histogram_tester.h" |
12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
13 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 14 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
14 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "net/base/network_delegate_impl.h" | 17 #include "net/base/network_delegate_impl.h" |
17 #include "net/url_request/url_request_interceptor.h" | 18 #include "net/url_request/url_request_interceptor.h" |
18 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 class NetworkDelegate; | 22 class NetworkDelegate; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 void SetUpInterceptorOnIOThread(); | 234 void SetUpInterceptorOnIOThread(); |
234 | 235 |
235 CertReportJobInterceptor* url_request_interceptor_; | 236 CertReportJobInterceptor* url_request_interceptor_; |
236 | 237 |
237 uint8_t server_public_key_[32]; | 238 uint8_t server_public_key_[32]; |
238 uint8_t server_private_key_[32]; | 239 uint8_t server_private_key_[32]; |
239 | 240 |
240 DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceTestHelper); | 241 DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceTestHelper); |
241 }; | 242 }; |
242 | 243 |
| 244 // Class to test reporting events histogram for CertificateReportingService. |
| 245 // We can't use a simple HistogramTester, as we need to wait until test teardown |
| 246 // to check the histogram contents. This ensures that all in-flight requests |
| 247 // are torn down by the time we check the histograms. |
| 248 class EventHistogramTester { |
| 249 public: |
| 250 EventHistogramTester(); |
| 251 ~EventHistogramTester(); |
| 252 |
| 253 void SetExpectedValues(int submitted, |
| 254 int failed, |
| 255 int successful, |
| 256 int dropped); |
| 257 |
| 258 private: |
| 259 int submitted_ = 0; |
| 260 int failed_ = 0; |
| 261 int successful_ = 0; |
| 262 int dropped_ = 0; |
| 263 base::HistogramTester histogram_tester_; |
| 264 }; |
| 265 |
243 } // namespace certificate_reporting_test_utils | 266 } // namespace certificate_reporting_test_utils |
244 | 267 |
245 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS
_H_ | 268 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_TEST_UTILS
_H_ |
OLD | NEW |