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

Side by Side Diff: net/http/http_proxy_client_socket_pool_unittest.cc

Issue 2140673002: Remove SPDY/3.1 tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 29 matching lines...) Expand all
40 }; 40 };
41 const int kAuthHeadersSize = arraysize(kAuthHeaders) / 2; 41 const int kAuthHeadersSize = arraysize(kAuthHeaders) / 2;
42 42
43 enum HttpProxyType { 43 enum HttpProxyType {
44 HTTP, 44 HTTP,
45 HTTPS, 45 HTTPS,
46 SPDY 46 SPDY
47 }; 47 };
48 48
49 struct HttpProxyClientSocketPoolTestParams { 49 struct HttpProxyClientSocketPoolTestParams {
50 HttpProxyClientSocketPoolTestParams()
51 : proxy_type(HTTP),
52 protocol(kProtoSPDY31),
53 priority_to_dependency(false) {}
54
55 HttpProxyClientSocketPoolTestParams(HttpProxyType proxy_type, 50 HttpProxyClientSocketPoolTestParams(HttpProxyType proxy_type,
56 NextProto protocol,
57 bool priority_to_dependency) 51 bool priority_to_dependency)
58 : proxy_type(proxy_type), 52 : proxy_type(proxy_type),
59 protocol(protocol),
60 priority_to_dependency(priority_to_dependency) {} 53 priority_to_dependency(priority_to_dependency) {}
61 54
62 HttpProxyType proxy_type; 55 HttpProxyType proxy_type;
63 NextProto protocol;
64 bool priority_to_dependency; 56 bool priority_to_dependency;
65 }; 57 };
66 58
67 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; 59 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam;
68 60
69 const char kHttpProxyHost[] = "httpproxy.example.com"; 61 const char kHttpProxyHost[] = "httpproxy.example.com";
70 const char kHttpsProxyHost[] = "httpsproxy.example.com"; 62 const char kHttpsProxyHost[] = "httpsproxy.example.com";
71 63
72 } // namespace 64 } // namespace
73 65
74 class HttpProxyClientSocketPoolTest 66 class HttpProxyClientSocketPoolTest
75 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> { 67 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> {
76 protected: 68 protected:
77 HttpProxyClientSocketPoolTest() 69 HttpProxyClientSocketPoolTest()
78 : session_deps_(GetParam().protocol), 70 : transport_socket_pool_(kMaxSockets,
79 transport_socket_pool_(kMaxSockets,
80 kMaxSocketsPerGroup, 71 kMaxSocketsPerGroup,
81 session_deps_.socket_factory.get()), 72 session_deps_.socket_factory.get()),
82 ssl_socket_pool_(kMaxSockets, 73 ssl_socket_pool_(kMaxSockets,
83 kMaxSocketsPerGroup, 74 kMaxSocketsPerGroup,
84 session_deps_.cert_verifier.get(), 75 session_deps_.cert_verifier.get(),
85 NULL /* channel_id_store */, 76 NULL /* channel_id_store */,
86 NULL /* transport_security_state */, 77 NULL /* transport_security_state */,
87 NULL /* cert_transparency_verifier */, 78 NULL /* cert_transparency_verifier */,
88 NULL /* ct_policy_enforcer */, 79 NULL /* ct_policy_enforcer */,
89 std::string() /* ssl_session_cache_shard */, 80 std::string() /* ssl_session_cache_shard */,
90 session_deps_.socket_factory.get(), 81 session_deps_.socket_factory.get(),
91 &transport_socket_pool_, 82 &transport_socket_pool_,
92 NULL, 83 NULL,
93 NULL, 84 NULL,
94 session_deps_.ssl_config_service.get(), 85 session_deps_.ssl_config_service.get(),
95 BoundNetLog().net_log()), 86 BoundNetLog().net_log()),
96 spdy_util_(GetParam().protocol, GetParam().priority_to_dependency), 87 spdy_util_(GetParam().priority_to_dependency),
97 pool_(kMaxSockets, 88 pool_(kMaxSockets,
98 kMaxSocketsPerGroup, 89 kMaxSocketsPerGroup,
99 &transport_socket_pool_, 90 &transport_socket_pool_,
100 &ssl_socket_pool_, 91 &ssl_socket_pool_,
101 NULL) { 92 NULL) {
102 session_deps_.enable_priority_dependencies = 93 session_deps_.enable_priority_dependencies =
103 GetParam().priority_to_dependency; 94 GetParam().priority_to_dependency;
104 session_ = CreateNetworkSession(); 95 session_ = CreateNetworkSession();
105 } 96 }
106 97
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 188
198 if (GetParam().proxy_type != HTTP) { 189 if (GetParam().proxy_type != HTTP) {
199 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK)); 190 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK));
200 if (GetParam().proxy_type == SPDY) { 191 if (GetParam().proxy_type == SPDY) {
201 InitializeSpdySsl(); 192 InitializeSpdySsl();
202 } 193 }
203 socket_factory()->AddSSLSocketDataProvider(ssl_data_.get()); 194 socket_factory()->AddSSLSocketDataProvider(ssl_data_.get());
204 } 195 }
205 } 196 }
206 197
207 void InitializeSpdySsl() { 198 void InitializeSpdySsl() { ssl_data_->SetNextProto(kProtoHTTP2); }
208 ssl_data_->SetNextProto(GetParam().protocol);
209 }
210 199
211 std::unique_ptr<HttpNetworkSession> CreateNetworkSession() { 200 std::unique_ptr<HttpNetworkSession> CreateNetworkSession() {
212 return SpdySessionDependencies::SpdyCreateSession(&session_deps_); 201 return SpdySessionDependencies::SpdyCreateSession(&session_deps_);
213 } 202 }
214 203
215 RequestPriority GetLastTransportRequestPriority() const { 204 RequestPriority GetLastTransportRequestPriority() const {
216 return transport_socket_pool_.last_request_priority(); 205 return transport_socket_pool_.last_request_priority();
217 } 206 }
218 207
219 private: 208 private:
(...skipping 17 matching lines...) Expand all
237 226
238 //----------------------------------------------------------------------------- 227 //-----------------------------------------------------------------------------
239 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY) 228 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY)
240 // and SPDY. 229 // and SPDY.
241 // 230 //
242 // TODO(akalin): Use ::testing::Combine() when we are able to use 231 // TODO(akalin): Use ::testing::Combine() when we are able to use
243 // <tr1/tuple>. 232 // <tr1/tuple>.
244 INSTANTIATE_TEST_CASE_P( 233 INSTANTIATE_TEST_CASE_P(
245 HttpProxyClientSocketPoolTests, 234 HttpProxyClientSocketPoolTests,
246 HttpProxyClientSocketPoolTest, 235 HttpProxyClientSocketPoolTest,
247 ::testing::Values( 236 ::testing::Values(HttpProxyClientSocketPoolTestParams(HTTP, false),
248 HttpProxyClientSocketPoolTestParams(HTTP, kProtoSPDY31, false), 237 HttpProxyClientSocketPoolTestParams(HTTP, true),
249 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoSPDY31, false), 238 HttpProxyClientSocketPoolTestParams(HTTPS, false),
250 HttpProxyClientSocketPoolTestParams(SPDY, kProtoSPDY31, false), 239 HttpProxyClientSocketPoolTestParams(HTTPS, true),
251 HttpProxyClientSocketPoolTestParams(HTTP, kProtoHTTP2, false), 240 HttpProxyClientSocketPoolTestParams(SPDY, false),
252 HttpProxyClientSocketPoolTestParams(HTTP, kProtoHTTP2, true), 241 HttpProxyClientSocketPoolTestParams(SPDY, true)));
253 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoHTTP2, false),
254 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoHTTP2, true),
255 HttpProxyClientSocketPoolTestParams(SPDY, kProtoHTTP2, false),
256 HttpProxyClientSocketPoolTestParams(SPDY, kProtoHTTP2, true)));
257 242
258 TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) { 243 TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) {
259 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0); 244 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0);
260 245
261 std::unique_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); 246 std::unique_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
262 int rv = handle_.Init("a", CreateNoTunnelParams(proxy_delegate.get()), LOW, 247 int rv = handle_.Init("a", CreateNoTunnelParams(proxy_delegate.get()), LOW,
263 ClientSocketPool::RespectLimits::ENABLED, 248 ClientSocketPool::RespectLimits::ENABLED,
264 CompletionCallback(), &pool_, BoundNetLog()); 249 CompletionCallback(), &pool_, BoundNetLog());
265 EXPECT_THAT(rv, IsOk()); 250 EXPECT_THAT(rv, IsOk());
266 EXPECT_TRUE(handle_.is_initialized()); 251 EXPECT_TRUE(handle_.is_initialized());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 NULL, 0, 1, LOW, HostPortPair("www.google.com", 443))); 284 NULL, 0, 1, LOW, HostPortPair("www.google.com", 443)));
300 std::unique_ptr<SpdySerializedFrame> rst( 285 std::unique_ptr<SpdySerializedFrame> rst(
301 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 286 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
302 MockWrite spdy_writes[] = { 287 MockWrite spdy_writes[] = {
303 CreateMockWrite(*req, 0, ASYNC), 288 CreateMockWrite(*req, 0, ASYNC),
304 CreateMockWrite(*rst, 2, ASYNC), 289 CreateMockWrite(*rst, 2, ASYNC),
305 }; 290 };
306 SpdyHeaderBlock resp_block; 291 SpdyHeaderBlock resp_block;
307 resp_block[spdy_util_.GetStatusKey()] = "407"; 292 resp_block[spdy_util_.GetStatusKey()] = "407";
308 resp_block["proxy-authenticate"] = "Basic realm=\"MyRealm1\""; 293 resp_block["proxy-authenticate"] = "Basic realm=\"MyRealm1\"";
309 spdy_util_.MaybeAddVersionHeader(&resp_block);
310 294
311 std::unique_ptr<SpdySerializedFrame> resp( 295 std::unique_ptr<SpdySerializedFrame> resp(
312 spdy_util_.ConstructSpdyReply(1, std::move(resp_block))); 296 spdy_util_.ConstructSpdyReply(1, std::move(resp_block)));
313 MockRead spdy_reads[] = { 297 MockRead spdy_reads[] = {
314 CreateMockRead(*resp, 1, ASYNC), 298 CreateMockRead(*resp, 1, ASYNC),
315 MockRead(ASYNC, 0, 3) 299 MockRead(ASYNC, 0, 3)
316 }; 300 };
317 301
318 Initialize(reads, arraysize(reads), writes, arraysize(writes), 302 Initialize(reads, arraysize(reads), writes, arraysize(writes),
319 spdy_reads, arraysize(spdy_reads), spdy_writes, 303 spdy_reads, arraysize(spdy_reads), spdy_writes,
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // Make sure Location header was included and correct. 735 // Make sure Location header was included and correct.
752 std::string location; 736 std::string location;
753 EXPECT_TRUE(headers->IsRedirect(&location)); 737 EXPECT_TRUE(headers->IsRedirect(&location));
754 EXPECT_EQ(location, redirectTarget); 738 EXPECT_EQ(location, redirectTarget);
755 } 739 }
756 } 740 }
757 741
758 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 742 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
759 743
760 } // namespace net 744 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_stream_factory_impl_job_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698