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

Unified Diff: media/base/audio_renderer_mixer_input_unittest.cc

Issue 10698066: Switch to pcm_low_latency and enable resampling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Remove RefCount. Squash ARMM changes. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
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..60bc41586392a450a586ca7b04f50bcdbc70a487 100644
--- a/media/base/audio_renderer_mixer_input_unittest.cc
+++ b/media/base/audio_renderer_mixer_input_unittest.cc
@@ -2,11 +2,12 @@
// 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 "base/bind.h"
+#include "base/bind_helpers.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,46 +15,56 @@ 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));
-
- mixer_ = new AudioRendererMixer(audio_parameters_, new NullAudioSink());
- mixer_input_ = new AudioRendererMixerInput(mixer_);
- fake_callback_.reset(new FakeAudioRenderCallback(audio_parameters_));
+ kBitsPerChannel, kBufferSize);
+
+ mixer_input_ = new AudioRendererMixerInput(
+ base::Bind(
+ &AudioRendererMixerInputTest::GetMixer, base::Unretained(this)),
+ base::Bind(
+ &AudioRendererMixerInputTest::RemoveMixer, base::Unretained(this)));
+ fake_callback_.reset(new FakeAudioRenderCallback(0));
mixer_input_->Initialize(audio_parameters_, fake_callback_.get());
+ EXPECT_CALL(*this, RemoveMixer(testing::_));
scherkus (not reviewing) 2012/07/14 01:45:02 nit: can you use audio_parameters_ instead of test
DaleCurtis 2012/07/14 02:10:03 Doesn't seem to like that: error: invalid operands
scherkus (not reviewing) 2012/07/14 02:15:31 I guess AP needs to implement operator==() -- I wo
}
- // 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());
+ AudioRendererMixer* GetMixer(const AudioParameters& params) {
+ if (mixer_ == NULL) {
scherkus (not reviewing) 2012/07/14 01:45:02 s/mixer_ == NULL/!mixer_.get()/ (general comment:
DaleCurtis 2012/07/14 02:10:03 Done.
+ scoped_refptr<MockAudioRendererSink> sink = new MockAudioRendererSink();
+ EXPECT_CALL(*sink, Start());
+ EXPECT_CALL(*sink, Stop());
- 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]);
+ mixer_.reset(new AudioRendererMixer(
+ audio_parameters_, audio_parameters_, sink));
+ }
+ return mixer_.get();
}
+ MOCK_METHOD1(RemoveMixer, void(const AudioParameters&));
+
protected:
virtual ~AudioRendererMixerInputTest() {}
AudioParameters audio_parameters_;
- scoped_refptr<AudioRendererMixer> mixer_;
+ scoped_ptr<AudioRendererMixer> mixer_;
scoped_refptr<AudioRendererMixerInput> mixer_input_;
scoped_ptr<FakeAudioRenderCallback> fake_callback_;
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 +78,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.

Powered by Google App Engine
This is Rietveld 408576698