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

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

Issue 1761263002: Landing recent QUIC changes until 7:19 PM, Feb 26, 2016 UTC-5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ActivateStream() call to QuicChromiumClientSession to fix server push failure Created 4 years, 9 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_server_session_base.cc ('k') | net/tools/quic/quic_simple_client_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_base.h" 5 #include "net/tools/quic/quic_server_session_base.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "net/quic/crypto/quic_crypto_server_config.h" 8 #include "net/quic/crypto/quic_crypto_server_config.h"
9 #include "net/quic/crypto/quic_random.h" 9 #include "net/quic/crypto/quic_random.h"
10 #include "net/quic/proto/cached_network_parameters.pb.h" 10 #include "net/quic/proto/cached_network_parameters.pb.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const QuicCryptoServerConfig* crypto_config) 76 const QuicCryptoServerConfig* crypto_config)
77 : QuicServerSessionBase(config, connection, visitor, crypto_config) {} 77 : QuicServerSessionBase(config, connection, visitor, crypto_config) {}
78 78
79 ~TestServerSession() override{}; 79 ~TestServerSession() override{};
80 80
81 protected: 81 protected:
82 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { 82 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override {
83 if (!ShouldCreateIncomingDynamicStream(id)) { 83 if (!ShouldCreateIncomingDynamicStream(id)) {
84 return nullptr; 84 return nullptr;
85 } 85 }
86 return new QuicSimpleServerStream(id, this); 86 QuicSpdyStream* stream = new QuicSimpleServerStream(id, this);
87 ActivateStream(stream);
88 return stream;
87 } 89 }
88 90
89 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { 91 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override {
90 if (!ShouldCreateOutgoingDynamicStream()) { 92 if (!ShouldCreateOutgoingDynamicStream()) {
91 return nullptr; 93 return nullptr;
92 } 94 }
93 95
94 QuicSpdyStream* stream = 96 QuicSpdyStream* stream =
95 new QuicSimpleServerStream(GetNextOutgoingStreamId(), this); 97 new QuicSimpleServerStream(GetNextOutgoingStreamId(), this);
96 stream->SetPriority(priority); 98 stream->SetPriority(priority);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 320 }
319 321
320 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { 322 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) {
321 // Don't create new streams if the connection is disconnected. 323 // Don't create new streams if the connection is disconnected.
322 QuicConnectionPeer::CloseConnection(connection_); 324 QuicConnectionPeer::CloseConnection(connection_);
323 EXPECT_DFATAL( 325 EXPECT_DFATAL(
324 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5), 326 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5),
325 "ShouldCreateIncomingDynamicStream called when disconnected"); 327 "ShouldCreateIncomingDynamicStream called when disconnected");
326 } 328 }
327 329
328 TEST_P(QuicServerSessionBaseTest, SetFecProtectionFromConfig) {
329 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
330
331 // Set received config to have FEC connection option.
332 QuicTagVector copt;
333 copt.push_back(kFHDR);
334 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt);
335 session_->OnConfigNegotiated();
336
337 // Verify that headers stream is always protected and data streams are
338 // optionally protected.
339 EXPECT_EQ(
340 FEC_PROTECT_ALWAYS,
341 QuicSpdySessionPeer::GetHeadersStream(session_.get())->fec_policy());
342 ReliableQuicStream* stream =
343 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(),
344 kClientDataStreamId1);
345 ASSERT_TRUE(stream);
346 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
347 }
348
349 class MockQuicCryptoServerStream : public QuicCryptoServerStream { 330 class MockQuicCryptoServerStream : public QuicCryptoServerStream {
350 public: 331 public:
351 explicit MockQuicCryptoServerStream( 332 explicit MockQuicCryptoServerStream(
352 const QuicCryptoServerConfig* crypto_config, 333 const QuicCryptoServerConfig* crypto_config,
353 QuicSession* session) 334 QuicSession* session)
354 : QuicCryptoServerStream(crypto_config, session) {} 335 : QuicCryptoServerStream(crypto_config, session) {}
355 ~MockQuicCryptoServerStream() override {} 336 ~MockQuicCryptoServerStream() override {}
356 337
357 MOCK_METHOD1(SendServerConfigUpdate, 338 MOCK_METHOD1(SendServerConfigUpdate,
358 void(const CachedNetworkParameters* cached_network_parameters)); 339 void(const CachedNetworkParameters* cached_network_parameters));
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 EXPECT_FALSE( 509 EXPECT_FALSE(
529 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 510 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
530 session_->OnConfigNegotiated(); 511 session_->OnConfigNegotiated();
531 EXPECT_FALSE( 512 EXPECT_FALSE(
532 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 513 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
533 } 514 }
534 515
535 } // namespace 516 } // namespace
536 } // namespace test 517 } // namespace test
537 } // namespace net 518 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server_session_base.cc ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698