@@ -29,20 +29,21 @@ class MockReceiver : public PacketReceiver {
29
29
virtual ~MockReceiver () {}
30
30
31
31
void IncomingPacket (const uint8_t * data, size_t length) {
32
- DeliverPacket (MediaType::ANY, data, length);
32
+ DeliverPacket (MediaType::ANY, data, length, PacketTime () );
33
33
delete [] data;
34
34
}
35
35
36
- MOCK_METHOD3 (DeliverPacket,
37
- DeliveryStatus (MediaType, const uint8_t *, size_t ));
36
+ MOCK_METHOD4 (
37
+ DeliverPacket,
38
+ DeliveryStatus (MediaType, const uint8_t *, size_t , const PacketTime&));
38
39
};
39
40
40
41
class FakeNetworkPipeTest : public ::testing::Test {
41
42
protected:
42
43
virtual void SetUp () {
43
44
TickTime::UseFakeClock (12345 );
44
45
receiver_.reset (new MockReceiver ());
45
- ON_CALL (*receiver_, DeliverPacket (_, _, _))
46
+ ON_CALL (*receiver_, DeliverPacket (_, _, _, _ ))
46
47
.WillByDefault (Return (PacketReceiver::DELIVERY_OK));
47
48
}
48
49
@@ -84,26 +85,22 @@ TEST_F(FakeNetworkPipeTest, CapacityTest) {
84
85
kPacketSize );
85
86
86
87
// Time haven't increased yet, so we souldn't get any packets.
87
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
88
- .Times (0 );
88
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (0 );
89
89
pipe ->Process ();
90
90
91
91
// Advance enough time to release one packet.
92
92
TickTime::AdvanceFakeClock (kPacketTimeMs );
93
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
94
- .Times (1 );
93
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (1 );
95
94
pipe ->Process ();
96
95
97
96
// Release all but one packet
98
97
TickTime::AdvanceFakeClock (9 * kPacketTimeMs - 1 );
99
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
100
- .Times (8 );
98
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (8 );
101
99
pipe ->Process ();
102
100
103
101
// And the last one.
104
102
TickTime::AdvanceFakeClock (1 );
105
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
106
- .Times (1 );
103
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (1 );
107
104
pipe ->Process ();
108
105
}
109
106
@@ -126,20 +123,17 @@ TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
126
123
127
124
// Increase more than kPacketTimeMs, but not more than the extra delay.
128
125
TickTime::AdvanceFakeClock (kPacketTimeMs );
129
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
130
- .Times (0 );
126
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (0 );
131
127
pipe ->Process ();
132
128
133
129
// Advance the network delay to get the first packet.
134
130
TickTime::AdvanceFakeClock (config.queue_delay_ms );
135
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
136
- .Times (1 );
131
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (1 );
137
132
pipe ->Process ();
138
133
139
134
// Advance one more kPacketTimeMs to get the last packet.
140
135
TickTime::AdvanceFakeClock (kPacketTimeMs );
141
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
142
- .Times (1 );
136
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (1 );
143
137
pipe ->Process ();
144
138
}
145
139
@@ -162,8 +156,7 @@ TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
162
156
// Increase time enough to deliver all three packets, verify only two are
163
157
// delivered.
164
158
TickTime::AdvanceFakeClock (3 * kPacketTimeMs );
165
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
166
- .Times (2 );
159
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (2 );
167
160
pipe ->Process ();
168
161
}
169
162
@@ -184,8 +177,7 @@ TEST_F(FakeNetworkPipeTest, StatisticsTest) {
184
177
SendPackets (pipe .get (), 3 , kPacketSize );
185
178
TickTime::AdvanceFakeClock (3 * kPacketTimeMs + config.queue_delay_ms );
186
179
187
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _))
188
- .Times (2 );
180
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _)).Times (2 );
189
181
pipe ->Process ();
190
182
191
183
// Packet 1: kPacketTimeMs + config.queue_delay_ms,
@@ -215,13 +207,13 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
215
207
int packet_time_ms = PacketTimeMs (config.link_capacity_kbps , kPacketSize );
216
208
217
209
// Time hasn't increased yet, so we souldn't get any packets.
218
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (0 );
210
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (0 );
219
211
pipe ->Process ();
220
212
221
213
// Advance time in steps to release one packet at a time.
222
214
for (int i = 0 ; i < kNumPackets ; ++i) {
223
215
TickTime::AdvanceFakeClock (packet_time_ms);
224
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (1 );
216
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (1 );
225
217
pipe ->Process ();
226
218
}
227
219
@@ -237,20 +229,20 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
237
229
packet_time_ms = PacketTimeMs (config.link_capacity_kbps , kPacketSize );
238
230
239
231
// Time hasn't increased yet, so we souldn't get any packets.
240
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (0 );
232
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (0 );
241
233
pipe ->Process ();
242
234
243
235
// Advance time in steps to release one packet at a time.
244
236
for (int i = 0 ; i < kNumPackets ; ++i) {
245
237
TickTime::AdvanceFakeClock (packet_time_ms);
246
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (1 );
238
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (1 );
247
239
pipe ->Process ();
248
240
}
249
241
250
242
// Check that all the packets were sent.
251
243
EXPECT_EQ (static_cast <size_t >(2 * kNumPackets ), pipe ->sent_packets ());
252
244
TickTime::AdvanceFakeClock (pipe ->TimeUntilNextProcess ());
253
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (0 );
245
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (0 );
254
246
pipe ->Process ();
255
247
}
256
248
@@ -283,27 +275,27 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
283
275
int packet_time_2_ms = PacketTimeMs (config.link_capacity_kbps , kPacketSize );
284
276
285
277
// Time hasn't increased yet, so we souldn't get any packets.
286
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (0 );
278
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (0 );
287
279
pipe ->Process ();
288
280
289
281
// Advance time in steps to release one packet at a time.
290
282
for (int i = 0 ; i < kNumPackets ; ++i) {
291
283
TickTime::AdvanceFakeClock (packet_time_1_ms);
292
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (1 );
284
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (1 );
293
285
pipe ->Process ();
294
286
}
295
287
296
288
// Advance time in steps to release one packet at a time.
297
289
for (int i = 0 ; i < kNumPackets ; ++i) {
298
290
TickTime::AdvanceFakeClock (packet_time_2_ms);
299
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (1 );
291
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (1 );
300
292
pipe ->Process ();
301
293
}
302
294
303
295
// Check that all the packets were sent.
304
296
EXPECT_EQ (static_cast <size_t >(2 * kNumPackets ), pipe ->sent_packets ());
305
297
TickTime::AdvanceFakeClock (pipe ->TimeUntilNextProcess ());
306
- EXPECT_CALL (*receiver_, DeliverPacket (_, _, _)).Times (0 );
298
+ EXPECT_CALL (*receiver_, DeliverPacket (_, _, _, _ )).Times (0 );
307
299
pipe ->Process ();
308
300
}
309
301
} // namespace webrtc
0 commit comments