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

Side by Side Diff: content/renderer/media/audio_renderer_mixer_manager_unittest.cc

Issue 11880009: Introduce AudioHardwareConfig for renderer side audio device info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style nits. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/logging.h"
5 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
7 #include "content/renderer/media/audio_renderer_mixer_manager.h" 8 #include "content/renderer/media/audio_renderer_mixer_manager.h"
9 #include "media/base/audio_hardware_config.h"
8 #include "media/base/audio_renderer_mixer.h" 10 #include "media/base/audio_renderer_mixer.h"
9 #include "media/base/audio_renderer_mixer_input.h" 11 #include "media/base/audio_renderer_mixer_input.h"
10 #include "media/base/fake_audio_render_callback.h" 12 #include "media/base/fake_audio_render_callback.h"
11 #include "media/base/mock_audio_renderer_sink.h" 13 #include "media/base/mock_audio_renderer_sink.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace content { 17 namespace content {
16 18
17 static const int kBitsPerChannel = 16; 19 static const int kBitsPerChannel = 16;
18 static const int kSampleRate = 48000; 20 static const int kSampleRate = 48000;
19 static const int kBufferSize = 8192; 21 static const int kBufferSize = 8192;
20 static const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO; 22 static const media::ChannelLayout kChannelLayout = media::CHANNEL_LAYOUT_STEREO;
21 23
22 static const int kRenderViewId = 123; 24 static const int kRenderViewId = 123;
23 static const int kAnotherRenderViewId = 456; 25 static const int kAnotherRenderViewId = 456;
24 26
25 class AudioRendererMixerManagerTest : public testing::Test { 27 class AudioRendererMixerManagerTest : public testing::Test {
26 public: 28 public:
27 AudioRendererMixerManagerTest() { 29 AudioRendererMixerManagerTest()
28 manager_.reset(new AudioRendererMixerManager(kSampleRate, kBufferSize)); 30 : fake_config_(kBufferSize, kSampleRate, 0, media::CHANNEL_LAYOUT_NONE) {
31 manager_.reset(new AudioRendererMixerManager(&fake_config_));
29 32
30 // We don't want to deal with instantiating a real AudioOutputDevice since 33 // We don't want to deal with instantiating a real AudioOutputDevice since
31 // it's not important to our testing, so we inject a mock. 34 // it's not important to our testing, so we inject a mock.
32 mock_sink_ = new media::MockAudioRendererSink(); 35 mock_sink_ = new media::MockAudioRendererSink();
33 manager_->SetAudioRendererSinkForTesting(mock_sink_); 36 manager_->SetAudioRendererSinkForTesting(mock_sink_);
34 } 37 }
35 38
36 media::AudioRendererMixer* GetMixer(int source_render_view_id, 39 media::AudioRendererMixer* GetMixer(int source_render_view_id,
37 const media::AudioParameters& params) { 40 const media::AudioParameters& params) {
38 return manager_->GetMixer(source_render_view_id, params); 41 return manager_->GetMixer(source_render_view_id, params);
39 } 42 }
40 43
41 void RemoveMixer(int source_render_view_id, 44 void RemoveMixer(int source_render_view_id,
42 const media::AudioParameters& params) { 45 const media::AudioParameters& params) {
43 return manager_->RemoveMixer(source_render_view_id, params); 46 return manager_->RemoveMixer(source_render_view_id, params);
44 } 47 }
45 48
46 // Number of instantiated mixers. 49 // Number of instantiated mixers.
47 int mixer_count() { 50 int mixer_count() {
48 return manager_->mixers_.size(); 51 return manager_->mixers_.size();
49 } 52 }
50 53
51 protected: 54 protected:
55 media::AudioHardwareConfig fake_config_;
52 scoped_ptr<AudioRendererMixerManager> manager_; 56 scoped_ptr<AudioRendererMixerManager> manager_;
53 scoped_refptr<media::MockAudioRendererSink> mock_sink_; 57 scoped_refptr<media::MockAudioRendererSink> mock_sink_;
54 58
55 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest); 59 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest);
56 }; 60 };
57 61
58 // Verify GetMixer() and RemoveMixer() both work as expected; particularly with 62 // Verify GetMixer() and RemoveMixer() both work as expected; particularly with
59 // respect to the explicit ref counting done. 63 // respect to the explicit ref counting done.
60 TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) { 64 TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) {
61 // Since we're testing two different sets of parameters, we expect 65 // Since we're testing two different sets of parameters, we expect
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_EQ(mixer_count(), 2); 136 EXPECT_EQ(mixer_count(), 2);
133 137
134 // Destroying the inputs should destroy the mixers. 138 // Destroying the inputs should destroy the mixers.
135 input = NULL; 139 input = NULL;
136 EXPECT_EQ(mixer_count(), 1); 140 EXPECT_EQ(mixer_count(), 1);
137 another_input = NULL; 141 another_input = NULL;
138 EXPECT_EQ(mixer_count(), 0); 142 EXPECT_EQ(mixer_count(), 0);
139 } 143 }
140 144
141 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/audio_renderer_mixer_manager.cc ('k') | content/renderer/media/webrtc_audio_capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698