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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 1 month 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/tools/quic/quic_server_session.h ('k') | net/tools/quic/quic_simple_server_bin.cc » ('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/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 11 matching lines...) Expand all
22 #include "net/quic/test_tools/quic_test_utils.h" 22 #include "net/quic/test_tools/quic_test_utils.h"
23 #include "net/test/gtest_util.h" 23 #include "net/test/gtest_util.h"
24 #include "net/tools/quic/quic_spdy_server_stream.h" 24 #include "net/tools/quic/quic_spdy_server_stream.h"
25 #include "net/tools/quic/test_tools/mock_quic_server_session_visitor.h" 25 #include "net/tools/quic/test_tools/mock_quic_server_session_visitor.h"
26 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 using __gnu_cxx::vector; 29 using __gnu_cxx::vector;
30 using net::test::CryptoTestUtils; 30 using net::test::CryptoTestUtils;
31 using net::test::MockConnection; 31 using net::test::MockConnection;
32 using net::test::MockHelper; 32 using net::test::MockConnectionHelper;
33 using net::test::QuicConfigPeer; 33 using net::test::QuicConfigPeer;
34 using net::test::QuicConnectionPeer; 34 using net::test::QuicConnectionPeer;
35 using net::test::QuicSpdyStreamPeer; 35 using net::test::QuicSpdyStreamPeer;
36 using net::test::QuicSentPacketManagerPeer; 36 using net::test::QuicSentPacketManagerPeer;
37 using net::test::QuicSessionPeer; 37 using net::test::QuicSessionPeer;
38 using net::test::QuicSpdySessionPeer; 38 using net::test::QuicSpdySessionPeer;
39 using net::test::QuicSustainedBandwidthRecorderPeer; 39 using net::test::QuicSustainedBandwidthRecorderPeer;
40 using net::test::SupportedVersions; 40 using net::test::SupportedVersions;
41 using net::test::ValueRestore; 41 using net::test::ValueRestore;
42 using net::test::kClientDataStreamId1; 42 using net::test::kClientDataStreamId1;
43 using net::test::kClientDataStreamId2; 43 using net::test::kClientDataStreamId2;
44 using net::test::kClientDataStreamId3; 44 using net::test::kClientDataStreamId3;
45 using net::test::kInitialSessionFlowControlWindowForTest; 45 using net::test::kInitialSessionFlowControlWindowForTest;
46 using net::test::kInitialStreamFlowControlWindowForTest; 46 using net::test::kInitialStreamFlowControlWindowForTest;
47 using std::string; 47 using std::string;
48 using testing::StrictMock; 48 using testing::StrictMock;
49 using testing::_; 49 using testing::_;
50 50
51 namespace net { 51 namespace net {
52 namespace tools { 52 namespace tools {
53 namespace test { 53 namespace test {
54 54
55 class QuicServerSessionPeer { 55 class QuicServerSessionPeer {
56 public: 56 public:
57 static ReliableQuicStream* GetIncomingDynamicStream(QuicServerSession* s, 57 static ReliableQuicStream* GetOrCreateDynamicStream(QuicServerSession* s,
58 QuicStreamId id) { 58 QuicStreamId id) {
59 return s->GetIncomingDynamicStream(id); 59 return s->GetOrCreateDynamicStream(id);
60 } 60 }
61 static void SetCryptoStream(QuicServerSession* s, 61 static void SetCryptoStream(QuicServerSession* s,
62 QuicCryptoServerStream* crypto_stream) { 62 QuicCryptoServerStream* crypto_stream) {
63 s->crypto_stream_.reset(crypto_stream); 63 s->crypto_stream_.reset(crypto_stream);
64 s->static_streams()[kCryptoStreamId] = crypto_stream; 64 s->static_streams()[kCryptoStreamId] = crypto_stream;
65 } 65 }
66 static bool IsBandwidthResumptionEnabled(QuicServerSession* s) { 66 static bool IsBandwidthResumptionEnabled(QuicServerSession* s) {
67 return s->bandwidth_resumption_enabled_; 67 return s->bandwidth_resumption_enabled_;
68 } 68 }
69 }; 69 };
(...skipping 21 matching lines...) Expand all
91 new QuicServerSession(config_, connection_, &owner_, &crypto_config_)); 91 new QuicServerSession(config_, connection_, &owner_, &crypto_config_));
92 MockClock clock; 92 MockClock clock;
93 handshake_message_.reset(crypto_config_.AddDefaultConfig( 93 handshake_message_.reset(crypto_config_.AddDefaultConfig(
94 QuicRandom::GetInstance(), &clock, 94 QuicRandom::GetInstance(), &clock,
95 QuicCryptoServerConfig::ConfigOptions())); 95 QuicCryptoServerConfig::ConfigOptions()));
96 session_->Initialize(); 96 session_->Initialize();
97 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 97 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
98 } 98 }
99 99
100 StrictMock<MockQuicServerSessionVisitor> owner_; 100 StrictMock<MockQuicServerSessionVisitor> owner_;
101 MockHelper helper_; 101 MockConnectionHelper helper_;
102 StrictMock<MockConnection>* connection_; 102 StrictMock<MockConnection>* connection_;
103 QuicConfig config_; 103 QuicConfig config_;
104 QuicCryptoServerConfig crypto_config_; 104 QuicCryptoServerConfig crypto_config_;
105 scoped_ptr<QuicServerSession> session_; 105 scoped_ptr<QuicServerSession> session_;
106 scoped_ptr<CryptoHandshakeMessage> handshake_message_; 106 scoped_ptr<CryptoHandshakeMessage> handshake_message_;
107 QuicConnectionVisitorInterface* visitor_; 107 QuicConnectionVisitorInterface* visitor_;
108 }; 108 };
109 109
110 // Compares CachedNetworkParameters. 110 // Compares CachedNetworkParameters.
111 MATCHER_P(EqualsProto, network_params, "") { 111 MATCHER_P(EqualsProto, network_params, "") {
(...skipping 15 matching lines...) Expand all
127 ::testing::ValuesIn(QuicSupportedVersions())); 127 ::testing::ValuesIn(QuicSupportedVersions()));
128 128
129 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) { 129 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
130 // Open a stream, then reset it. 130 // Open a stream, then reset it.
131 // Send two bytes of payload to open it. 131 // Send two bytes of payload to open it.
132 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); 132 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT"));
133 session_->OnStreamFrame(data1); 133 session_->OnStreamFrame(data1);
134 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 134 EXPECT_EQ(1u, session_->GetNumOpenStreams());
135 135
136 // Send a reset (and expect the peer to send a RST in response). 136 // Send a reset (and expect the peer to send a RST in response).
137 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 137 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
138 0);
138 EXPECT_CALL(*connection_, 139 EXPECT_CALL(*connection_,
139 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 140 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
140 visitor_->OnRstStream(rst1); 141 visitor_->OnRstStream(rst1);
141 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 142 EXPECT_EQ(0u, session_->GetNumOpenStreams());
142 143
143 // Send the same two bytes of payload in a new packet. 144 // Send the same two bytes of payload in a new packet.
144 visitor_->OnStreamFrame(data1); 145 visitor_->OnStreamFrame(data1);
145 146
146 // The stream should not be re-opened. 147 // The stream should not be re-opened.
147 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 148 EXPECT_EQ(0u, session_->GetNumOpenStreams());
148 EXPECT_TRUE(connection_->connected()); 149 EXPECT_TRUE(connection_->connected());
149 } 150 }
150 151
151 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { 152 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
152 // Send a reset (and expect the peer to send a RST in response). 153 // Send a reset (and expect the peer to send a RST in response).
153 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 154 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
155 0);
154 EXPECT_CALL(*connection_, 156 EXPECT_CALL(*connection_,
155 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 157 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
156 visitor_->OnRstStream(rst1); 158 visitor_->OnRstStream(rst1);
157 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 159 EXPECT_EQ(0u, session_->GetNumOpenStreams());
158 160
159 // Send two bytes of payload. 161 // Send two bytes of payload.
160 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); 162 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT"));
161 visitor_->OnStreamFrame(data1); 163 visitor_->OnStreamFrame(data1);
162 164
163 // The stream should never be opened, now that the reset is received. 165 // The stream should never be opened, now that the reset is received.
164 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 166 EXPECT_EQ(0u, session_->GetNumOpenStreams());
165 EXPECT_TRUE(connection_->connected()); 167 EXPECT_TRUE(connection_->connected());
166 } 168 }
167 169
168 TEST_P(QuicServerSessionTest, AcceptClosedStream) { 170 TEST_P(QuicServerSessionTest, AcceptClosedStream) {
169 // Send (empty) compressed headers followed by two bytes of data. 171 // Send (empty) compressed headers followed by two bytes of data.
170 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, 172 QuicStreamFrame frame1(kClientDataStreamId1, false, 0,
171 StringPiece("\1\0\0\0\0\0\0\0HT")); 173 StringPiece("\1\0\0\0\0\0\0\0HT"));
172 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, 174 QuicStreamFrame frame2(kClientDataStreamId2, false, 0,
173 StringPiece("\2\0\0\0\0\0\0\0HT")); 175 StringPiece("\2\0\0\0\0\0\0\0HT"));
174 visitor_->OnStreamFrame(frame1); 176 visitor_->OnStreamFrame(frame1);
175 visitor_->OnStreamFrame(frame2); 177 visitor_->OnStreamFrame(frame2);
176 EXPECT_EQ(2u, session_->GetNumOpenStreams()); 178 EXPECT_EQ(2u, session_->GetNumOpenStreams());
177 179
178 // Send a reset (and expect the peer to send a RST in response). 180 // Send a reset (and expect the peer to send a RST in response).
179 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); 181 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0);
180 EXPECT_CALL(*connection_, 182 EXPECT_CALL(*connection_,
181 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); 183 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0));
182 visitor_->OnRstStream(rst); 184 visitor_->OnRstStream(rst);
183 185
184 // If we were tracking, we'd probably want to reject this because it's data 186 // If we were tracking, we'd probably want to reject this because it's data
185 // past the reset point of stream 3. As it's a closed stream we just drop the 187 // past the reset point of stream 3. As it's a closed stream we just drop the
186 // data on the floor, but accept the packet because it has data for stream 5. 188 // data on the floor, but accept the packet because it has data for stream 5.
187 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); 189 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP"));
188 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); 190 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP"));
189 visitor_->OnStreamFrame(frame3); 191 visitor_->OnStreamFrame(frame3);
(...skipping 14 matching lines...) Expand all
204 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); 206 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
205 session_->OnConfigNegotiated(); 207 session_->OnConfigNegotiated();
206 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, 208 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest,
207 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); 209 kMaxStreamsForTest + kMaxStreamsMinimumIncrement);
208 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, 210 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement,
209 session_->get_max_open_streams()); 211 session_->get_max_open_streams());
210 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 212 EXPECT_EQ(0u, session_->GetNumOpenStreams());
211 QuicStreamId stream_id = kClientDataStreamId1; 213 QuicStreamId stream_id = kClientDataStreamId1;
212 // Open the max configured number of streams, should be no problem. 214 // Open the max configured number of streams, should be no problem.
213 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { 215 for (size_t i = 0; i < kMaxStreamsForTest; ++i) {
214 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDynamicStream(session_.get(), 216 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(),
215 stream_id)); 217 stream_id));
216 stream_id += 2; 218 stream_id += 2;
217 } 219 }
218 220
219 // Open more streams: server should accept slightly more than the limit. 221 // Open more streams: server should accept slightly more than the limit.
220 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) { 222 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) {
221 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDynamicStream(session_.get(), 223 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(),
222 stream_id)); 224 stream_id));
223 stream_id += 2; 225 stream_id += 2;
224 } 226 }
225 227
226 // Now violate the server's internal stream limit. 228 // Now violate the server's internal stream limit.
227 stream_id += 2; 229 stream_id += 2;
228 if (connection_->version() <= QUIC_VERSION_27) { 230 if (connection_->version() <= QUIC_VERSION_27) {
229 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); 231 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
230 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(0); 232 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(0);
231 } else { 233 } else {
232 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0); 234 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0);
233 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0)); 235 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0));
234 } 236 }
235 // Even if the connection remains open, the stream creation should fail. 237 // Even if the connection remains open, the stream creation should fail.
236 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDynamicStream(session_.get(), 238 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(),
237 stream_id)); 239 stream_id));
238 } 240 }
239 241
240 TEST_P(QuicServerSessionTest, MaxAvailableStreams) { 242 TEST_P(QuicServerSessionTest, MaxAvailableStreams) {
241 // Test that the server closes the connection if a client makes too many data 243 // Test that the server closes the connection if a client makes too many data
242 // streams available. The server accepts slightly more than the negotiated 244 // streams available. The server accepts slightly more than the negotiated
243 // stream limit to deal with rare cases where a client FIN/RST is lost. 245 // stream limit to deal with rare cases where a client FIN/RST is lost.
244 246
245 // The slightly increased stream limit is set during config negotiation. 247 // The slightly increased stream limit is set during config negotiation.
246 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); 248 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
247 session_->OnConfigNegotiated(); 249 session_->OnConfigNegotiated();
248 const size_t kAvailableStreamLimit = session_->get_max_available_streams(); 250 const size_t kAvailableStreamLimit = session_->get_max_available_streams();
249 EXPECT_EQ(session_->get_max_open_streams() * kMaxAvailableStreamsMultiplier, 251 EXPECT_EQ(session_->get_max_open_streams() * kMaxAvailableStreamsMultiplier,
250 session_->get_max_available_streams()); 252 session_->get_max_available_streams());
251 // The protocol specification requires that there can be at least 10 times 253 // The protocol specification requires that there can be at least 10 times
252 // as many available streams as the connection's maximum open streams. 254 // as many available streams as the connection's maximum open streams.
253 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); 255 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit);
254 256
255 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 257 EXPECT_EQ(0u, session_->GetNumOpenStreams());
256 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDynamicStream( 258 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(
257 session_.get(), kClientDataStreamId1)); 259 session_.get(), kClientDataStreamId1));
258 260
259 // Establish available streams up to the server's limit. 261 // Establish available streams up to the server's limit.
260 const int kLimitingStreamId = 262 const int kLimitingStreamId =
261 FLAGS_allow_many_available_streams 263 FLAGS_allow_many_available_streams
262 ? kClientDataStreamId1 + (kAvailableStreamLimit)*2 + 2 264 ? kClientDataStreamId1 + (kAvailableStreamLimit)*2 + 2
263 : kClientDataStreamId1 + (session_->get_max_open_streams() - 1) * 2; 265 : kClientDataStreamId1 + (session_->get_max_open_streams() - 1) * 2;
264 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDynamicStream( 266 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(
265 session_.get(), kLimitingStreamId)); 267 session_.get(), kLimitingStreamId));
266 268
267 // A further available stream will result in connection close. 269 // A further available stream will result in connection close.
268 if (FLAGS_allow_many_available_streams) { 270 if (FLAGS_allow_many_available_streams) {
269 EXPECT_CALL(*connection_, 271 EXPECT_CALL(*connection_,
270 SendConnectionClose(QUIC_TOO_MANY_AVAILABLE_STREAMS)); 272 SendConnectionClose(QUIC_TOO_MANY_AVAILABLE_STREAMS));
271 } else { 273 } else {
272 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); 274 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
273 } 275 }
274 // This forces stream kLimitingStreamId + 2 to become available, which 276 // This forces stream kLimitingStreamId + 2 to become available, which
275 // violates the quota. 277 // violates the quota.
276 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDynamicStream( 278 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream(
277 session_.get(), kLimitingStreamId + 4)); 279 session_.get(), kLimitingStreamId + 4));
278 } 280 }
279 281
280 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { 282 TEST_P(QuicServerSessionTest, GetEvenIncomingError) {
281 // Incoming streams on the server session must be odd. 283 // Incoming streams on the server session must be odd.
282 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); 284 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID));
283 EXPECT_EQ(nullptr, 285 EXPECT_EQ(nullptr,
284 QuicServerSessionPeer::GetIncomingDynamicStream(session_.get(), 4)); 286 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 4));
285 } 287 }
286 288
287 TEST_P(QuicServerSessionTest, GetStreamDisconnected) { 289 TEST_P(QuicServerSessionTest, GetStreamDisconnected) {
288 // Don't create new streams if the connection is disconnected. 290 // Don't create new streams if the connection is disconnected.
289 QuicConnectionPeer::CloseConnection(connection_); 291 QuicConnectionPeer::CloseConnection(connection_);
290 EXPECT_DFATAL( 292 EXPECT_DFATAL(
291 QuicServerSessionPeer::GetIncomingDynamicStream(session_.get(), 5), 293 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 5),
292 "ShouldCreateIncomingDynamicStream called when disconnected"); 294 "ShouldCreateIncomingDynamicStream called when disconnected");
293 } 295 }
294 296
295 TEST_P(QuicServerSessionTest, SetFecProtectionFromConfig) { 297 TEST_P(QuicServerSessionTest, SetFecProtectionFromConfig) {
296 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); 298 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
297 299
298 // Set received config to have FEC connection option. 300 // Set received config to have FEC connection option.
299 QuicTagVector copt; 301 QuicTagVector copt;
300 copt.push_back(kFHDR); 302 copt.push_back(kFHDR);
301 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); 303 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt);
302 session_->OnConfigNegotiated(); 304 session_->OnConfigNegotiated();
303 305
304 // Verify that headers stream is always protected and data streams are 306 // Verify that headers stream is always protected and data streams are
305 // optionally protected. 307 // optionally protected.
306 EXPECT_EQ(FEC_PROTECT_ALWAYS, QuicSpdySessionPeer::GetHeadersStream( 308 EXPECT_EQ(FEC_PROTECT_ALWAYS, QuicSpdySessionPeer::GetHeadersStream(
307 session_.get())->fec_policy()); 309 session_.get())->fec_policy());
308 ReliableQuicStream* stream = QuicServerSessionPeer::GetIncomingDynamicStream( 310 ReliableQuicStream* stream = QuicServerSessionPeer::GetOrCreateDynamicStream(
309 session_.get(), kClientDataStreamId1); 311 session_.get(), kClientDataStreamId1);
310 ASSERT_TRUE(stream); 312 ASSERT_TRUE(stream);
311 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); 313 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
312 } 314 }
313 315
314 class MockQuicCryptoServerStream : public QuicCryptoServerStream { 316 class MockQuicCryptoServerStream : public QuicCryptoServerStream {
315 public: 317 public:
316 explicit MockQuicCryptoServerStream( 318 explicit MockQuicCryptoServerStream(
317 const QuicCryptoServerConfig* crypto_config, QuicSession* session) 319 const QuicCryptoServerConfig* crypto_config, QuicSession* session)
318 : QuicCryptoServerStream(crypto_config, session) {} 320 : QuicCryptoServerStream(crypto_config, session) {}
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); 492 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get()));
491 session_->OnConfigNegotiated(); 493 session_->OnConfigNegotiated();
492 EXPECT_FALSE( 494 EXPECT_FALSE(
493 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); 495 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get()));
494 } 496 }
495 497
496 } // namespace 498 } // namespace
497 } // namespace test 499 } // namespace test
498 } // namespace tools 500 } // namespace tools
499 } // namespace net 501 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server_session.h ('k') | net/tools/quic/quic_simple_server_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698