OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class SendTimeHistoryTest : public ::testing::Test { | 25 class SendTimeHistoryTest : public ::testing::Test { |
26 protected: | 26 protected: |
27 SendTimeHistoryTest() | 27 SendTimeHistoryTest() |
28 : clock_(0), history_(&clock_, kDefaultHistoryLengthMs) {} | 28 : clock_(0), history_(&clock_, kDefaultHistoryLengthMs) {} |
29 ~SendTimeHistoryTest() {} | 29 ~SendTimeHistoryTest() {} |
30 | 30 |
31 virtual void SetUp() {} | 31 virtual void SetUp() {} |
32 | 32 |
33 virtual void TearDown() {} | 33 virtual void TearDown() {} |
34 | 34 |
35 void AddPacketWithSendTime(uint16_t sequence_number, | 35 void AddPacketWithSendTime(uint16_t sequence_number, |
philipel
2017/03/15 10:38:37
A test where we save/restore the network ids would
stefan-webrtc
2017/03/15 10:51:39
Done.
| |
36 size_t length, | 36 size_t length, |
37 int64_t send_time_ms, | 37 int64_t send_time_ms, |
38 const PacedPacketInfo& pacing_info) { | 38 const PacedPacketInfo& pacing_info) { |
39 history_.AddAndRemoveOld(sequence_number, length, pacing_info); | 39 PacketFeedback packet(clock_.TimeInMilliseconds(), -1, -1, sequence_number, |
40 length, 0, 0, pacing_info); | |
41 history_.AddAndRemoveOld(packet); | |
40 history_.OnSentPacket(sequence_number, send_time_ms); | 42 history_.OnSentPacket(sequence_number, send_time_ms); |
41 } | 43 } |
42 | 44 |
43 webrtc::SimulatedClock clock_; | 45 webrtc::SimulatedClock clock_; |
44 SendTimeHistory history_; | 46 SendTimeHistory history_; |
45 }; | 47 }; |
46 | 48 |
47 TEST_F(SendTimeHistoryTest, AddRemoveOne) { | 49 TEST_F(SendTimeHistoryTest, AddRemoveOne) { |
48 const uint16_t kSeqNo = 10; | 50 const uint16_t kSeqNo = 10; |
49 // TODO(philipel): Fix PacedPacketInfo constructor? | 51 // TODO(philipel): Fix PacedPacketInfo constructor? |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 const PacedPacketInfo kPacingInfo(1, 2, 200); | 92 const PacedPacketInfo kPacingInfo(1, 2, 200); |
91 for (size_t i = 0; i < num_items; ++i) { | 93 for (size_t i = 0; i < num_items; ++i) { |
92 sent_packets.push_back(PacketFeedback(0, static_cast<int64_t>(i), | 94 sent_packets.push_back(PacketFeedback(0, static_cast<int64_t>(i), |
93 static_cast<uint16_t>(i), kPacketSize, | 95 static_cast<uint16_t>(i), kPacketSize, |
94 kPacingInfo)); | 96 kPacingInfo)); |
95 received_packets.push_back(PacketFeedback( | 97 received_packets.push_back(PacketFeedback( |
96 static_cast<int64_t>(i) + kTransmissionTime, 0, | 98 static_cast<int64_t>(i) + kTransmissionTime, 0, |
97 static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo())); | 99 static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo())); |
98 } | 100 } |
99 for (size_t i = 0; i < num_items; ++i) { | 101 for (size_t i = 0; i < num_items; ++i) { |
100 history_.AddAndRemoveOld(sent_packets[i].sequence_number, | 102 PacketFeedback packet = sent_packets[i]; |
101 sent_packets[i].payload_size, | 103 packet.arrival_time_ms = -1; |
102 PacedPacketInfo(1, 2, 200)); | 104 packet.send_time_ms = -1; |
105 history_.AddAndRemoveOld(packet); | |
103 } | 106 } |
104 for (size_t i = 0; i < num_items; ++i) | 107 for (size_t i = 0; i < num_items; ++i) |
105 history_.OnSentPacket(sent_packets[i].sequence_number, | 108 history_.OnSentPacket(sent_packets[i].sequence_number, |
106 sent_packets[i].send_time_ms); | 109 sent_packets[i].send_time_ms); |
107 std::random_shuffle(received_packets.begin(), received_packets.end()); | 110 std::random_shuffle(received_packets.begin(), received_packets.end()); |
108 for (size_t i = 0; i < num_items; ++i) { | 111 for (size_t i = 0; i < num_items; ++i) { |
109 PacketFeedback packet = received_packets[i]; | 112 PacketFeedback packet = received_packets[i]; |
110 EXPECT_TRUE(history_.GetFeedback(&packet, false)); | 113 EXPECT_TRUE(history_.GetFeedback(&packet, false)); |
111 PacketFeedback sent_packet = sent_packets[packet.sequence_number]; | 114 PacketFeedback sent_packet = sent_packets[packet.sequence_number]; |
112 sent_packet.arrival_time_ms = packet.arrival_time_ms; | 115 sent_packet.arrival_time_ms = packet.arrival_time_ms; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 packets[2].send_time_ms, packets[2].pacing_info); | 208 packets[2].send_time_ms, packets[2].pacing_info); |
206 | 209 |
207 PacketFeedback packet2(0, 0, packets[1].sequence_number, 0, kPacingInfo1); | 210 PacketFeedback packet2(0, 0, packets[1].sequence_number, 0, kPacingInfo1); |
208 EXPECT_TRUE(history_.GetFeedback(&packet2, true)); | 211 EXPECT_TRUE(history_.GetFeedback(&packet2, true)); |
209 EXPECT_EQ(packets[1], packet2); | 212 EXPECT_EQ(packets[1], packet2); |
210 | 213 |
211 PacketFeedback packet3(0, 0, packets[2].sequence_number, 0, kPacingInfo2); | 214 PacketFeedback packet3(0, 0, packets[2].sequence_number, 0, kPacingInfo2); |
212 EXPECT_TRUE(history_.GetFeedback(&packet3, true)); | 215 EXPECT_TRUE(history_.GetFeedback(&packet3, true)); |
213 EXPECT_EQ(packets[2], packet3); | 216 EXPECT_EQ(packets[2], packet3); |
214 } | 217 } |
215 | |
216 TEST_F(SendTimeHistoryTest, Clear) { | |
217 const uint16_t kSeqNo = 1; | |
218 const int64_t kTimestamp = 2; | |
219 const PacedPacketInfo kPacingInfo(0, 5, 1200); | |
220 | |
221 PacketFeedback packets[] = {{0, kTimestamp, kSeqNo, 0, kPacingInfo}, | |
222 {0, kTimestamp + 1, kSeqNo + 1, 0, kPacingInfo}}; | |
223 | |
224 AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size, | |
225 packets[0].send_time_ms, kPacingInfo); | |
226 AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size, | |
227 packets[1].send_time_ms, kPacingInfo); | |
228 PacketFeedback info(0, 0, packets[0].sequence_number, 0, kPacingInfo); | |
229 EXPECT_TRUE(history_.GetFeedback(&info, true)); | |
230 EXPECT_EQ(packets[0], info); | |
231 | |
232 history_.Clear(); | |
233 | |
234 PacketFeedback info2(0, 0, packets[1].sequence_number, 0, kPacingInfo); | |
235 EXPECT_FALSE(history_.GetFeedback(&info2, true)); | |
236 } | |
237 | |
238 } // namespace test | 218 } // namespace test |
239 } // namespace webrtc | 219 } // namespace webrtc |
OLD | NEW |