OLD | NEW |
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/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
10 #include "net/quic/test_tools/quic_connection_peer.h" | 10 #include "net/quic/test_tools/quic_connection_peer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using net::test::SupportedVersions; | 23 using net::test::SupportedVersions; |
24 using testing::_; | 24 using testing::_; |
25 using testing::StrictMock; | 25 using testing::StrictMock; |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 namespace tools { | 28 namespace tools { |
29 namespace test { | 29 namespace test { |
30 | 30 |
31 class QuicServerSessionPeer { | 31 class QuicServerSessionPeer { |
32 public: | 32 public: |
33 static QuicDataStream* GetIncomingReliableStream( | 33 static QuicDataStream* GetIncomingDataStream( |
34 QuicServerSession* s, QuicStreamId id) { | 34 QuicServerSession* s, QuicStreamId id) { |
35 return s->GetIncomingReliableStream(id); | 35 return s->GetIncomingDataStream(id); |
36 } | 36 } |
37 static QuicDataStream* GetDataStream(QuicServerSession* s, QuicStreamId id) { | 37 static QuicDataStream* GetDataStream(QuicServerSession* s, QuicStreamId id) { |
38 return s->GetDataStream(id); | 38 return s->GetDataStream(id); |
39 } | 39 } |
40 }; | 40 }; |
41 | 41 |
42 class CloseOnDataStream : public QuicDataStream { | 42 class CloseOnDataStream : public QuicDataStream { |
43 public: | 43 public: |
44 CloseOnDataStream(QuicStreamId id, QuicSession* session) | 44 CloseOnDataStream(QuicStreamId id, QuicSession* session) |
45 : QuicDataStream(id, session) { | 45 : QuicDataStream(id, session) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 frames.clear(); | 217 frames.clear(); |
218 frames.push_back(QuicStreamFrame(stream_id, false, 2, MakeIOVector("TP"))); | 218 frames.push_back(QuicStreamFrame(stream_id, false, 2, MakeIOVector("TP"))); |
219 frames.push_back(QuicStreamFrame(stream_id + 2, false, 2, | 219 frames.push_back(QuicStreamFrame(stream_id + 2, false, 2, |
220 MakeIOVector("TP"))); | 220 MakeIOVector("TP"))); |
221 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); | 221 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); |
222 } | 222 } |
223 | 223 |
224 TEST_P(QuicServerSessionTest, MaxNumConnections) { | 224 TEST_P(QuicServerSessionTest, MaxNumConnections) { |
225 QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5; | 225 QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5; |
226 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 226 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
227 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 227 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
228 stream_id)); | 228 stream_id)); |
229 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 229 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
230 stream_id + 2)); | 230 stream_id + 2)); |
231 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 231 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
232 stream_id + 4)); | 232 stream_id + 4)); |
233 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); | 233 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); |
234 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 234 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
235 stream_id + 6)); | 235 stream_id + 6)); |
236 } | 236 } |
237 | 237 |
238 TEST_P(QuicServerSessionTest, MaxNumConnectionsImplicit) { | 238 TEST_P(QuicServerSessionTest, MaxNumConnectionsImplicit) { |
239 QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5; | 239 QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5; |
240 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 240 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
241 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 241 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
242 stream_id)); | 242 stream_id)); |
243 // Implicitly opens two more streams. | 243 // Implicitly opens two more streams. |
244 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); | 244 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); |
245 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), | 245 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), |
246 stream_id + 6)); | 246 stream_id + 6)); |
247 } | 247 } |
248 | 248 |
249 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { | 249 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { |
250 // Incoming streams on the server session must be odd. | 250 // Incoming streams on the server session must be odd. |
251 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 251 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); |
252 EXPECT_EQ(NULL, | 252 EXPECT_EQ(NULL, |
253 QuicServerSessionPeer::GetIncomingReliableStream( | 253 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); |
254 session_.get(), 4)); | |
255 } | 254 } |
256 | 255 |
257 } // namespace | 256 } // namespace |
258 } // namespace test | 257 } // namespace test |
259 } // namespace tools | 258 } // namespace tools |
260 } // namespace net | 259 } // namespace net |
OLD | NEW |