Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / net / quic / congestion_control / inter_arrival_receiver_test.cc
blob927fb6d92f7494c8fe1263bd8de70bb1fa47d0e4
1 // Copyright (c) 2013 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 "net/quic/congestion_control/inter_arrival_receiver.h"
7 #include "net/quic/test_tools/mock_clock.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace net {
11 namespace test {
13 class InterArrivalReceiverTest : public ::testing::Test {
14 protected:
15 InterArrivalReceiver receiver_;
16 MockClock clock_;
19 TEST_F(InterArrivalReceiverTest, SimpleReceiver) {
20 QuicTime start = clock_.ApproximateNow();
21 QuicTime::Delta received_delta = QuicTime::Delta::FromMilliseconds(10);
22 clock_.AdvanceTime(received_delta);
23 QuicTime receive_timestamp = clock_.ApproximateNow();
24 receiver_.RecordIncomingPacket(1, 1, receive_timestamp, false);
26 QuicCongestionFeedbackFrame feedback;
27 ASSERT_FALSE(receiver_.GenerateCongestionFeedback(&feedback));
29 clock_.AdvanceTime(received_delta);
30 receive_timestamp = clock_.ApproximateNow();
31 // Packet not received; but rather revived by FEC.
32 receiver_.RecordIncomingPacket(1, 2, receive_timestamp, true);
33 clock_.AdvanceTime(received_delta);
34 receive_timestamp = clock_.ApproximateNow();
35 receiver_.RecordIncomingPacket(1, 3, receive_timestamp, false);
37 ASSERT_TRUE(receiver_.GenerateCongestionFeedback(&feedback));
39 EXPECT_EQ(kInterArrival, feedback.type);
40 EXPECT_EQ(1, feedback.inter_arrival.accumulated_number_of_lost_packets);
41 EXPECT_EQ(3u, feedback.inter_arrival.received_packet_times.size());
42 TimeMap::iterator it = feedback.inter_arrival.received_packet_times.begin();
43 EXPECT_EQ(1u, it->first);
44 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10), it->second.Subtract(start));
45 it = feedback.inter_arrival.received_packet_times.begin();
46 it++;
47 EXPECT_EQ(2u, it->first);
48 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(20), it->second.Subtract(start));
49 it++;
50 EXPECT_EQ(3u, it->first);
51 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(30), it->second.Subtract(start));
54 } // namespace test
55 } // namespace net