| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, bool fin) { | 170 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, bool fin) { |
| 171 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); | 171 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void WriteHeadersAndCheckData(QuicStreamId stream_id, | 174 void WriteHeadersAndCheckData(QuicStreamId stream_id, |
| 175 bool fin, | 175 bool fin, |
| 176 SpdyPriority priority, | 176 SpdyPriority priority, |
| 177 SpdyFrameType type) { | 177 SpdyFrameType type) { |
| 178 // Write the headers and capture the outgoing data | 178 // Write the headers and capture the outgoing data |
| 179 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, _, nullptr)) | 179 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, nullptr)) |
| 180 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); | 180 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
| 181 headers_stream_->WriteHeaders(stream_id, headers_, fin, priority, nullptr); | 181 headers_stream_->WriteHeaders(stream_id, headers_, fin, priority, nullptr); |
| 182 | 182 |
| 183 // Parse the outgoing data and check that it matches was was written. | 183 // Parse the outgoing data and check that it matches was was written. |
| 184 if (type == SYN_STREAM) { | 184 if (type == SYN_STREAM) { |
| 185 EXPECT_CALL(visitor_, | 185 EXPECT_CALL(visitor_, |
| 186 OnHeaders(stream_id, kHasPriority, priority, | 186 OnHeaders(stream_id, kHasPriority, priority, |
| 187 /*parent_stream_id=*/0, | 187 /*parent_stream_id=*/0, |
| 188 /*exclusive=*/false, fin, kFrameComplete)); | 188 /*exclusive=*/false, fin, kFrameComplete)); |
| 189 } else { | 189 } else { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 TEST_P(QuicHeadersStreamTest, WritePushPromises) { | 273 TEST_P(QuicHeadersStreamTest, WritePushPromises) { |
| 274 for (QuicStreamId stream_id = kClientDataStreamId1; | 274 for (QuicStreamId stream_id = kClientDataStreamId1; |
| 275 stream_id < kClientDataStreamId3; stream_id += 2) { | 275 stream_id < kClientDataStreamId3; stream_id += 2) { |
| 276 QuicStreamId promised_stream_id = NextPromisedStreamId(); | 276 QuicStreamId promised_stream_id = NextPromisedStreamId(); |
| 277 if (perspective() == Perspective::IS_SERVER) { | 277 if (perspective() == Perspective::IS_SERVER) { |
| 278 // Write the headers and capture the outgoing data | 278 // Write the headers and capture the outgoing data |
| 279 EXPECT_CALL(session_, | 279 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, nullptr)) |
| 280 WritevData(kHeadersStreamId, _, _, false, _, nullptr)) | |
| 281 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); | 280 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
| 282 headers_stream_->WritePushPromise(stream_id, promised_stream_id, headers_, | 281 headers_stream_->WritePushPromise(stream_id, promised_stream_id, headers_, |
| 283 nullptr); | 282 nullptr); |
| 284 | 283 |
| 285 // Parse the outgoing data and check that it matches was was written. | 284 // Parse the outgoing data and check that it matches was was written. |
| 286 EXPECT_CALL(visitor_, | 285 EXPECT_CALL(visitor_, |
| 287 OnPushPromise(stream_id, promised_stream_id, kFrameComplete)); | 286 OnPushPromise(stream_id, promised_stream_id, kFrameComplete)); |
| 288 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) | 287 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) |
| 289 .WillRepeatedly(WithArgs<1, 2>( | 288 .WillRepeatedly(WithArgs<1, 2>( |
| 290 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); | 289 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 } | 578 } |
| 580 | 579 |
| 581 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { | 580 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { |
| 582 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( | 581 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( |
| 583 headers_stream_)); | 582 headers_stream_)); |
| 584 } | 583 } |
| 585 | 584 |
| 586 } // namespace | 585 } // namespace |
| 587 } // namespace test | 586 } // namespace test |
| 588 } // namespace net | 587 } // namespace net |
| OLD | NEW |