| 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/ssl/chrome_fraudulent_certificate_reporter.h" | 5 #include "chrome/browser/ssl/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" |
| 11 #include "base/location.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 15 #include "chrome/browser/net/certificate_error_reporter.h" | 17 #include "chrome/browser/net/certificate_error_reporter.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 17 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 18 #include "net/base/test_data_directory.h" | 20 #include "net/base/test_data_directory.h" |
| 19 #include "net/cert/x509_certificate.h" | 21 #include "net/cert/x509_certificate.h" |
| 20 #include "net/http/transport_security_state.h" | 22 #include "net/http/transport_security_state.h" |
| 21 #include "net/ssl/ssl_info.h" | 23 #include "net/ssl/ssl_info.h" |
| 22 #include "net/test/cert_test_util.h" | 24 #include "net/test/cert_test_util.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SSLInfo good = GetGoodSSLInfo(); | 167 SSLInfo good = GetGoodSSLInfo(); |
| 166 EXPECT_TRUE(IsGoodSSLInfo(good)); | 168 EXPECT_TRUE(IsGoodSSLInfo(good)); |
| 167 | 169 |
| 168 SSLInfo bad = GetBadSSLInfo(); | 170 SSLInfo bad = GetBadSSLInfo(); |
| 169 EXPECT_FALSE(IsGoodSSLInfo(bad)); | 171 EXPECT_FALSE(IsGoodSSLInfo(bad)); |
| 170 } | 172 } |
| 171 | 173 |
| 172 TEST(ChromeFraudulentCertificateReporterTest, ReportIsSent) { | 174 TEST(ChromeFraudulentCertificateReporterTest, ReportIsSent) { |
| 173 base::MessageLoopForIO loop; | 175 base::MessageLoopForIO loop; |
| 174 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 176 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
| 175 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsSent)); | 177 loop.task_runner()->PostTask(FROM_HERE, base::Bind(&DoReportIsSent)); |
| 176 loop.RunUntilIdle(); | 178 loop.RunUntilIdle(); |
| 177 } | 179 } |
| 178 | 180 |
| 179 TEST(ChromeFraudulentCertificateReporterTest, MockReportIsSent) { | 181 TEST(ChromeFraudulentCertificateReporterTest, MockReportIsSent) { |
| 180 base::MessageLoopForIO loop; | 182 base::MessageLoopForIO loop; |
| 181 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 183 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
| 182 loop.PostTask(FROM_HERE, base::Bind(&DoMockReportIsSent)); | 184 loop.task_runner()->PostTask(FROM_HERE, base::Bind(&DoMockReportIsSent)); |
| 183 loop.RunUntilIdle(); | 185 loop.RunUntilIdle(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { | 188 TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { |
| 187 base::MessageLoopForIO loop; | 189 base::MessageLoopForIO loop; |
| 188 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); | 190 content::TestBrowserThread io_thread(BrowserThread::IO, &loop); |
| 189 loop.PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); | 191 loop.task_runner()->PostTask(FROM_HERE, base::Bind(&DoReportIsNotSent)); |
| 190 loop.RunUntilIdle(); | 192 loop.RunUntilIdle(); |
| 191 } | 193 } |
| 192 | 194 |
| 193 } // namespace | 195 } // namespace |
| OLD | NEW |