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

Side by Side Diff: media/base/mock_filters.h

Issue 10753021: Move AudioRenderer out of Filter heirarchy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: thing Created 8 years, 5 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 // A new breed of mock media filters, this time using gmock! Feel free to add 5 // A new breed of mock media filters, this time using gmock! Feel free to add
6 // actions if you need interesting side-effects. 6 // actions if you need interesting side-effects.
7 // 7 //
8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock 8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock
9 // filters to fail the test or do nothing when an unexpected method is called. 9 // filters to fail the test or do nothing when an unexpected method is called.
10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks 10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 virtual ~MockVideoRenderer(); 190 virtual ~MockVideoRenderer();
191 191
192 private: 192 private:
193 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); 193 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer);
194 }; 194 };
195 195
196 class MockAudioRenderer : public AudioRenderer { 196 class MockAudioRenderer : public AudioRenderer {
197 public: 197 public:
198 MockAudioRenderer(); 198 MockAudioRenderer();
199 199
200 // Filter implementation. 200 // AudioRenderer implementation.
201 MOCK_METHOD1(SetHost, void(FilterHost* host)); 201 MOCK_METHOD6(Initialize, void(const scoped_refptr<AudioDecoder>& decoder,
202 const PipelineStatusCB& init_cb,
203 const base::Closure& underflow_cb,
204 const TimeCB& time_cb,
205 const base::Closure& ended_cb,
206 const base::Closure& disabled_cb));
202 MOCK_METHOD1(Play, void(const base::Closure& callback)); 207 MOCK_METHOD1(Play, void(const base::Closure& callback));
203 MOCK_METHOD1(Pause, void(const base::Closure& callback)); 208 MOCK_METHOD1(Pause, void(const base::Closure& callback));
204 MOCK_METHOD1(Flush, void(const base::Closure& callback)); 209 MOCK_METHOD1(Flush, void(const base::Closure& callback));
205 MOCK_METHOD1(Stop, void(const base::Closure& callback)); 210 MOCK_METHOD1(Stop, void(const base::Closure& callback));
206 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); 211 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
207 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); 212 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
208
209 // AudioRenderer implementation.
210 MOCK_METHOD4(Initialize, void(const scoped_refptr<AudioDecoder>& decoder,
211 const PipelineStatusCB& init_cb,
212 const base::Closure& underflow_cb,
213 const TimeCB& time_cb));
214 MOCK_METHOD0(HasEnded, bool()); 213 MOCK_METHOD0(HasEnded, bool());
215 MOCK_METHOD1(SetVolume, void(float volume)); 214 MOCK_METHOD1(SetVolume, void(float volume));
216
217 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); 215 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio));
218 216
219 protected: 217 protected:
220 virtual ~MockAudioRenderer(); 218 virtual ~MockAudioRenderer();
221 219
222 private: 220 private:
223 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); 221 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer);
224 }; 222 };
225 223
226 class MockDecryptorClient : public DecryptorClient { 224 class MockDecryptorClient : public DecryptorClient {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 private: 276 private:
279 scoped_refptr<MockDemuxer> demuxer_; 277 scoped_refptr<MockDemuxer> demuxer_;
280 scoped_refptr<MockVideoDecoder> video_decoder_; 278 scoped_refptr<MockVideoDecoder> video_decoder_;
281 scoped_refptr<MockAudioDecoder> audio_decoder_; 279 scoped_refptr<MockAudioDecoder> audio_decoder_;
282 scoped_refptr<MockVideoRenderer> video_renderer_; 280 scoped_refptr<MockVideoRenderer> video_renderer_;
283 scoped_refptr<MockAudioRenderer> audio_renderer_; 281 scoped_refptr<MockAudioRenderer> audio_renderer_;
284 282
285 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); 283 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection);
286 }; 284 };
287 285
288 // Helper gmock functions that immediately executes and destroys the
289 // Closure on behalf of the provided filter. Can be used when mocking
290 // the Initialize() and Seek() methods.
291 void RunPipelineStatusCB(const PipelineStatusCB& status_cb);
292 void RunPipelineStatusCB2(::testing::Unused, const PipelineStatusCB& status_cb);
293 void RunPipelineStatusCB3(::testing::Unused, const PipelineStatusCB& status_cb,
294 ::testing::Unused);
295 void RunPipelineStatusCB4(::testing::Unused, const PipelineStatusCB& status_cb,
296 ::testing::Unused, ::testing::Unused);
297 // Helper gmock function that immediately executes the Closure on behalf of the
298 // provided filter. Can be used when mocking the Stop() method.
299 void RunClosure(const base::Closure& closure);
300
301 // Helper gmock action that calls SetError() on behalf of the provided filter. 286 // Helper gmock action that calls SetError() on behalf of the provided filter.
302 ACTION_P2(SetError, filter, error) { 287 ACTION_P2(SetError, filter, error) {
303 filter->host()->SetError(error); 288 filter->host()->SetError(error);
304 } 289 }
305 290
306 // Helper gmock action that calls SetDuration() on behalf of the provided 291 // Helper gmock action that calls SetDuration() on behalf of the provided
307 // filter. 292 // filter.
308 ACTION_P2(SetDuration, filter, duration) { 293 ACTION_P2(SetDuration, filter, duration) {
309 filter->host()->SetDuration(duration); 294 filter->host()->SetDuration(duration);
310 } 295 }
311 296
297 ACTION(RunClosure) {
298 arg0.Run();
299 }
300
312 // Helper mock statistics callback. 301 // Helper mock statistics callback.
313 class MockStatisticsCB { 302 class MockStatisticsCB {
314 public: 303 public:
315 MockStatisticsCB(); 304 MockStatisticsCB();
316 ~MockStatisticsCB(); 305 ~MockStatisticsCB();
317 306
318 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); 307 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics));
319 }; 308 };
320 309
321 } // namespace media 310 } // namespace media
322 311
323 #endif // MEDIA_BASE_MOCK_FILTERS_H_ 312 #endif // MEDIA_BASE_MOCK_FILTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698