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

Side by Side Diff: net/spdy/spdy_stream_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_session_unittest.cc ('k') | net/spdy/spdy_test_util_common.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_stream.h" 5 #include "net/spdy/spdy_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <limits> 10 #include <limits>
(...skipping 27 matching lines...) Expand all
38 38
39 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc 39 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc
40 // 40 //
41 namespace net { 41 namespace net {
42 42
43 namespace test { 43 namespace test {
44 44
45 namespace { 45 namespace {
46 46
47 enum TestCase { 47 enum TestCase {
48 // Test using the SPDY/3.1 protocol. 48 // Test without specifying a stream dependency based on the RequestPriority.
49 kTestCaseSPDY31, 49 kTestCaseNoPriorityDependencies,
50 50
51 // Test using the HTTP/2 protocol, without specifying a stream 51 // Test specifying a stream dependency based on the RequestPriority.
52 // dependency based on the RequestPriority. 52 kTestCasePriorityDependencies
53 kTestCaseHTTP2NoPriorityDependencies,
54
55 // Test using the HTTP/2 protocol, specifying a stream
56 // dependency based on the RequestPriority.
57 kTestCaseHTTP2PriorityDependencies
58 }; 53 };
59 54
60 const char kStreamUrl[] = "http://www.example.org/"; 55 const char kStreamUrl[] = "http://www.example.org/";
61 const char kPostBody[] = "\0hello!\xff"; 56 const char kPostBody[] = "\0hello!\xff";
62 const size_t kPostBodyLength = arraysize(kPostBody); 57 const size_t kPostBodyLength = arraysize(kPostBody);
63 const base::StringPiece kPostBodyStringPiece(kPostBody, kPostBodyLength); 58 const base::StringPiece kPostBodyStringPiece(kPostBody, kPostBodyLength);
64 59
65 } // namespace 60 } // namespace
66 61
67 class SpdyStreamTest : public ::testing::Test, 62 class SpdyStreamTest : public ::testing::Test,
68 public ::testing::WithParamInterface<TestCase> { 63 public ::testing::WithParamInterface<TestCase> {
69 protected: 64 protected:
70 // A function that takes a SpdyStream and the number of bytes which 65 // A function that takes a SpdyStream and the number of bytes which
71 // will unstall the next frame completely. 66 // will unstall the next frame completely.
72 typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32_t)> 67 typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32_t)>
73 UnstallFunction; 68 UnstallFunction;
74 69
75 SpdyStreamTest() 70 SpdyStreamTest() : spdy_util_(GetDependenciesFromPriority()), offset_(0) {
76 : spdy_util_(GetProtocol(), GetDependenciesFromPriority()),
77 session_deps_(GetProtocol()),
78 offset_(0) {
79 spdy_util_.set_default_url(GURL(kStreamUrl)); 71 spdy_util_.set_default_url(GURL(kStreamUrl));
80 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); 72 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority();
81 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 73 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
82 } 74 }
83 75
84 ~SpdyStreamTest() { 76 ~SpdyStreamTest() {
85 } 77 }
86 78
87 base::WeakPtr<SpdySession> CreateDefaultSpdySession() { 79 base::WeakPtr<SpdySession> CreateDefaultSpdySession() {
88 SpdySessionKey key(HostPortPair("www.example.org", 80), 80 SpdySessionKey key(HostPortPair("www.example.org", 80),
89 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); 81 ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
90 return CreateInsecureSpdySession(session_.get(), key, BoundNetLog()); 82 return CreateInsecureSpdySession(session_.get(), key, BoundNetLog());
91 } 83 }
92 84
93 void TearDown() override { base::RunLoop().RunUntilIdle(); } 85 void TearDown() override { base::RunLoop().RunUntilIdle(); }
94 86
95 NextProto GetProtocol() const {
96 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2;
97 }
98
99 bool GetDependenciesFromPriority() const { 87 bool GetDependenciesFromPriority() const {
100 return GetParam() == kTestCaseHTTP2PriorityDependencies; 88 return GetParam() == kTestCasePriorityDependencies;
101 } 89 }
102 90
103 void RunResumeAfterUnstallRequestResponseTest( 91 void RunResumeAfterUnstallRequestResponseTest(
104 const UnstallFunction& unstall_function); 92 const UnstallFunction& unstall_function);
105 93
106 void RunResumeAfterUnstallBidirectionalTest( 94 void RunResumeAfterUnstallBidirectionalTest(
107 const UnstallFunction& unstall_function); 95 const UnstallFunction& unstall_function);
108 96
109 // Add{Read,Write}() populates lists that are eventually passed to a 97 // Add{Read,Write}() populates lists that are eventually passed to a
110 // SocketData class. |frame| must live for the whole test. 98 // SocketData class. |frame| must live for the whole test.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 142
155 private: 143 private:
156 // Used by Add{Read,Write}() above. 144 // Used by Add{Read,Write}() above.
157 std::vector<MockWrite> writes_; 145 std::vector<MockWrite> writes_;
158 std::vector<MockRead> reads_; 146 std::vector<MockRead> reads_;
159 int offset_; 147 int offset_;
160 }; 148 };
161 149
162 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend, 150 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
163 SpdyStreamTest, 151 SpdyStreamTest,
164 testing::Values(kTestCaseSPDY31, 152 testing::Values(kTestCaseNoPriorityDependencies,
165 kTestCaseHTTP2NoPriorityDependencies, 153 kTestCasePriorityDependencies));
166 kTestCaseHTTP2PriorityDependencies));
167 154
168 TEST_P(SpdyStreamTest, SendDataAfterOpen) { 155 TEST_P(SpdyStreamTest, SendDataAfterOpen) {
169 GURL url(kStreamUrl); 156 GURL url(kStreamUrl);
170 157
171 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( 158 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
172 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); 159 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
173 AddWrite(*req); 160 AddWrite(*req);
174 161
175 std::unique_ptr<SpdySerializedFrame> resp( 162 std::unique_ptr<SpdySerializedFrame> resp(
176 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 163 spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // Set required request headers. 319 // Set required request headers.
333 SpdyHeaderBlock request_headers; 320 SpdyHeaderBlock request_headers;
334 spdy_util_.AddUrlToHeaderBlock(kStreamUrl, &request_headers); 321 spdy_util_.AddUrlToHeaderBlock(kStreamUrl, &request_headers);
335 stream->OnPushPromiseHeadersReceived(request_headers); 322 stream->OnPushPromiseHeadersReceived(request_headers);
336 323
337 base::Time response_time = base::Time::Now(); 324 base::Time response_time = base::Time::Now();
338 base::TimeTicks first_byte_time = base::TimeTicks::Now(); 325 base::TimeTicks first_byte_time = base::TimeTicks::Now();
339 // Send some basic response headers. 326 // Send some basic response headers.
340 SpdyHeaderBlock response; 327 SpdyHeaderBlock response;
341 response[spdy_util_.GetStatusKey()] = "200"; 328 response[spdy_util_.GetStatusKey()] = "200";
342 response[spdy_util_.GetVersionKey()] = "OK";
343 stream->OnInitialResponseHeadersReceived(response, response_time, 329 stream->OnInitialResponseHeadersReceived(response, response_time,
344 first_byte_time); 330 first_byte_time);
345 331
346 // And some more headers. 332 // And some more headers.
347 // TODO(baranovich): not valid for HTTP 2. 333 // TODO(baranovich): not valid for HTTP 2.
348 SpdyHeaderBlock headers; 334 SpdyHeaderBlock headers;
349 headers["alpha"] = "beta"; 335 headers["alpha"] = "beta";
350 stream->OnAdditionalResponseHeadersReceived(headers); 336 stream->OnAdditionalResponseHeadersReceived(headers);
351 337
352 EXPECT_TRUE(stream->HasUrlFromHeaders()); 338 EXPECT_TRUE(stream->HasUrlFromHeaders());
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1113
1128 std::unique_ptr<SpdyHeaderBlock> headers( 1114 std::unique_ptr<SpdyHeaderBlock> headers(
1129 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kStreamUrl))); 1115 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kStreamUrl)));
1130 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequestHeaders(std::move(headers), 1116 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequestHeaders(std::move(headers),
1131 NO_MORE_DATA_TO_SEND)); 1117 NO_MORE_DATA_TO_SEND));
1132 EXPECT_TRUE(stream->HasUrlFromHeaders()); 1118 EXPECT_TRUE(stream->HasUrlFromHeaders());
1133 EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec()); 1119 EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec());
1134 1120
1135 int64_t reply_frame_len = reply->size(); 1121 int64_t reply_frame_len = reply->size();
1136 int64_t data_header_len = SpdyConstants::GetDataFrameMinimumSize( 1122 int64_t data_header_len = SpdyConstants::GetDataFrameMinimumSize(
1137 NextProtoToSpdyMajorVersion(GetProtocol())); 1123 NextProtoToSpdyMajorVersion(kProtoHTTP2));
1138 int64_t data_frame_len = data_header_len + kPostBodyLength; 1124 int64_t data_frame_len = data_header_len + kPostBodyLength;
1139 int64_t response_len = reply_frame_len + data_frame_len; 1125 int64_t response_len = reply_frame_len + data_frame_len;
1140 1126
1141 EXPECT_EQ(0, stream->raw_received_bytes()); 1127 EXPECT_EQ(0, stream->raw_received_bytes());
1142 1128
1143 // SYN 1129 // SYN
1144 data.RunUntilPaused(); 1130 data.RunUntilPaused();
1145 EXPECT_EQ(0, stream->raw_received_bytes()); 1131 EXPECT_EQ(0, stream->raw_received_bytes());
1146 1132
1147 // REPLY 1133 // REPLY
1148 data.Resume(); 1134 data.Resume();
1149 data.RunUntilPaused(); 1135 data.RunUntilPaused();
1150 EXPECT_EQ(reply_frame_len, stream->raw_received_bytes()); 1136 EXPECT_EQ(reply_frame_len, stream->raw_received_bytes());
1151 1137
1152 // DATA 1138 // DATA
1153 data.Resume(); 1139 data.Resume();
1154 data.RunUntilPaused(); 1140 data.RunUntilPaused();
1155 EXPECT_EQ(response_len, stream->raw_received_bytes()); 1141 EXPECT_EQ(response_len, stream->raw_received_bytes());
1156 1142
1157 // FIN 1143 // FIN
1158 data.Resume(); 1144 data.Resume();
1159 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED)); 1145 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
1160 } 1146 }
1161 1147
1162 } // namespace test 1148 } // namespace test
1163 1149
1164 } // namespace net 1150 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_unittest.cc ('k') | net/spdy/spdy_test_util_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698