| 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. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 MockAudioDecoder(); | 204 MockAudioDecoder(); |
| 205 | 205 |
| 206 // Filter implementation. | 206 // Filter implementation. |
| 207 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 207 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
| 208 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 208 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 209 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | 209 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); |
| 210 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 210 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
| 211 | 211 |
| 212 // AudioDecoder implementation. | 212 // AudioDecoder implementation. |
| 213 MOCK_METHOD3(Initialize, void(DemuxerStream* stream, | 213 MOCK_METHOD3(Initialize, void(DemuxerStream* stream, |
| 214 const base::Closure& callback, | 214 const PipelineStatusCB& callback, |
| 215 const StatisticsCallback& stats_callback)); | 215 const StatisticsCallback& stats_callback)); |
| 216 MOCK_METHOD1(Read, void(const ReadCB& callback)); | 216 MOCK_METHOD1(Read, void(const ReadCB& callback)); |
| 217 MOCK_METHOD1(ProduceAudioSamples, void(scoped_refptr<Buffer>)); | 217 MOCK_METHOD1(ProduceAudioSamples, void(scoped_refptr<Buffer>)); |
| 218 MOCK_METHOD0(bits_per_channel, int(void)); | 218 MOCK_METHOD0(bits_per_channel, int(void)); |
| 219 MOCK_METHOD0(channel_layout, ChannelLayout(void)); | 219 MOCK_METHOD0(channel_layout, ChannelLayout(void)); |
| 220 MOCK_METHOD0(samples_per_second, int(void)); | 220 MOCK_METHOD0(samples_per_second, int(void)); |
| 221 | 221 |
| 222 protected: | 222 protected: |
| 223 virtual ~MockAudioDecoder(); | 223 virtual ~MockAudioDecoder(); |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); | 226 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 class MockVideoRenderer : public VideoRenderer { | 229 class MockVideoRenderer : public VideoRenderer { |
| 230 public: | 230 public: |
| 231 MockVideoRenderer(); | 231 MockVideoRenderer(); |
| 232 | 232 |
| 233 // Filter implementation. | 233 // Filter implementation. |
| 234 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 234 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
| 235 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 235 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 236 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | 236 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); |
| 237 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 237 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
| 238 | 238 |
| 239 // VideoRenderer implementation. | 239 // VideoRenderer implementation. |
| 240 MOCK_METHOD3(Initialize, void(VideoDecoder* decoder, | 240 MOCK_METHOD3(Initialize, void(VideoDecoder* decoder, |
| 241 const base::Closure& callback, | 241 const PipelineStatusCB& callback, |
| 242 const StatisticsCallback& stats_callback)); | 242 const StatisticsCallback& stats_callback)); |
| 243 MOCK_METHOD0(HasEnded, bool()); | 243 MOCK_METHOD0(HasEnded, bool()); |
| 244 | 244 |
| 245 // TODO(scherkus): although VideoRendererBase defines this method, this really | 245 // TODO(scherkus): although VideoRendererBase defines this method, this really |
| 246 // shouldn't be here OR should be renamed. | 246 // shouldn't be here OR should be renamed. |
| 247 MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame)); | 247 MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame)); |
| 248 | 248 |
| 249 protected: | 249 protected: |
| 250 virtual ~MockVideoRenderer(); | 250 virtual ~MockVideoRenderer(); |
| 251 | 251 |
| 252 private: | 252 private: |
| 253 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); | 253 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 class MockAudioRenderer : public AudioRenderer { | 256 class MockAudioRenderer : public AudioRenderer { |
| 257 public: | 257 public: |
| 258 MockAudioRenderer(); | 258 MockAudioRenderer(); |
| 259 | 259 |
| 260 // Filter implementation. | 260 // Filter implementation. |
| 261 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 261 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
| 262 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 262 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 263 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | 263 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); |
| 264 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 264 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
| 265 | 265 |
| 266 // AudioRenderer implementation. | 266 // AudioRenderer implementation. |
| 267 MOCK_METHOD3(Initialize, void(AudioDecoder* decoder, | 267 MOCK_METHOD3(Initialize, void(AudioDecoder* decoder, |
| 268 const base::Closure& init_callback, | 268 const PipelineStatusCB& init_callback, |
| 269 const base::Closure& underflow_callback)); | 269 const base::Closure& underflow_callback)); |
| 270 MOCK_METHOD0(HasEnded, bool()); | 270 MOCK_METHOD0(HasEnded, bool()); |
| 271 MOCK_METHOD1(SetVolume, void(float volume)); | 271 MOCK_METHOD1(SetVolume, void(float volume)); |
| 272 | 272 |
| 273 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); | 273 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); |
| 274 | 274 |
| 275 protected: | 275 protected: |
| 276 virtual ~MockAudioRenderer(); | 276 virtual ~MockAudioRenderer(); |
| 277 | 277 |
| 278 private: | 278 private: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); | 311 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 // Helper gmock functions that immediately executes and destroys the | 314 // Helper gmock functions that immediately executes and destroys the |
| 315 // Closure on behalf of the provided filter. Can be used when mocking | 315 // Closure on behalf of the provided filter. Can be used when mocking |
| 316 // the Initialize() and Seek() methods. | 316 // the Initialize() and Seek() methods. |
| 317 void RunFilterCallback(::testing::Unused, const base::Closure& callback); | 317 void RunFilterCallback(::testing::Unused, const base::Closure& callback); |
| 318 void RunFilterStatusCB(::testing::Unused, const FilterStatusCB& cb); | 318 void RunFilterStatusCB(::testing::Unused, const FilterStatusCB& cb); |
| 319 void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb); | 319 void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb); |
| 320 void RunFilterCallback3(::testing::Unused, const base::Closure& callback, | 320 void RunPipelineStatusCB3(::testing::Unused, const PipelineStatusCB& callback, |
| 321 ::testing::Unused); | 321 ::testing::Unused); |
| 322 | 322 |
| 323 // Helper gmock function that immediately executes the Closure on behalf of the | 323 // Helper gmock function that immediately executes the Closure on behalf of the |
| 324 // provided filter. Can be used when mocking the Stop() method. | 324 // provided filter. Can be used when mocking the Stop() method. |
| 325 void RunStopFilterCallback(const base::Closure& callback); | 325 void RunStopFilterCallback(const base::Closure& callback); |
| 326 | 326 |
| 327 // Helper gmock action that calls SetError() on behalf of the provided filter. | 327 // Helper gmock action that calls SetError() on behalf of the provided filter. |
| 328 ACTION_P2(SetError, filter, error) { | 328 ACTION_P2(SetError, filter, error) { |
| 329 filter->host()->SetError(error); | 329 filter->host()->SetError(error); |
| 330 } | 330 } |
| 331 | 331 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 346 public: | 346 public: |
| 347 MockStatisticsCallback(); | 347 MockStatisticsCallback(); |
| 348 ~MockStatisticsCallback(); | 348 ~MockStatisticsCallback(); |
| 349 | 349 |
| 350 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 350 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 } // namespace media | 353 } // namespace media |
| 354 | 354 |
| 355 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 355 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |