OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "content/renderer/media/audio_device_factory.h" | 6 #include "content/renderer/media/audio_device_factory.h" |
7 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 7 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
8 #include "media/base/audio_renderer_mixer.h" | 8 #include "media/base/audio_renderer_mixer.h" |
9 #include "media/base/audio_renderer_mixer_input.h" | 9 #include "media/base/audio_renderer_mixer_input.h" |
10 #include "media/base/fake_audio_render_callback.h" | 10 #include "media/base/fake_audio_render_callback.h" |
11 #include "media/base/mock_audio_renderer_sink.h" | 11 #include "media/base/mock_audio_renderer_sink.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 static const int kBitsPerChannel = 16; | 17 static const int kBitsPerChannel = 16; |
18 static const int kSampleRate = 48000; | 18 static const int kSampleRate = 48000; |
19 static const int kBufferSize = 8192; | 19 static const int kBufferSize = 8192; |
20 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; | 20 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; |
21 | 21 |
22 // By sub-classing AudioDeviceFactory we've overridden the factory to use our | 22 // By sub-classing AudioDeviceFactory we've overridden the factory to use our |
23 // CreateAudioDevice() method globally. | 23 // CreateAudioDevice() method globally. |
24 class MockAudioRenderSinkFactory : public AudioDeviceFactory { | 24 class MockAudioRenderSinkFactory : public AudioDeviceFactory { |
25 public: | 25 public: |
26 MockAudioRenderSinkFactory() {} | 26 MockAudioRenderSinkFactory() {} |
27 virtual ~MockAudioRenderSinkFactory() {} | 27 virtual ~MockAudioRenderSinkFactory() {} |
28 | 28 |
29 protected: | 29 protected: |
30 virtual media::MockAudioRendererSink* CreateAudioDevice() { | 30 virtual media::MockAudioRendererSink* CreateOutputDevice() OVERRIDE { |
31 media::MockAudioRendererSink* sink = new media::MockAudioRendererSink(); | 31 media::MockAudioRendererSink* sink = new media::MockAudioRendererSink(); |
32 EXPECT_CALL(*sink, Start()); | 32 EXPECT_CALL(*sink, Start()); |
33 EXPECT_CALL(*sink, Stop()); | 33 EXPECT_CALL(*sink, Stop()); |
34 return sink; | 34 return sink; |
35 } | 35 } |
36 | 36 |
| 37 virtual AudioInputDevice* CreateInputDevice() OVERRIDE { |
| 38 ADD_FAILURE(); |
| 39 return NULL; |
| 40 } |
| 41 |
37 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderSinkFactory); | 42 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderSinkFactory); |
38 }; | 43 }; |
39 | 44 |
40 class AudioRendererMixerManagerTest : public testing::Test { | 45 class AudioRendererMixerManagerTest : public testing::Test { |
41 public: | 46 public: |
42 AudioRendererMixerManagerTest() { | 47 AudioRendererMixerManagerTest() { |
43 // We don't want to deal with instantiating a real AudioDevice since it's | 48 // We don't want to deal with instantiating a real AudioDevice since it's |
44 // not important to our testing, so use a mock AudioDeviceFactory. | 49 // not important to our testing, so use a mock AudioDeviceFactory. |
45 mock_sink_factory_.reset(new MockAudioRenderSinkFactory()); | 50 mock_sink_factory_.reset(new MockAudioRenderSinkFactory()); |
46 manager_.reset(new AudioRendererMixerManager(kSampleRate, kBufferSize)); | 51 manager_.reset(new AudioRendererMixerManager(kSampleRate, kBufferSize)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 media::FakeAudioRenderCallback callback(0); | 127 media::FakeAudioRenderCallback callback(0); |
123 input->Initialize(params, &callback); | 128 input->Initialize(params, &callback); |
124 EXPECT_EQ(mixer_count(), 1); | 129 EXPECT_EQ(mixer_count(), 1); |
125 | 130 |
126 // Destroying the input should destroy the mixer. | 131 // Destroying the input should destroy the mixer. |
127 input = NULL; | 132 input = NULL; |
128 EXPECT_EQ(mixer_count(), 0); | 133 EXPECT_EQ(mixer_count(), 0); |
129 } | 134 } |
130 | 135 |
131 } // namespace content | 136 } // namespace content |
OLD | NEW |