[Mac] Enable MacViews bookmark editor behind --enable-mac-views-dialogs.
[chromium-blink-merge.git] / net / quic / congestion_control / hybrid_slow_start_test.cc
blob97dc32f6b328ff495c409cd6817df323c88cd39a
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
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "net/quic/congestion_control/hybrid_slow_start.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace net {
11 namespace test {
13 class HybridSlowStartTest : public ::testing::Test {
14 protected:
15 HybridSlowStartTest()
16 : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
17 rtt_(QuicTime::Delta::FromMilliseconds(60)) {
19 void SetUp() override { slow_start_.reset(new HybridSlowStart()); }
20 const QuicTime::Delta one_ms_;
21 const QuicTime::Delta rtt_;
22 scoped_ptr<HybridSlowStart> slow_start_;
25 TEST_F(HybridSlowStartTest, Simple) {
26 QuicPacketSequenceNumber sequence_number = 1;
27 QuicPacketSequenceNumber end_sequence_number = 3;
28 slow_start_->StartReceiveRound(end_sequence_number);
30 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
32 // Test duplicates.
33 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number));
35 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
36 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
38 // Test without a new registered end_sequence_number;
39 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
41 end_sequence_number = 20;
42 slow_start_->StartReceiveRound(end_sequence_number);
43 while (sequence_number < end_sequence_number) {
44 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
46 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
49 TEST_F(HybridSlowStartTest, Delay) {
50 // We expect to detect the increase at +1/8 of the RTT; hence at a typical
51 // RTT of 60ms the detection will happen at 67.5 ms.
52 const int kHybridStartMinSamples = 8; // Number of acks required to trigger.
54 QuicPacketSequenceNumber end_sequence_number = 1;
55 slow_start_->StartReceiveRound(end_sequence_number++);
57 // Will not trigger since our lowest RTT in our burst is the same as the long
58 // term RTT provided.
59 for (int n = 0; n < kHybridStartMinSamples; ++n) {
60 EXPECT_FALSE(slow_start_->ShouldExitSlowStart(
61 rtt_.Add(QuicTime::Delta::FromMilliseconds(n)), rtt_, 100));
63 slow_start_->StartReceiveRound(end_sequence_number++);
64 for (int n = 1; n < kHybridStartMinSamples; ++n) {
65 EXPECT_FALSE(slow_start_->ShouldExitSlowStart(
66 rtt_.Add(QuicTime::Delta::FromMilliseconds(n + 10)), rtt_, 100));
68 // Expect to trigger since all packets in this burst was above the long term
69 // RTT provided.
70 EXPECT_TRUE(slow_start_->ShouldExitSlowStart(
71 rtt_.Add(QuicTime::Delta::FromMilliseconds(10)), rtt_, 100));
74 } // namespace test
75 } // namespace net