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

Side by Side Diff: webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc

Issue 2276913002: DecoderDatabase: Made several methods nonvirtual to minimize mockable interface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Turned DecoderInfo factory into a raw pointer. Removed two unnecessary comments. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 PacketList list; 167 PacketList list;
168 const int payload_len = 10; 168 const int payload_len = 10;
169 169
170 // Insert 10 small packets. 170 // Insert 10 small packets.
171 for (int i = 0; i < 10; ++i) { 171 for (int i = 0; i < 10; ++i) {
172 Packet* packet = gen.NextPacket(payload_len); 172 Packet* packet = gen.NextPacket(payload_len);
173 list.push_back(packet); 173 list.push_back(packet);
174 } 174 }
175 175
176 MockDecoderDatabase decoder_database; 176 MockDecoderDatabase decoder_database;
177 EXPECT_CALL(decoder_database, IsComfortNoise(0))
178 .WillRepeatedly(Return(false));
179 EXPECT_CALL(decoder_database, IsDtmf(0))
180 .WillRepeatedly(Return(false));
181 uint8_t current_pt = 0xFF; 177 uint8_t current_pt = 0xFF;
182 uint8_t current_cng_pt = 0xFF; 178 uint8_t current_cng_pt = 0xFF;
183 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list, 179 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
184 decoder_database, 180 decoder_database,
185 &current_pt, 181 &current_pt,
186 &current_cng_pt)); 182 &current_cng_pt));
187 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 183 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
188 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); 184 EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
189 EXPECT_EQ(0, current_pt); // Current payload type changed to 0. 185 EXPECT_EQ(0, current_pt); // Current payload type changed to 0.
190 EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed. 186 EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
(...skipping 18 matching lines...) Expand all
209 Packet* packet = gen.NextPacket(payload_len); 205 Packet* packet = gen.NextPacket(payload_len);
210 list.push_back(packet); 206 list.push_back(packet);
211 } 207 }
212 // Insert 11th packet of another payload type (not CNG). 208 // Insert 11th packet of another payload type (not CNG).
213 Packet* packet = gen.NextPacket(payload_len); 209 Packet* packet = gen.NextPacket(payload_len);
214 packet->header.payloadType = 1; 210 packet->header.payloadType = 1;
215 list.push_back(packet); 211 list.push_back(packet);
216 212
217 213
218 MockDecoderDatabase decoder_database; 214 MockDecoderDatabase decoder_database;
219 EXPECT_CALL(decoder_database, IsComfortNoise(_))
220 .WillRepeatedly(Return(false));
221 EXPECT_CALL(decoder_database, IsDtmf(_))
222 .WillRepeatedly(Return(false));
223 uint8_t current_pt = 0xFF; 215 uint8_t current_pt = 0xFF;
224 uint8_t current_cng_pt = 0xFF; 216 uint8_t current_cng_pt = 0xFF;
225 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list, 217 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list,
226 decoder_database, 218 decoder_database,
227 &current_pt, 219 &current_pt,
228 &current_cng_pt)); 220 &current_cng_pt));
229 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 221 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
230 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet. 222 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet.
231 EXPECT_EQ(1, current_pt); // Current payload type changed to 0. 223 EXPECT_EQ(1, current_pt); // Current payload type changed to 0.
232 EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed. 224 EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 for (int i = 0; i < 10; ++i) { 334 for (int i = 0; i < 10; ++i) {
343 Packet* packet = gen.NextPacket(payload_len); 335 Packet* packet = gen.NextPacket(payload_len);
344 if (i % 2) { 336 if (i % 2) {
345 list.push_front(packet); 337 list.push_front(packet);
346 } else { 338 } else {
347 list.push_back(packet); 339 list.push_back(packet);
348 } 340 }
349 } 341 }
350 342
351 MockDecoderDatabase decoder_database; 343 MockDecoderDatabase decoder_database;
352 EXPECT_CALL(decoder_database, IsComfortNoise(0))
353 .WillRepeatedly(Return(false));
354 EXPECT_CALL(decoder_database, IsDtmf(0))
355 .WillRepeatedly(Return(false));
356 uint8_t current_pt = 0xFF; 344 uint8_t current_pt = 0xFF;
357 uint8_t current_cng_pt = 0xFF; 345 uint8_t current_cng_pt = 0xFF;
358 346
359 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list, 347 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
360 decoder_database, 348 decoder_database,
361 &current_pt, 349 &current_pt,
362 &current_cng_pt)); 350 &current_cng_pt));
363 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); 351 EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
364 352
365 // Extract them and make sure that come out in the right order. 353 // Extract them and make sure that come out in the right order.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // discarded. 405 // discarded.
418 buffer = new PacketBuffer(100, &tick_timer); // 100 packets. 406 buffer = new PacketBuffer(100, &tick_timer); // 100 packets.
419 PacketList list; 407 PacketList list;
420 list.push_back(gen.NextPacket(payload_len)); // Valid packet. 408 list.push_back(gen.NextPacket(payload_len)); // Valid packet.
421 packet = gen.NextPacket(payload_len); 409 packet = gen.NextPacket(payload_len);
422 delete [] packet->payload; 410 delete [] packet->payload;
423 packet->payload = NULL; // Invalid. 411 packet->payload = NULL; // Invalid.
424 list.push_back(packet); 412 list.push_back(packet);
425 list.push_back(gen.NextPacket(payload_len)); // Valid packet. 413 list.push_back(gen.NextPacket(payload_len)); // Valid packet.
426 MockDecoderDatabase decoder_database; 414 MockDecoderDatabase decoder_database;
427 EXPECT_CALL(decoder_database, IsComfortNoise(0))
428 .WillRepeatedly(Return(false));
429 EXPECT_CALL(decoder_database, IsDtmf(0))
430 .WillRepeatedly(Return(false));
431 uint8_t current_pt = 0xFF; 415 uint8_t current_pt = 0xFF;
432 uint8_t current_cng_pt = 0xFF; 416 uint8_t current_cng_pt = 0xFF;
433 EXPECT_EQ(PacketBuffer::kInvalidPacket, 417 EXPECT_EQ(PacketBuffer::kInvalidPacket,
434 buffer->InsertPacketList(&list, 418 buffer->InsertPacketList(&list,
435 decoder_database, 419 decoder_database,
436 &current_pt, 420 &current_pt,
437 &current_cng_pt)); 421 &current_cng_pt));
438 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 422 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
439 EXPECT_EQ(1u, buffer->NumPacketsInBuffer()); 423 EXPECT_EQ(1u, buffer->NumPacketsInBuffer());
440 delete buffer; 424 delete buffer;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // Test the IsObsoleteTimestamp method with different limit timestamps. 564 // Test the IsObsoleteTimestamp method with different limit timestamps.
581 TEST(PacketBuffer, IsObsoleteTimestamp) { 565 TEST(PacketBuffer, IsObsoleteTimestamp) {
582 TestIsObsoleteTimestamp(0); 566 TestIsObsoleteTimestamp(0);
583 TestIsObsoleteTimestamp(1); 567 TestIsObsoleteTimestamp(1);
584 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. 568 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t.
585 TestIsObsoleteTimestamp(0x80000000); // 2^31. 569 TestIsObsoleteTimestamp(0x80000000); // 2^31.
586 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. 570 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1.
587 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. 571 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1.
588 } 572 }
589 } // namespace webrtc 573 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698