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

Side by Side Diff: net/quic/core/quic_server_session_base_test.cc

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. Created 4 years, 3 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/core/quic_server_session_base.cc ('k') | net/quic/core/quic_session_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 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/quic/core/quic_server_session_base.h" 5 #include "net/quic/core/quic_server_session_base.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 }; 69 };
70 70
71 namespace { 71 namespace {
72 72
73 class TestServerSession : public QuicServerSessionBase { 73 class TestServerSession : public QuicServerSessionBase {
74 public: 74 public:
75 TestServerSession(const QuicConfig& config, 75 TestServerSession(const QuicConfig& config,
76 QuicConnection* connection, 76 QuicConnection* connection,
77 QuicServerSessionBase::Visitor* visitor, 77 QuicServerSessionBase::Visitor* visitor,
78 QuicServerSessionBase::Helper* helper, 78 QuicCryptoServerStream::Helper* helper,
79 const QuicCryptoServerConfig* crypto_config, 79 const QuicCryptoServerConfig* crypto_config,
80 QuicCompressedCertsCache* compressed_certs_cache) 80 QuicCompressedCertsCache* compressed_certs_cache)
81 : QuicServerSessionBase(config, 81 : QuicServerSessionBase(config,
82 connection, 82 connection,
83 visitor, 83 visitor,
84 helper, 84 helper,
85 crypto_config, 85 crypto_config,
86 compressed_certs_cache) {} 86 compressed_certs_cache) {}
87 87
88 ~TestServerSession() override { delete connection(); }; 88 ~TestServerSession() override { delete connection(); };
(...skipping 18 matching lines...) Expand all
107 stream->SetPriority(priority); 107 stream->SetPriority(priority);
108 ActivateStream(stream); 108 ActivateStream(stream);
109 return stream; 109 return stream;
110 } 110 }
111 111
112 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( 112 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream(
113 const QuicCryptoServerConfig* crypto_config, 113 const QuicCryptoServerConfig* crypto_config,
114 QuicCompressedCertsCache* compressed_certs_cache) override { 114 QuicCompressedCertsCache* compressed_certs_cache) override {
115 return new QuicCryptoServerStream( 115 return new QuicCryptoServerStream(
116 crypto_config, compressed_certs_cache, 116 crypto_config, compressed_certs_cache,
117 FLAGS_enable_quic_stateless_reject_support, this); 117 FLAGS_enable_quic_stateless_reject_support, this, stream_helper());
118 } 118 }
119 }; 119 };
120 120
121 const size_t kMaxStreamsForTest = 10; 121 const size_t kMaxStreamsForTest = 10;
122 122
123 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { 123 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> {
124 protected: 124 protected:
125 QuicServerSessionBaseTest() 125 QuicServerSessionBaseTest()
126 : crypto_config_(QuicCryptoServerConfig::TESTING, 126 : crypto_config_(QuicCryptoServerConfig::TESTING,
127 QuicRandom::GetInstance(), 127 QuicRandom::GetInstance(),
128 CryptoTestUtils::ProofSourceForTesting()), 128 CryptoTestUtils::ProofSourceForTesting()),
129 compressed_certs_cache_( 129 compressed_certs_cache_(
130 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { 130 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) {
131 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 131 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
132 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest); 132 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest);
133 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_, 133 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_,
134 kMaxStreamsForTest); 134 kMaxStreamsForTest);
135 config_.SetInitialStreamFlowControlWindowToSend( 135 config_.SetInitialStreamFlowControlWindowToSend(
136 kInitialStreamFlowControlWindowForTest); 136 kInitialStreamFlowControlWindowForTest);
137 config_.SetInitialSessionFlowControlWindowToSend( 137 config_.SetInitialSessionFlowControlWindowToSend(
138 kInitialSessionFlowControlWindowForTest); 138 kInitialSessionFlowControlWindowForTest);
139 139
140 connection_ = new StrictMock<MockQuicConnection>( 140 connection_ = new StrictMock<MockQuicConnection>(
141 &helper_, &alarm_factory_, Perspective::IS_SERVER, 141 &helper_, &alarm_factory_, Perspective::IS_SERVER,
142 SupportedVersions(GetParam())); 142 SupportedVersions(GetParam()));
143 session_.reset(new TestServerSession(config_, connection_, &owner_, 143 session_.reset(new TestServerSession(config_, connection_, &owner_,
144 &session_helper_, &crypto_config_, 144 &stream_helper_, &crypto_config_,
145 &compressed_certs_cache_)); 145 &compressed_certs_cache_));
146 MockClock clock; 146 MockClock clock;
147 handshake_message_.reset(crypto_config_.AddDefaultConfig( 147 handshake_message_.reset(crypto_config_.AddDefaultConfig(
148 QuicRandom::GetInstance(), &clock, 148 QuicRandom::GetInstance(), &clock,
149 QuicCryptoServerConfig::ConfigOptions())); 149 QuicCryptoServerConfig::ConfigOptions()));
150 session_->Initialize(); 150 session_->Initialize();
151 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 151 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
152 } 152 }
153 153
154 StrictMock<MockQuicServerSessionVisitor> owner_; 154 StrictMock<MockQuicServerSessionVisitor> owner_;
155 StrictMock<MockQuicServerSessionHelper> session_helper_; 155 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_;
156 MockQuicConnectionHelper helper_; 156 MockQuicConnectionHelper helper_;
157 MockAlarmFactory alarm_factory_; 157 MockAlarmFactory alarm_factory_;
158 StrictMock<MockQuicConnection>* connection_; 158 StrictMock<MockQuicConnection>* connection_;
159 QuicConfig config_; 159 QuicConfig config_;
160 QuicCryptoServerConfig crypto_config_; 160 QuicCryptoServerConfig crypto_config_;
161 QuicCompressedCertsCache compressed_certs_cache_; 161 QuicCompressedCertsCache compressed_certs_cache_;
162 std::unique_ptr<TestServerSession> session_; 162 std::unique_ptr<TestServerSession> session_;
163 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; 163 std::unique_ptr<CryptoHandshakeMessage> handshake_message_;
164 QuicConnectionVisitorInterface* visitor_; 164 QuicConnectionVisitorInterface* visitor_;
165 }; 165 };
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 EXPECT_QUIC_BUG( 364 EXPECT_QUIC_BUG(
365 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5), 365 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5),
366 "ShouldCreateIncomingDynamicStream called when disconnected"); 366 "ShouldCreateIncomingDynamicStream called when disconnected");
367 } 367 }
368 368
369 class MockQuicCryptoServerStream : public QuicCryptoServerStream { 369 class MockQuicCryptoServerStream : public QuicCryptoServerStream {
370 public: 370 public:
371 explicit MockQuicCryptoServerStream( 371 explicit MockQuicCryptoServerStream(
372 const QuicCryptoServerConfig* crypto_config, 372 const QuicCryptoServerConfig* crypto_config,
373 QuicCompressedCertsCache* compressed_certs_cache, 373 QuicCompressedCertsCache* compressed_certs_cache,
374 QuicServerSessionBase* session) 374 QuicServerSessionBase* session,
375 QuicCryptoServerStream::Helper* helper)
375 : QuicCryptoServerStream(crypto_config, 376 : QuicCryptoServerStream(crypto_config,
376 compressed_certs_cache, 377 compressed_certs_cache,
377 FLAGS_enable_quic_stateless_reject_support, 378 FLAGS_enable_quic_stateless_reject_support,
378 session) {} 379 session,
380 helper) {}
379 ~MockQuicCryptoServerStream() override {} 381 ~MockQuicCryptoServerStream() override {}
380 382
381 MOCK_METHOD1(SendServerConfigUpdate, 383 MOCK_METHOD1(SendServerConfigUpdate,
382 void(const CachedNetworkParameters* cached_network_parameters)); 384 void(const CachedNetworkParameters* cached_network_parameters));
383 385
384 void set_encryption_established(bool has_established) { 386 void set_encryption_established(bool has_established) {
385 encryption_established_ = has_established; 387 encryption_established_ = has_established;
386 } 388 }
387 389
388 private: 390 private:
(...skipping 15 matching lines...) Expand all
404 session_->OnConfigNegotiated(); 406 session_->OnConfigNegotiated();
405 EXPECT_TRUE( 407 EXPECT_TRUE(
406 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 408 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
407 409
408 int32_t bandwidth_estimate_kbytes_per_second = 123; 410 int32_t bandwidth_estimate_kbytes_per_second = 123;
409 int32_t max_bandwidth_estimate_kbytes_per_second = 134; 411 int32_t max_bandwidth_estimate_kbytes_per_second = 134;
410 int32_t max_bandwidth_estimate_timestamp = 1122334455; 412 int32_t max_bandwidth_estimate_timestamp = 1122334455;
411 const string serving_region = "not a real region"; 413 const string serving_region = "not a real region";
412 session_->set_serving_region(serving_region); 414 session_->set_serving_region(serving_region);
413 415
414 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream( 416 MockQuicCryptoServerStream* crypto_stream =
415 &crypto_config_, &compressed_certs_cache_, session_.get()); 417 new MockQuicCryptoServerStream(&crypto_config_, &compressed_certs_cache_,
418 session_.get(), &stream_helper_);
416 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream); 419 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream);
417 420
418 // Set some initial bandwidth values. 421 // Set some initial bandwidth values.
419 QuicSentPacketManager* sent_packet_manager = 422 QuicSentPacketManager* sent_packet_manager =
420 QuicConnectionPeer::GetSentPacketManager(session_->connection(), 423 QuicConnectionPeer::GetSentPacketManager(session_->connection(),
421 kDefaultPathId); 424 kDefaultPathId);
422 QuicSustainedBandwidthRecorder& bandwidth_recorder = 425 QuicSustainedBandwidthRecorder& bandwidth_recorder =
423 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager); 426 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager);
424 // Seed an rtt measurement equal to the initial default rtt. 427 // Seed an rtt measurement equal to the initial default rtt.
425 RttStats* rtt_stats = 428 RttStats* rtt_stats =
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_FALSE( 558 EXPECT_FALSE(
556 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 559 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
557 session_->OnConfigNegotiated(); 560 session_->OnConfigNegotiated();
558 EXPECT_FALSE( 561 EXPECT_FALSE(
559 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 562 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
560 } 563 }
561 564
562 } // namespace 565 } // namespace
563 } // namespace test 566 } // namespace test
564 } // namespace net 567 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_server_session_base.cc ('k') | net/quic/core/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698