Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / net / quic / congestion_control / hybrid_slow_start_test.cc
blob1b34ad5bed97b780f8b67b547c1197a2e2b31c98
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 "net/quic/test_tools/mock_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace net {
12 namespace test {
14 class HybridSlowStartTest : public ::testing::Test {
15 protected:
16 HybridSlowStartTest()
17 : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
18 rtt_(QuicTime::Delta::FromMilliseconds(60)) {
20 void SetUp() override { slow_start_.reset(new HybridSlowStart(&clock_)); }
21 const QuicTime::Delta one_ms_;
22 const QuicTime::Delta rtt_;
23 MockClock clock_;
24 scoped_ptr<HybridSlowStart> slow_start_;
27 TEST_F(HybridSlowStartTest, Simple) {
28 QuicPacketSequenceNumber sequence_number = 1;
29 QuicPacketSequenceNumber end_sequence_number = 3;
30 slow_start_->StartReceiveRound(end_sequence_number);
32 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
34 // Test duplicates.
35 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number));
37 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
38 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
40 // Test without a new registered end_sequence_number;
41 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
43 end_sequence_number = 20;
44 slow_start_->StartReceiveRound(end_sequence_number);
45 while (sequence_number < end_sequence_number) {
46 EXPECT_FALSE(slow_start_->IsEndOfRound(sequence_number++));
48 EXPECT_TRUE(slow_start_->IsEndOfRound(sequence_number++));
51 TEST_F(HybridSlowStartTest, Delay) {
52 // We expect to detect the increase at +1/8 of the RTT; hence at a typical
53 // RTT of 60ms the detection will happen at 67.5 ms.
54 const int kHybridStartMinSamples = 8; // Number of acks required to trigger.
56 QuicPacketSequenceNumber end_sequence_number = 1;
57 slow_start_->StartReceiveRound(end_sequence_number++);
59 // Will not trigger since our lowest RTT in our burst is the same as the long
60 // term RTT provided.
61 for (int n = 0; n < kHybridStartMinSamples; ++n) {
62 EXPECT_FALSE(slow_start_->ShouldExitSlowStart(
63 rtt_.Add(QuicTime::Delta::FromMilliseconds(n)), rtt_, 100));
65 slow_start_->StartReceiveRound(end_sequence_number++);
66 for (int n = 1; n < kHybridStartMinSamples; ++n) {
67 EXPECT_FALSE(slow_start_->ShouldExitSlowStart(
68 rtt_.Add(QuicTime::Delta::FromMilliseconds(n + 10)), rtt_, 100));
70 // Expect to trigger since all packets in this burst was above the long term
71 // RTT provided.
72 EXPECT_TRUE(slow_start_->ShouldExitSlowStart(
73 rtt_.Add(QuicTime::Delta::FromMilliseconds(10)), rtt_, 100));
76 } // namespace test
77 } // namespace net