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

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

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 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/tools/quic/quic_simple_server.cc ('k') | net/tools/quic/quic_simple_server_stream.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/tools/quic/quic_simple_server_session.h" 5 #include "net/tools/quic/quic_simple_server_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory>
8 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "net/quic/crypto/quic_crypto_server_config.h" 12 #include "net/quic/crypto/quic_crypto_server_config.h"
12 #include "net/quic/crypto/quic_random.h" 13 #include "net/quic/crypto/quic_random.h"
13 #include "net/quic/proto/cached_network_parameters.pb.h" 14 #include "net/quic/proto/cached_network_parameters.pb.h"
14 #include "net/quic/quic_connection.h" 15 #include "net/quic/quic_connection.h"
15 #include "net/quic/quic_crypto_server_stream.h" 16 #include "net/quic/quic_crypto_server_stream.h"
16 #include "net/quic/quic_utils.h" 17 #include "net/quic/quic_utils.h"
17 #include "net/quic/test_tools/crypto_test_utils.h" 18 #include "net/quic/test_tools/crypto_test_utils.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 encryption_established_ = has_established; 99 encryption_established_ = has_established;
99 } 100 }
100 101
101 private: 102 private:
102 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); 103 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream);
103 }; 104 };
104 105
105 class MockConnectionWithSendStreamData : public MockConnection { 106 class MockConnectionWithSendStreamData : public MockConnection {
106 public: 107 public:
107 MockConnectionWithSendStreamData(MockConnectionHelper* helper, 108 MockConnectionWithSendStreamData(MockConnectionHelper* helper,
109 MockAlarmFactory* alarm_factory,
108 Perspective perspective, 110 Perspective perspective,
109 const QuicVersionVector& supported_versions) 111 const QuicVersionVector& supported_versions)
110 : MockConnection(helper, perspective, supported_versions) {} 112 : MockConnection(helper, alarm_factory, perspective, supported_versions) {
113 }
111 114
112 MOCK_METHOD5(SendStreamData, 115 MOCK_METHOD5(SendStreamData,
113 QuicConsumedData(QuicStreamId id, 116 QuicConsumedData(QuicStreamId id,
114 QuicIOVector iov, 117 QuicIOVector iov,
115 QuicStreamOffset offset, 118 QuicStreamOffset offset,
116 bool fin, 119 bool fin,
117 QuicAckListenerInterface* listern)); 120 QuicAckListenerInterface* listern));
118 }; 121 };
119 122
120 class QuicSimpleServerSessionPeer { 123 class QuicSimpleServerSessionPeer {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 compressed_certs_cache_( 163 compressed_certs_cache_(
161 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { 164 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) {
162 FLAGS_quic_always_log_bugs_for_tests = true; 165 FLAGS_quic_always_log_bugs_for_tests = true;
163 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 166 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
164 config_.SetInitialStreamFlowControlWindowToSend( 167 config_.SetInitialStreamFlowControlWindowToSend(
165 kInitialStreamFlowControlWindowForTest); 168 kInitialStreamFlowControlWindowForTest);
166 config_.SetInitialSessionFlowControlWindowToSend( 169 config_.SetInitialSessionFlowControlWindowToSend(
167 kInitialSessionFlowControlWindowForTest); 170 kInitialSessionFlowControlWindowForTest);
168 171
169 connection_ = new StrictMock<MockConnectionWithSendStreamData>( 172 connection_ = new StrictMock<MockConnectionWithSendStreamData>(
170 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); 173 &helper_, &alarm_factory_, Perspective::IS_SERVER,
174 SupportedVersions(GetParam()));
171 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_, 175 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_,
172 &crypto_config_, 176 &crypto_config_,
173 &compressed_certs_cache_)); 177 &compressed_certs_cache_));
174 MockClock clock; 178 MockClock clock;
175 handshake_message_.reset(crypto_config_.AddDefaultConfig( 179 handshake_message_.reset(crypto_config_.AddDefaultConfig(
176 QuicRandom::GetInstance(), &clock, 180 QuicRandom::GetInstance(), &clock,
177 QuicCryptoServerConfig::ConfigOptions())); 181 QuicCryptoServerConfig::ConfigOptions()));
178 session_->Initialize(); 182 session_->Initialize();
179 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 183 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
180 headers_stream_ = new MockQuicHeadersStream(session_.get()); 184 headers_stream_ = new MockQuicHeadersStream(session_.get());
181 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 185 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
182 // TODO(jri): Remove this line once tests pass. 186 // TODO(jri): Remove this line once tests pass.
183 FLAGS_quic_cede_correctly = false; 187 FLAGS_quic_cede_correctly = false;
184 } 188 }
185 189
186 StrictMock<MockQuicServerSessionVisitor> owner_; 190 StrictMock<MockQuicServerSessionVisitor> owner_;
187 MockConnectionHelper helper_; 191 MockConnectionHelper helper_;
192 MockAlarmFactory alarm_factory_;
188 StrictMock<MockConnectionWithSendStreamData>* connection_; 193 StrictMock<MockConnectionWithSendStreamData>* connection_;
189 QuicConfig config_; 194 QuicConfig config_;
190 QuicCryptoServerConfig crypto_config_; 195 QuicCryptoServerConfig crypto_config_;
191 QuicCompressedCertsCache compressed_certs_cache_; 196 QuicCompressedCertsCache compressed_certs_cache_;
192 std::unique_ptr<QuicSimpleServerSession> session_; 197 std::unique_ptr<QuicSimpleServerSession> session_;
193 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; 198 std::unique_ptr<CryptoHandshakeMessage> handshake_message_;
194 QuicConnectionVisitorInterface* visitor_; 199 QuicConnectionVisitorInterface* visitor_;
195 MockQuicHeadersStream* headers_stream_; 200 MockQuicHeadersStream* headers_stream_;
196 }; 201 };
197 202
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // enough that it won't block any stream to write before stream level flow 400 // enough that it won't block any stream to write before stream level flow
396 // control blocks it. 401 // control blocks it.
397 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow( 402 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow(
398 &config_, kInitialSessionFlowControlWindowForTest); 403 &config_, kInitialSessionFlowControlWindowForTest);
399 // Enable server push. 404 // Enable server push.
400 QuicTagVector copt; 405 QuicTagVector copt;
401 copt.push_back(kSPSH); 406 copt.push_back(kSPSH);
402 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt); 407 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt);
403 408
404 connection_ = new StrictMock<MockConnectionWithSendStreamData>( 409 connection_ = new StrictMock<MockConnectionWithSendStreamData>(
405 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); 410 &helper_, &alarm_factory_, Perspective::IS_SERVER,
411 SupportedVersions(GetParam()));
406 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_, 412 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_,
407 &crypto_config_, 413 &crypto_config_,
408 &compressed_certs_cache_)); 414 &compressed_certs_cache_));
409 session_->Initialize(); 415 session_->Initialize();
410 // Needed to make new session flow control window and server push work. 416 // Needed to make new session flow control window and server push work.
411 session_->OnConfigNegotiated(); 417 session_->OnConfigNegotiated();
412 418
413 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 419 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
414 headers_stream_ = new MockQuicHeadersStream(session_.get()); 420 headers_stream_ = new MockQuicHeadersStream(session_.get());
415 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 421 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); 570 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false)));
565 571
566 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); 572 EXPECT_CALL(*connection_, SendBlocked(stream_to_open));
567 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); 573 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0);
568 visitor_->OnRstStream(rst); 574 visitor_->OnRstStream(rst);
569 } 575 }
570 576
571 } // namespace 577 } // namespace
572 } // namespace test 578 } // namespace test
573 } // namespace net 579 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server.cc ('k') | net/tools/quic/quic_simple_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698