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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/tools/quic/quic_server_session.cc ('k') | net/tools/quic/quic_spdy_server_stream_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/tools/quic/quic_server_session.h" 5 #include "net/tools/quic/quic_server_session.h"
6 6
7 #include "net/quic/crypto/cached_network_parameters.h" 7 #include "net/quic/crypto/cached_network_parameters.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/quic_connection.h" 10 #include "net/quic/quic_connection.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 session_.get(), kClientDataStreamId1); 285 session_.get(), kClientDataStreamId1);
286 ASSERT_TRUE(stream); 286 ASSERT_TRUE(stream);
287 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); 287 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
288 } 288 }
289 289
290 class MockQuicCryptoServerStream : public QuicCryptoServerStream { 290 class MockQuicCryptoServerStream : public QuicCryptoServerStream {
291 public: 291 public:
292 explicit MockQuicCryptoServerStream( 292 explicit MockQuicCryptoServerStream(
293 const QuicCryptoServerConfig& crypto_config, QuicSession* session) 293 const QuicCryptoServerConfig& crypto_config, QuicSession* session)
294 : QuicCryptoServerStream(crypto_config, session) {} 294 : QuicCryptoServerStream(crypto_config, session) {}
295 virtual ~MockQuicCryptoServerStream() {} 295 ~MockQuicCryptoServerStream() override {}
296 296
297 MOCK_METHOD1(SendServerConfigUpdate, 297 MOCK_METHOD1(SendServerConfigUpdate,
298 void(const CachedNetworkParameters* cached_network_parameters)); 298 void(const CachedNetworkParameters* cached_network_parameters));
299 299
300 private: 300 private:
301 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); 301 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream);
302 }; 302 };
303 303
304 TEST_P(QuicServerSessionTest, BandwidthEstimates) { 304 TEST_P(QuicServerSessionTest, BandwidthEstimates) {
305 if (version() <= QUIC_VERSION_21) { 305 if (version() <= QUIC_VERSION_21) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 expected_network_params.set_timestamp( 376 expected_network_params.set_timestamp(
377 session_->connection()->clock()->WallNow().ToUNIXSeconds()); 377 session_->connection()->clock()->WallNow().ToUNIXSeconds());
378 expected_network_params.set_serving_region(serving_region); 378 expected_network_params.set_serving_region(serving_region);
379 379
380 EXPECT_CALL(*crypto_stream, 380 EXPECT_CALL(*crypto_stream,
381 SendServerConfigUpdate(EqualsProto(expected_network_params))) 381 SendServerConfigUpdate(EqualsProto(expected_network_params)))
382 .Times(1); 382 .Times(1);
383 session_->OnCongestionWindowChange(now); 383 session_->OnCongestionWindowChange(now);
384 } 384 }
385 385
386 TEST_P(QuicServerSessionTest, BandwidthResumptionExperiment) {
387 ValueRestore<bool> old_flag(
388 &FLAGS_quic_enable_bandwidth_resumption_experiment, true);
389
390 // Test that if a client provides a CachedNetworkParameters with the same
391 // serving region as the current server, that this data is passed down to the
392 // send algorithm.
393
394 // Client has sent kBWRE connection option to trigger bandwidth resumption.
395 QuicTagVector copt;
396 copt.push_back(kBWRE);
397 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt);
398
399 const string kTestServingRegion = "a serving region";
400 session_->set_serving_region(kTestServingRegion);
401
402 QuicCryptoServerStream* crypto_stream =
403 static_cast<QuicCryptoServerStream*>(
404 QuicSessionPeer::GetCryptoStream(session_.get()));
405
406 // No effect if no CachedNetworkParameters provided.
407 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0);
408 session_->OnConfigNegotiated();
409
410 // No effect if CachedNetworkParameters provided, but different serving
411 // regions.
412 CachedNetworkParameters cached_network_params;
413 cached_network_params.set_bandwidth_estimate_bytes_per_second(1);
414 cached_network_params.set_serving_region("different serving region");
415 crypto_stream->set_previous_cached_network_params(cached_network_params);
416 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0);
417 session_->OnConfigNegotiated();
418
419 // Same serving region results in CachedNetworkParameters being stored.
420 cached_network_params.set_serving_region(kTestServingRegion);
421 crypto_stream->set_previous_cached_network_params(cached_network_params);
422 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(1);
423 session_->OnConfigNegotiated();
424 }
425
386 } // namespace 426 } // namespace
387 } // namespace test 427 } // namespace test
388 } // namespace tools 428 } // namespace tools
389 } // namespace net 429 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server_session.cc ('k') | net/tools/quic/quic_spdy_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698