| 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. | 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 private: | 272 private: |
| 273 scoped_refptr<MockDemuxer> demuxer_; | 273 scoped_refptr<MockDemuxer> demuxer_; |
| 274 scoped_refptr<MockVideoDecoder> video_decoder_; | 274 scoped_refptr<MockVideoDecoder> video_decoder_; |
| 275 scoped_refptr<MockAudioDecoder> audio_decoder_; | 275 scoped_refptr<MockAudioDecoder> audio_decoder_; |
| 276 scoped_refptr<MockVideoRenderer> video_renderer_; | 276 scoped_refptr<MockVideoRenderer> video_renderer_; |
| 277 scoped_refptr<MockAudioRenderer> audio_renderer_; | 277 scoped_refptr<MockAudioRenderer> audio_renderer_; |
| 278 | 278 |
| 279 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); | 279 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 // Helper gmock action that calls SetError() on behalf of the provided filter. | |
| 283 ACTION_P2(SetError, filter, error) { | |
| 284 filter->host()->SetError(error); | |
| 285 } | |
| 286 | |
| 287 // Helper gmock action that calls SetDuration() on behalf of the provided | |
| 288 // filter. | |
| 289 ACTION_P2(SetDuration, filter, duration) { | |
| 290 filter->host()->SetDuration(duration); | |
| 291 } | |
| 292 | |
| 293 ACTION(RunClosure) { | 282 ACTION(RunClosure) { |
| 294 arg0.Run(); | 283 arg0.Run(); |
| 295 } | 284 } |
| 296 | 285 |
| 297 // Helper mock statistics callback. | 286 // Helper mock statistics callback. |
| 298 class MockStatisticsCB { | 287 class MockStatisticsCB { |
| 299 public: | 288 public: |
| 300 MockStatisticsCB(); | 289 MockStatisticsCB(); |
| 301 ~MockStatisticsCB(); | 290 ~MockStatisticsCB(); |
| 302 | 291 |
| 303 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 292 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 304 }; | 293 }; |
| 305 | 294 |
| 306 } // namespace media | 295 } // namespace media |
| 307 | 296 |
| 308 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 297 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |