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

Side by Side Diff: net/quic/core/quic_server_session_base_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
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/quic/core/quic_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/quic/core/quic_server_session_base.h" 5 #include "net/quic/core/quic_server_session_base.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { 203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) {
204 // Open a stream, then reset it. 204 // Open a stream, then reset it.
205 // Send two bytes of payload to open it. 205 // Send two bytes of payload to open it.
206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); 206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
207 session_->OnStreamFrame(data1); 207 session_->OnStreamFrame(data1);
208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); 208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams());
209 209
210 // Send a reset (and expect the peer to send a RST in response). 210 // Send a reset (and expect the peer to send a RST in response).
211 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 211 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
212 0); 212 0);
213 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
213 EXPECT_CALL(*connection_, 214 EXPECT_CALL(*connection_,
214 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 215 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
215 visitor_->OnRstStream(rst1); 216 visitor_->OnRstStream(rst1);
216 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 217 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
217 218
218 // Send the same two bytes of payload in a new packet. 219 // Send the same two bytes of payload in a new packet.
219 visitor_->OnStreamFrame(data1); 220 visitor_->OnStreamFrame(data1);
220 221
221 // The stream should not be re-opened. 222 // The stream should not be re-opened.
222 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 223 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
223 EXPECT_TRUE(connection_->connected()); 224 EXPECT_TRUE(connection_->connected());
224 } 225 }
225 226
226 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { 227 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) {
227 // Send a reset (and expect the peer to send a RST in response). 228 // Send a reset (and expect the peer to send a RST in response).
228 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 229 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
229 0); 230 0);
231 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
230 EXPECT_CALL(*connection_, 232 EXPECT_CALL(*connection_,
231 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 233 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
232 visitor_->OnRstStream(rst1); 234 visitor_->OnRstStream(rst1);
233 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 235 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
234 236
235 // Send two bytes of payload. 237 // Send two bytes of payload.
236 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); 238 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
237 visitor_->OnStreamFrame(data1); 239 visitor_->OnStreamFrame(data1);
238 240
239 // The stream should never be opened, now that the reset is received. 241 // The stream should never be opened, now that the reset is received.
240 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 242 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
241 EXPECT_TRUE(connection_->connected()); 243 EXPECT_TRUE(connection_->connected());
242 } 244 }
243 245
244 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { 246 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) {
245 // Send (empty) compressed headers followed by two bytes of data. 247 // Send (empty) compressed headers followed by two bytes of data.
246 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, 248 QuicStreamFrame frame1(kClientDataStreamId1, false, 0,
247 QuicStringPiece("\1\0\0\0\0\0\0\0HT")); 249 QuicStringPiece("\1\0\0\0\0\0\0\0HT"));
248 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, 250 QuicStreamFrame frame2(kClientDataStreamId2, false, 0,
249 QuicStringPiece("\2\0\0\0\0\0\0\0HT")); 251 QuicStringPiece("\2\0\0\0\0\0\0\0HT"));
250 visitor_->OnStreamFrame(frame1); 252 visitor_->OnStreamFrame(frame1);
251 visitor_->OnStreamFrame(frame2); 253 visitor_->OnStreamFrame(frame2);
252 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); 254 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams());
253 255
254 // Send a reset (and expect the peer to send a RST in response). 256 // Send a reset (and expect the peer to send a RST in response).
255 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); 257 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0);
258 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
256 EXPECT_CALL(*connection_, 259 EXPECT_CALL(*connection_,
257 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 260 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
258 visitor_->OnRstStream(rst); 261 visitor_->OnRstStream(rst);
259 262
260 // If we were tracking, we'd probably want to reject this because it's data 263 // If we were tracking, we'd probably want to reject this because it's data
261 // past the reset point of stream 3. As it's a closed stream we just drop the 264 // past the reset point of stream 3. As it's a closed stream we just drop the
262 // data on the floor, but accept the packet because it has data for stream 5. 265 // data on the floor, but accept the packet because it has data for stream 5.
263 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP")); 266 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP"));
264 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP")); 267 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP"));
265 visitor_->OnStreamFrame(frame3); 268 visitor_->OnStreamFrame(frame3);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 645
643 // Allow the async ProofSource::GetProof call to complete. Verify (under 646 // Allow the async ProofSource::GetProof call to complete. Verify (under
644 // asan) that this does not result in accesses to any freed memory from the 647 // asan) that this does not result in accesses to any freed memory from the
645 // session or its subobjects. 648 // session or its subobjects.
646 GetFakeProofSource()->InvokePendingCallback(0); 649 GetFakeProofSource()->InvokePendingCallback(0);
647 } 650 }
648 651
649 } // namespace 652 } // namespace
650 } // namespace test 653 } // namespace test
651 } // namespace net 654 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/quic/core/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698