| Index: content/renderer/media/audio_renderer_mixer_manager_unittest.cc
|
| diff --git a/content/renderer/media/audio_renderer_mixer_manager_unittest.cc b/content/renderer/media/audio_renderer_mixer_manager_unittest.cc
|
| index 40b642e44b0e981cc60a915ca1a7721c81230608..63a1660c267bae663c4052c78c340cbf36980604 100644
|
| --- a/content/renderer/media/audio_renderer_mixer_manager_unittest.cc
|
| +++ b/content/renderer/media/audio_renderer_mixer_manager_unittest.cc
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "content/renderer/media/audio_device_factory.h"
|
| #include "content/renderer/media/audio_renderer_mixer_manager.h"
|
| #include "media/base/audio_renderer_mixer.h"
|
| #include "media/base/audio_renderer_mixer_input.h"
|
| @@ -19,36 +19,15 @@ static const int kSampleRate = 48000;
|
| static const int kBufferSize = 8192;
|
| static const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO;
|
|
|
| -// By sub-classing AudioDeviceFactory we've overridden the factory to use our
|
| -// CreateAudioDevice() method globally.
|
| -class MockAudioRenderSinkFactory : public AudioDeviceFactory {
|
| - public:
|
| - MockAudioRenderSinkFactory() {}
|
| - virtual ~MockAudioRenderSinkFactory() {}
|
| -
|
| - protected:
|
| - virtual media::MockAudioRendererSink* CreateOutputDevice() OVERRIDE {
|
| - media::MockAudioRendererSink* sink = new media::MockAudioRendererSink();
|
| - EXPECT_CALL(*sink, Start());
|
| - EXPECT_CALL(*sink, Stop());
|
| - return sink;
|
| - }
|
| -
|
| - virtual media::AudioInputDevice* CreateInputDevice() OVERRIDE {
|
| - ADD_FAILURE();
|
| - return NULL;
|
| - }
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MockAudioRenderSinkFactory);
|
| -};
|
| -
|
| class AudioRendererMixerManagerTest : public testing::Test {
|
| public:
|
| AudioRendererMixerManagerTest() {
|
| - // We don't want to deal with instantiating a real AudioOutputDevice since
|
| - // it's not important to our testing, so use a mock AudioDeviceFactory.
|
| - mock_sink_factory_.reset(new MockAudioRenderSinkFactory());
|
| manager_.reset(new AudioRendererMixerManager(kSampleRate, kBufferSize));
|
| +
|
| + // We don't want to deal with instantiating a real AudioOutputDevice since
|
| + // it's not important to our testing, so we inject a mock.
|
| + mock_sink_ = new media::MockAudioRendererSink();
|
| + manager_->SetAudioRendererSinkForTesting(mock_sink_);
|
| }
|
|
|
| media::AudioRendererMixer* GetMixer(const media::AudioParameters& params) {
|
| @@ -65,8 +44,8 @@ class AudioRendererMixerManagerTest : public testing::Test {
|
| }
|
|
|
| protected:
|
| - scoped_ptr<MockAudioRenderSinkFactory> mock_sink_factory_;
|
| scoped_ptr<AudioRendererMixerManager> manager_;
|
| + scoped_refptr<media::MockAudioRendererSink> mock_sink_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest);
|
| };
|
| @@ -74,6 +53,11 @@ class AudioRendererMixerManagerTest : public testing::Test {
|
| // Verify GetMixer() and RemoveMixer() both work as expected; particularly with
|
| // respect to the explicit ref counting done.
|
| TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) {
|
| + // Since we're testing two different sets of parameters, we expect
|
| + // AudioRendererMixerManager to call Start and Stop on our mock twice.
|
| + EXPECT_CALL(*mock_sink_, Start()).Times(2);
|
| + EXPECT_CALL(*mock_sink_, Stop()).Times(2);
|
| +
|
| // There should be no mixers outstanding to start with.
|
| EXPECT_EQ(mixer_count(), 0);
|
|
|
| @@ -113,6 +97,11 @@ TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) {
|
| // Verify CreateInput() provides AudioRendererMixerInput with the appropriate
|
| // callbacks and they are working as expected.
|
| TEST_F(AudioRendererMixerManagerTest, CreateInput) {
|
| + // Since we're testing only one set of parameters, we expect
|
| + // AudioRendererMixerManager to call Start and Stop on our mock once each.
|
| + EXPECT_CALL(*mock_sink_, Start()).Times(1);
|
| + EXPECT_CALL(*mock_sink_, Stop()).Times(1);
|
| +
|
| media::AudioParameters params(
|
| media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate,
|
| kBitsPerChannel, kBufferSize);
|
|
|