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

Side by Side Diff: webrtc/audio/utility/audio_frame_operations_unittest.cc

Issue 2739143002: Revert of Enable cpplint and fix cpplint errors in webrtc/*audio (Closed)
Patch Set: Created 3 years, 9 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/audio/utility/audio_frame_operations.cc ('k') | webrtc/common_audio/audio_converter.h » ('j') | 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 EXPECT_EQ(-21, GetChannelData(frame_, 1, 1)); 419 EXPECT_EQ(-21, GetChannelData(frame_, 1, 1));
420 EXPECT_EQ(989, GetChannelData(frame_, 0, 91)); 420 EXPECT_EQ(989, GetChannelData(frame_, 0, 91));
421 EXPECT_EQ(-989, GetChannelData(frame_, 1, 91)); 421 EXPECT_EQ(-989, GetChannelData(frame_, 1, 91));
422 EXPECT_EQ(999, GetChannelData(frame_, 0, 92)); 422 EXPECT_EQ(999, GetChannelData(frame_, 0, 92));
423 EXPECT_EQ(-999, GetChannelData(frame_, 1, 92)); 423 EXPECT_EQ(-999, GetChannelData(frame_, 1, 92));
424 } 424 }
425 425
426 // TODO(andrew): should not allow negative scales. 426 // TODO(andrew): should not allow negative scales.
427 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleFailsWithBadParameters) { 427 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleFailsWithBadParameters) {
428 frame_.num_channels_ = 1; 428 frame_.num_channels_ = 1;
429 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, 1.0, &frame_)); 429 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, 1.0, frame_));
430 430
431 frame_.num_channels_ = 3; 431 frame_.num_channels_ = 3;
432 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, 1.0, &frame_)); 432 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, 1.0, frame_));
433 433
434 frame_.num_channels_ = 2; 434 frame_.num_channels_ = 2;
435 EXPECT_EQ(-1, AudioFrameOperations::Scale(-1.0, 1.0, &frame_)); 435 EXPECT_EQ(-1, AudioFrameOperations::Scale(-1.0, 1.0, frame_));
436 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, -1.0, &frame_)); 436 EXPECT_EQ(-1, AudioFrameOperations::Scale(1.0, -1.0, frame_));
437 } 437 }
438 438
439 // TODO(andrew): fix the wraparound bug. We should always saturate. 439 // TODO(andrew): fix the wraparound bug. We should always saturate.
440 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleDoesNotWrapAround) { 440 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleDoesNotWrapAround) {
441 SetFrameData(4000, -4000, &frame_); 441 SetFrameData(4000, -4000, &frame_);
442 EXPECT_EQ(0, AudioFrameOperations::Scale(10.0, 10.0, &frame_)); 442 EXPECT_EQ(0, AudioFrameOperations::Scale(10.0, 10.0, frame_));
443 443
444 AudioFrame clipped_frame; 444 AudioFrame clipped_frame;
445 clipped_frame.samples_per_channel_ = 320; 445 clipped_frame.samples_per_channel_ = 320;
446 clipped_frame.num_channels_ = 2; 446 clipped_frame.num_channels_ = 2;
447 SetFrameData(32767, -32768, &clipped_frame); 447 SetFrameData(32767, -32768, &clipped_frame);
448 VerifyFramesAreEqual(clipped_frame, frame_); 448 VerifyFramesAreEqual(clipped_frame, frame_);
449 } 449 }
450 450
451 TEST_F(AudioFrameOperationsTest, ScaleSucceeds) { 451 TEST_F(AudioFrameOperationsTest, ScaleSucceeds) {
452 SetFrameData(1, -1, &frame_); 452 SetFrameData(1, -1, &frame_);
453 EXPECT_EQ(0, AudioFrameOperations::Scale(2.0, 3.0, &frame_)); 453 EXPECT_EQ(0, AudioFrameOperations::Scale(2.0, 3.0, frame_));
454 454
455 AudioFrame scaled_frame; 455 AudioFrame scaled_frame;
456 scaled_frame.samples_per_channel_ = 320; 456 scaled_frame.samples_per_channel_ = 320;
457 scaled_frame.num_channels_ = 2; 457 scaled_frame.num_channels_ = 2;
458 SetFrameData(2, -3, &scaled_frame); 458 SetFrameData(2, -3, &scaled_frame);
459 VerifyFramesAreEqual(scaled_frame, frame_); 459 VerifyFramesAreEqual(scaled_frame, frame_);
460 } 460 }
461 461
462 // TODO(andrew): should fail with a negative scale. 462 // TODO(andrew): should fail with a negative scale.
463 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleWithSatFailsWithBadParameters) { 463 TEST_F(AudioFrameOperationsTest, DISABLED_ScaleWithSatFailsWithBadParameters) {
464 EXPECT_EQ(-1, AudioFrameOperations::ScaleWithSat(-1.0, &frame_)); 464 EXPECT_EQ(-1, AudioFrameOperations::ScaleWithSat(-1.0, frame_));
465 } 465 }
466 466
467 TEST_F(AudioFrameOperationsTest, ScaleWithSatDoesNotWrapAround) { 467 TEST_F(AudioFrameOperationsTest, ScaleWithSatDoesNotWrapAround) {
468 frame_.num_channels_ = 1; 468 frame_.num_channels_ = 1;
469 SetFrameData(4000, &frame_); 469 SetFrameData(4000, &frame_);
470 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(10.0, &frame_)); 470 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(10.0, frame_));
471 471
472 AudioFrame clipped_frame; 472 AudioFrame clipped_frame;
473 clipped_frame.samples_per_channel_ = 320; 473 clipped_frame.samples_per_channel_ = 320;
474 clipped_frame.num_channels_ = 1; 474 clipped_frame.num_channels_ = 1;
475 SetFrameData(32767, &clipped_frame); 475 SetFrameData(32767, &clipped_frame);
476 VerifyFramesAreEqual(clipped_frame, frame_); 476 VerifyFramesAreEqual(clipped_frame, frame_);
477 477
478 SetFrameData(-4000, &frame_); 478 SetFrameData(-4000, &frame_);
479 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(10.0, &frame_)); 479 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(10.0, frame_));
480 SetFrameData(-32768, &clipped_frame); 480 SetFrameData(-32768, &clipped_frame);
481 VerifyFramesAreEqual(clipped_frame, frame_); 481 VerifyFramesAreEqual(clipped_frame, frame_);
482 } 482 }
483 483
484 TEST_F(AudioFrameOperationsTest, ScaleWithSatSucceeds) { 484 TEST_F(AudioFrameOperationsTest, ScaleWithSatSucceeds) {
485 frame_.num_channels_ = 1; 485 frame_.num_channels_ = 1;
486 SetFrameData(1, &frame_); 486 SetFrameData(1, &frame_);
487 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(2.0, &frame_)); 487 EXPECT_EQ(0, AudioFrameOperations::ScaleWithSat(2.0, frame_));
488 488
489 AudioFrame scaled_frame; 489 AudioFrame scaled_frame;
490 scaled_frame.samples_per_channel_ = 320; 490 scaled_frame.samples_per_channel_ = 320;
491 scaled_frame.num_channels_ = 1; 491 scaled_frame.num_channels_ = 1;
492 SetFrameData(2, &scaled_frame); 492 SetFrameData(2, &scaled_frame);
493 VerifyFramesAreEqual(scaled_frame, frame_); 493 VerifyFramesAreEqual(scaled_frame, frame_);
494 } 494 }
495 495
496 TEST_F(AudioFrameOperationsTest, AddingXToEmptyGivesX) { 496 TEST_F(AudioFrameOperationsTest, AddingXToEmptyGivesX) {
497 // When samples_per_channel_ is 0, the frame counts as empty and zero. 497 // When samples_per_channel_ is 0, the frame counts as empty and zero.
(...skipping 10 matching lines...) Expand all
508 frame_to_add_to.samples_per_channel_ = frame_.samples_per_channel_; 508 frame_to_add_to.samples_per_channel_ = frame_.samples_per_channel_;
509 frame_to_add_to.num_channels_ = frame_.num_channels_; 509 frame_to_add_to.num_channels_ = frame_.num_channels_;
510 SetFrameData(1000, &frame_to_add_to); 510 SetFrameData(1000, &frame_to_add_to);
511 511
512 AudioFrameOperations::Add(frame_, &frame_to_add_to); 512 AudioFrameOperations::Add(frame_, &frame_to_add_to);
513 SetFrameData(frame_.data_[0] + 1000, &frame_); 513 SetFrameData(frame_.data_[0] + 1000, &frame_);
514 VerifyFramesAreEqual(frame_, frame_to_add_to); 514 VerifyFramesAreEqual(frame_, frame_to_add_to);
515 } 515 }
516 } // namespace 516 } // namespace
517 } // namespace webrtc 517 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/utility/audio_frame_operations.cc ('k') | webrtc/common_audio/audio_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698