This source file includes following definitions.
- rtt_
- SetUp
- TEST_F
- TEST_F
- TEST_F
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "net/quic/congestion_control/hybrid_slow_start.h"
#include "net/quic/test_tools/mock_clock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace test {
class HybridSlowStartTest : public ::testing::Test {
protected:
HybridSlowStartTest()
: one_ms_(QuicTime::Delta::FromMilliseconds(1)),
rtt_(QuicTime::Delta::FromMilliseconds(60)) {
}
virtual void SetUp() {
slowStart_.reset(new HybridSlowStart(&clock_));
}
const QuicTime::Delta one_ms_;
const QuicTime::Delta rtt_;
MockClock clock_;
scoped_ptr<HybridSlowStart> slowStart_;
};
TEST_F(HybridSlowStartTest, Simple) {
QuicPacketSequenceNumber sequence_number = 1;
QuicPacketSequenceNumber end_sequence_number = 3;
slowStart_->Reset(end_sequence_number);
EXPECT_FALSE(slowStart_->IsEndOfRound(sequence_number++));
EXPECT_FALSE(slowStart_->IsEndOfRound(sequence_number));
EXPECT_FALSE(slowStart_->IsEndOfRound(sequence_number++));
EXPECT_TRUE(slowStart_->IsEndOfRound(sequence_number++));
EXPECT_TRUE(slowStart_->IsEndOfRound(sequence_number++));
end_sequence_number = 20;
slowStart_->Reset(end_sequence_number);
while (sequence_number < end_sequence_number) {
EXPECT_FALSE(slowStart_->IsEndOfRound(sequence_number++));
}
EXPECT_TRUE(slowStart_->IsEndOfRound(sequence_number++));
}
TEST_F(HybridSlowStartTest, AckTrain) {
const int kMaxLoopCount = 5;
QuicPacketSequenceNumber sequence_number = 2;
QuicPacketSequenceNumber end_sequence_number = 2;
for (int burst = 0; burst < kMaxLoopCount; ++burst) {
slowStart_->Reset(end_sequence_number);
do {
clock_.AdvanceTime(one_ms_);
slowStart_->Update(rtt_, rtt_);
EXPECT_FALSE(slowStart_->Exit());
} while (!slowStart_->IsEndOfRound(sequence_number++));
end_sequence_number *= 2;
}
slowStart_->Reset(end_sequence_number);
for (int n = 0; n < 29 && !slowStart_->IsEndOfRound(sequence_number++); ++n) {
clock_.AdvanceTime(one_ms_);
slowStart_->Update(rtt_, rtt_);
EXPECT_FALSE(slowStart_->Exit());
}
clock_.AdvanceTime(one_ms_);
slowStart_->Update(rtt_, rtt_);
EXPECT_TRUE(slowStart_->Exit());
}
TEST_F(HybridSlowStartTest, Delay) {
const int kHybridStartMinSamples = 8;
QuicPacketSequenceNumber end_sequence_number = 1;
slowStart_->Reset(end_sequence_number++);
for (int n = 0; n < kHybridStartMinSamples; ++n) {
slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(n)), rtt_);
EXPECT_FALSE(slowStart_->Exit());
}
slowStart_->Reset(end_sequence_number++);
for (int n = 1; n < kHybridStartMinSamples; ++n) {
slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(n + 4)),
rtt_);
EXPECT_FALSE(slowStart_->Exit());
}
slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(4)), rtt_);
EXPECT_TRUE(slowStart_->Exit());
}
}
}