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
3 // found in the LICENSE file.
5 #include "net/quic/quic_data_stream.h"
7 #include "net/quic/quic_ack_notifier.h"
8 #include "net/quic/quic_connection.h"
9 #include "net/quic/quic_utils.h"
10 #include "net/quic/quic_write_blocked_list.h"
11 #include "net/quic/spdy_utils.h"
12 #include "net/quic/test_tools/quic_flow_controller_peer.h"
13 #include "net/quic/test_tools/quic_session_peer.h"
14 #include "net/quic/test_tools/quic_test_utils.h"
15 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
16 #include "net/test/gtest_util.h"
17 #include "testing/gmock/include/gmock/gmock.h"
19 using base::StringPiece
;
22 using testing::AnyNumber
;
23 using testing::InSequence
;
24 using testing::Return
;
25 using testing::SaveArg
;
26 using testing::StrictMock
;
33 const bool kIsServer
= true;
34 const bool kShouldProcessData
= true;
36 class TestStream
: public QuicDataStream
{
38 TestStream(QuicStreamId id
,
40 bool should_process_data
)
41 : QuicDataStream(id
, session
),
42 should_process_data_(should_process_data
) {}
44 uint32
ProcessData(const char* data
, uint32 data_len
) override
{
45 EXPECT_NE(0u, data_len
);
46 DVLOG(1) << "ProcessData data_len: " << data_len
;
47 data_
+= string(data
, data_len
);
48 return should_process_data_
? data_len
: 0;
51 using ReliableQuicStream::WriteOrBufferData
;
52 using ReliableQuicStream::CloseReadSide
;
53 using ReliableQuicStream::CloseWriteSide
;
55 const string
& data() const { return data_
; }
58 bool should_process_data_
;
62 class QuicDataStreamTest
: public ::testing::TestWithParam
<QuicVersion
> {
64 QuicDataStreamTest() {
65 headers_
[":host"] = "www.google.com";
66 headers_
[":path"] = "/index.hml";
67 headers_
[":scheme"] = "https";
69 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; "
71 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX"
72 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX"
73 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT"
74 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0"
75 "O3YeHLmVCs62O6zp89QwakfAWK9d3IDQvVSJzCQsvxvNIvaZFa567MawWlXg0Rh"
76 "1zFMi5vzcns38-8_Sns; "
77 "GA=v*2%2Fmem*57968640*47239936%2Fmem*57968640*47114716%2Fno-nm-"
78 "yj*15%2Fno-cc-yj*5%2Fpc-ch*133685%2Fpc-s-cr*133947%2Fpc-s-t*1339"
79 "47%2Fno-nm-yj*4%2Fno-cc-yj*1%2Fceft-as*1%2Fceft-nqas*0%2Fad-ra-c"
80 "v_p%2Fad-nr-cv_p-f*1%2Fad-v-cv_p*859%2Fad-ns-cv_p-f*1%2Ffn-v-ad%"
81 "2Fpc-t*250%2Fpc-cm*461%2Fpc-s-cr*722%2Fpc-s-t*722%2Fau_p*4"
82 "SICAID=AJKiYcHdKgxum7KMXG0ei2t1-W4OD1uW-ecNsCqC0wDuAXiDGIcT_HA2o1"
83 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP"
84 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6"
85 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b"
86 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6"
87 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG"
88 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk"
89 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
90 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
91 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
94 void Initialize(bool stream_should_process_data
) {
95 connection_
= new testing::StrictMock
<MockConnection
>(
96 kIsServer
, SupportedVersions(GetParam()));
97 session_
.reset(new testing::StrictMock
<MockSession
>(connection_
));
98 stream_
.reset(new TestStream(kClientDataStreamId1
, session_
.get(),
99 stream_should_process_data
));
100 stream2_
.reset(new TestStream(kClientDataStreamId2
, session_
.get(),
101 stream_should_process_data
));
102 write_blocked_list_
=
103 QuicSessionPeer::GetWriteBlockedStreams(session_
.get());
107 MockConnection
* connection_
;
108 scoped_ptr
<MockSession
> session_
;
109 scoped_ptr
<TestStream
> stream_
;
110 scoped_ptr
<TestStream
> stream2_
;
111 SpdyHeaderBlock headers_
;
112 QuicWriteBlockedList
* write_blocked_list_
;
115 INSTANTIATE_TEST_CASE_P(Tests
, QuicDataStreamTest
,
116 ::testing::ValuesIn(QuicSupportedVersions()));
118 TEST_P(QuicDataStreamTest
, ProcessHeaders
) {
119 Initialize(kShouldProcessData
);
121 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
122 stream_
->OnStreamHeadersPriority(QuicUtils::HighestPriority());
123 stream_
->OnStreamHeaders(headers
);
124 EXPECT_EQ(headers
, stream_
->data());
125 stream_
->OnStreamHeadersComplete(false, headers
.size());
126 EXPECT_EQ(QuicUtils::HighestPriority(), stream_
->EffectivePriority());
127 EXPECT_EQ(headers
, stream_
->data());
128 EXPECT_FALSE(stream_
->IsDoneReading());
131 TEST_P(QuicDataStreamTest
, ProcessHeadersAndBody
) {
132 Initialize(kShouldProcessData
);
134 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
135 string body
= "this is the body";
137 stream_
->OnStreamHeaders(headers
);
138 EXPECT_EQ(headers
, stream_
->data());
139 stream_
->OnStreamHeadersComplete(false, headers
.size());
140 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
141 stream_
->OnStreamFrame(frame
);
143 EXPECT_EQ(headers
+ body
, stream_
->data());
146 TEST_P(QuicDataStreamTest
, ProcessHeadersAndBodyFragments
) {
147 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
148 string body
= "this is the body";
150 for (size_t fragment_size
= 1; fragment_size
< body
.size();
152 Initialize(kShouldProcessData
);
153 for (size_t offset
= 0; offset
< headers
.size();
154 offset
+= fragment_size
) {
155 size_t remaining_data
= headers
.size() - offset
;
156 StringPiece
fragment(headers
.data() + offset
,
157 min(fragment_size
, remaining_data
));
158 stream_
->OnStreamHeaders(fragment
);
160 stream_
->OnStreamHeadersComplete(false, headers
.size());
161 for (size_t offset
= 0; offset
< body
.size(); offset
+= fragment_size
) {
162 size_t remaining_data
= body
.size() - offset
;
163 StringPiece
fragment(body
.data() + offset
,
164 min(fragment_size
, remaining_data
));
165 QuicStreamFrame
frame(kClientDataStreamId1
, false, offset
,
166 MakeIOVector(fragment
));
167 stream_
->OnStreamFrame(frame
);
169 ASSERT_EQ(headers
+ body
,
170 stream_
->data()) << "fragment_size: " << fragment_size
;
174 TEST_P(QuicDataStreamTest
, ProcessHeadersAndBodyFragmentsSplit
) {
175 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
176 string body
= "this is the body";
178 for (size_t split_point
= 1; split_point
< body
.size() - 1; ++split_point
) {
179 Initialize(kShouldProcessData
);
180 StringPiece
headers1(headers
.data(), split_point
);
181 stream_
->OnStreamHeaders(headers1
);
183 StringPiece
headers2(headers
.data() + split_point
,
184 headers
.size() - split_point
);
185 stream_
->OnStreamHeaders(headers2
);
186 stream_
->OnStreamHeadersComplete(false, headers
.size());
188 StringPiece
fragment1(body
.data(), split_point
);
189 QuicStreamFrame
frame1(kClientDataStreamId1
, false, 0,
190 MakeIOVector(fragment1
));
191 stream_
->OnStreamFrame(frame1
);
193 StringPiece
fragment2(body
.data() + split_point
,
194 body
.size() - split_point
);
195 QuicStreamFrame
frame2(kClientDataStreamId1
, false, split_point
,
196 MakeIOVector(fragment2
));
197 stream_
->OnStreamFrame(frame2
);
199 ASSERT_EQ(headers
+ body
,
200 stream_
->data()) << "split_point: " << split_point
;
204 TEST_P(QuicDataStreamTest
, ProcessHeadersAndBodyReadv
) {
205 Initialize(!kShouldProcessData
);
207 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
208 string body
= "this is the body";
210 stream_
->OnStreamHeaders(headers
);
211 EXPECT_EQ(headers
, stream_
->data());
212 stream_
->OnStreamHeadersComplete(false, headers
.size());
213 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
214 stream_
->OnStreamFrame(frame
);
217 ASSERT_LT(headers
.length() + body
.length(), arraysize(buffer
));
219 vec
.iov_base
= buffer
;
220 vec
.iov_len
= arraysize(buffer
);
222 size_t bytes_read
= stream_
->Readv(&vec
, 1);
223 EXPECT_EQ(headers
.length(), bytes_read
);
224 EXPECT_EQ(headers
, string(buffer
, bytes_read
));
226 bytes_read
= stream_
->Readv(&vec
, 1);
227 EXPECT_EQ(body
.length(), bytes_read
);
228 EXPECT_EQ(body
, string(buffer
, bytes_read
));
231 TEST_P(QuicDataStreamTest
, ProcessHeadersAndBodyIncrementalReadv
) {
232 Initialize(!kShouldProcessData
);
234 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
235 string body
= "this is the body";
236 stream_
->OnStreamHeaders(headers
);
237 EXPECT_EQ(headers
, stream_
->data());
238 stream_
->OnStreamHeadersComplete(false, headers
.size());
239 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
240 stream_
->OnStreamFrame(frame
);
244 vec
.iov_base
= buffer
;
245 vec
.iov_len
= arraysize(buffer
);
247 string data
= headers
+ body
;
248 for (size_t i
= 0; i
< data
.length(); ++i
) {
249 size_t bytes_read
= stream_
->Readv(&vec
, 1);
250 ASSERT_EQ(1u, bytes_read
);
251 EXPECT_EQ(data
.data()[i
], buffer
[0]);
255 TEST_P(QuicDataStreamTest
, ProcessHeadersUsingReadvWithMultipleIovecs
) {
256 Initialize(!kShouldProcessData
);
258 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
259 string body
= "this is the body";
260 stream_
->OnStreamHeaders(headers
);
261 EXPECT_EQ(headers
, stream_
->data());
262 stream_
->OnStreamHeadersComplete(false, headers
.size());
263 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
264 stream_
->OnStreamFrame(frame
);
269 vec
[0].iov_base
= buffer1
;
270 vec
[0].iov_len
= arraysize(buffer1
);
271 vec
[1].iov_base
= buffer2
;
272 vec
[1].iov_len
= arraysize(buffer2
);
273 string data
= headers
+ body
;
274 for (size_t i
= 0; i
< data
.length(); i
+= 2) {
275 size_t bytes_read
= stream_
->Readv(vec
, 2);
276 ASSERT_EQ(2u, bytes_read
) << i
;
277 ASSERT_EQ(data
.data()[i
], buffer1
[0]) << i
;
278 ASSERT_EQ(data
.data()[i
+ 1], buffer2
[0]) << i
;
282 TEST_P(QuicDataStreamTest
, StreamFlowControlBlocked
) {
283 // Tests that we send a BLOCKED frame to the peer when we attempt to write,
284 // but are flow control blocked.
285 Initialize(kShouldProcessData
);
287 // Set a small flow control limit.
288 const uint64 kWindow
= 36;
289 QuicFlowControllerPeer::SetSendWindowOffset(stream_
->flow_controller(),
291 EXPECT_EQ(kWindow
, QuicFlowControllerPeer::SendWindowOffset(
292 stream_
->flow_controller()));
294 // Try to send more data than the flow control limit allows.
295 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
297 const uint64 kOverflow
= 15;
298 GenerateBody(&body
, kWindow
+ kOverflow
);
300 EXPECT_CALL(*connection_
, SendBlocked(kClientDataStreamId1
));
301 EXPECT_CALL(*session_
, WritevData(kClientDataStreamId1
, _
, _
, _
, _
, _
))
302 .WillOnce(Return(QuicConsumedData(kWindow
, true)));
303 stream_
->WriteOrBufferData(body
, false, nullptr);
305 // Should have sent as much as possible, resulting in no send window left.
307 QuicFlowControllerPeer::SendWindowSize(stream_
->flow_controller()));
309 // And we should have queued the overflowed data.
311 ReliableQuicStreamPeer::SizeOfQueuedData(stream_
.get()));
314 TEST_P(QuicDataStreamTest
, StreamFlowControlNoWindowUpdateIfNotConsumed
) {
315 // The flow control receive window decreases whenever we add new bytes to the
316 // sequencer, whether they are consumed immediately or buffered. However we
317 // only send WINDOW_UPDATE frames based on increasing number of bytes
320 // Don't process data - it will be buffered instead.
321 Initialize(!kShouldProcessData
);
323 // Expect no WINDOW_UPDATE frames to be sent.
324 EXPECT_CALL(*connection_
, SendWindowUpdate(_
, _
)).Times(0);
326 // Set a small flow control receive window.
327 const uint64 kWindow
= 36;
328 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(),
330 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_
->flow_controller(),
332 EXPECT_EQ(kWindow
, QuicFlowControllerPeer::ReceiveWindowOffset(
333 stream_
->flow_controller()));
335 // Stream receives enough data to fill a fraction of the receive window.
336 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
338 GenerateBody(&body
, kWindow
/ 3);
339 stream_
->OnStreamHeaders(headers
);
340 EXPECT_EQ(headers
, stream_
->data());
341 stream_
->OnStreamHeadersComplete(false, headers
.size());
343 QuicStreamFrame
frame1(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
344 stream_
->OnStreamFrame(frame1
);
345 EXPECT_EQ(kWindow
- (kWindow
/ 3), QuicFlowControllerPeer::ReceiveWindowSize(
346 stream_
->flow_controller()));
348 // Now receive another frame which results in the receive window being over
349 // half full. This should all be buffered, decreasing the receive window but
350 // not sending WINDOW_UPDATE.
351 QuicStreamFrame
frame2(kClientDataStreamId1
, false, kWindow
/ 3,
353 stream_
->OnStreamFrame(frame2
);
355 kWindow
- (2 * kWindow
/ 3),
356 QuicFlowControllerPeer::ReceiveWindowSize(stream_
->flow_controller()));
359 TEST_P(QuicDataStreamTest
, StreamFlowControlWindowUpdate
) {
360 // Tests that on receipt of data, the stream updates its receive window offset
361 // appropriately, and sends WINDOW_UPDATE frames when its receive window drops
363 Initialize(kShouldProcessData
);
365 // Set a small flow control limit.
366 const uint64 kWindow
= 36;
367 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(),
369 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_
->flow_controller(),
371 EXPECT_EQ(kWindow
, QuicFlowControllerPeer::ReceiveWindowOffset(
372 stream_
->flow_controller()));
374 // Stream receives enough data to fill a fraction of the receive window.
375 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
377 GenerateBody(&body
, kWindow
/ 3);
378 stream_
->OnStreamHeaders(headers
);
379 EXPECT_EQ(headers
, stream_
->data());
380 stream_
->OnStreamHeadersComplete(false, headers
.size());
382 QuicStreamFrame
frame1(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
383 stream_
->OnStreamFrame(frame1
);
384 EXPECT_EQ(kWindow
- (kWindow
/ 3), QuicFlowControllerPeer::ReceiveWindowSize(
385 stream_
->flow_controller()));
387 // Now receive another frame which results in the receive window being over
388 // half full. This will trigger the stream to increase its receive window
389 // offset and send a WINDOW_UPDATE. The result will be again an available
390 // window of kWindow bytes.
391 QuicStreamFrame
frame2(kClientDataStreamId1
, false, kWindow
/ 3,
393 EXPECT_CALL(*connection_
,
394 SendWindowUpdate(kClientDataStreamId1
,
395 QuicFlowControllerPeer::ReceiveWindowOffset(
396 stream_
->flow_controller()) +
398 stream_
->OnStreamFrame(frame2
);
399 EXPECT_EQ(kWindow
, QuicFlowControllerPeer::ReceiveWindowSize(
400 stream_
->flow_controller()));
403 TEST_P(QuicDataStreamTest
, ConnectionFlowControlWindowUpdate
) {
404 // Tests that on receipt of data, the connection updates its receive window
405 // offset appropriately, and sends WINDOW_UPDATE frames when its receive
406 // window drops too low.
407 Initialize(kShouldProcessData
);
409 // Set a small flow control limit for streams and connection.
410 const uint64 kWindow
= 36;
411 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(),
413 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_
->flow_controller(),
415 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_
->flow_controller(),
417 QuicFlowControllerPeer::SetMaxReceiveWindow(stream2_
->flow_controller(),
419 QuicFlowControllerPeer::SetReceiveWindowOffset(session_
->flow_controller(),
421 QuicFlowControllerPeer::SetMaxReceiveWindow(session_
->flow_controller(),
424 // Supply headers to both streams so that they are happy to receive data.
425 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
426 stream_
->OnStreamHeaders(headers
);
427 stream_
->OnStreamHeadersComplete(false, headers
.size());
428 stream2_
->OnStreamHeaders(headers
);
429 stream2_
->OnStreamHeadersComplete(false, headers
.size());
431 // Each stream gets a quarter window of data. This should not trigger a
432 // WINDOW_UPDATE for either stream, nor for the connection.
434 GenerateBody(&body
, kWindow
/ 4);
435 QuicStreamFrame
frame1(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
436 stream_
->OnStreamFrame(frame1
);
437 QuicStreamFrame
frame2(kClientDataStreamId2
, false, 0, MakeIOVector(body
));
438 stream2_
->OnStreamFrame(frame2
);
440 // Now receive a further single byte on one stream - again this does not
441 // trigger a stream WINDOW_UPDATE, but now the connection flow control window
442 // is over half full and thus a connection WINDOW_UPDATE is sent.
443 EXPECT_CALL(*connection_
, SendWindowUpdate(kClientDataStreamId1
, _
)).Times(0);
444 EXPECT_CALL(*connection_
, SendWindowUpdate(kClientDataStreamId2
, _
)).Times(0);
445 EXPECT_CALL(*connection_
,
446 SendWindowUpdate(0, QuicFlowControllerPeer::ReceiveWindowOffset(
447 session_
->flow_controller()) +
449 QuicStreamFrame
frame3(kClientDataStreamId1
, false, (kWindow
/ 4),
451 stream_
->OnStreamFrame(frame3
);
454 TEST_P(QuicDataStreamTest
, StreamFlowControlViolation
) {
455 // Tests that on if the peer sends too much data (i.e. violates the flow
456 // control protocol), then we terminate the connection.
458 // Stream should not process data, so that data gets buffered in the
459 // sequencer, triggering flow control limits.
460 Initialize(!kShouldProcessData
);
462 // Set a small flow control limit.
463 const uint64 kWindow
= 50;
464 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(),
467 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
468 stream_
->OnStreamHeaders(headers
);
469 EXPECT_EQ(headers
, stream_
->data());
470 stream_
->OnStreamHeadersComplete(false, headers
.size());
472 // Receive data to overflow the window, violating flow control.
474 GenerateBody(&body
, kWindow
+ 1);
475 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
476 EXPECT_CALL(*connection_
,
477 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA
));
478 stream_
->OnStreamFrame(frame
);
481 TEST_P(QuicDataStreamTest
, ConnectionFlowControlViolation
) {
482 // Tests that on if the peer sends too much data (i.e. violates the flow
483 // control protocol), at the connection level (rather than the stream level)
484 // then we terminate the connection.
486 // Stream should not process data, so that data gets buffered in the
487 // sequencer, triggering flow control limits.
488 Initialize(!kShouldProcessData
);
490 // Set a small flow control window on streams, and connection.
491 const uint64 kStreamWindow
= 50;
492 const uint64 kConnectionWindow
= 10;
493 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(),
495 QuicFlowControllerPeer::SetReceiveWindowOffset(session_
->flow_controller(),
498 string headers
= SpdyUtils::SerializeUncompressedHeaders(headers_
);
499 stream_
->OnStreamHeaders(headers
);
500 EXPECT_EQ(headers
, stream_
->data());
501 stream_
->OnStreamHeadersComplete(false, headers
.size());
503 // Send enough data to overflow the connection level flow control window.
505 GenerateBody(&body
, kConnectionWindow
+ 1);
506 EXPECT_LT(body
.size(), kStreamWindow
);
507 QuicStreamFrame
frame(kClientDataStreamId1
, false, 0, MakeIOVector(body
));
509 EXPECT_CALL(*connection_
,
510 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA
));
511 stream_
->OnStreamFrame(frame
);
514 TEST_P(QuicDataStreamTest
, StreamFlowControlFinNotBlocked
) {
515 // An attempt to write a FIN with no data should not be flow control blocked,
516 // even if the send window is 0.
518 Initialize(kShouldProcessData
);
520 // Set a flow control limit of zero.
521 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_
->flow_controller(), 0);
522 EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset(
523 stream_
->flow_controller()));
525 // Send a frame with a FIN but no data. This should not be blocked.
529 EXPECT_CALL(*connection_
, SendBlocked(kClientDataStreamId1
)).Times(0);
530 EXPECT_CALL(*session_
, WritevData(kClientDataStreamId1
, _
, _
, _
, _
, _
))
531 .WillOnce(Return(QuicConsumedData(0, fin
)));
533 stream_
->WriteOrBufferData(body
, fin
, nullptr);