| OLD | NEW |
| 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/quic/quic_headers_stream.h" | 5 #include "net/quic/quic_headers_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_utils.h" | 7 #include "net/quic/quic_utils.h" |
| 8 #include "net/quic/spdy_utils.h" | 8 #include "net/quic/spdy_utils.h" |
| 9 #include "net/quic/test_tools/quic_connection_peer.h" | 9 #include "net/quic/test_tools/quic_connection_peer.h" |
| 10 #include "net/quic/test_tools/quic_session_peer.h" | 10 #include "net/quic/test_tools/quic_session_peer.h" |
| 11 #include "net/quic/test_tools/quic_test_utils.h" | 11 #include "net/quic/test_tools/quic_test_utils.h" |
| 12 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 12 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 13 #include "net/spdy/spdy_protocol.h" | 13 #include "net/spdy/spdy_protocol.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using base::StringPiece; | 16 using base::StringPiece; |
| 17 using std::ostream; |
| 17 using std::string; | 18 using std::string; |
| 19 using std::vector; |
| 18 using testing::Invoke; | 20 using testing::Invoke; |
| 19 using testing::StrictMock; | 21 using testing::StrictMock; |
| 20 using testing::WithArgs; | 22 using testing::WithArgs; |
| 21 using testing::_; | 23 using testing::_; |
| 22 | 24 |
| 23 namespace net { | 25 namespace net { |
| 24 namespace test { | 26 namespace test { |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 class MockVisitor : public SpdyFramerVisitorInterface { | 29 class MockVisitor : public SpdyFramerVisitorInterface { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 MOCK_METHOD2(OnContinuation, void(SpdyStreamId stream_id, bool end)); | 67 MOCK_METHOD2(OnContinuation, void(SpdyStreamId stream_id, bool end)); |
| 66 MOCK_METHOD6(OnAltSvc, void(SpdyStreamId stream_id, | 68 MOCK_METHOD6(OnAltSvc, void(SpdyStreamId stream_id, |
| 67 uint32 max_age, | 69 uint32 max_age, |
| 68 uint16 port, | 70 uint16 port, |
| 69 StringPiece protocol_id, | 71 StringPiece protocol_id, |
| 70 StringPiece host, | 72 StringPiece host, |
| 71 StringPiece origin)); | 73 StringPiece origin)); |
| 72 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); | 74 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 class QuicHeadersStreamTest : public ::testing::TestWithParam<bool> { | 77 // Run all tests with each version, and client or server |
| 76 public: | 78 struct TestParams { |
| 77 static QuicVersionVector GetVersions() { | 79 TestParams(QuicVersion version, bool is_server) |
| 78 QuicVersionVector versions; | 80 : version(version), is_server(is_server) {} |
| 79 versions.push_back(QuicVersionMax()); | 81 |
| 80 return versions; | 82 friend ostream& operator<<(ostream& os, const TestParams& p) { |
| 83 os << "{ version: " << QuicVersionToString(p.version); |
| 84 os << ", is_server: " << p.is_server << " }"; |
| 85 return os; |
| 81 } | 86 } |
| 82 | 87 |
| 88 QuicVersion version; |
| 89 bool is_server; |
| 90 }; |
| 91 |
| 92 // Constructs various test permutations. |
| 93 vector<TestParams> GetTestParams() { |
| 94 vector<TestParams> params; |
| 95 QuicVersionVector all_supported_versions = QuicSupportedVersions(); |
| 96 for (const QuicVersion version : all_supported_versions) { |
| 97 params.push_back(TestParams(version, false)); |
| 98 params.push_back(TestParams(version, true)); |
| 99 } |
| 100 return params; |
| 101 } |
| 102 |
| 103 class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> { |
| 104 public: |
| 83 QuicHeadersStreamTest() | 105 QuicHeadersStreamTest() |
| 84 : connection_(new StrictMock<MockConnection>(is_server(), GetVersions())), | 106 : connection_(new StrictMock<MockConnection>(is_server(), GetVersion())), |
| 85 session_(connection_), | 107 session_(connection_), |
| 86 headers_stream_(QuicSessionPeer::GetHeadersStream(&session_)), | 108 headers_stream_(QuicSessionPeer::GetHeadersStream(&session_)), |
| 87 body_("hello world"), | 109 body_("hello world"), |
| 88 framer_(SPDY3) { | 110 framer_(version() > QUIC_VERSION_23 ? SPDY4 : SPDY3) { |
| 89 headers_[":version"] = "HTTP/1.1"; | 111 headers_[":version"] = "HTTP/1.1"; |
| 90 headers_[":status"] = "200 Ok"; | 112 headers_[":status"] = "200 Ok"; |
| 91 headers_["content-length"] = "11"; | 113 headers_["content-length"] = "11"; |
| 92 framer_.set_visitor(&visitor_); | 114 framer_.set_visitor(&visitor_); |
| 93 EXPECT_EQ(QuicVersionMax(), session_.connection()->version()); | 115 EXPECT_EQ(version(), session_.connection()->version()); |
| 94 EXPECT_TRUE(headers_stream_ != nullptr); | 116 EXPECT_TRUE(headers_stream_ != nullptr); |
| 117 VLOG(1) << GetParam(); |
| 95 } | 118 } |
| 96 | 119 |
| 97 QuicConsumedData SaveIov(const IOVector& data) { | 120 QuicConsumedData SaveIov(const IOVector& data) { |
| 98 const iovec* iov = data.iovec(); | 121 const iovec* iov = data.iovec(); |
| 99 int count = data.Capacity(); | 122 int count = data.Capacity(); |
| 100 for (int i = 0 ; i < count; ++i) { | 123 for (int i = 0 ; i < count; ++i) { |
| 101 saved_data_.append(static_cast<char*>(iov[i].iov_base), iov[i].iov_len); | 124 saved_data_.append(static_cast<char*>(iov[i].iov_base), iov[i].iov_len); |
| 102 } | 125 } |
| 103 return QuicConsumedData(saved_data_.length(), false); | 126 return QuicConsumedData(saved_data_.length(), false); |
| 104 } | 127 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 123 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); | 146 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); |
| 124 } | 147 } |
| 125 | 148 |
| 126 void WriteHeadersAndCheckData(QuicStreamId stream_id, | 149 void WriteHeadersAndCheckData(QuicStreamId stream_id, |
| 127 bool fin, | 150 bool fin, |
| 128 QuicPriority priority, | 151 QuicPriority priority, |
| 129 SpdyFrameType type) { | 152 SpdyFrameType type) { |
| 130 // Write the headers and capture the outgoing data | 153 // Write the headers and capture the outgoing data |
| 131 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, _, nullptr)) | 154 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, _, nullptr)) |
| 132 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); | 155 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
| 133 headers_stream_->WriteHeaders(stream_id, headers_, fin, nullptr); | 156 headers_stream_->WriteHeaders(stream_id, headers_, fin, priority, nullptr); |
| 134 | 157 |
| 135 // Parse the outgoing data and check that it matches was was written. | 158 // Parse the outgoing data and check that it matches was was written. |
| 136 if (type == SYN_STREAM) { | 159 if (type == SYN_STREAM) { |
| 137 EXPECT_CALL(visitor_, OnSynStream(stream_id, kNoAssociatedStream, 0, | 160 if (version() > QUIC_VERSION_23) { |
| 138 // priority, | 161 EXPECT_CALL(visitor_, OnHeaders(stream_id, kHasPriority, priority, fin, |
| 139 fin, kNotUnidirectional)); | 162 kFrameComplete)); |
| 163 } else { |
| 164 EXPECT_CALL(visitor_, |
| 165 OnSynStream(stream_id, kNoAssociatedStream, |
| 166 /*priority=*/0, fin, kNotUnidirectional)); |
| 167 } |
| 140 } else { | 168 } else { |
| 141 EXPECT_CALL(visitor_, OnSynReply(stream_id, fin)); | 169 if (version() > QUIC_VERSION_23) { |
| 170 EXPECT_CALL(visitor_, OnHeaders(stream_id, !kHasPriority, |
| 171 /*priority=*/0, fin, kFrameComplete)); |
| 172 } else { |
| 173 EXPECT_CALL(visitor_, OnSynReply(stream_id, fin)); |
| 174 } |
| 142 } | 175 } |
| 143 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) | 176 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) |
| 144 .WillRepeatedly(WithArgs<1, 2>( | 177 .WillRepeatedly(WithArgs<1, 2>( |
| 145 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); | 178 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); |
| 146 if (fin) { | 179 if (fin) { |
| 147 EXPECT_CALL(visitor_, OnStreamFrameData(stream_id, nullptr, 0, true)); | 180 EXPECT_CALL(visitor_, OnStreamFrameData(stream_id, nullptr, 0, true)); |
| 148 } | 181 } |
| 149 framer_.ProcessInput(saved_data_.data(), saved_data_.length()); | 182 framer_.ProcessInput(saved_data_.data(), saved_data_.length()); |
| 150 EXPECT_FALSE(framer_.HasError()) << framer_.error_code(); | 183 EXPECT_FALSE(framer_.HasError()) |
| 184 << SpdyFramer::ErrorCodeToString(framer_.error_code()); |
| 151 | 185 |
| 152 CheckHeaders(); | 186 CheckHeaders(); |
| 153 saved_data_.clear(); | 187 saved_data_.clear(); |
| 154 } | 188 } |
| 155 | 189 |
| 156 void CheckHeaders() { | 190 void CheckHeaders() { |
| 157 SpdyHeaderBlock headers; | 191 SpdyHeaderBlock headers; |
| 158 EXPECT_EQ(saved_header_data_.length(), | 192 EXPECT_EQ(saved_header_data_.length(), |
| 159 framer_.ParseHeaderBlockInBuffer(saved_header_data_.data(), | 193 framer_.ParseHeaderBlockInBuffer(saved_header_data_.data(), |
| 160 saved_header_data_.length(), | 194 saved_header_data_.length(), |
| 161 &headers)); | 195 &headers)); |
| 162 EXPECT_EQ(headers_, headers); | 196 EXPECT_EQ(headers_, headers); |
| 163 saved_header_data_.clear(); | 197 saved_header_data_.clear(); |
| 164 } | 198 } |
| 165 | 199 |
| 166 bool is_server() { | 200 bool is_server() { return GetParam().is_server; } |
| 167 return GetParam(); | 201 |
| 202 QuicVersion version() { return GetParam().version; } |
| 203 |
| 204 QuicVersionVector GetVersion() { |
| 205 QuicVersionVector versions; |
| 206 versions.push_back(version()); |
| 207 return versions; |
| 168 } | 208 } |
| 169 | 209 |
| 170 void CloseConnection() { | 210 void CloseConnection() { |
| 171 QuicConnectionPeer::CloseConnection(connection_); | 211 QuicConnectionPeer::CloseConnection(connection_); |
| 172 } | 212 } |
| 173 | 213 |
| 214 static const bool kFrameComplete = true; |
| 215 static const bool kHasPriority = true; |
| 174 static const bool kNotUnidirectional = false; | 216 static const bool kNotUnidirectional = false; |
| 175 static const bool kNoAssociatedStream = false; | 217 static const bool kNoAssociatedStream = false; |
| 176 | 218 |
| 177 StrictMock<MockConnection>* connection_; | 219 StrictMock<MockConnection>* connection_; |
| 178 StrictMock<MockSession> session_; | 220 StrictMock<MockSession> session_; |
| 179 QuicHeadersStream* headers_stream_; | 221 QuicHeadersStream* headers_stream_; |
| 180 SpdyHeaderBlock headers_; | 222 SpdyHeaderBlock headers_; |
| 181 string body_; | 223 string body_; |
| 182 string saved_data_; | 224 string saved_data_; |
| 183 string saved_header_data_; | 225 string saved_header_data_; |
| 184 SpdyFramer framer_; | 226 SpdyFramer framer_; |
| 185 StrictMock<MockVisitor> visitor_; | 227 StrictMock<MockVisitor> visitor_; |
| 186 }; | 228 }; |
| 187 | 229 |
| 188 INSTANTIATE_TEST_CASE_P(Tests, QuicHeadersStreamTest, testing::Bool()); | 230 INSTANTIATE_TEST_CASE_P(Tests, |
| 231 QuicHeadersStreamTest, |
| 232 ::testing::ValuesIn(GetTestParams())); |
| 189 | 233 |
| 190 TEST_P(QuicHeadersStreamTest, StreamId) { | 234 TEST_P(QuicHeadersStreamTest, StreamId) { |
| 191 EXPECT_EQ(3u, headers_stream_->id()); | 235 EXPECT_EQ(3u, headers_stream_->id()); |
| 192 } | 236 } |
| 193 | 237 |
| 194 TEST_P(QuicHeadersStreamTest, EffectivePriority) { | 238 TEST_P(QuicHeadersStreamTest, EffectivePriority) { |
| 195 EXPECT_EQ(0u, headers_stream_->EffectivePriority()); | 239 EXPECT_EQ(0u, headers_stream_->EffectivePriority()); |
| 196 } | 240 } |
| 197 | 241 |
| 198 TEST_P(QuicHeadersStreamTest, WriteHeaders) { | 242 TEST_P(QuicHeadersStreamTest, WriteHeaders) { |
| 199 for (QuicStreamId stream_id = kClientDataStreamId1; | 243 for (QuicStreamId stream_id = kClientDataStreamId1; |
| 200 stream_id < kClientDataStreamId3; stream_id += 2) { | 244 stream_id < kClientDataStreamId3; stream_id += 2) { |
| 201 for (int count = 0; count < 2; ++count) { | 245 for (int count = 0; count < 2; ++count) { |
| 202 bool fin = (count == 0); | 246 bool fin = (count == 0); |
| 203 if (is_server()) { | 247 if (is_server()) { |
| 204 WriteHeadersAndExpectSynReply(stream_id, fin); | 248 WriteHeadersAndExpectSynReply(stream_id, fin); |
| 205 } else { | 249 } else { |
| 206 for (QuicPriority priority = 0; priority < 7; ++priority) { | 250 for (QuicPriority priority = 0; priority < 7; ++priority) { |
| 207 WriteHeadersAndExpectSynStream(stream_id, fin, priority); | 251 // TODO(rch): implement priorities correctly. |
| 252 WriteHeadersAndExpectSynStream(stream_id, fin, 0); |
| 208 } | 253 } |
| 209 } | 254 } |
| 210 } | 255 } |
| 211 } | 256 } |
| 212 } | 257 } |
| 213 | 258 |
| 214 TEST_P(QuicHeadersStreamTest, ProcessRawData) { | 259 TEST_P(QuicHeadersStreamTest, ProcessRawData) { |
| 215 for (QuicStreamId stream_id = kClientDataStreamId1; | 260 for (QuicStreamId stream_id = kClientDataStreamId1; |
| 216 stream_id < kClientDataStreamId3; stream_id += 2) { | 261 stream_id < kClientDataStreamId3; stream_id += 2) { |
| 217 for (int count = 0; count < 2; ++count) { | 262 for (int count = 0; count < 2; ++count) { |
| 218 bool fin = (count == 0); | 263 bool fin = (count == 0); |
| 219 for (QuicPriority priority = 0; priority < 7; ++priority) { | 264 for (QuicPriority priority = 0; priority < 7; ++priority) { |
| 220 // Replace with "WriteHeadersAndSaveData" | 265 // Replace with "WriteHeadersAndSaveData" |
| 221 scoped_ptr<SpdySerializedFrame> frame; | 266 scoped_ptr<SpdySerializedFrame> frame; |
| 222 if (is_server()) { | 267 if (is_server()) { |
| 223 SpdySynStreamIR syn_stream(stream_id); | 268 if (version() > QUIC_VERSION_23) { |
| 224 syn_stream.set_name_value_block(headers_); | 269 SpdyHeadersIR headers_frame(stream_id); |
| 225 syn_stream.set_fin(fin); | 270 headers_frame.set_name_value_block(headers_); |
| 226 frame.reset(framer_.SerializeSynStream(syn_stream)); | 271 headers_frame.set_fin(fin); |
| 272 headers_frame.set_has_priority(true); |
| 273 frame.reset(framer_.SerializeFrame(headers_frame)); |
| 274 } else { |
| 275 SpdySynStreamIR syn_stream(stream_id); |
| 276 syn_stream.set_name_value_block(headers_); |
| 277 syn_stream.set_fin(fin); |
| 278 frame.reset(framer_.SerializeSynStream(syn_stream)); |
| 279 } |
| 227 EXPECT_CALL(session_, OnStreamHeadersPriority(stream_id, 0)); | 280 EXPECT_CALL(session_, OnStreamHeadersPriority(stream_id, 0)); |
| 228 } else { | 281 } else { |
| 229 SpdySynReplyIR syn_reply(stream_id); | 282 if (version() > QUIC_VERSION_23) { |
| 230 syn_reply.set_name_value_block(headers_); | 283 SpdyHeadersIR headers_frame(stream_id); |
| 231 syn_reply.set_fin(fin); | 284 headers_frame.set_name_value_block(headers_); |
| 232 frame.reset(framer_.SerializeSynReply(syn_reply)); | 285 headers_frame.set_fin(fin); |
| 286 frame.reset(framer_.SerializeFrame(headers_frame)); |
| 287 } else { |
| 288 SpdySynReplyIR syn_reply(stream_id); |
| 289 syn_reply.set_name_value_block(headers_); |
| 290 syn_reply.set_fin(fin); |
| 291 frame.reset(framer_.SerializeSynReply(syn_reply)); |
| 292 } |
| 233 } | 293 } |
| 234 EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)) | 294 EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)) |
| 235 .WillRepeatedly(WithArgs<1>( | 295 .WillRepeatedly(WithArgs<1>( |
| 236 Invoke(this, | 296 Invoke(this, |
| 237 &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); | 297 &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); |
| 238 EXPECT_CALL(session_, | 298 EXPECT_CALL(session_, |
| 239 OnStreamHeadersComplete(stream_id, fin, frame->size())); | 299 OnStreamHeadersComplete(stream_id, fin, frame->size())); |
| 240 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 300 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 241 | |
| 242 CheckHeaders(); | 301 CheckHeaders(); |
| 243 } | 302 } |
| 244 } | 303 } |
| 304 } |
| 305 } |
| 306 |
| 307 TEST_P(QuicHeadersStreamTest, ProcessLargeRawData) { |
| 308 // We want to create a frame that is more than the SPDY Framer's max control |
| 309 // frame size, which is 16K, but less than the HPACK decoders max decode |
| 310 // buffer size, which is 32K. |
| 311 headers_["key0"] = string(1 << 13, '.'); |
| 312 headers_["key1"] = string(1 << 13, '.'); |
| 313 headers_["key2"] = string(1 << 13, '.'); |
| 314 for (QuicStreamId stream_id = kClientDataStreamId1; |
| 315 stream_id < kClientDataStreamId3; stream_id += 2) { |
| 316 for (int count = 0; count < 2; ++count) { |
| 317 bool fin = (count == 0); |
| 318 for (QuicPriority priority = 0; priority < 7; ++priority) { |
| 319 // Replace with "WriteHeadersAndSaveData" |
| 320 scoped_ptr<SpdySerializedFrame> frame; |
| 321 if (is_server()) { |
| 322 if (version() > QUIC_VERSION_23) { |
| 323 SpdyHeadersIR headers_frame(stream_id); |
| 324 headers_frame.set_name_value_block(headers_); |
| 325 headers_frame.set_fin(fin); |
| 326 headers_frame.set_has_priority(true); |
| 327 frame.reset(framer_.SerializeFrame(headers_frame)); |
| 328 } else { |
| 329 SpdySynStreamIR syn_stream(stream_id); |
| 330 syn_stream.set_name_value_block(headers_); |
| 331 syn_stream.set_fin(fin); |
| 332 frame.reset(framer_.SerializeSynStream(syn_stream)); |
| 333 } |
| 334 EXPECT_CALL(session_, OnStreamHeadersPriority(stream_id, 0)); |
| 335 } else { |
| 336 if (version() > QUIC_VERSION_23) { |
| 337 SpdyHeadersIR headers_frame(stream_id); |
| 338 headers_frame.set_name_value_block(headers_); |
| 339 headers_frame.set_fin(fin); |
| 340 frame.reset(framer_.SerializeFrame(headers_frame)); |
| 341 } else { |
| 342 SpdySynReplyIR syn_reply(stream_id); |
| 343 syn_reply.set_name_value_block(headers_); |
| 344 syn_reply.set_fin(fin); |
| 345 frame.reset(framer_.SerializeSynReply(syn_reply)); |
| 346 } |
| 347 } |
| 348 EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)) |
| 349 .WillRepeatedly(WithArgs<1>(Invoke( |
| 350 this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); |
| 351 EXPECT_CALL(session_, |
| 352 OnStreamHeadersComplete(stream_id, fin, frame->size())); |
| 353 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 354 CheckHeaders(); |
| 355 } |
| 356 } |
| 245 } | 357 } |
| 246 } | 358 } |
| 247 | 359 |
| 248 TEST_P(QuicHeadersStreamTest, ProcessBadData) { | 360 TEST_P(QuicHeadersStreamTest, ProcessBadData) { |
| 249 const char kBadData[] = "blah blah blah"; | 361 const char kBadData[] = "blah blah blah"; |
| 250 EXPECT_CALL(*connection_, | 362 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails( |
| 251 SendConnectionCloseWithDetails( | 363 QUIC_INVALID_HEADERS_STREAM_DATA, _)) |
| 252 QUIC_INVALID_HEADERS_STREAM_DATA, | 364 .Times(::testing::AnyNumber()); |
| 253 "SPDY framing error: SPDY_INVALID_DATA_FRAME_FLAGS")); | |
| 254 headers_stream_->ProcessRawData(kBadData, strlen(kBadData)); | 365 headers_stream_->ProcessRawData(kBadData, strlen(kBadData)); |
| 255 } | 366 } |
| 256 | 367 |
| 257 TEST_P(QuicHeadersStreamTest, ProcessSpdyDataFrame) { | 368 TEST_P(QuicHeadersStreamTest, ProcessSpdyDataFrame) { |
| 258 SpdyDataIR data(2, ""); | 369 SpdyDataIR data(2, ""); |
| 259 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); | 370 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); |
| 260 EXPECT_CALL(*connection_, | 371 EXPECT_CALL(*connection_, |
| 261 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, | 372 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 262 "SPDY DATA frame received.")) | 373 "SPDY DATA frame received.")) |
| 263 .WillOnce(InvokeWithoutArgs(this, | 374 .WillOnce(InvokeWithoutArgs(this, |
| 264 &QuicHeadersStreamTest::CloseConnection)); | 375 &QuicHeadersStreamTest::CloseConnection)); |
| 265 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 376 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 266 } | 377 } |
| 267 | 378 |
| 268 TEST_P(QuicHeadersStreamTest, ProcessSpdyRstStreamFrame) { | 379 TEST_P(QuicHeadersStreamTest, ProcessSpdyRstStreamFrame) { |
| 269 SpdyRstStreamIR data(2, RST_STREAM_PROTOCOL_ERROR, ""); | 380 SpdyRstStreamIR data(2, RST_STREAM_PROTOCOL_ERROR, ""); |
| 270 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); | 381 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); |
| 271 EXPECT_CALL(*connection_, | 382 EXPECT_CALL(*connection_, |
| 272 SendConnectionCloseWithDetails( | 383 SendConnectionCloseWithDetails( |
| 273 QUIC_INVALID_HEADERS_STREAM_DATA, | 384 QUIC_INVALID_HEADERS_STREAM_DATA, |
| 274 "SPDY RST_STREAM frame received.")) | 385 "SPDY RST_STREAM frame received.")) |
| 275 .WillOnce(InvokeWithoutArgs(this, | 386 .WillOnce(InvokeWithoutArgs(this, |
| 276 &QuicHeadersStreamTest::CloseConnection)); | 387 &QuicHeadersStreamTest::CloseConnection)); |
| 277 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 388 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 278 } | 389 } |
| 279 | 390 |
| 280 TEST_P(QuicHeadersStreamTest, ProcessSpdySettingsFrame) { | 391 TEST_P(QuicHeadersStreamTest, ProcessSpdySettingsFrame) { |
| 281 SpdySettingsIR data; | 392 SpdySettingsIR data; |
| 282 data.AddSetting(SETTINGS_UPLOAD_BANDWIDTH, true, true, 0); | 393 if (version() > QUIC_VERSION_23) { |
| 394 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, true, true, 0); |
| 395 } else { |
| 396 data.AddSetting(SETTINGS_UPLOAD_BANDWIDTH, true, true, 0); |
| 397 } |
| 283 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); | 398 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); |
| 284 EXPECT_CALL(*connection_, | 399 EXPECT_CALL(*connection_, |
| 285 SendConnectionCloseWithDetails( | 400 SendConnectionCloseWithDetails( |
| 286 QUIC_INVALID_HEADERS_STREAM_DATA, | 401 QUIC_INVALID_HEADERS_STREAM_DATA, |
| 287 "SPDY SETTINGS frame received.")) | 402 "SPDY SETTINGS frame received.")) |
| 288 .WillOnce(InvokeWithoutArgs(this, | 403 .WillOnce(InvokeWithoutArgs(this, |
| 289 &QuicHeadersStreamTest::CloseConnection)); | 404 &QuicHeadersStreamTest::CloseConnection)); |
| 290 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 405 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 291 } | 406 } |
| 292 | 407 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 306 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); | 421 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); |
| 307 EXPECT_CALL(*connection_, | 422 EXPECT_CALL(*connection_, |
| 308 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, | 423 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 309 "SPDY GOAWAY frame received.")) | 424 "SPDY GOAWAY frame received.")) |
| 310 .WillOnce(InvokeWithoutArgs(this, | 425 .WillOnce(InvokeWithoutArgs(this, |
| 311 &QuicHeadersStreamTest::CloseConnection)); | 426 &QuicHeadersStreamTest::CloseConnection)); |
| 312 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 427 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 313 } | 428 } |
| 314 | 429 |
| 315 TEST_P(QuicHeadersStreamTest, ProcessSpdyHeadersFrame) { | 430 TEST_P(QuicHeadersStreamTest, ProcessSpdyHeadersFrame) { |
| 431 if (version() > QUIC_VERSION_23) { |
| 432 // HEADERS frames are an error when using SPDY/3, but |
| 433 // when using SPDY/4 they're the "normal" way of sending headers |
| 434 // so we test their handling in the ProcessRawData test. |
| 435 return; |
| 436 } |
| 316 SpdyHeadersIR data(1); | 437 SpdyHeadersIR data(1); |
| 317 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); | 438 scoped_ptr<SpdySerializedFrame> frame(framer_.SerializeFrame(data)); |
| 318 EXPECT_CALL(*connection_, | 439 EXPECT_CALL(*connection_, |
| 319 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, | 440 SendConnectionCloseWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 320 "SPDY HEADERS frame received.")) | 441 "SPDY HEADERS frame received.")) |
| 321 .WillOnce(InvokeWithoutArgs(this, | 442 .WillOnce(InvokeWithoutArgs(this, |
| 322 &QuicHeadersStreamTest::CloseConnection)); | 443 &QuicHeadersStreamTest::CloseConnection)); |
| 323 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 444 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
| 324 } | 445 } |
| 325 | 446 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 337 | 458 |
| 338 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { | 459 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { |
| 339 EXPECT_TRUE(headers_stream_->flow_controller()->IsEnabled()); | 460 EXPECT_TRUE(headers_stream_->flow_controller()->IsEnabled()); |
| 340 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( | 461 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( |
| 341 headers_stream_)); | 462 headers_stream_)); |
| 342 } | 463 } |
| 343 | 464 |
| 344 } // namespace | 465 } // namespace |
| 345 } // namespace test | 466 } // namespace test |
| 346 } // namespace net | 467 } // namespace net |
| OLD | NEW |