| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 base::TimeDelta duration_; | 127 base::TimeDelta duration_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(MockDemuxer); | 129 DISALLOW_COPY_AND_ASSIGN(MockDemuxer); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 class MockDemuxerFactory : public DemuxerFactory { | 132 class MockDemuxerFactory : public DemuxerFactory { |
| 133 public: | 133 public: |
| 134 explicit MockDemuxerFactory(MockDemuxer* demuxer); | 134 explicit MockDemuxerFactory(MockDemuxer* demuxer); |
| 135 virtual ~MockDemuxerFactory(); | 135 virtual ~MockDemuxerFactory(); |
| 136 | 136 |
| 137 void SetError(PipelineError error); | 137 void SetError(PipelineStatus error); |
| 138 void RunBuildCallback(const std::string& url, BuildCallback* callback); | 138 void RunBuildCallback(const std::string& url, BuildCallback* callback); |
| 139 void DestroyBuildCallback(const std::string& url, BuildCallback* callback); | 139 void DestroyBuildCallback(const std::string& url, BuildCallback* callback); |
| 140 | 140 |
| 141 // DemuxerFactory methods. | 141 // DemuxerFactory methods. |
| 142 MOCK_METHOD2(Build, void(const std::string& url, BuildCallback* callback)); | 142 MOCK_METHOD2(Build, void(const std::string& url, BuildCallback* callback)); |
| 143 virtual DemuxerFactory* Clone() const; | 143 virtual DemuxerFactory* Clone() const; |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 scoped_refptr<MockDemuxer> demuxer_; | 146 scoped_refptr<MockDemuxer> demuxer_; |
| 147 PipelineError error_; | 147 PipelineStatus status_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(MockDemuxerFactory); | 149 DISALLOW_COPY_AND_ASSIGN(MockDemuxerFactory); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 class MockDemuxerStream : public DemuxerStream { | 152 class MockDemuxerStream : public DemuxerStream { |
| 153 public: | 153 public: |
| 154 MockDemuxerStream(); | 154 MockDemuxerStream(); |
| 155 | 155 |
| 156 // DemuxerStream implementation. | 156 // DemuxerStream implementation. |
| 157 MOCK_METHOD0(type, Type()); | 157 MOCK_METHOD0(type, Type()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 MockAudioDecoder* audio_decoder() const { return audio_decoder_; } | 288 MockAudioDecoder* audio_decoder() const { return audio_decoder_; } |
| 289 MockVideoRenderer* video_renderer() const { return video_renderer_; } | 289 MockVideoRenderer* video_renderer() const { return video_renderer_; } |
| 290 MockAudioRenderer* audio_renderer() const { return audio_renderer_; } | 290 MockAudioRenderer* audio_renderer() const { return audio_renderer_; } |
| 291 | 291 |
| 292 FilterCollection* filter_collection() const { | 292 FilterCollection* filter_collection() const { |
| 293 return filter_collection(true, true, PIPELINE_OK); | 293 return filter_collection(true, true, PIPELINE_OK); |
| 294 } | 294 } |
| 295 | 295 |
| 296 FilterCollection* filter_collection(bool include_demuxer, | 296 FilterCollection* filter_collection(bool include_demuxer, |
| 297 bool run_build_callback, | 297 bool run_build_callback, |
| 298 PipelineError build_error) const; | 298 PipelineStatus build_status) const; |
| 299 | 299 |
| 300 private: | 300 private: |
| 301 scoped_refptr<MockDemuxer> demuxer_; | 301 scoped_refptr<MockDemuxer> demuxer_; |
| 302 scoped_refptr<MockVideoDecoder> video_decoder_; | 302 scoped_refptr<MockVideoDecoder> video_decoder_; |
| 303 scoped_refptr<MockAudioDecoder> audio_decoder_; | 303 scoped_refptr<MockAudioDecoder> audio_decoder_; |
| 304 scoped_refptr<MockVideoRenderer> video_renderer_; | 304 scoped_refptr<MockVideoRenderer> video_renderer_; |
| 305 scoped_refptr<MockAudioRenderer> audio_renderer_; | 305 scoped_refptr<MockAudioRenderer> audio_renderer_; |
| 306 | 306 |
| 307 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); | 307 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 // Helper gmock functions that immediately executes and destroys the | 310 // Helper gmock functions that immediately executes and destroys the |
| 311 // FilterCallback on behalf of the provided filter. Can be used when mocking | 311 // FilterCallback on behalf of the provided filter. Can be used when mocking |
| 312 // the Initialize() and Seek() methods. | 312 // the Initialize() and Seek() methods. |
| 313 void RunFilterCallback(::testing::Unused, FilterCallback* callback); | 313 void RunFilterCallback(::testing::Unused, FilterCallback* callback); |
| 314 void RunPipelineStatusCallback(PipelineError status, | 314 void RunPipelineStatusCallback(PipelineStatus status, |
| 315 PipelineStatusCallback* callback); | 315 PipelineStatusCallback* callback); |
| 316 void RunFilterCallback3(::testing::Unused, FilterCallback* callback, | 316 void RunFilterCallback3(::testing::Unused, FilterCallback* callback, |
| 317 ::testing::Unused); | 317 ::testing::Unused); |
| 318 | 318 |
| 319 // Helper gmock function that immediately destroys the FilterCallback on behalf | 319 // Helper gmock function that immediately destroys the FilterCallback on behalf |
| 320 // of the provided filter. Can be used when mocking the Initialize() and Seek() | 320 // of the provided filter. Can be used when mocking the Initialize() and Seek() |
| 321 // methods. | 321 // methods. |
| 322 void DestroyFilterCallback(::testing::Unused, FilterCallback* callback); | 322 void DestroyFilterCallback(::testing::Unused, FilterCallback* callback); |
| 323 | 323 |
| 324 // Helper gmock function that immediately executes and destroys the | 324 // Helper gmock function that immediately executes and destroys the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 348 public: | 348 public: |
| 349 MockStatisticsCallback(); | 349 MockStatisticsCallback(); |
| 350 ~MockStatisticsCallback(); | 350 ~MockStatisticsCallback(); |
| 351 | 351 |
| 352 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 352 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 } // namespace media | 355 } // namespace media |
| 356 | 356 |
| 357 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 357 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |