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

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

Issue 1231343004: relnote: Change QuicConnectionVisitorInterface::OnStreamFrames to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Fix_flag_quic_delay_retransmission_alarm_97271704
Patch Set: Created 5 years, 5 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/quic/test_tools/quic_test_utils.h ('k') | no next file » | 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/tools/quic/quic_server_session.h" 5 #include "net/tools/quic/quic_server_session.h"
6 6
7 #include "net/quic/crypto/quic_crypto_server_config.h" 7 #include "net/quic/crypto/quic_crypto_server_config.h"
8 #include "net/quic/crypto/quic_random.h" 8 #include "net/quic/crypto/quic_random.h"
9 #include "net/quic/proto/cached_network_parameters.pb.h" 9 #include "net/quic/proto/cached_network_parameters.pb.h"
10 #include "net/quic/quic_connection.h" 10 #include "net/quic/quic_connection.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 reference.previous_connection_state()); 116 reference.previous_connection_state());
117 } 117 }
118 118
119 INSTANTIATE_TEST_CASE_P(Tests, QuicServerSessionTest, 119 INSTANTIATE_TEST_CASE_P(Tests, QuicServerSessionTest,
120 ::testing::ValuesIn(QuicSupportedVersions())); 120 ::testing::ValuesIn(QuicSupportedVersions()));
121 121
122 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) { 122 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
123 // Open a stream, then reset it. 123 // Open a stream, then reset it.
124 // Send two bytes of payload to open it. 124 // Send two bytes of payload to open it.
125 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); 125 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT"));
126 vector<QuicStreamFrame> frames; 126 session_->OnStreamFrame(data1);
127 frames.push_back(data1);
128 session_->OnStreamFrames(frames);
129 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 127 EXPECT_EQ(1u, session_->GetNumOpenStreams());
130 128
131 // Send a reset (and expect the peer to send a RST in response). 129 // Send a reset (and expect the peer to send a RST in response).
132 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 130 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0);
133 EXPECT_CALL(*connection_, 131 EXPECT_CALL(*connection_,
134 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 132 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
135 visitor_->OnRstStream(rst1); 133 visitor_->OnRstStream(rst1);
136 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 134 EXPECT_EQ(0u, session_->GetNumOpenStreams());
137 135
138 // Send the same two bytes of payload in a new packet. 136 // Send the same two bytes of payload in a new packet.
139 visitor_->OnStreamFrames(frames); 137 visitor_->OnStreamFrame(data1);
140 138
141 // The stream should not be re-opened. 139 // The stream should not be re-opened.
142 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 140 EXPECT_EQ(0u, session_->GetNumOpenStreams());
143 EXPECT_TRUE(connection_->connected()); 141 EXPECT_TRUE(connection_->connected());
144 } 142 }
145 143
146 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { 144 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
147 // Send a reset (and expect the peer to send a RST in response). 145 // Send a reset (and expect the peer to send a RST in response).
148 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 146 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0);
149 EXPECT_CALL(*connection_, 147 EXPECT_CALL(*connection_,
150 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 148 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
151 visitor_->OnRstStream(rst1); 149 visitor_->OnRstStream(rst1);
152 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 150 EXPECT_EQ(0u, session_->GetNumOpenStreams());
153 151
154 // Send two bytes of payload. 152 // Send two bytes of payload.
155 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); 153 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT"));
156 vector<QuicStreamFrame> frames; 154 visitor_->OnStreamFrame(data1);
157 frames.push_back(data1);
158 visitor_->OnStreamFrames(frames);
159 155
160 // The stream should never be opened, now that the reset is received. 156 // The stream should never be opened, now that the reset is received.
161 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 157 EXPECT_EQ(0u, session_->GetNumOpenStreams());
162 EXPECT_TRUE(connection_->connected()); 158 EXPECT_TRUE(connection_->connected());
163 } 159 }
164 160
165 TEST_P(QuicServerSessionTest, AcceptClosedStream) { 161 TEST_P(QuicServerSessionTest, AcceptClosedStream) {
166 vector<QuicStreamFrame> frames;
167 // Send (empty) compressed headers followed by two bytes of data. 162 // Send (empty) compressed headers followed by two bytes of data.
168 frames.push_back(QuicStreamFrame(kClientDataStreamId1, false, 0, 163 QuicStreamFrame frame1(kClientDataStreamId1, false, 0,
169 StringPiece("\1\0\0\0\0\0\0\0HT"))); 164 StringPiece("\1\0\0\0\0\0\0\0HT"));
170 frames.push_back(QuicStreamFrame(kClientDataStreamId2, false, 0, 165 QuicStreamFrame frame2(kClientDataStreamId2, false, 0,
171 StringPiece("\2\0\0\0\0\0\0\0HT"))); 166 StringPiece("\2\0\0\0\0\0\0\0HT"));
172 visitor_->OnStreamFrames(frames); 167 visitor_->OnStreamFrame(frame1);
168 visitor_->OnStreamFrame(frame2);
173 EXPECT_EQ(2u, session_->GetNumOpenStreams()); 169 EXPECT_EQ(2u, session_->GetNumOpenStreams());
174 170
175 // Send a reset (and expect the peer to send a RST in response). 171 // Send a reset (and expect the peer to send a RST in response).
176 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 172 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0);
177 EXPECT_CALL(*connection_, 173 EXPECT_CALL(*connection_,
178 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 174 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
179 visitor_->OnRstStream(rst); 175 visitor_->OnRstStream(rst);
180 176
181 // If we were tracking, we'd probably want to reject this because it's data 177 // If we were tracking, we'd probably want to reject this because it's data
182 // past the reset point of stream 3. As it's a closed stream we just drop the 178 // past the reset point of stream 3. As it's a closed stream we just drop the
183 // data on the floor, but accept the packet because it has data for stream 5. 179 // data on the floor, but accept the packet because it has data for stream 5.
184 frames.clear(); 180 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP"));
185 frames.push_back( 181 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP"));
186 QuicStreamFrame(kClientDataStreamId1, false, 2, StringPiece("TP"))); 182 visitor_->OnStreamFrame(frame3);
187 frames.push_back( 183 visitor_->OnStreamFrame(frame4);
188 QuicStreamFrame(kClientDataStreamId2, false, 2, StringPiece("TP")));
189 visitor_->OnStreamFrames(frames);
190 // The stream should never be opened, now that the reset is received. 184 // The stream should never be opened, now that the reset is received.
191 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 185 EXPECT_EQ(1u, session_->GetNumOpenStreams());
192 EXPECT_TRUE(connection_->connected()); 186 EXPECT_TRUE(connection_->connected());
193 } 187 }
194 188
195 TEST_P(QuicServerSessionTest, MaxOpenStreams) { 189 TEST_P(QuicServerSessionTest, MaxOpenStreams) {
196 // Test that the server closes the connection if a client attempts to open too 190 // Test that the server closes the connection if a client attempts to open too
197 // many data streams. The server accepts slightly more than the negotiated 191 // many data streams. The server accepts slightly more than the negotiated
198 // stream limit to deal with rare cases where a client FIN/RST is lost. 192 // stream limit to deal with rare cases where a client FIN/RST is lost.
199 193
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); 455 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get()));
462 session_->OnConfigNegotiated(); 456 session_->OnConfigNegotiated();
463 EXPECT_FALSE( 457 EXPECT_FALSE(
464 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); 458 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get()));
465 } 459 }
466 460
467 } // namespace 461 } // namespace
468 } // namespace test 462 } // namespace test
469 } // namespace tools 463 } // namespace tools
470 } // namespace net 464 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698