OLD | NEW |
---|---|
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 (i.e., copying data to the | 6 // actions if you need interesting side-effects (i.e., copying data to the |
7 // buffer passed into MockDataSource::Read()). | 7 // buffer passed into MockDataSource::Read()). |
8 // | 8 // |
9 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock | 9 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock |
10 // filters to fail the test or do nothing when an unexpected method is called. | 10 // filters to fail the test or do nothing when an unexpected method is called. |
11 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks | 11 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks |
12 | 12 |
13 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ | 13 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ |
14 #define MEDIA_BASE_MOCK_FILTERS_H_ | 14 #define MEDIA_BASE_MOCK_FILTERS_H_ |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "base/callback.h" | 18 #include "base/callback.h" |
19 #include "media/base/audio_decoder.h" | |
19 #include "media/base/audio_decoder_config.h" | 20 #include "media/base/audio_decoder_config.h" |
20 #include "media/base/demuxer.h" | 21 #include "media/base/demuxer.h" |
21 #include "media/base/filters.h" | 22 #include "media/base/filters.h" |
22 #include "media/base/filter_collection.h" | 23 #include "media/base/filter_collection.h" |
23 #include "media/base/pipeline.h" | 24 #include "media/base/pipeline.h" |
24 #include "media/base/video_decoder_config.h" | 25 #include "media/base/video_decoder_config.h" |
25 #include "media/base/video_frame.h" | 26 #include "media/base/video_frame.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 | 28 |
28 namespace media { | 29 namespace media { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 virtual ~MockVideoDecoder(); | 197 virtual ~MockVideoDecoder(); |
197 | 198 |
198 private: | 199 private: |
199 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); | 200 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); |
200 }; | 201 }; |
201 | 202 |
202 class MockAudioDecoder : public AudioDecoder { | 203 class MockAudioDecoder : public AudioDecoder { |
203 public: | 204 public: |
204 MockAudioDecoder(); | 205 MockAudioDecoder(); |
205 | 206 |
206 // Filter implementation. | |
207 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | |
208 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | |
209 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | |
210 MOCK_METHOD0(OnAudioRendererDisabled, void()); | |
211 | |
212 // AudioDecoder implementation. | 207 // AudioDecoder implementation. |
213 MOCK_METHOD3(Initialize, void(DemuxerStream* stream, | 208 MOCK_METHOD3(Initialize, void(const scoped_refptr<DemuxerStream>, |
scherkus (not reviewing)
2012/02/06 21:04:04
const-ref
Ami GONE FROM CHROMIUM
2012/02/06 21:38:48
Done.
| |
214 const PipelineStatusCB& callback, | 209 const PipelineStatusCB&, |
215 const StatisticsCallback& stats_callback)); | 210 const StatisticsCallback&)); |
216 MOCK_METHOD1(Read, void(const ReadCB& callback)); | 211 MOCK_METHOD1(Read, void(const ReadCB&)); |
217 MOCK_METHOD1(ProduceAudioSamples, void(scoped_refptr<Buffer>)); | 212 MOCK_METHOD1(ProduceAudioSamples, void(scoped_refptr<Buffer>)); |
218 MOCK_METHOD0(bits_per_channel, int(void)); | 213 MOCK_METHOD0(bits_per_channel, int(void)); |
219 MOCK_METHOD0(channel_layout, ChannelLayout(void)); | 214 MOCK_METHOD0(channel_layout, ChannelLayout(void)); |
220 MOCK_METHOD0(samples_per_second, int(void)); | 215 MOCK_METHOD0(samples_per_second, int(void)); |
216 MOCK_METHOD1(Reset, void(const base::Closure&)); | |
221 | 217 |
222 protected: | 218 protected: |
223 virtual ~MockAudioDecoder(); | 219 virtual ~MockAudioDecoder(); |
224 | 220 |
225 private: | 221 private: |
226 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); | 222 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); |
227 }; | 223 }; |
228 | 224 |
229 class MockVideoRenderer : public VideoRenderer { | 225 class MockVideoRenderer : public VideoRenderer { |
230 public: | 226 public: |
(...skipping 28 matching lines...) Expand all Loading... | |
259 public: | 255 public: |
260 MockAudioRenderer(); | 256 MockAudioRenderer(); |
261 | 257 |
262 // Filter implementation. | 258 // Filter implementation. |
263 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 259 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
264 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 260 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
265 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | 261 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); |
266 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 262 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
267 | 263 |
268 // AudioRenderer implementation. | 264 // AudioRenderer implementation. |
269 MOCK_METHOD4(Initialize, void(AudioDecoder* decoder, | 265 MOCK_METHOD4(Initialize, void(const scoped_refptr<AudioDecoder> decoder, |
scherkus (not reviewing)
2012/02/06 21:04:04
const-ref
Ami GONE FROM CHROMIUM
2012/02/06 21:38:48
Done.
| |
270 const PipelineStatusCB& init_callback, | 266 const PipelineStatusCB& init_callback, |
271 const base::Closure& underflow_callback, | 267 const base::Closure& underflow_callback, |
272 const AudioTimeCB& time_cb)); | 268 const AudioTimeCB& time_cb)); |
273 MOCK_METHOD0(HasEnded, bool()); | 269 MOCK_METHOD0(HasEnded, bool()); |
274 MOCK_METHOD1(SetVolume, void(float volume)); | 270 MOCK_METHOD1(SetVolume, void(float volume)); |
275 | 271 |
276 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); | 272 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); |
277 | 273 |
278 protected: | 274 protected: |
279 virtual ~MockAudioRenderer(); | 275 virtual ~MockAudioRenderer(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 public: | 346 public: |
351 MockStatisticsCallback(); | 347 MockStatisticsCallback(); |
352 ~MockStatisticsCallback(); | 348 ~MockStatisticsCallback(); |
353 | 349 |
354 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 350 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
355 }; | 351 }; |
356 | 352 |
357 } // namespace media | 353 } // namespace media |
358 | 354 |
359 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 355 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
OLD | NEW |