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

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

Issue 1411383005: Initial implementation of RequestPriority-based HTTP/2 dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated tests. Created 5 years, 1 month 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 "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 23 matching lines...) Expand all
34 34
35 enum HttpProxyType { 35 enum HttpProxyType {
36 HTTP, 36 HTTP,
37 HTTPS, 37 HTTPS,
38 SPDY 38 SPDY
39 }; 39 };
40 40
41 struct HttpProxyClientSocketPoolTestParams { 41 struct HttpProxyClientSocketPoolTestParams {
42 HttpProxyClientSocketPoolTestParams() 42 HttpProxyClientSocketPoolTestParams()
43 : proxy_type(HTTP), 43 : proxy_type(HTTP),
44 protocol(kProtoSPDY31) {} 44 protocol(kProtoSPDY31),
45 priority_to_dependency(false) {}
45 46
46 HttpProxyClientSocketPoolTestParams( 47 HttpProxyClientSocketPoolTestParams(HttpProxyType proxy_type,
47 HttpProxyType proxy_type, 48 NextProto protocol,
48 NextProto protocol) 49 bool priority_to_dependency)
49 : proxy_type(proxy_type), 50 : proxy_type(proxy_type),
50 protocol(protocol) {} 51 protocol(protocol),
52 priority_to_dependency(priority_to_dependency) {}
51 53
52 HttpProxyType proxy_type; 54 HttpProxyType proxy_type;
53 NextProto protocol; 55 NextProto protocol;
56 bool priority_to_dependency;
54 }; 57 };
55 58
56 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; 59 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam;
57 60
58 const char kHttpProxyHost[] = "httpproxy.example.com"; 61 const char kHttpProxyHost[] = "httpproxy.example.com";
59 const char kHttpsProxyHost[] = "httpsproxy.example.com"; 62 const char kHttpsProxyHost[] = "httpsproxy.example.com";
60 63
61 class TestProxyDelegate : public ProxyDelegate { 64 class TestProxyDelegate : public ProxyDelegate {
62 public: 65 public:
63 TestProxyDelegate() 66 TestProxyDelegate()
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 NULL /* cert_transparency_verifier */, 169 NULL /* cert_transparency_verifier */,
167 NULL /* cert_policy_enforcer */, 170 NULL /* cert_policy_enforcer */,
168 std::string() /* ssl_session_cache_shard */, 171 std::string() /* ssl_session_cache_shard */,
169 session_deps_.socket_factory.get(), 172 session_deps_.socket_factory.get(),
170 &transport_socket_pool_, 173 &transport_socket_pool_,
171 NULL, 174 NULL,
172 NULL, 175 NULL,
173 session_deps_.ssl_config_service.get(), 176 session_deps_.ssl_config_service.get(),
174 BoundNetLog().net_log()), 177 BoundNetLog().net_log()),
175 session_(CreateNetworkSession()), 178 session_(CreateNetworkSession()),
176 spdy_util_(GetParam().protocol), 179 spdy_util_(GetParam().protocol, GetParam().priority_to_dependency),
177 pool_(kMaxSockets, 180 pool_(kMaxSockets,
178 kMaxSocketsPerGroup, 181 kMaxSocketsPerGroup,
179 &transport_socket_pool_, 182 &transport_socket_pool_,
180 &ssl_socket_pool_, 183 &ssl_socket_pool_,
181 NULL) {} 184 NULL) {
185 SpdySession::SetPriorityDependencyDefaultForTesting(
186 GetParam().priority_to_dependency);
187 }
182 188
183 virtual ~HttpProxyClientSocketPoolTest() { 189 virtual ~HttpProxyClientSocketPoolTest() {
190 SpdySession::SetPriorityDependencyDefaultForTesting(false);
184 } 191 }
185 192
186 void AddAuthToCache() { 193 void AddAuthToCache() {
187 const base::string16 kFoo(base::ASCIIToUTF16("foo")); 194 const base::string16 kFoo(base::ASCIIToUTF16("foo"));
188 const base::string16 kBar(base::ASCIIToUTF16("bar")); 195 const base::string16 kBar(base::ASCIIToUTF16("bar"));
189 GURL proxy_url(GetParam().proxy_type == HTTP ? 196 GURL proxy_url(GetParam().proxy_type == HTTP ?
190 (std::string("http://") + kHttpProxyHost) : 197 (std::string("http://") + kHttpProxyHost) :
191 (std::string("https://") + kHttpsProxyHost)); 198 (std::string("https://") + kHttpsProxyHost));
192 session_->http_auth_cache()->Add(proxy_url, 199 session_->http_auth_cache()->Add(proxy_url,
193 "MyRealm1", 200 "MyRealm1",
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 323
317 //----------------------------------------------------------------------------- 324 //-----------------------------------------------------------------------------
318 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY) 325 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY)
319 // and SPDY. 326 // and SPDY.
320 // 327 //
321 // TODO(akalin): Use ::testing::Combine() when we are able to use 328 // TODO(akalin): Use ::testing::Combine() when we are able to use
322 // <tr1/tuple>. 329 // <tr1/tuple>.
323 INSTANTIATE_TEST_CASE_P( 330 INSTANTIATE_TEST_CASE_P(
324 HttpProxyClientSocketPoolTests, 331 HttpProxyClientSocketPoolTests,
325 HttpProxyClientSocketPoolTest, 332 HttpProxyClientSocketPoolTest,
326 ::testing::Values(HttpProxyClientSocketPoolTestParams(HTTP, kProtoSPDY31), 333 ::testing::Values(
327 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoSPDY31), 334 HttpProxyClientSocketPoolTestParams(HTTP, kProtoSPDY31, false),
328 HttpProxyClientSocketPoolTestParams(SPDY, kProtoSPDY31), 335 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoSPDY31, false),
329 HttpProxyClientSocketPoolTestParams(HTTP, kProtoHTTP2), 336 HttpProxyClientSocketPoolTestParams(SPDY, kProtoSPDY31, false),
330 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoHTTP2), 337 HttpProxyClientSocketPoolTestParams(HTTP, kProtoHTTP2, false),
331 HttpProxyClientSocketPoolTestParams(SPDY, kProtoHTTP2))); 338 HttpProxyClientSocketPoolTestParams(HTTP, kProtoHTTP2, true),
339 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoHTTP2, false),
340 HttpProxyClientSocketPoolTestParams(HTTPS, kProtoHTTP2, true),
341 HttpProxyClientSocketPoolTestParams(SPDY, kProtoHTTP2, false)));
Bence 2015/11/11 18:47:14 Why is (SPDY, kProtoHTTP2, true) not included here
Randy Smith (Not in Mondays) 2015/11/11 23:25:59 Actually, it not being there was me just spacing.
332 342
333 TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) { 343 TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) {
334 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0); 344 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0);
335 345
336 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); 346 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
337 int rv = handle_.Init("a", CreateNoTunnelParams(proxy_delegate.get()), LOW, 347 int rv = handle_.Init("a", CreateNoTunnelParams(proxy_delegate.get()), LOW,
338 CompletionCallback(), &pool_, BoundNetLog()); 348 CompletionCallback(), &pool_, BoundNetLog());
339 EXPECT_EQ(OK, rv); 349 EXPECT_EQ(OK, rv);
340 EXPECT_TRUE(handle_.is_initialized()); 350 EXPECT_TRUE(handle_.is_initialized());
341 ASSERT_TRUE(handle_.socket()); 351 ASSERT_TRUE(handle_.socket());
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 EXPECT_TRUE(headers->IsRedirect(&location)); 818 EXPECT_TRUE(headers->IsRedirect(&location));
809 EXPECT_EQ(location, redirectTarget); 819 EXPECT_EQ(location, redirectTarget);
810 } 820 }
811 } 821 }
812 822
813 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 823 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
814 824
815 } // namespace 825 } // namespace
816 826
817 } // namespace net 827 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698