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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/logging.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/renderer/media/audio_renderer_mixer_manager.h" 8 #include "content/renderer/media/audio_renderer_mixer_manager.h"
9 #include "media/audio/audio_parameters.h" 9 #include "media/audio/audio_parameters.h"
10 #include "media/base/audio_hardware_config.h" 10 #include "media/base/audio_hardware_config.h"
(...skipping 26 matching lines...) Expand all
37 kSampleRate, 37 kSampleRate,
38 16, 38 16,
39 kBufferSize); 39 kBufferSize);
40 fake_config_.UpdateOutputConfig(output_params); 40 fake_config_.UpdateOutputConfig(output_params);
41 41
42 manager_.reset(new AudioRendererMixerManager(&fake_config_)); 42 manager_.reset(new AudioRendererMixerManager(&fake_config_));
43 43
44 // We don't want to deal with instantiating a real AudioOutputDevice since 44 // We don't want to deal with instantiating a real AudioOutputDevice since
45 // it's not important to our testing, so we inject a mock. 45 // it's not important to our testing, so we inject a mock.
46 mock_sink_ = new media::MockAudioRendererSink(); 46 mock_sink_ = new media::MockAudioRendererSink();
47 manager_->SetAudioRendererSinkForTesting(mock_sink_); 47 manager_->SetAudioRendererSinkForTesting(mock_sink_.get());
48 } 48 }
49 49
50 media::AudioRendererMixer* GetMixer(int source_render_view_id, 50 media::AudioRendererMixer* GetMixer(int source_render_view_id,
51 const media::AudioParameters& params) { 51 const media::AudioParameters& params) {
52 return manager_->GetMixer(source_render_view_id, params); 52 return manager_->GetMixer(source_render_view_id, params);
53 } 53 }
54 54
55 void RemoveMixer(int source_render_view_id, 55 void RemoveMixer(int source_render_view_id,
56 const media::AudioParameters& params) { 56 const media::AudioParameters& params) {
57 return manager_->RemoveMixer(source_render_view_id, params); 57 return manager_->RemoveMixer(source_render_view_id, params);
(...skipping 10 matching lines...) Expand all
68 scoped_refptr<media::MockAudioRendererSink> mock_sink_; 68 scoped_refptr<media::MockAudioRendererSink> mock_sink_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest); 70 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManagerTest);
71 }; 71 };
72 72
73 // Verify GetMixer() and RemoveMixer() both work as expected; particularly with 73 // Verify GetMixer() and RemoveMixer() both work as expected; particularly with
74 // respect to the explicit ref counting done. 74 // respect to the explicit ref counting done.
75 TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) { 75 TEST_F(AudioRendererMixerManagerTest, GetRemoveMixer) {
76 // Since we're testing two different sets of parameters, we expect 76 // Since we're testing two different sets of parameters, we expect
77 // AudioRendererMixerManager to call Start and Stop on our mock twice. 77 // AudioRendererMixerManager to call Start and Stop on our mock twice.
78 EXPECT_CALL(*mock_sink_, Start()).Times(2); 78 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2);
79 EXPECT_CALL(*mock_sink_, Stop()).Times(2); 79 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2);
80 80
81 // There should be no mixers outstanding to start with. 81 // There should be no mixers outstanding to start with.
82 EXPECT_EQ(mixer_count(), 0); 82 EXPECT_EQ(mixer_count(), 0);
83 83
84 media::AudioParameters params1( 84 media::AudioParameters params1(
85 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, 85 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate,
86 kBitsPerChannel, kBufferSize); 86 kBitsPerChannel, kBufferSize);
87 87
88 media::AudioRendererMixer* mixer1 = GetMixer(kRenderViewId, params1); 88 media::AudioRendererMixer* mixer1 = GetMixer(kRenderViewId, params1);
89 ASSERT_TRUE(mixer1); 89 ASSERT_TRUE(mixer1);
(...skipping 24 matching lines...) Expand all
114 EXPECT_EQ(mixer_count(), 0); 114 EXPECT_EQ(mixer_count(), 0);
115 } 115 }
116 116
117 // Verify CreateInput() provides AudioRendererMixerInput with the appropriate 117 // Verify CreateInput() provides AudioRendererMixerInput with the appropriate
118 // callbacks and they are working as expected. Also, verify that separate 118 // callbacks and they are working as expected. Also, verify that separate
119 // mixers are created for separate render views, even though the AudioParameters 119 // mixers are created for separate render views, even though the AudioParameters
120 // are the same. 120 // are the same.
121 TEST_F(AudioRendererMixerManagerTest, CreateInput) { 121 TEST_F(AudioRendererMixerManagerTest, CreateInput) {
122 // Expect AudioRendererMixerManager to call Start and Stop on our mock twice 122 // Expect AudioRendererMixerManager to call Start and Stop on our mock twice
123 // each. Note: Under normal conditions, each mixer would get its own sink! 123 // each. Note: Under normal conditions, each mixer would get its own sink!
124 EXPECT_CALL(*mock_sink_, Start()).Times(2); 124 EXPECT_CALL(*mock_sink_.get(), Start()).Times(2);
125 EXPECT_CALL(*mock_sink_, Stop()).Times(2); 125 EXPECT_CALL(*mock_sink_.get(), Stop()).Times(2);
126 126
127 media::AudioParameters params( 127 media::AudioParameters params(
128 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, 128 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate,
129 kBitsPerChannel, kBufferSize); 129 kBitsPerChannel, kBufferSize);
130 130
131 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet. 131 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet.
132 EXPECT_EQ(mixer_count(), 0); 132 EXPECT_EQ(mixer_count(), 0);
133 scoped_refptr<media::AudioRendererMixerInput> input( 133 scoped_refptr<media::AudioRendererMixerInput> input(
134 manager_->CreateInput(kRenderViewId)); 134 manager_->CreateInput(kRenderViewId));
135 EXPECT_EQ(mixer_count(), 0); 135 EXPECT_EQ(mixer_count(), 0);
(...skipping 11 matching lines...) Expand all
147 EXPECT_EQ(mixer_count(), 2); 147 EXPECT_EQ(mixer_count(), 2);
148 148
149 // Destroying the inputs should destroy the mixers. 149 // Destroying the inputs should destroy the mixers.
150 input = NULL; 150 input = NULL;
151 EXPECT_EQ(mixer_count(), 1); 151 EXPECT_EQ(mixer_count(), 1);
152 another_input = NULL; 152 another_input = NULL;
153 EXPECT_EQ(mixer_count(), 0); 153 EXPECT_EQ(mixer_count(), 0);
154 } 154 }
155 155
156 } // namespace content 156 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.cc ('k') | content/renderer/media/media_stream_center.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698