| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 5 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // For the first version of the feature, sending reports is "fire and forget". | 117 // For the first version of the feature, sending reports is "fire and forget". |
| 118 // Therefore, we test only that the Reporter tried to send a request at all. | 118 // Therefore, we test only that the Reporter tried to send a request at all. |
| 119 // In the future, when we have more sophisticated (i.e., any) error handling | 119 // In the future, when we have more sophisticated (i.e., any) error handling |
| 120 // and re-tries, we will need more sopisticated tests as well. | 120 // and re-tries, we will need more sopisticated tests as well. |
| 121 // | 121 // |
| 122 // This class doesn't do anything now, but in near future versions it will. | 122 // This class doesn't do anything now, but in near future versions it will. |
| 123 class MockURLRequest : public net::URLRequest { | 123 class MockURLRequest : public net::URLRequest { |
| 124 public: | 124 public: |
| 125 explicit MockURLRequest(net::URLRequestContext* context) | 125 explicit MockURLRequest(net::URLRequestContext* context) |
| 126 : net::URLRequest(GURL(""), NULL, context) { | 126 : net::URLRequest(GURL(std::string()), NULL, context) {} |
| 127 } | |
| 128 | 127 |
| 129 private: | 128 private: |
| 130 }; | 129 }; |
| 131 | 130 |
| 132 // A ChromeFraudulentCertificateReporter that uses a MockURLRequest, but is | 131 // A ChromeFraudulentCertificateReporter that uses a MockURLRequest, but is |
| 133 // otherwise normal: reports are constructed and sent in the usual way. | 132 // otherwise normal: reports are constructed and sent in the usual way. |
| 134 class MockReporter : public ChromeFraudulentCertificateReporter { | 133 class MockReporter : public ChromeFraudulentCertificateReporter { |
| 135 public: | 134 public: |
| 136 explicit MockReporter(net::URLRequestContext* request_context) | 135 explicit MockReporter(net::URLRequestContext* request_context) |
| 137 : ChromeFraudulentCertificateReporter(request_context) {} | 136 : ChromeFraudulentCertificateReporter(request_context) {} |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 198 } |
| 200 | 199 |
| 201 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { | 200 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { |
| 202 MessageLoop loop(MessageLoop::TYPE_IO); | 201 MessageLoop loop(MessageLoop::TYPE_IO); |
| 203 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 202 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
| 204 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); | 203 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); |
| 205 loop.RunUntilIdle(); | 204 loop.RunUntilIdle(); |
| 206 } | 205 } |
| 207 | 206 |
| 208 } // namespace chrome_browser_net | 207 } // namespace chrome_browser_net |
| OLD | NEW |