Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: net/test/embedded_test_server/embedded_test_server_unittest.cc

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ssl/token_binding_nss.cc ('k') | net/test/net_test_suite.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/test/embedded_test_server/embedded_test_server.h" 5 #include "net/test/embedded_test_server/embedded_test_server.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 13 matching lines...) Expand all
24 #include "net/test/embedded_test_server/embedded_test_server_connection_listener .h" 24 #include "net/test/embedded_test_server/embedded_test_server_connection_listener .h"
25 #include "net/test/embedded_test_server/http_request.h" 25 #include "net/test/embedded_test_server/http_request.h"
26 #include "net/test/embedded_test_server/http_response.h" 26 #include "net/test/embedded_test_server/http_response.h"
27 #include "net/test/embedded_test_server/request_handler_util.h" 27 #include "net/test/embedded_test_server/request_handler_util.h"
28 #include "net/url_request/url_fetcher.h" 28 #include "net/url_request/url_fetcher.h"
29 #include "net/url_request/url_fetcher_delegate.h" 29 #include "net/url_request/url_fetcher_delegate.h"
30 #include "net/url_request/url_request.h" 30 #include "net/url_request/url_request.h"
31 #include "net/url_request/url_request_test_util.h" 31 #include "net/url_request/url_request_test_util.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 33
34 #if defined(USE_NSS_VERIFIER) 34 #if defined(USE_NSS_CERTS)
35 #include "net/cert_net/nss_ocsp.h" 35 #include "net/cert_net/nss_ocsp.h"
36 #endif 36 #endif
37 37
38 namespace net { 38 namespace net {
39 namespace test_server { 39 namespace test_server {
40 40
41 namespace { 41 namespace {
42 42
43 // Gets the content from the given URLFetcher. 43 // Gets the content from the given URLFetcher.
44 std::string GetContentFromFetcher(const URLFetcher& fetcher) { 44 std::string GetContentFromFetcher(const URLFetcher& fetcher) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 : public testing::TestWithParam<EmbeddedTestServer::Type>, 116 : public testing::TestWithParam<EmbeddedTestServer::Type>,
117 public URLFetcherDelegate { 117 public URLFetcherDelegate {
118 public: 118 public:
119 EmbeddedTestServerTest() 119 EmbeddedTestServerTest()
120 : num_responses_received_(0), 120 : num_responses_received_(0),
121 num_responses_expected_(0), 121 num_responses_expected_(0),
122 io_thread_("io_thread") { 122 io_thread_("io_thread") {
123 } 123 }
124 124
125 void SetUp() override { 125 void SetUp() override {
126 #if defined(USE_NSS_VERIFIER) 126 #if defined(USE_NSS_CERTS)
127 // This is needed so NSS's HTTP client functions are initialized on the 127 // This is needed so NSS's HTTP client functions are initialized on the
128 // right thread. These tests create SSLClientSockets on a different thread. 128 // right thread. These tests create SSLClientSockets on a different thread.
129 // TODO(davidben): Initialization can't be deferred to SSLClientSocket. See 129 // TODO(davidben): Initialization can't be deferred to SSLClientSocket. See
130 // https://crbug.com/539520. 130 // https://crbug.com/539520.
131 crypto::EnsureNSSInit(); 131 crypto::EnsureNSSInit();
132 EnsureNSSHttpIOInit(); 132 EnsureNSSHttpIOInit();
133 #endif 133 #endif
134 134
135 base::Thread::Options thread_options; 135 base::Thread::Options thread_options;
136 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 136 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
137 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); 137 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options));
138 138
139 request_context_getter_ = 139 request_context_getter_ =
140 new TestURLRequestContextGetter(io_thread_.task_runner()); 140 new TestURLRequestContextGetter(io_thread_.task_runner());
141 141
142 server_.reset(new EmbeddedTestServer(GetParam())); 142 server_.reset(new EmbeddedTestServer(GetParam()));
143 server_->SetConnectionListener(&connection_listener_); 143 server_->SetConnectionListener(&connection_listener_);
144 } 144 }
145 145
146 void TearDown() override { 146 void TearDown() override {
147 if (server_->Started()) 147 if (server_->Started())
148 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); 148 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete());
149 #if defined(USE_NSS_VERIFIER) 149 #if defined(USE_NSS_CERTS)
150 ShutdownNSSHttpIO(); 150 ShutdownNSSHttpIO();
151 #endif 151 #endif
152 } 152 }
153 153
154 // URLFetcherDelegate override. 154 // URLFetcherDelegate override.
155 void OnURLFetchComplete(const URLFetcher* source) override { 155 void OnURLFetchComplete(const URLFetcher* source) override {
156 ++num_responses_received_; 156 ++num_responses_received_;
157 if (num_responses_received_ == num_responses_expected_) 157 if (num_responses_received_ == num_responses_expected_)
158 base::MessageLoop::current()->QuitWhenIdle(); 158 base::MessageLoop::current()->QuitWhenIdle();
159 } 159 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // Below test exercises EmbeddedTestServer's ability to cope with the situation 491 // Below test exercises EmbeddedTestServer's ability to cope with the situation
492 // where there is no MessageLoop available on the thread at EmbeddedTestServer 492 // where there is no MessageLoop available on the thread at EmbeddedTestServer
493 // initialization and/or destruction. 493 // initialization and/or destruction.
494 494
495 typedef std::tr1::tuple<bool, bool, EmbeddedTestServer::Type> 495 typedef std::tr1::tuple<bool, bool, EmbeddedTestServer::Type>
496 ThreadingTestParams; 496 ThreadingTestParams;
497 497
498 class EmbeddedTestServerThreadingTest 498 class EmbeddedTestServerThreadingTest
499 : public testing::TestWithParam<ThreadingTestParams> { 499 : public testing::TestWithParam<ThreadingTestParams> {
500 void SetUp() override { 500 void SetUp() override {
501 #if defined(USE_NSS_VERIFIER) 501 #if defined(USE_NSS_CERTS)
502 // This is needed so NSS's HTTP client functions are initialized on the 502 // This is needed so NSS's HTTP client functions are initialized on the
503 // right thread. These tests create SSLClientSockets on a different thread. 503 // right thread. These tests create SSLClientSockets on a different thread.
504 // TODO(davidben): Initialization can't be deferred to SSLClientSocket. See 504 // TODO(davidben): Initialization can't be deferred to SSLClientSocket. See
505 // https://crbug.com/539520. 505 // https://crbug.com/539520.
506 crypto::EnsureNSSInit(); 506 crypto::EnsureNSSInit();
507 EnsureNSSHttpIOInit(); 507 EnsureNSSHttpIOInit();
508 #endif 508 #endif
509 } 509 }
510 510
511 void TearDown() override { 511 void TearDown() override {
512 #if defined(USE_NSS_VERIFIER) 512 #if defined(USE_NSS_CERTS)
513 ShutdownNSSHttpIO(); 513 ShutdownNSSHttpIO();
514 #endif 514 #endif
515 } 515 }
516 }; 516 };
517 517
518 class EmbeddedTestServerThreadingTestDelegate 518 class EmbeddedTestServerThreadingTestDelegate
519 : public base::PlatformThread::Delegate, 519 : public base::PlatformThread::Delegate,
520 public URLFetcherDelegate { 520 public URLFetcherDelegate {
521 public: 521 public:
522 EmbeddedTestServerThreadingTestDelegate( 522 EmbeddedTestServerThreadingTestDelegate(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 INSTANTIATE_TEST_CASE_P( 593 INSTANTIATE_TEST_CASE_P(
594 EmbeddedTestServerThreadingTestInstantiation, 594 EmbeddedTestServerThreadingTestInstantiation,
595 EmbeddedTestServerThreadingTest, 595 EmbeddedTestServerThreadingTest,
596 testing::Combine(testing::Bool(), 596 testing::Combine(testing::Bool(),
597 testing::Bool(), 597 testing::Bool(),
598 testing::Values(EmbeddedTestServer::TYPE_HTTP, 598 testing::Values(EmbeddedTestServer::TYPE_HTTP,
599 EmbeddedTestServer::TYPE_HTTPS))); 599 EmbeddedTestServer::TYPE_HTTPS)));
600 600
601 } // namespace test_server 601 } // namespace test_server
602 } // namespace net 602 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/token_binding_nss.cc ('k') | net/test/net_test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698