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

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: error_cb 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
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/mock_filters.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 // 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 virtual ~MockVideoRenderer(); 192 virtual ~MockVideoRenderer();
193 193
194 private: 194 private:
195 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); 195 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer);
196 }; 196 };
197 197
198 class MockAudioRenderer : public AudioRenderer { 198 class MockAudioRenderer : public AudioRenderer {
199 public: 199 public:
200 MockAudioRenderer(); 200 MockAudioRenderer();
201 201
202 // Filter implementation. 202 // AudioRenderer implementation.
203 MOCK_METHOD1(SetHost, void(FilterHost* host)); 203 MOCK_METHOD7(Initialize, void(const scoped_refptr<AudioDecoder>& decoder,
204 const PipelineStatusCB& init_cb,
205 const base::Closure& underflow_cb,
206 const TimeCB& time_cb,
207 const base::Closure& ended_cb,
208 const base::Closure& disabled_cb,
209 const PipelineStatusCB& error_cb));
204 MOCK_METHOD1(Play, void(const base::Closure& callback)); 210 MOCK_METHOD1(Play, void(const base::Closure& callback));
205 MOCK_METHOD1(Pause, void(const base::Closure& callback)); 211 MOCK_METHOD1(Pause, void(const base::Closure& callback));
206 MOCK_METHOD1(Flush, void(const base::Closure& callback)); 212 MOCK_METHOD1(Flush, void(const base::Closure& callback));
207 MOCK_METHOD1(Stop, void(const base::Closure& callback)); 213 MOCK_METHOD1(Stop, void(const base::Closure& callback));
208 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); 214 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
209 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); 215 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
210
211 // AudioRenderer implementation.
212 MOCK_METHOD4(Initialize, void(const scoped_refptr<AudioDecoder>& decoder,
213 const PipelineStatusCB& init_cb,
214 const base::Closure& underflow_cb,
215 const TimeCB& time_cb));
216 MOCK_METHOD0(HasEnded, bool()); 216 MOCK_METHOD0(HasEnded, bool());
217 MOCK_METHOD1(SetVolume, void(float volume)); 217 MOCK_METHOD1(SetVolume, void(float volume));
218
219 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); 218 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio));
220 219
221 protected: 220 protected:
222 virtual ~MockAudioRenderer(); 221 virtual ~MockAudioRenderer();
223 222
224 private: 223 private:
225 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); 224 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer);
226 }; 225 };
227 226
228 class MockDecryptor : public Decryptor { 227 class MockDecryptor : public Decryptor {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 private: 302 private:
304 scoped_refptr<MockDemuxer> demuxer_; 303 scoped_refptr<MockDemuxer> demuxer_;
305 scoped_refptr<MockVideoDecoder> video_decoder_; 304 scoped_refptr<MockVideoDecoder> video_decoder_;
306 scoped_refptr<MockAudioDecoder> audio_decoder_; 305 scoped_refptr<MockAudioDecoder> audio_decoder_;
307 scoped_refptr<MockVideoRenderer> video_renderer_; 306 scoped_refptr<MockVideoRenderer> video_renderer_;
308 scoped_refptr<MockAudioRenderer> audio_renderer_; 307 scoped_refptr<MockAudioRenderer> audio_renderer_;
309 308
310 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); 309 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection);
311 }; 310 };
312 311
313 // Helper gmock functions that immediately executes and destroys the
314 // Closure on behalf of the provided filter. Can be used when mocking
315 // the Initialize() and Seek() methods.
316 void RunPipelineStatusCB(const PipelineStatusCB& status_cb);
317 void RunPipelineStatusCB2(::testing::Unused, const PipelineStatusCB& status_cb);
318 void RunPipelineStatusCB3(::testing::Unused, const PipelineStatusCB& status_cb,
319 ::testing::Unused);
320 void RunPipelineStatusCB4(::testing::Unused, const PipelineStatusCB& status_cb,
321 ::testing::Unused, ::testing::Unused);
322 // Helper gmock function that immediately executes the Closure on behalf of the
323 // provided filter. Can be used when mocking the Stop() method.
324 void RunClosure(const base::Closure& closure);
325
326 // Helper gmock action that calls SetError() on behalf of the provided filter. 312 // Helper gmock action that calls SetError() on behalf of the provided filter.
327 ACTION_P2(SetError, filter, error) { 313 ACTION_P2(SetError, filter, error) {
328 filter->host()->SetError(error); 314 filter->host()->SetError(error);
329 } 315 }
330 316
331 // Helper gmock action that calls SetDuration() on behalf of the provided 317 // Helper gmock action that calls SetDuration() on behalf of the provided
332 // filter. 318 // filter.
333 ACTION_P2(SetDuration, filter, duration) { 319 ACTION_P2(SetDuration, filter, duration) {
334 filter->host()->SetDuration(duration); 320 filter->host()->SetDuration(duration);
335 } 321 }
336 322
323 ACTION(RunClosure) {
324 arg0.Run();
325 }
326
337 // Helper mock statistics callback. 327 // Helper mock statistics callback.
338 class MockStatisticsCB { 328 class MockStatisticsCB {
339 public: 329 public:
340 MockStatisticsCB(); 330 MockStatisticsCB();
341 ~MockStatisticsCB(); 331 ~MockStatisticsCB();
342 332
343 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); 333 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics));
344 }; 334 };
345 335
346 } // namespace media 336 } // namespace media
347 337
348 #endif // MEDIA_BASE_MOCK_FILTERS_H_ 338 #endif // MEDIA_BASE_MOCK_FILTERS_H_
OLDNEW
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/mock_filters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698