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

Side by Side Diff: net/tools/quic/quic_simple_server_session_test.cc

Issue 2692813002: Server push cancellation: add a finch trial parameter (Closed)
Patch Set: Spin the message loop to ensure the client receives the response Created 3 years, 8 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
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/tools/quic/quic_simple_server_session.h" 5 #include "net/tools/quic/quic_simple_server_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 TEST_P(QuicSimpleServerSessionTest, CloseStreamDueToReset) { 229 TEST_P(QuicSimpleServerSessionTest, CloseStreamDueToReset) {
230 // Open a stream, then reset it. 230 // Open a stream, then reset it.
231 // Send two bytes of payload to open it. 231 // Send two bytes of payload to open it.
232 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); 232 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
233 session_->OnStreamFrame(data1); 233 session_->OnStreamFrame(data1);
234 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); 234 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams());
235 235
236 // Receive a reset (and send a RST in response). 236 // Receive a reset (and send a RST in response).
237 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 237 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
238 0); 238 0);
239 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
239 EXPECT_CALL(*connection_, 240 EXPECT_CALL(*connection_,
240 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 241 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
241 visitor_->OnRstStream(rst1); 242 visitor_->OnRstStream(rst1);
242 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 243 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
243 244
244 // Send the same two bytes of payload in a new packet. 245 // Send the same two bytes of payload in a new packet.
245 visitor_->OnStreamFrame(data1); 246 visitor_->OnStreamFrame(data1);
246 247
247 // The stream should not be re-opened. 248 // The stream should not be re-opened.
248 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 249 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
249 EXPECT_TRUE(connection_->connected()); 250 EXPECT_TRUE(connection_->connected());
250 } 251 }
251 252
252 TEST_P(QuicSimpleServerSessionTest, NeverOpenStreamDueToReset) { 253 TEST_P(QuicSimpleServerSessionTest, NeverOpenStreamDueToReset) {
253 // Send a reset (and expect the peer to send a RST in response). 254 // Send a reset (and expect the peer to send a RST in response).
254 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 255 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
255 0); 256 0);
257 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
256 EXPECT_CALL(*connection_, 258 EXPECT_CALL(*connection_,
257 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 259 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
258 visitor_->OnRstStream(rst1); 260 visitor_->OnRstStream(rst1);
259 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 261 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
260 262
261 // Send two bytes of payload. 263 // Send two bytes of payload.
262 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); 264 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
263 visitor_->OnStreamFrame(data1); 265 visitor_->OnStreamFrame(data1);
264 266
265 // The stream should never be opened, now that the reset is received. 267 // The stream should never be opened, now that the reset is received.
266 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 268 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
267 EXPECT_TRUE(connection_->connected()); 269 EXPECT_TRUE(connection_->connected());
268 } 270 }
269 271
270 TEST_P(QuicSimpleServerSessionTest, AcceptClosedStream) { 272 TEST_P(QuicSimpleServerSessionTest, AcceptClosedStream) {
271 // Send (empty) compressed headers followed by two bytes of data. 273 // Send (empty) compressed headers followed by two bytes of data.
272 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, 274 QuicStreamFrame frame1(kClientDataStreamId1, false, 0,
273 QuicStringPiece("\1\0\0\0\0\0\0\0HT")); 275 QuicStringPiece("\1\0\0\0\0\0\0\0HT"));
274 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, 276 QuicStreamFrame frame2(kClientDataStreamId2, false, 0,
275 QuicStringPiece("\2\0\0\0\0\0\0\0HT")); 277 QuicStringPiece("\2\0\0\0\0\0\0\0HT"));
276 visitor_->OnStreamFrame(frame1); 278 visitor_->OnStreamFrame(frame1);
277 visitor_->OnStreamFrame(frame2); 279 visitor_->OnStreamFrame(frame2);
278 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); 280 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams());
279 281
280 // Send a reset (and expect the peer to send a RST in response). 282 // Send a reset (and expect the peer to send a RST in response).
281 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); 283 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0);
284 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
282 EXPECT_CALL(*connection_, 285 EXPECT_CALL(*connection_,
283 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 286 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
284 visitor_->OnRstStream(rst); 287 visitor_->OnRstStream(rst);
285 288
286 // If we were tracking, we'd probably want to reject this because it's data 289 // If we were tracking, we'd probably want to reject this because it's data
287 // past the reset point of stream 3. As it's a closed stream we just drop the 290 // past the reset point of stream 3. As it's a closed stream we just drop the
288 // data on the floor, but accept the packet because it has data for stream 5. 291 // data on the floor, but accept the packet because it has data for stream 5.
289 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP")); 292 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP"));
290 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP")); 293 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP"));
291 visitor_->OnStreamFrame(frame3); 294 visitor_->OnStreamFrame(frame3);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // prevent a promised resource to be send out. 566 // prevent a promised resource to be send out.
564 567
565 // Having two extra resources to be send later. One of them will be reset, so 568 // Having two extra resources to be send later. One of them will be reset, so
566 // when opened stream become close, only one will become open. 569 // when opened stream become close, only one will become open.
567 size_t num_resources = kMaxStreamsForTest + 2; 570 size_t num_resources = kMaxStreamsForTest + 2;
568 PromisePushResources(num_resources); 571 PromisePushResources(num_resources);
569 572
570 // Reset the last stream in the queue. It should be marked cancelled. 573 // Reset the last stream in the queue. It should be marked cancelled.
571 QuicStreamId stream_got_reset = num_resources * 2; 574 QuicStreamId stream_got_reset = num_resources * 2;
572 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); 575 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0);
576 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
573 EXPECT_CALL(*connection_, 577 EXPECT_CALL(*connection_,
574 SendRstStream(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT, 0)); 578 SendRstStream(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT, 0));
575 visitor_->OnRstStream(rst); 579 visitor_->OnRstStream(rst);
576 580
577 // When the first 2 streams becomes draining, the two queued up stream could 581 // When the first 2 streams becomes draining, the two queued up stream could
578 // be created. But since one of them was marked cancelled due to RST frame, 582 // be created. But since one of them was marked cancelled due to RST frame,
579 // only one queued resource will be sent out. 583 // only one queued resource will be sent out.
580 QuicStreamId stream_not_reset = (kMaxStreamsForTest + 1) * 2; 584 QuicStreamId stream_not_reset = (kMaxStreamsForTest + 1) * 2;
581 InSequence s; 585 InSequence s;
582 EXPECT_CALL(*session_, WriteHeadersMock(stream_not_reset, _, false, 586 EXPECT_CALL(*session_, WriteHeadersMock(stream_not_reset, _, false,
(...skipping 24 matching lines...) Expand all
607 // stream to be opened. 611 // stream to be opened.
608 QuicStreamId stream_got_reset = 2; 612 QuicStreamId stream_got_reset = 2;
609 EXPECT_CALL(*connection_, 613 EXPECT_CALL(*connection_,
610 SendRstStream(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT, _)); 614 SendRstStream(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT, _));
611 EXPECT_CALL(*session_, 615 EXPECT_CALL(*session_,
612 WriteHeadersMock(stream_to_open, _, false, kDefaultPriority, _)); 616 WriteHeadersMock(stream_to_open, _, false, kDefaultPriority, _));
613 EXPECT_CALL(*connection_, SendStreamData(stream_to_open, _, 0, false, _)) 617 EXPECT_CALL(*connection_, SendStreamData(stream_to_open, _, 0, false, _))
614 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); 618 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false)));
615 619
616 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); 620 EXPECT_CALL(*connection_, SendBlocked(stream_to_open));
621 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
617 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); 622 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0);
618 visitor_->OnRstStream(rst); 623 visitor_->OnRstStream(rst);
619 } 624 }
620 625
621 } // namespace 626 } // namespace
622 } // namespace test 627 } // namespace test
623 } // namespace net 628 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_dispatcher.cc ('k') | net/tools/quic/test_tools/mock_quic_session_visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698