Chromium Code Reviews| Index: media/cast/audio_sender/audio_encoder_unittest.cc |
| diff --git a/media/cast/audio_sender/audio_encoder_unittest.cc b/media/cast/audio_sender/audio_encoder_unittest.cc |
| index 877f2f2577397be21a45fefde3c1cc964b36ca88..09f5e2f0047076e53da32f24015f1c159a25518d 100644 |
| --- a/media/cast/audio_sender/audio_encoder_unittest.cc |
| +++ b/media/cast/audio_sender/audio_encoder_unittest.cc |
| @@ -26,21 +26,15 @@ namespace { |
| class TestEncodedAudioFrameReceiver { |
| public: |
| - explicit TestEncodedAudioFrameReceiver(transport::AudioCodec codec) : |
| - codec_(codec), frames_received_(0) {} |
| + explicit TestEncodedAudioFrameReceiver(transport::AudioCodec codec) |
| + : codec_(codec), frames_received_(0) {} |
| virtual ~TestEncodedAudioFrameReceiver() {} |
| - int frames_received() const { |
| - return frames_received_; |
| - } |
| + int frames_received() const { return frames_received_; } |
| - void SetRecordedTimeLowerBound(const base::TimeTicks& t) { |
| - lower_bound_ = t; |
| - } |
| + void SetRecordedTimeLowerBound(const base::TimeTicks& t) { lower_bound_ = t; } |
| - void SetRecordedTimeUpperBound(const base::TimeTicks& t) { |
| - upper_bound_ = t; |
| - } |
| + void SetRecordedTimeUpperBound(const base::TimeTicks& t) { upper_bound_ = t; } |
| void FrameEncoded(scoped_ptr<transport::EncodedAudioFrame> encoded_frame, |
| const base::TimeTicks& recorded_time) { |
| @@ -97,18 +91,22 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { |
| virtual void SetUp() { |
| task_runner_ = new test::FakeTaskRunner(testing_clock_); |
| - cast_environment_ = new CastEnvironment( |
| - scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_, |
| - task_runner_, task_runner_, task_runner_, task_runner_, task_runner_, |
| - GetDefaultCastSenderLoggingConfig()); |
| + cast_environment_ = |
| + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
| + task_runner_, |
| + task_runner_, |
| + task_runner_, |
| + task_runner_, |
| + task_runner_, |
| + task_runner_, |
| + GetDefaultCastSenderLoggingConfig()); |
| } |
| virtual ~AudioEncoderTest() {} |
| void RunTestForCodec(transport::AudioCodec codec) { |
| const TestScenario& scenario = GetParam(); |
| - SCOPED_TRACE(::testing::Message() |
| - << "Durations: " << scenario.ToString()); |
| + SCOPED_TRACE(::testing::Message() << "Durations: " << scenario.ToString()); |
| CreateObjectsForCodec(codec); |
| @@ -116,15 +114,16 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { |
| for (size_t i = 0; i < scenario.num_durations; ++i) { |
| const base::TimeDelta duration = |
| base::TimeDelta::FromMilliseconds(scenario.durations_in_ms[i]); |
| - receiver_->SetRecordedTimeUpperBound( |
| - testing_clock_->NowTicks() + duration); |
| + receiver_->SetRecordedTimeUpperBound(testing_clock_->NowTicks() + |
| + duration); |
| const scoped_ptr<AudioBus> bus( |
| audio_bus_factory_->NextAudioBus(duration)); |
| const int last_count = release_callback_count_; |
| audio_encoder_->InsertAudio( |
| - bus.get(), testing_clock_->NowTicks(), |
| + bus.get(), |
| + testing_clock_->NowTicks(), |
| base::Bind(&AudioEncoderTest::IncrementReleaseCallbackCounter, |
| base::Unretained(this))); |
| task_runner_->RunTasks(); |
| @@ -148,24 +147,25 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { |
| audio_config.bitrate = kDefaultAudioEncoderBitrate; |
| audio_config.rtp_payload_type = 127; |
| - audio_bus_factory_.reset(new TestAudioBusFactory( |
| - audio_config.channels, audio_config.frequency, |
| - TestAudioBusFactory::kMiddleANoteFreq, 0.5f)); |
| + audio_bus_factory_.reset( |
| + new TestAudioBusFactory(audio_config.channels, |
| + audio_config.frequency, |
| + TestAudioBusFactory::kMiddleANoteFreq, |
| + 0.5f)); |
| receiver_.reset(new TestEncodedAudioFrameReceiver(codec)); |
| audio_encoder_ = new AudioEncoder( |
| - cast_environment_, audio_config, |
| + cast_environment_, |
| + audio_config, |
| base::Bind(&TestEncodedAudioFrameReceiver::FrameEncoded, |
| base::Unretained(receiver_.get()))); |
| release_callback_count_ = 0; |
| } |
| - void IncrementReleaseCallbackCounter() { |
| - ++release_callback_count_; |
| - } |
| + void IncrementReleaseCallbackCounter() { ++release_callback_count_; } |
| - base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
| + base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
| scoped_refptr<test::FakeTaskRunner> task_runner_; |
| scoped_ptr<TestAudioBusFactory> audio_bus_factory_; |
| scoped_ptr<TestEncodedAudioFrameReceiver> receiver_; |
| @@ -176,61 +176,58 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { |
| DISALLOW_COPY_AND_ASSIGN(AudioEncoderTest); |
| }; |
| -TEST_P(AudioEncoderTest, EncodeOpus) { |
| - RunTestForCodec(transport::kOpus); |
| -} |
| - |
| -TEST_P(AudioEncoderTest, EncodePcm16) { |
| - RunTestForCodec(transport::kPcm16); |
| -} |
| - |
| -static const int64 kOneCall_3Millis[] = { 3 }; |
| -static const int64 kOneCall_10Millis[] = { 10 }; |
| -static const int64 kOneCall_13Millis[] = { 13 }; |
| -static const int64 kOneCall_20Millis[] = { 20 }; |
| - |
| -static const int64 kTwoCalls_3Millis[] = { 3, 3 }; |
| -static const int64 kTwoCalls_10Millis[] = { 10, 10 }; |
| -static const int64 kTwoCalls_Mixed1[] = { 3, 10 }; |
| -static const int64 kTwoCalls_Mixed2[] = { 10, 3 }; |
| -static const int64 kTwoCalls_Mixed3[] = { 3, 17 }; |
| -static const int64 kTwoCalls_Mixed4[] = { 17, 3 }; |
| - |
| -static const int64 kManyCalls_3Millis[] = |
| - { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; |
| -static const int64 kManyCalls_10Millis[] = |
| - { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; |
| -static const int64 kManyCalls_Mixed1[] = |
| - { 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10 }; |
| -static const int64 kManyCalls_Mixed2[] = |
| - { 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3 }; |
| -static const int64 kManyCalls_Mixed3[] = |
| - { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4 }; |
| -static const int64 kManyCalls_Mixed4[] = |
| - { 31, 4, 15, 9, 26, 53, 5, 8, 9, 7, 9, 32, 38, 4, 62, 64, 3 }; |
| -static const int64 kManyCalls_Mixed5[] = |
| - { 3, 14, 15, 9, 26, 53, 58, 9, 7, 9, 3, 23, 8, 4, 6, 2, 6, 43 }; |
| +TEST_P(AudioEncoderTest, EncodeOpus) { RunTestForCodec(transport::kOpus); } |
| + |
| +TEST_P(AudioEncoderTest, EncodePcm16) { RunTestForCodec(transport::kPcm16); } |
| + |
| +static const int64 kOneCall_3Millis[] = {3}; |
| +static const int64 kOneCall_10Millis[] = {10}; |
| +static const int64 kOneCall_13Millis[] = {13}; |
| +static const int64 kOneCall_20Millis[] = {20}; |
| + |
| +static const int64 kTwoCalls_3Millis[] = {3, 3}; |
| +static const int64 kTwoCalls_10Millis[] = {10, 10}; |
| +static const int64 kTwoCalls_Mixed1[] = {3, 10}; |
| +static const int64 kTwoCalls_Mixed2[] = {10, 3}; |
| +static const int64 kTwoCalls_Mixed3[] = {3, 17}; |
| +static const int64 kTwoCalls_Mixed4[] = {17, 3}; |
| + |
| +static const int64 kManyCalls_3Millis[] = {3, 3, 3, 3, 3, 3, 3, 3, |
|
hubbe
2014/01/29 20:12:20
This block looked better before I think.
mikhal1
2014/01/29 20:53:43
I'd rather keep as is, so we won't get many change
|
| + 3, 3, 3, 3, 3, 3, 3}; |
| +static const int64 kManyCalls_10Millis[] = {10, 10, 10, 10, 10, 10, 10, 10, |
| + 10, 10, 10, 10, 10, 10, 10}; |
| +static const int64 kManyCalls_Mixed1[] = {3, 10, 3, 10, 3, 10, 3, 10, 3, |
| + 10, 3, 10, 3, 10, 3, 10, 3, 10}; |
| +static const int64 kManyCalls_Mixed2[] = {10, 3, 10, 3, 10, 3, 10, 3, 10, 3, |
| + 10, 3, 10, 3, 10, 3, 10, 3, 10, 3}; |
| +static const int64 kManyCalls_Mixed3[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, |
| + 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4}; |
| +static const int64 kManyCalls_Mixed4[] = {31, 4, 15, 9, 26, 53, 5, 8, 9, |
| + 7, 9, 32, 38, 4, 62, 64, 3}; |
| +static const int64 kManyCalls_Mixed5[] = {3, 14, 15, 9, 26, 53, 58, 9, 7, |
| + 9, 3, 23, 8, 4, 6, 2, 6, 43}; |
| INSTANTIATE_TEST_CASE_P( |
| - AudioEncoderTestScenarios, AudioEncoderTest, |
| + AudioEncoderTestScenarios, |
| + AudioEncoderTest, |
| ::testing::Values( |
| - TestScenario(kOneCall_3Millis, arraysize(kOneCall_3Millis)), |
| - TestScenario(kOneCall_10Millis, arraysize(kOneCall_10Millis)), |
| - TestScenario(kOneCall_13Millis, arraysize(kOneCall_13Millis)), |
| - TestScenario(kOneCall_20Millis, arraysize(kOneCall_20Millis)), |
| - TestScenario(kTwoCalls_3Millis, arraysize(kTwoCalls_3Millis)), |
| - TestScenario(kTwoCalls_10Millis, arraysize(kTwoCalls_10Millis)), |
| - TestScenario(kTwoCalls_Mixed1, arraysize(kTwoCalls_Mixed1)), |
| - TestScenario(kTwoCalls_Mixed2, arraysize(kTwoCalls_Mixed2)), |
| - TestScenario(kTwoCalls_Mixed3, arraysize(kTwoCalls_Mixed3)), |
| - TestScenario(kTwoCalls_Mixed4, arraysize(kTwoCalls_Mixed4)), |
| - TestScenario(kManyCalls_3Millis, arraysize(kManyCalls_3Millis)), |
| - TestScenario(kManyCalls_10Millis, arraysize(kManyCalls_10Millis)), |
| - TestScenario(kManyCalls_Mixed1, arraysize(kManyCalls_Mixed1)), |
| - TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), |
| - TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), |
| - TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), |
| - TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)))); |
| + TestScenario(kOneCall_3Millis, arraysize(kOneCall_3Millis)), |
| + TestScenario(kOneCall_10Millis, arraysize(kOneCall_10Millis)), |
| + TestScenario(kOneCall_13Millis, arraysize(kOneCall_13Millis)), |
| + TestScenario(kOneCall_20Millis, arraysize(kOneCall_20Millis)), |
| + TestScenario(kTwoCalls_3Millis, arraysize(kTwoCalls_3Millis)), |
| + TestScenario(kTwoCalls_10Millis, arraysize(kTwoCalls_10Millis)), |
| + TestScenario(kTwoCalls_Mixed1, arraysize(kTwoCalls_Mixed1)), |
| + TestScenario(kTwoCalls_Mixed2, arraysize(kTwoCalls_Mixed2)), |
| + TestScenario(kTwoCalls_Mixed3, arraysize(kTwoCalls_Mixed3)), |
| + TestScenario(kTwoCalls_Mixed4, arraysize(kTwoCalls_Mixed4)), |
| + TestScenario(kManyCalls_3Millis, arraysize(kManyCalls_3Millis)), |
| + TestScenario(kManyCalls_10Millis, arraysize(kManyCalls_10Millis)), |
| + TestScenario(kManyCalls_Mixed1, arraysize(kManyCalls_Mixed1)), |
| + TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), |
| + TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), |
| + TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), |
| + TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)))); |
| } // namespace cast |
| } // namespace media |