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

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

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