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

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

Issue 447093004: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed indenation in QuicFramer.cc Created 6 years, 4 months 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
« no previous file with comments | « net/quic/congestion_control/timestamp_receiver.cc ('k') | net/quic/crypto/crypto_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/timestamp_receiver_test.cc
diff --git a/net/quic/congestion_control/timestamp_receiver_test.cc b/net/quic/congestion_control/timestamp_receiver_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2c477ea887b531653e97466c026cf1cc790a9727
--- /dev/null
+++ b/net/quic/congestion_control/timestamp_receiver_test.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "net/quic/congestion_control/timestamp_receiver.h"
+#include "net/quic/test_tools/mock_clock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+
+class TimestampReceiverTest : public ::testing::Test {
+ protected:
+ TimestampReceiver receiver_;
+ MockClock clock_;
+};
+
+TEST_F(TimestampReceiverTest, SimpleReceiver) {
+ QuicTime start = clock_.ApproximateNow();
+ QuicTime::Delta received_delta = QuicTime::Delta::FromMilliseconds(10);
+ clock_.AdvanceTime(received_delta);
+ QuicTime receive_timestamp = clock_.ApproximateNow();
+ receiver_.RecordIncomingPacket(1, 1, receive_timestamp);
+
+ QuicCongestionFeedbackFrame feedback;
+ // Do not generate a congestion feedback frame because it has only one packet.
+ ASSERT_FALSE(receiver_.GenerateCongestionFeedback(&feedback));
+
+ clock_.AdvanceTime(received_delta);
+ receive_timestamp = clock_.ApproximateNow();
+ // Packet not received; but rather revived by FEC.
+ receiver_.RecordIncomingPacket(1, 2, receive_timestamp);
+ clock_.AdvanceTime(received_delta);
+ receive_timestamp = clock_.ApproximateNow();
+ receiver_.RecordIncomingPacket(1, 3, receive_timestamp);
+
+ ASSERT_TRUE(receiver_.GenerateCongestionFeedback(&feedback));
+
+ EXPECT_EQ(kTimestamp, feedback.type);
+ EXPECT_EQ(3u, feedback.timestamp.received_packet_times.size());
+ TimeMap::iterator it = feedback.timestamp.received_packet_times.begin();
+ EXPECT_EQ(1u, it->first);
+ EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10), it->second.Subtract(start));
+ it = feedback.timestamp.received_packet_times.begin();
+ ++it;
+ EXPECT_EQ(2u, it->first);
+ EXPECT_EQ(QuicTime::Delta::FromMilliseconds(20), it->second.Subtract(start));
+ ++it;
+ EXPECT_EQ(3u, it->first);
+ EXPECT_EQ(QuicTime::Delta::FromMilliseconds(30), it->second.Subtract(start));
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/congestion_control/timestamp_receiver.cc ('k') | net/quic/crypto/crypto_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698