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_spdy_session_peer.h" | 10 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, bool fin) { | 171 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, bool fin) { |
172 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); | 172 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); |
173 } | 173 } |
174 | 174 |
175 void WriteHeadersAndCheckData(QuicStreamId stream_id, | 175 void WriteHeadersAndCheckData(QuicStreamId stream_id, |
176 bool fin, | 176 bool fin, |
177 SpdyPriority priority, | 177 SpdyPriority priority, |
178 SpdyFrameType type) { | 178 SpdyFrameType type) { |
179 // Write the headers and capture the outgoing data | 179 // Write the headers and capture the outgoing data |
180 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, nullptr)) | 180 EXPECT_CALL(session_, WritevData(headers_stream_, kHeadersStreamId, _, _, |
181 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); | 181 false, nullptr)) |
| 182 .WillOnce(WithArgs<2>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
182 headers_stream_->WriteHeaders(stream_id, headers_, fin, priority, nullptr); | 183 headers_stream_->WriteHeaders(stream_id, headers_, fin, priority, nullptr); |
183 | 184 |
184 // Parse the outgoing data and check that it matches was was written. | 185 // Parse the outgoing data and check that it matches was was written. |
185 if (type == SYN_STREAM) { | 186 if (type == SYN_STREAM) { |
186 EXPECT_CALL(visitor_, | 187 EXPECT_CALL(visitor_, |
187 OnHeaders(stream_id, kHasPriority, priority, | 188 OnHeaders(stream_id, kHasPriority, priority, |
188 /*parent_stream_id=*/0, | 189 /*parent_stream_id=*/0, |
189 /*exclusive=*/false, fin, kFrameComplete)); | 190 /*exclusive=*/false, fin, kFrameComplete)); |
190 } else { | 191 } else { |
191 EXPECT_CALL(visitor_, | 192 EXPECT_CALL(visitor_, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 274 } |
274 } | 275 } |
275 } | 276 } |
276 | 277 |
277 TEST_P(QuicHeadersStreamTest, WritePushPromises) { | 278 TEST_P(QuicHeadersStreamTest, WritePushPromises) { |
278 for (QuicStreamId stream_id = kClientDataStreamId1; | 279 for (QuicStreamId stream_id = kClientDataStreamId1; |
279 stream_id < kClientDataStreamId3; stream_id += 2) { | 280 stream_id < kClientDataStreamId3; stream_id += 2) { |
280 QuicStreamId promised_stream_id = NextPromisedStreamId(); | 281 QuicStreamId promised_stream_id = NextPromisedStreamId(); |
281 if (perspective() == Perspective::IS_SERVER) { | 282 if (perspective() == Perspective::IS_SERVER) { |
282 // Write the headers and capture the outgoing data | 283 // Write the headers and capture the outgoing data |
283 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, nullptr)) | 284 EXPECT_CALL(session_, WritevData(headers_stream_, kHeadersStreamId, _, _, |
284 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); | 285 false, nullptr)) |
| 286 .WillOnce(WithArgs<2>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
285 headers_stream_->WritePushPromise(stream_id, promised_stream_id, headers_, | 287 headers_stream_->WritePushPromise(stream_id, promised_stream_id, headers_, |
286 nullptr); | 288 nullptr); |
287 | 289 |
288 // Parse the outgoing data and check that it matches was was written. | 290 // Parse the outgoing data and check that it matches was was written. |
289 EXPECT_CALL(visitor_, | 291 EXPECT_CALL(visitor_, |
290 OnPushPromise(stream_id, promised_stream_id, kFrameComplete)); | 292 OnPushPromise(stream_id, promised_stream_id, kFrameComplete)); |
291 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) | 293 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) |
292 .WillRepeatedly(WithArgs<1, 2>( | 294 .WillRepeatedly(WithArgs<1, 2>( |
293 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); | 295 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); |
294 framer_->ProcessInput(saved_data_.data(), saved_data_.length()); | 296 framer_->ProcessInput(saved_data_.data(), saved_data_.length()); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 585 } |
584 | 586 |
585 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { | 587 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { |
586 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( | 588 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( |
587 headers_stream_)); | 589 headers_stream_)); |
588 } | 590 } |
589 | 591 |
590 } // namespace | 592 } // namespace |
591 } // namespace test | 593 } // namespace test |
592 } // namespace net | 594 } // namespace net |
OLD | NEW |