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

Unified Diff: net/quic/congestion_control/quic_congestion_manager_test.cc

Issue 76723002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/congestion_control/quic_congestion_manager_test.cc
diff --git a/net/quic/congestion_control/quic_congestion_manager_test.cc b/net/quic/congestion_control/quic_congestion_manager_test.cc
index a05972d7008dbd2ed083c452426a50ae194b70f5..4e434b0cad44a3f1059d6dc9e797007b5d532aa6 100644
--- a/net/quic/congestion_control/quic_congestion_manager_test.cc
+++ b/net/quic/congestion_control/quic_congestion_manager_test.cc
@@ -29,10 +29,14 @@ class QuicCongestionManagerPeer : public QuicCongestionManager {
this->send_algorithm_.reset(send_algorithm);
}
- using QuicCongestionManager::rtt;
+ QuicTime::Delta rtt() {
+ return rtt_sample_;
+ }
+
const SendAlgorithmInterface::SentPacketsMap& packet_history_map() {
return packet_history_map_;
}
+
private:
DISALLOW_COPY_AND_ASSIGN(QuicCongestionManagerPeer);
};
@@ -162,15 +166,16 @@ TEST_F(QuicCongestionManagerTest, Rtt) {
}
TEST_F(QuicCongestionManagerTest, RttWithInvalidDelta) {
- // Expect that the RTT is infinite since the delta_time_largest_observed is
- // larger than the local time elapsed aka invalid.
+ // Expect that the RTT is equal to the local time elapsed, since the
+ // delta_time_largest_observed is larger than the local time elapsed
+ // and is hence invalid.
SetUpCongestionType(kFixRate);
MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
manager_->SetSendAlgorithm(send_algorithm);
QuicPacketSequenceNumber sequence_number = 1;
- QuicTime::Delta expected_rtt = QuicTime::Delta::Infinite();
+ QuicTime::Delta expected_rtt = QuicTime::Delta::FromMilliseconds(10);
EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _))
.Times(1).WillOnce(Return(true));
@@ -189,16 +194,16 @@ TEST_F(QuicCongestionManagerTest, RttWithInvalidDelta) {
EXPECT_EQ(manager_->rtt(), expected_rtt);
}
-TEST_F(QuicCongestionManagerTest, RttInfiniteDelta) {
- // Expect that the RTT is infinite since the delta_time_largest_observed is
- // infinite aka invalid.
+TEST_F(QuicCongestionManagerTest, RttWithInfiniteDelta) {
+ // Expect that the RTT is equal to the local time elapsed, since the
+ // delta_time_largest_observed is infinite, and is hence invalid.
SetUpCongestionType(kFixRate);
MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
manager_->SetSendAlgorithm(send_algorithm);
QuicPacketSequenceNumber sequence_number = 1;
- QuicTime::Delta expected_rtt = QuicTime::Delta::Infinite();
+ QuicTime::Delta expected_rtt = QuicTime::Delta::FromMilliseconds(10);
EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _))
.Times(1).WillOnce(Return(true));
@@ -243,5 +248,70 @@ TEST_F(QuicCongestionManagerTest, RttZeroDelta) {
EXPECT_EQ(manager_->rtt(), expected_rtt);
}
+TEST_F(QuicCongestionManagerTest, GetTransmissionDelayMin) {
+ SetUpCongestionType(kFixRate);
+
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ manager_->SetSendAlgorithm(send_algorithm);
+
+ QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(1);
+ EXPECT_CALL(*send_algorithm, RetransmissionDelay())
+ .WillOnce(Return(delay));
+
+ EXPECT_EQ(QuicTime::Delta::FromMilliseconds(200),
+ manager_->GetRetransmissionDelay(1, 1));
+}
+
+TEST_F(QuicCongestionManagerTest, GetTransmissionDelayMax) {
+ SetUpCongestionType(kFixRate);
+
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ manager_->SetSendAlgorithm(send_algorithm);
+
+ QuicTime::Delta delay = QuicTime::Delta::FromSeconds(500);
+ EXPECT_CALL(*send_algorithm, RetransmissionDelay())
+ .WillOnce(Return(delay));
+
+ EXPECT_EQ(QuicTime::Delta::FromSeconds(60),
+ manager_->GetRetransmissionDelay(1, 1));
+}
+
+TEST_F(QuicCongestionManagerTest, GetTransmissionDelay) {
+ SetUpCongestionType(kFixRate);
+
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ manager_->SetSendAlgorithm(send_algorithm);
+
+ QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
+ EXPECT_CALL(*send_algorithm, RetransmissionDelay())
+ .WillRepeatedly(Return(delay));
+
+ const int kUnackedPackets = 6;
+ // Delay should back off exponentially.
+ for (int i = 0; i < 5; ++i) {
+ EXPECT_EQ(delay, manager_->GetRetransmissionDelay(kUnackedPackets, i));
+ delay = delay.Add(delay);
+ }
+}
+
+TEST_F(QuicCongestionManagerTest, GetTransmissionDelayTailDrop) {
+ SetUpCongestionType(kFixRate);
+
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ manager_->SetSendAlgorithm(send_algorithm);
+
+ QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
+ EXPECT_CALL(*send_algorithm, RetransmissionDelay())
+ .WillRepeatedly(Return(delay));
+
+ // No backoff for the first 5 retransmission.
+ for (int i = 0; i < 5; ++i) {
+ EXPECT_EQ(delay, manager_->GetRetransmissionDelay(1, i));
+ }
+
+ // Then backoff starts
+ EXPECT_EQ(delay.Add(delay), manager_->GetRetransmissionDelay(1, 5));
+}
+
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/congestion_control/quic_congestion_manager.cc ('k') | net/quic/congestion_control/send_algorithm_interface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698