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

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

Issue 1178843002: Adds support for webrtc::test::ResourcePath on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nits Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 // Test to verify correct operation for externally created decoders. 11 // Test to verify correct operation for externally created decoders.
12 12
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "webrtc/base/scoped_ptr.h" 14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h" 15 #include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h"
16 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" 16 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
17 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" 17 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h"
18 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 18 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
19 #include "webrtc/test/testsupport/fileutils.h" 19 #include "webrtc/test/testsupport/fileutils.h"
20 #include "webrtc/test/testsupport/gtest_disable.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 22
24 using ::testing::_; 23 using ::testing::_;
25 using ::testing::Return; 24 using ::testing::Return;
26 25
27 class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { 26 class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest {
28 protected: 27 protected:
29 static const int kFrameSizeMs = 10; // Frame size of Pcm16B. 28 static const int kFrameSizeMs = 10; // Frame size of Pcm16B.
30 29
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 226
228 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; } 227 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; }
229 228
230 private: 229 private:
231 int sample_rate_hz_; 230 int sample_rate_hz_;
232 rtc::scoped_ptr<NetEq> neteq_internal_; 231 rtc::scoped_ptr<NetEq> neteq_internal_;
233 int16_t output_internal_[kMaxBlockSize]; 232 int16_t output_internal_[kMaxBlockSize];
234 int16_t output_[kMaxBlockSize]; 233 int16_t output_[kMaxBlockSize];
235 }; 234 };
236 235
237 TEST_F(NetEqExternalVsInternalDecoderTest, DISABLED_ON_IOS(RunTest)) { 236 TEST_F(NetEqExternalVsInternalDecoderTest, RunTest) {
238 RunTest(100); // Run 100 laps @ 10 ms each in the test loop. 237 RunTest(100); // Run 100 laps @ 10 ms each in the test loop.
239 } 238 }
240 239
241 class LargeTimestampJumpTest : public NetEqExternalDecoderUnitTest, 240 class LargeTimestampJumpTest : public NetEqExternalDecoderUnitTest,
242 public ::testing::Test { 241 public ::testing::Test {
243 protected: 242 protected:
244 static const int kMaxBlockSize = 480; // 10 ms @ 48 kHz. 243 static const int kMaxBlockSize = 480; // 10 ms @ 48 kHz.
245 244
246 enum TestStates { 245 enum TestStates {
247 kInitialPhase, 246 kInitialPhase,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // last packets not being decoded. 321 // last packets not being decoded.
323 return num_loops - 2; 322 return num_loops - 2;
324 } 323 }
325 324
326 TestStates test_state_; 325 TestStates test_state_;
327 326
328 private: 327 private:
329 int16_t output_[kMaxBlockSize]; 328 int16_t output_[kMaxBlockSize];
330 }; 329 };
331 330
332 TEST_F(LargeTimestampJumpTest, DISABLED_ON_IOS(JumpLongerThanHalfRange)) { 331 TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRange) {
333 // Set the timestamp series to start at 2880, increase to 7200, then jump to 332 // Set the timestamp series to start at 2880, increase to 7200, then jump to
334 // 2869342376. The sequence numbers start at 42076 and increase by 1 for each 333 // 2869342376. The sequence numbers start at 42076 and increase by 1 for each
335 // packet, also when the timestamp jumps. 334 // packet, also when the timestamp jumps.
336 static const uint16_t kStartSeqeunceNumber = 42076; 335 static const uint16_t kStartSeqeunceNumber = 42076;
337 static const uint32_t kStartTimestamp = 2880; 336 static const uint32_t kStartTimestamp = 2880;
338 static const uint32_t kJumpFromTimestamp = 7200; 337 static const uint32_t kJumpFromTimestamp = 7200;
339 static const uint32_t kJumpToTimestamp = 2869342376; 338 static const uint32_t kJumpToTimestamp = 2869342376;
340 static_assert(kJumpFromTimestamp < kJumpToTimestamp, 339 static_assert(kJumpFromTimestamp < kJumpToTimestamp,
341 "timestamp jump should not result in wrap"); 340 "timestamp jump should not result in wrap");
342 static_assert( 341 static_assert(
343 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF, 342 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF,
344 "jump should be larger than half range"); 343 "jump should be larger than half range");
345 // Replace the default RTP generator with one that jumps in timestamp. 344 // Replace the default RTP generator with one that jumps in timestamp.
346 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), 345 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
347 kStartSeqeunceNumber, 346 kStartSeqeunceNumber,
348 kStartTimestamp, 347 kStartTimestamp,
349 kJumpFromTimestamp, 348 kJumpFromTimestamp,
350 kJumpToTimestamp)); 349 kJumpToTimestamp));
351 350
352 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. 351 RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
353 EXPECT_EQ(kRecovered, test_state_); 352 EXPECT_EQ(kRecovered, test_state_);
354 } 353 }
355 354
356 TEST_F(LargeTimestampJumpTest, 355 TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRangeAndWrap) {
357 DISABLED_ON_IOS(JumpLongerThanHalfRangeAndWrap)) {
358 // Make a jump larger than half the 32-bit timestamp range. Set the start 356 // Make a jump larger than half the 32-bit timestamp range. Set the start
359 // timestamp such that the jump will result in a wrap around. 357 // timestamp such that the jump will result in a wrap around.
360 static const uint16_t kStartSeqeunceNumber = 42076; 358 static const uint16_t kStartSeqeunceNumber = 42076;
361 // Set the jump length slightly larger than 2^31. 359 // Set the jump length slightly larger than 2^31.
362 static const uint32_t kStartTimestamp = 3221223116; 360 static const uint32_t kStartTimestamp = 3221223116;
363 static const uint32_t kJumpFromTimestamp = 3221223216; 361 static const uint32_t kJumpFromTimestamp = 3221223216;
364 static const uint32_t kJumpToTimestamp = 1073744278; 362 static const uint32_t kJumpToTimestamp = 1073744278;
365 static_assert(kJumpToTimestamp < kJumpFromTimestamp, 363 static_assert(kJumpToTimestamp < kJumpFromTimestamp,
366 "timestamp jump should result in wrap"); 364 "timestamp jump should result in wrap");
367 static_assert( 365 static_assert(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 default: { FAIL(); } 404 default: { FAIL(); }
407 } 405 }
408 } 406 }
409 407
410 int NumExpectedDecodeCalls(int num_loops) override { 408 int NumExpectedDecodeCalls(int num_loops) override {
411 // Some packets won't be decoded because of the timestamp jump. 409 // Some packets won't be decoded because of the timestamp jump.
412 return num_loops - 2; 410 return num_loops - 2;
413 } 411 }
414 }; 412 };
415 413
416 TEST_F(ShortTimestampJumpTest, DISABLED_ON_IOS(JumpShorterThanHalfRange)) { 414 TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRange) {
417 // Make a jump shorter than half the 32-bit timestamp range. Set the start 415 // Make a jump shorter than half the 32-bit timestamp range. Set the start
418 // timestamp such that the jump will not result in a wrap around. 416 // timestamp such that the jump will not result in a wrap around.
419 static const uint16_t kStartSeqeunceNumber = 42076; 417 static const uint16_t kStartSeqeunceNumber = 42076;
420 // Set the jump length slightly smaller than 2^31. 418 // Set the jump length slightly smaller than 2^31.
421 static const uint32_t kStartTimestamp = 4711; 419 static const uint32_t kStartTimestamp = 4711;
422 static const uint32_t kJumpFromTimestamp = 4811; 420 static const uint32_t kJumpFromTimestamp = 4811;
423 static const uint32_t kJumpToTimestamp = 2147483747; 421 static const uint32_t kJumpToTimestamp = 2147483747;
424 static_assert(kJumpFromTimestamp < kJumpToTimestamp, 422 static_assert(kJumpFromTimestamp < kJumpToTimestamp,
425 "timestamp jump should not result in wrap"); 423 "timestamp jump should not result in wrap");
426 static_assert( 424 static_assert(
427 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF, 425 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
428 "jump should be smaller than half range"); 426 "jump should be smaller than half range");
429 // Replace the default RTP generator with one that jumps in timestamp. 427 // Replace the default RTP generator with one that jumps in timestamp.
430 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), 428 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
431 kStartSeqeunceNumber, 429 kStartSeqeunceNumber,
432 kStartTimestamp, 430 kStartTimestamp,
433 kJumpFromTimestamp, 431 kJumpFromTimestamp,
434 kJumpToTimestamp)); 432 kJumpToTimestamp));
435 433
436 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. 434 RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
437 EXPECT_EQ(kRecovered, test_state_); 435 EXPECT_EQ(kRecovered, test_state_);
438 } 436 }
439 437
440 TEST_F(ShortTimestampJumpTest, 438 TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRangeAndWrap) {
441 DISABLED_ON_IOS(JumpShorterThanHalfRangeAndWrap)) {
442 // Make a jump shorter than half the 32-bit timestamp range. Set the start 439 // Make a jump shorter than half the 32-bit timestamp range. Set the start
443 // timestamp such that the jump will result in a wrap around. 440 // timestamp such that the jump will result in a wrap around.
444 static const uint16_t kStartSeqeunceNumber = 42076; 441 static const uint16_t kStartSeqeunceNumber = 42076;
445 // Set the jump length slightly smaller than 2^31. 442 // Set the jump length slightly smaller than 2^31.
446 static const uint32_t kStartTimestamp = 3221227827; 443 static const uint32_t kStartTimestamp = 3221227827;
447 static const uint32_t kJumpFromTimestamp = 3221227927; 444 static const uint32_t kJumpFromTimestamp = 3221227927;
448 static const uint32_t kJumpToTimestamp = 1073739567; 445 static const uint32_t kJumpToTimestamp = 1073739567;
449 static_assert(kJumpToTimestamp < kJumpFromTimestamp, 446 static_assert(kJumpToTimestamp < kJumpFromTimestamp,
450 "timestamp jump should result in wrap"); 447 "timestamp jump should result in wrap");
451 static_assert( 448 static_assert(
452 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF, 449 static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
453 "jump should be smaller than half range"); 450 "jump should be smaller than half range");
454 // Replace the default RTP generator with one that jumps in timestamp. 451 // Replace the default RTP generator with one that jumps in timestamp.
455 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(), 452 ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
456 kStartSeqeunceNumber, 453 kStartSeqeunceNumber,
457 kStartTimestamp, 454 kStartTimestamp,
458 kJumpFromTimestamp, 455 kJumpFromTimestamp,
459 kJumpToTimestamp)); 456 kJumpToTimestamp));
460 457
461 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. 458 RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
462 EXPECT_EQ(kRecovered, test_state_); 459 EXPECT_EQ(kRecovered, test_state_);
463 } 460 }
464 461
465 } // namespace webrtc 462 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/audio_classifier_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/neteq_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698