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

Side by Side Diff: media/audio/linux/cras_output_unittest.cc

Issue 10184011: Remove unused parameter "stream" from all variants of OnMoreData(). (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « media/audio/linux/cras_output.cc ('k') | media/audio/mac/audio_low_latency_output_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
6
5 #include "media/audio/linux/audio_manager_linux.h" 7 #include "media/audio/linux/audio_manager_linux.h"
6 #include "media/audio/linux/cras_output.h" 8 #include "media/audio/linux/cras_output.h"
7 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
9 11
10 using testing::_; 12 using testing::_;
11 using testing::DoAll; 13 using testing::DoAll;
12 using testing::Return; 14 using testing::Return;
13 using testing::SetArgumentPointee; 15 using testing::SetArgumentPointee;
14 using testing::StrictMock; 16 using testing::StrictMock;
15 17
16 namespace media { 18 namespace media {
17 19
18 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { 20 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback {
19 public: 21 public:
20 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, 22 MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size,
21 uint8* dest, uint32 max_size,
22 AudioBuffersState buffers_state)); 23 AudioBuffersState buffers_state));
23 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); 24 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
24 }; 25 };
25 26
26 class MockAudioManagerLinux : public AudioManagerLinux { 27 class MockAudioManagerLinux : public AudioManagerLinux {
27 public: 28 public:
28 MOCK_METHOD0(Init, void()); 29 MOCK_METHOD0(Init, void());
29 MOCK_METHOD0(HasAudioOutputDevices, bool()); 30 MOCK_METHOD0(HasAudioOutputDevices, bool());
30 MOCK_METHOD0(HasAudioInputDevices, bool()); 31 MOCK_METHOD0(HasAudioInputDevices, bool());
31 MOCK_METHOD0(MuteAll, void()); 32 MOCK_METHOD0(MuteAll, void());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 CrasOutputStreamTest::kTestBytesPerFrame; 114 CrasOutputStreamTest::kTestBytesPerFrame;
114 struct cras_audio_format* const CrasOutputStreamTest::kFakeAudioFormat = 115 struct cras_audio_format* const CrasOutputStreamTest::kFakeAudioFormat =
115 reinterpret_cast<struct cras_audio_format*>(1); 116 reinterpret_cast<struct cras_audio_format*>(1);
116 struct cras_stream_params* const CrasOutputStreamTest::kFakeStreamParams = 117 struct cras_stream_params* const CrasOutputStreamTest::kFakeStreamParams =
117 reinterpret_cast<struct cras_stream_params*>(1); 118 reinterpret_cast<struct cras_stream_params*>(1);
118 struct cras_client* const CrasOutputStreamTest::kFakeClient = 119 struct cras_client* const CrasOutputStreamTest::kFakeClient =
119 reinterpret_cast<struct cras_client*>(1); 120 reinterpret_cast<struct cras_client*>(1);
120 121
121 TEST_F(CrasOutputStreamTest, ConstructedState) { 122 TEST_F(CrasOutputStreamTest, ConstructedState) {
122 // Should support mono. 123 // Should support mono.
123 CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 124 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
124 EXPECT_EQ(CrasOutputStream::kCreated, test_stream->state()); 125 EXPECT_EQ(CrasOutputStream::kCreated, test_stream->state());
125 test_stream->Close(); 126 test_stream->Close();
126 127
127 // Should support stereo. 128 // Should support stereo.
128 test_stream = CreateStream(CHANNEL_LAYOUT_SURROUND); 129 test_stream = CreateStream(CHANNEL_LAYOUT_SURROUND);
129 EXPECT_EQ(CrasOutputStream::kCreated, test_stream->state()); 130 EXPECT_EQ(CrasOutputStream::kCreated, test_stream->state());
130 test_stream->Close(); 131 test_stream->Close();
131 132
132 // Bad bits per sample. 133 // Bad bits per sample.
133 AudioParameters bad_bps_params(kTestFormat, kTestChannelLayout, 134 AudioParameters bad_bps_params(kTestFormat, kTestChannelLayout,
(...skipping 13 matching lines...) Expand all
147 148
148 // Bad sample rate. 149 // Bad sample rate.
149 AudioParameters bad_rate_params(kTestFormat, kTestChannelLayout, 150 AudioParameters bad_rate_params(kTestFormat, kTestChannelLayout,
150 0, kTestBitsPerSample, kTestFramesPerPacket); 151 0, kTestBitsPerSample, kTestFramesPerPacket);
151 test_stream = new CrasOutputStream(bad_rate_params, mock_manager_.get()); 152 test_stream = new CrasOutputStream(bad_rate_params, mock_manager_.get());
152 EXPECT_EQ(CrasOutputStream::kInError, test_stream->state()); 153 EXPECT_EQ(CrasOutputStream::kInError, test_stream->state());
153 test_stream->Close(); 154 test_stream->Close();
154 } 155 }
155 156
156 TEST_F(CrasOutputStreamTest, OpenClose) { 157 TEST_F(CrasOutputStreamTest, OpenClose) {
157 CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 158 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
158 // Open the stream. 159 // Open the stream.
159 ASSERT_TRUE(test_stream->Open()); 160 ASSERT_TRUE(test_stream->Open());
160 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); 161 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state());
161 162
162 // Close the stream. 163 // Close the stream.
163 test_stream->Close(); 164 test_stream->Close();
164 } 165 }
165 166
166 TEST_F(CrasOutputStreamTest, StartFailBeforeOpen) { 167 TEST_F(CrasOutputStreamTest, StartFailBeforeOpen) {
167 CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 168 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
168 MockAudioSourceCallback mock_callback; 169 MockAudioSourceCallback mock_callback;
169 170
170 test_stream->Start(&mock_callback); 171 test_stream->Start(&mock_callback);
171 EXPECT_EQ(CrasOutputStream::kInError, test_stream->state()); 172 EXPECT_EQ(CrasOutputStream::kInError, test_stream->state());
172 } 173 }
173 174
174 TEST_F(CrasOutputStreamTest, StartStop) { 175 TEST_F(CrasOutputStreamTest, StartStop) {
175 CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 176 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
176 MockAudioSourceCallback mock_callback; 177 MockAudioSourceCallback mock_callback;
177 178
178 // Open the stream. 179 // Open the stream.
179 ASSERT_TRUE(test_stream->Open()); 180 ASSERT_TRUE(test_stream->Open());
180 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); 181 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state());
181 182
182 // Start. 183 // Start.
183 test_stream->Start(&mock_callback); 184 test_stream->Start(&mock_callback);
184 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state()); 185 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state());
185 186
186 // Stop. 187 // Stop.
187 test_stream->Stop(); 188 test_stream->Stop();
188 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state()); 189 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state());
189 190
190 // Close the stream. 191 // Close the stream.
191 test_stream->Close(); 192 test_stream->Close();
192 } 193 }
193 194
194 TEST_F(CrasOutputStreamTest, RenderFrames) { 195 TEST_F(CrasOutputStreamTest, RenderFrames) {
195 CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 196 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
196 MockAudioSourceCallback mock_callback; 197 MockAudioSourceCallback mock_callback;
197 const uint32 amount_rendered_return = 2048; 198 const uint32 amount_rendered_return = 2048;
198 199
199 // Open the stream. 200 // Open the stream.
200 ASSERT_TRUE(test_stream->Open()); 201 ASSERT_TRUE(test_stream->Open());
201 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); 202 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state());
202 203
203 // Render Callback. 204 // Render Callback.
204 EXPECT_CALL(mock_callback, OnMoreData(test_stream, _, 205 EXPECT_CALL(mock_callback, OnMoreData(_,
205 kTestFramesPerPacket * kTestBytesPerFrame, _)) 206 kTestFramesPerPacket * kTestBytesPerFrame, _))
206 .WillRepeatedly(Return(amount_rendered_return)); 207 .WillRepeatedly(Return(amount_rendered_return));
207 208
208 // Start. 209 // Start.
209 test_stream->Start(&mock_callback); 210 test_stream->Start(&mock_callback);
210 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state()); 211 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state());
211 212
212 // Stop. 213 // Stop.
213 test_stream->Stop(); 214 test_stream->Stop();
214 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state()); 215 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state());
215 216
216 // Close the stream. 217 // Close the stream.
217 test_stream->Close(); 218 test_stream->Close();
218 } 219 }
219 220
220 } // namespace media 221 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/linux/cras_output.cc ('k') | media/audio/mac/audio_low_latency_output_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698