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

Side by Side Diff: net/quic/quic_session_test.cc

Issue 102313005: Remove the is_server argument from the QuicSession constructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_sequencer_test.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic_session.h" 5 #include "net/quic/quic_session.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 session_->MarkWriteBlocked(stream_id_, kSomeMiddlePriority); 83 session_->MarkWriteBlocked(stream_id_, kSomeMiddlePriority);
84 } 84 }
85 85
86 private: 86 private:
87 QuicSession* const session_; 87 QuicSession* const session_;
88 const QuicStreamId stream_id_; 88 const QuicStreamId stream_id_;
89 }; 89 };
90 90
91 class TestSession : public QuicSession { 91 class TestSession : public QuicSession {
92 public: 92 public:
93 TestSession(QuicConnection* connection, bool is_server) 93 explicit TestSession(QuicConnection* connection)
94 : QuicSession(connection, DefaultQuicConfig(), is_server), 94 : QuicSession(connection, DefaultQuicConfig()),
95 crypto_stream_(this) { 95 crypto_stream_(this) {
96 } 96 }
97 97
98 virtual TestCryptoStream* GetCryptoStream() OVERRIDE { 98 virtual TestCryptoStream* GetCryptoStream() OVERRIDE {
99 return &crypto_stream_; 99 return &crypto_stream_;
100 } 100 }
101 101
102 virtual TestStream* CreateOutgoingDataStream() OVERRIDE { 102 virtual TestStream* CreateOutgoingDataStream() OVERRIDE {
103 TestStream* stream = new TestStream(GetNextStreamId(), this); 103 TestStream* stream = new TestStream(GetNextStreamId(), this);
104 ActivateStream(stream); 104 ActivateStream(stream);
(...skipping 11 matching lines...) Expand all
116 QuicDataStream* GetIncomingReliableStream(QuicStreamId stream_id) { 116 QuicDataStream* GetIncomingReliableStream(QuicStreamId stream_id) {
117 return QuicSession::GetIncomingReliableStream(stream_id); 117 return QuicSession::GetIncomingReliableStream(stream_id);
118 } 118 }
119 119
120 TestCryptoStream crypto_stream_; 120 TestCryptoStream crypto_stream_;
121 }; 121 };
122 122
123 class QuicSessionTest : public ::testing::Test { 123 class QuicSessionTest : public ::testing::Test {
124 protected: 124 protected:
125 QuicSessionTest() 125 QuicSessionTest()
126 : connection_(new MockConnection(false)), 126 : connection_(new MockConnection(true)),
127 session_(connection_, true) { 127 session_(connection_) {
128 headers_[":host"] = "www.google.com"; 128 headers_[":host"] = "www.google.com";
129 headers_[":path"] = "/index.hml"; 129 headers_[":path"] = "/index.hml";
130 headers_[":scheme"] = "http"; 130 headers_[":scheme"] = "http";
131 headers_["cookie"] = 131 headers_["cookie"] =
132 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " 132 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; "
133 "__utmc=160408618; " 133 "__utmc=160408618; "
134 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX" 134 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX"
135 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX" 135 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX"
136 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT" 136 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT"
137 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0" 137 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 TEST_F(QuicSessionTest, StreamIdTooLarge) { 239 TEST_F(QuicSessionTest, StreamIdTooLarge) {
240 session_.GetIncomingReliableStream(3); 240 session_.GetIncomingReliableStream(3);
241 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); 241 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID));
242 session_.GetIncomingReliableStream(105); 242 session_.GetIncomingReliableStream(105);
243 } 243 }
244 244
245 TEST_F(QuicSessionTest, DecompressionError) { 245 TEST_F(QuicSessionTest, DecompressionError) {
246 ReliableQuicStream* stream = session_.GetIncomingReliableStream(3); 246 ReliableQuicStream* stream = session_.GetIncomingReliableStream(3);
247 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_DECOMPRESSION_FAILURE)); 247 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_DECOMPRESSION_FAILURE));
248 const char data[] = 248 const char data[] =
249 "\0\0\0\0" // priority
249 "\1\0\0\0" // headers id 250 "\1\0\0\0" // headers id
250 "\0\0\0\4" // length 251 "\0\0\0\4" // length
251 "abcd"; // invalid compressed data 252 "abcd"; // invalid compressed data
252 stream->ProcessRawData(data, arraysize(data)); 253 stream->ProcessRawData(data, arraysize(data));
253 } 254 }
254 255
255 TEST_F(QuicSessionTest, OnCanWrite) { 256 TEST_F(QuicSessionTest, OnCanWrite) {
256 TestStream* stream2 = session_.CreateOutgoingDataStream(); 257 TestStream* stream2 = session_.CreateOutgoingDataStream();
257 TestStream* stream4 = session_.CreateOutgoingDataStream(); 258 TestStream* stream4 = session_.CreateOutgoingDataStream();
258 TestStream* stream6 = session_.CreateOutgoingDataStream(); 259 TestStream* stream6 = session_.CreateOutgoingDataStream();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 388 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
388 CryptoHandshakeMessage msg; 389 CryptoHandshakeMessage msg;
389 session_.crypto_stream_.OnHandshakeMessage(msg); 390 session_.crypto_stream_.OnHandshakeMessage(msg);
390 EXPECT_EQ(kDefaultTimeoutSecs, 391 EXPECT_EQ(kDefaultTimeoutSecs,
391 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 392 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
392 } 393 }
393 394
394 TEST_F(QuicSessionTest, ZombieStream) { 395 TEST_F(QuicSessionTest, ZombieStream) {
395 StrictMock<MockConnection>* connection = 396 StrictMock<MockConnection>* connection =
396 new StrictMock<MockConnection>(false); 397 new StrictMock<MockConnection>(false);
397 TestSession session(connection, /*is_server=*/ false); 398 TestSession session(connection);
398 399
399 TestStream* stream3 = session.CreateOutgoingDataStream(); 400 TestStream* stream3 = session.CreateOutgoingDataStream();
400 EXPECT_EQ(3u, stream3->id()); 401 EXPECT_EQ(3u, stream3->id());
401 TestStream* stream5 = session.CreateOutgoingDataStream(); 402 TestStream* stream5 = session.CreateOutgoingDataStream();
402 EXPECT_EQ(5u, stream5->id()); 403 EXPECT_EQ(5u, stream5->id());
403 EXPECT_EQ(2u, session.GetNumOpenStreams()); 404 EXPECT_EQ(2u, session.GetNumOpenStreams());
404 405
405 // Reset the stream, but since the headers have not been decompressed 406 // Reset the stream, but since the headers have not been decompressed
406 // it will become a zombie and will continue to process data 407 // it will become a zombie and will continue to process data
407 // until the headers are decompressed. 408 // until the headers are decompressed.
(...skipping 19 matching lines...) Expand all
427 428
428 session.OnStreamFrames(frames); 429 session.OnStreamFrames(frames);
429 EXPECT_EQ(1u, session.GetNumOpenStreams()); 430 EXPECT_EQ(1u, session.GetNumOpenStreams());
430 431
431 EXPECT_TRUE(connection->connected()); 432 EXPECT_TRUE(connection->connected());
432 } 433 }
433 434
434 TEST_F(QuicSessionTest, ZombieStreamConnectionClose) { 435 TEST_F(QuicSessionTest, ZombieStreamConnectionClose) {
435 StrictMock<MockConnection>* connection = 436 StrictMock<MockConnection>* connection =
436 new StrictMock<MockConnection>(false); 437 new StrictMock<MockConnection>(false);
437 TestSession session(connection, /*is_server=*/ false); 438 TestSession session(connection);
438 439
439 TestStream* stream3 = session.CreateOutgoingDataStream(); 440 TestStream* stream3 = session.CreateOutgoingDataStream();
440 EXPECT_EQ(3u, stream3->id()); 441 EXPECT_EQ(3u, stream3->id());
441 TestStream* stream5 = session.CreateOutgoingDataStream(); 442 TestStream* stream5 = session.CreateOutgoingDataStream();
442 EXPECT_EQ(5u, stream5->id()); 443 EXPECT_EQ(5u, stream5->id());
443 EXPECT_EQ(2u, session.GetNumOpenStreams()); 444 EXPECT_EQ(2u, session.GetNumOpenStreams());
444 445
445 stream3->CloseWriteSide(); 446 stream3->CloseWriteSide();
446 // Reset the stream, but since the headers have not been decompressed 447 // Reset the stream, but since the headers have not been decompressed
447 // it will become a zombie and will continue to process data 448 // it will become a zombie and will continue to process data
(...skipping 22 matching lines...) Expand all
470 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED)); 471 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED));
471 472
472 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR); 473 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR);
473 session_.OnRstStream(rst1); 474 session_.OnRstStream(rst1);
474 EXPECT_EQ(0u, session_.GetNumOpenStreams()); 475 EXPECT_EQ(0u, session_.GetNumOpenStreams());
475 } 476 }
476 477
477 } // namespace 478 } // namespace
478 } // namespace test 479 } // namespace test
479 } // namespace net 480 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698