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

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

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Comments. Created 8 years, 3 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.h » ('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> 5 #include <string>
6 6
7 #include "media/audio/linux/audio_manager_linux.h" 7 #include "media/audio/linux/audio_manager_linux.h"
8 #include "media/audio/linux/cras_output.h" 8 #include "media/audio/linux/cras_output.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using testing::_; 12 using testing::_;
13 using testing::DoAll; 13 using testing::DoAll;
14 using testing::Return; 14 using testing::Return;
15 using testing::SetArgumentPointee; 15 using testing::SetArgumentPointee;
16 using testing::StrictMock; 16 using testing::StrictMock;
17 17
18 namespace media { 18 namespace media {
19 19
20 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { 20 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback {
21 public: 21 public:
22 MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, 22 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus,
23 AudioBuffersState buffers_state)); 23 AudioBuffersState buffers_state));
24 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); 24 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code));
25 }; 25 };
26 26
27 class MockAudioManagerLinux : public AudioManagerLinux { 27 class MockAudioManagerLinux : public AudioManagerLinux {
28 public: 28 public:
29 MOCK_METHOD0(Init, void()); 29 MOCK_METHOD0(Init, void());
30 MOCK_METHOD0(HasAudioOutputDevices, bool()); 30 MOCK_METHOD0(HasAudioOutputDevices, bool());
31 MOCK_METHOD0(HasAudioInputDevices, bool()); 31 MOCK_METHOD0(HasAudioInputDevices, bool());
32 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*( 32 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*(
33 const AudioParameters& params)); 33 const AudioParameters& params));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 test_stream->Stop(); 186 test_stream->Stop();
187 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state()); 187 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state());
188 188
189 // Close the stream. 189 // Close the stream.
190 test_stream->Close(); 190 test_stream->Close();
191 } 191 }
192 192
193 TEST_F(CrasOutputStreamTest, RenderFrames) { 193 TEST_F(CrasOutputStreamTest, RenderFrames) {
194 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); 194 CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO);
195 MockAudioSourceCallback mock_callback; 195 MockAudioSourceCallback mock_callback;
196 const uint32 amount_rendered_return = 2048;
197 196
198 // Open the stream. 197 // Open the stream.
199 ASSERT_TRUE(test_stream->Open()); 198 ASSERT_TRUE(test_stream->Open());
200 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); 199 EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state());
201 200
202 // Render Callback. 201 // Render Callback.
203 EXPECT_CALL(mock_callback, OnMoreData(_, 202 EXPECT_CALL(mock_callback, OnMoreData(_, _))
204 kTestFramesPerPacket * kTestBytesPerFrame, _)) 203 .WillRepeatedly(Return(kTestFramesPerPacket));
205 .WillRepeatedly(Return(amount_rendered_return));
206 204
207 // Start. 205 // Start.
208 test_stream->Start(&mock_callback); 206 test_stream->Start(&mock_callback);
209 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state()); 207 EXPECT_EQ(CrasOutputStream::kIsPlaying, test_stream->state());
210 208
211 // Stop. 209 // Stop.
212 test_stream->Stop(); 210 test_stream->Stop();
213 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state()); 211 EXPECT_EQ(CrasOutputStream::kIsStopped, test_stream->state());
214 212
215 // Close the stream. 213 // Close the stream.
216 test_stream->Close(); 214 test_stream->Close();
217 } 215 }
218 216
219 } // namespace media 217 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/linux/cras_output.cc ('k') | media/audio/mac/audio_low_latency_output_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698