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

Side by Side Diff: net/spdy/spdy_proxy_client_socket_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
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/spdy/spdy_session_pool_unittest.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/spdy/spdy_proxy_client_socket.h" 5 #include "net/spdy/spdy_proxy_client_socket.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 25 matching lines...) Expand all
36 #include "testing/platform_test.h" 36 #include "testing/platform_test.h"
37 37
38 using net::test::IsError; 38 using net::test::IsError;
39 using net::test::IsOk; 39 using net::test::IsOk;
40 40
41 //----------------------------------------------------------------------------- 41 //-----------------------------------------------------------------------------
42 42
43 namespace { 43 namespace {
44 44
45 enum TestCase { 45 enum TestCase {
46 // Test using the SPDY/3.1 protocol. 46 // Test without specifying a stream dependency based on the RequestPriority.
47 kTestCaseSPDY31, 47 kTestCaseNoPriorityDependencies,
48 48
49 // Test using the HTTP/2 protocol, without specifying a stream 49 // Test specifying a stream dependency based on the RequestPriority.
50 // dependency based on the RequestPriority. 50 kTestCasePriorityDependencies
51 kTestCaseHTTP2NoPriorityDependencies,
52
53 // Test using the HTTP/2 protocol, specifying a stream
54 // dependency based on the RequestPriority.
55 kTestCaseHTTP2PriorityDependencies
56 }; 51 };
57 52
58 static const char kRequestUrl[] = "https://www.google.com/"; 53 static const char kRequestUrl[] = "https://www.google.com/";
59 static const char kOriginHost[] = "www.google.com"; 54 static const char kOriginHost[] = "www.google.com";
60 static const int kOriginPort = 443; 55 static const int kOriginPort = 443;
61 static const char kOriginHostPort[] = "www.google.com:443"; 56 static const char kOriginHostPort[] = "www.google.com:443";
62 static const char kProxyUrl[] = "https://myproxy:6121/"; 57 static const char kProxyUrl[] = "https://myproxy:6121/";
63 static const char kProxyHost[] = "myproxy"; 58 static const char kProxyHost[] = "myproxy";
64 static const int kProxyPort = 6121; 59 static const int kProxyPort = 6121;
65 static const char kUserAgent[] = "Mozilla/1.0"; 60 static const char kUserAgent[] = "Mozilla/1.0";
(...skipping 19 matching lines...) Expand all
85 80
86 class SpdyProxyClientSocketTest : public PlatformTest, 81 class SpdyProxyClientSocketTest : public PlatformTest,
87 public testing::WithParamInterface<TestCase> { 82 public testing::WithParamInterface<TestCase> {
88 public: 83 public:
89 SpdyProxyClientSocketTest(); 84 SpdyProxyClientSocketTest();
90 ~SpdyProxyClientSocketTest(); 85 ~SpdyProxyClientSocketTest();
91 86
92 void TearDown() override; 87 void TearDown() override;
93 88
94 protected: 89 protected:
95 NextProto GetProtocol() const;
96 bool GetDependenciesFromPriority() const; 90 bool GetDependenciesFromPriority() const;
97 91
98 void Initialize(MockRead* reads, size_t reads_count, MockWrite* writes, 92 void Initialize(MockRead* reads, size_t reads_count, MockWrite* writes,
99 size_t writes_count); 93 size_t writes_count);
100 void PopulateConnectRequestIR(SpdyHeaderBlock* syn_ir); 94 void PopulateConnectRequestIR(SpdyHeaderBlock* syn_ir);
101 void PopulateConnectReplyIR(SpdyHeaderBlock* block, const char* status); 95 void PopulateConnectReplyIR(SpdyHeaderBlock* block, const char* status);
102 SpdySerializedFrame* ConstructConnectRequestFrame(); 96 SpdySerializedFrame* ConstructConnectRequestFrame();
103 SpdySerializedFrame* ConstructConnectAuthRequestFrame(); 97 SpdySerializedFrame* ConstructConnectAuthRequestFrame();
104 SpdySerializedFrame* ConstructConnectReplyFrame(); 98 SpdySerializedFrame* ConstructConnectReplyFrame();
105 SpdySerializedFrame* ConstructConnectAuthReplyFrame(); 99 SpdySerializedFrame* ConstructConnectAuthReplyFrame();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 HostPortPair proxy_host_port_; 154 HostPortPair proxy_host_port_;
161 HostPortPair endpoint_host_port_pair_; 155 HostPortPair endpoint_host_port_pair_;
162 ProxyServer proxy_; 156 ProxyServer proxy_;
163 SpdySessionKey endpoint_spdy_session_key_; 157 SpdySessionKey endpoint_spdy_session_key_;
164 158
165 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocketTest); 159 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocketTest);
166 }; 160 };
167 161
168 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend, 162 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
169 SpdyProxyClientSocketTest, 163 SpdyProxyClientSocketTest,
170 testing::Values(kTestCaseSPDY31, 164 testing::Values(kTestCaseNoPriorityDependencies,
171 kTestCaseHTTP2NoPriorityDependencies, 165 kTestCasePriorityDependencies));
172 kTestCaseHTTP2PriorityDependencies));
173 166
174 SpdyProxyClientSocketTest::SpdyProxyClientSocketTest() 167 SpdyProxyClientSocketTest::SpdyProxyClientSocketTest()
175 : spdy_util_(GetProtocol(), GetDependenciesFromPriority()), 168 : spdy_util_(GetDependenciesFromPriority()),
176 read_buf_(NULL), 169 read_buf_(NULL),
177 session_deps_(GetProtocol()),
178 connect_data_(SYNCHRONOUS, OK), 170 connect_data_(SYNCHRONOUS, OK),
179 framer_(spdy_util_.spdy_version()), 171 framer_(HTTP2),
180 user_agent_(kUserAgent), 172 user_agent_(kUserAgent),
181 url_(kRequestUrl), 173 url_(kRequestUrl),
182 proxy_host_port_(kProxyHost, kProxyPort), 174 proxy_host_port_(kProxyHost, kProxyPort),
183 endpoint_host_port_pair_(kOriginHost, kOriginPort), 175 endpoint_host_port_pair_(kOriginHost, kOriginPort),
184 proxy_(ProxyServer::SCHEME_HTTPS, proxy_host_port_), 176 proxy_(ProxyServer::SCHEME_HTTPS, proxy_host_port_),
185 endpoint_spdy_session_key_(endpoint_host_port_pair_, 177 endpoint_spdy_session_key_(endpoint_host_port_pair_,
186 proxy_, 178 proxy_,
187 PRIVACY_MODE_DISABLED) { 179 PRIVACY_MODE_DISABLED) {
188 session_deps_.net_log = net_log_.bound().net_log(); 180 session_deps_.net_log = net_log_.bound().net_log();
189 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); 181 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority();
190 } 182 }
191 183
192 SpdyProxyClientSocketTest::~SpdyProxyClientSocketTest() { 184 SpdyProxyClientSocketTest::~SpdyProxyClientSocketTest() {
193 EXPECT_TRUE(data_->AllWriteDataConsumed()); 185 EXPECT_TRUE(data_->AllWriteDataConsumed());
194 EXPECT_TRUE(data_->AllReadDataConsumed()); 186 EXPECT_TRUE(data_->AllReadDataConsumed());
195 } 187 }
196 188
197 void SpdyProxyClientSocketTest::TearDown() { 189 void SpdyProxyClientSocketTest::TearDown() {
198 if (session_.get() != NULL) 190 if (session_.get() != NULL)
199 session_->spdy_session_pool()->CloseAllSessions(); 191 session_->spdy_session_pool()->CloseAllSessions();
200 192
201 // Empty the current queue. 193 // Empty the current queue.
202 base::RunLoop().RunUntilIdle(); 194 base::RunLoop().RunUntilIdle();
203 PlatformTest::TearDown(); 195 PlatformTest::TearDown();
204 } 196 }
205 197
206 NextProto SpdyProxyClientSocketTest::GetProtocol() const {
207 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2;
208 }
209
210 bool SpdyProxyClientSocketTest::GetDependenciesFromPriority() const { 198 bool SpdyProxyClientSocketTest::GetDependenciesFromPriority() const {
211 return GetParam() == kTestCaseHTTP2PriorityDependencies; 199 return GetParam() == kTestCasePriorityDependencies;
212 } 200 }
213 201
214 void SpdyProxyClientSocketTest::Initialize(MockRead* reads, 202 void SpdyProxyClientSocketTest::Initialize(MockRead* reads,
215 size_t reads_count, 203 size_t reads_count,
216 MockWrite* writes, 204 MockWrite* writes,
217 size_t writes_count) { 205 size_t writes_count) {
218 data_.reset( 206 data_.reset(
219 new SequencedSocketData(reads, reads_count, writes, writes_count)); 207 new SequencedSocketData(reads, reads_count, writes, writes_count));
220 data_->set_connect_data(connect_data_); 208 data_->set_connect_data(connect_data_);
221 209
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 EXPECT_EQ(rv, 307 EXPECT_EQ(rv,
320 sock_->Write(buf.get(), buf->size(), write_callback_.callback())); 308 sock_->Write(buf.get(), buf->size(), write_callback_.callback()));
321 } 309 }
322 310
323 void SpdyProxyClientSocketTest::AssertWriteLength(int len) { 311 void SpdyProxyClientSocketTest::AssertWriteLength(int len) {
324 EXPECT_EQ(len, write_callback_.WaitForResult()); 312 EXPECT_EQ(len, write_callback_.WaitForResult());
325 } 313 }
326 314
327 void SpdyProxyClientSocketTest::PopulateConnectRequestIR( 315 void SpdyProxyClientSocketTest::PopulateConnectRequestIR(
328 SpdyHeaderBlock* block) { 316 SpdyHeaderBlock* block) {
329 spdy_util_.MaybeAddVersionHeader(block);
330 (*block)[spdy_util_.GetMethodKey()] = "CONNECT"; 317 (*block)[spdy_util_.GetMethodKey()] = "CONNECT";
331 if (spdy_util_.spdy_version() == HTTP2) { 318 (*block)[spdy_util_.GetHostKey()] = kOriginHostPort;
332 (*block)[spdy_util_.GetHostKey()] = kOriginHostPort;
333 } else {
334 (*block)[spdy_util_.GetHostKey()] = kOriginHost;
335 (*block)[spdy_util_.GetPathKey()] = kOriginHostPort;
336 }
337 (*block)["user-agent"] = kUserAgent; 319 (*block)["user-agent"] = kUserAgent;
338 } 320 }
339 321
340 void SpdyProxyClientSocketTest::PopulateConnectReplyIR(SpdyHeaderBlock* block, 322 void SpdyProxyClientSocketTest::PopulateConnectReplyIR(SpdyHeaderBlock* block,
341 const char* status) { 323 const char* status) {
342 (*block)[spdy_util_.GetStatusKey()] = status; 324 (*block)[spdy_util_.GetStatusKey()] = status;
343 spdy_util_.MaybeAddVersionHeader(block);
344 } 325 }
345 326
346 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. 327 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request.
347 SpdySerializedFrame* SpdyProxyClientSocketTest::ConstructConnectRequestFrame() { 328 SpdySerializedFrame* SpdyProxyClientSocketTest::ConstructConnectRequestFrame() {
348 SpdyHeaderBlock block; 329 SpdyHeaderBlock block;
349 PopulateConnectRequestIR(&block); 330 PopulateConnectRequestIR(&block);
350 return spdy_util_.ConstructSpdySyn(kStreamId, std::move(block), LOWEST, 331 return spdy_util_.ConstructSpdySyn(kStreamId, std::move(block), LOWEST,
351 false); 332 false);
352 } 333 }
353 334
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 1375
1395 EXPECT_FALSE(sock_.get()); 1376 EXPECT_FALSE(sock_.get());
1396 EXPECT_TRUE(read_callback.have_result()); 1377 EXPECT_TRUE(read_callback.have_result());
1397 EXPECT_FALSE(write_callback_.have_result()); 1378 EXPECT_FALSE(write_callback_.have_result());
1398 1379
1399 // Let the RST_STREAM write while |rst| is in-scope. 1380 // Let the RST_STREAM write while |rst| is in-scope.
1400 base::RunLoop().RunUntilIdle(); 1381 base::RunLoop().RunUntilIdle();
1401 } 1382 }
1402 1383
1403 } // namespace net 1384 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698