Chromium Code Reviews| Index: media/base/audio_renderer_mixer_input_unittest.cc |
| diff --git a/media/base/audio_renderer_mixer_input_unittest.cc b/media/base/audio_renderer_mixer_input_unittest.cc |
| index b57b7cc5ab91e451cef0b51c200bb9d67023a678..0c7fd24d42f8cf916c90e98e15cd1abc4b8661fa 100644 |
| --- a/media/base/audio_renderer_mixer_input_unittest.cc |
| +++ b/media/base/audio_renderer_mixer_input_unittest.cc |
| @@ -2,11 +2,10 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "media/audio/audio_util.h" |
| -#include "media/audio/null_audio_sink.h" |
| #include "media/base/audio_renderer_mixer.h" |
| #include "media/base/audio_renderer_mixer_input.h" |
| #include "media/base/fake_audio_render_callback.h" |
| +#include "media/base/mock_audio_renderer_sink.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -14,33 +13,24 @@ namespace media { |
| static const int kBitsPerChannel = 16; |
| static const int kSampleRate = 48000; |
| +static const int kBufferSize = 8192; |
| static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; |
| -class AudioRendererMixerInputTest : public ::testing::Test { |
| +class AudioRendererMixerInputTest : public testing::Test { |
| public: |
| AudioRendererMixerInputTest() { |
| audio_parameters_ = AudioParameters( |
| AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, |
| - kBitsPerChannel, GetHighLatencyOutputBufferSize(kSampleRate)); |
| + kBitsPerChannel, kBufferSize); |
| - mixer_ = new AudioRendererMixer(audio_parameters_, new NullAudioSink()); |
| + scoped_refptr<MockAudioRendererSink> sink = new MockAudioRendererSink(); |
| + EXPECT_CALL(*sink, Start()); |
| + EXPECT_CALL(*sink, Stop()); |
|
scherkus (not reviewing)
2012/07/12 23:02:52
ideally you should try to move this closer to wher
DaleCurtis
2012/07/12 23:16:29
Would need to make sink a class variable then, it
scherkus (not reviewing)
2012/07/14 01:45:02
ah didn't notice sink wasn't saved anywhere -- wha
|
| + mixer_ = new AudioRendererMixer(audio_parameters_, audio_parameters_, sink); |
| mixer_input_ = new AudioRendererMixerInput(mixer_); |
| - fake_callback_.reset(new FakeAudioRenderCallback(audio_parameters_)); |
| + fake_callback_.reset(new FakeAudioRenderCallback(0)); |
| mixer_input_->Initialize(audio_parameters_, fake_callback_.get()); |
| - } |
| - |
| - // Render audio_parameters_.frames_per_buffer() frames into |audio_data_| and |
| - // verify the result against |check_value|. |
| - void RenderAndValidateAudioData(float check_value) { |
| - const std::vector<float*>& audio_data = mixer_input_->audio_data(); |
| - |
| - ASSERT_EQ(fake_callback_->Render( |
| - audio_data, audio_parameters_.frames_per_buffer(), 0), |
| - audio_parameters_.frames_per_buffer()); |
| - |
| - for (size_t i = 0; i < audio_data.size(); ++i) |
| - for (int j = 0; j < audio_parameters_.frames_per_buffer(); j++) |
| - ASSERT_FLOAT_EQ(check_value, audio_data[i][j]); |
| + EXPECT_TRUE(sink->callback()); |
| } |
| protected: |
| @@ -54,6 +44,11 @@ class AudioRendererMixerInputTest : public ::testing::Test { |
| DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInputTest); |
| }; |
| +// Test callback() works as expected. |
| +TEST_F(AudioRendererMixerInputTest, GetCallback) { |
| + EXPECT_EQ(mixer_input_->callback(), fake_callback_.get()); |
| +} |
| + |
| // Test that getting and setting the volume work as expected. |
| TEST_F(AudioRendererMixerInputTest, GetSetVolume) { |
| // Starting volume should be 0. |
| @@ -67,20 +62,6 @@ TEST_F(AudioRendererMixerInputTest, GetSetVolume) { |
| EXPECT_EQ(volume, kVolume); |
| } |
| -// Test audio_data() is allocated correctly. |
| -TEST_F(AudioRendererMixerInputTest, GetAudioData) { |
| - RenderAndValidateAudioData(fake_callback_->fill_value()); |
| - |
| - // TODO(dalecurtis): Perform alignment and size checks when we switch over to |
| - // FFmpeg optimized vector_fmac. |
| -} |
| - |
| -// Test callback() works as expected. |
| -TEST_F(AudioRendererMixerInputTest, GetCallback) { |
| - EXPECT_EQ(mixer_input_->callback(), fake_callback_.get()); |
| - RenderAndValidateAudioData(fake_callback_->fill_value()); |
| -} |
| - |
| // Test Start()/Play()/Pause()/Stop()/playing() all work as expected. Also |
| // implicitly tests that AddMixerInput() and RemoveMixerInput() work without |
| // crashing; functional tests for these methods are in AudioRendererMixerTest. |