| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 MockVideoDecoder(); | 181 MockVideoDecoder(); |
| 182 | 182 |
| 183 // Filter implementation. | 183 // Filter implementation. |
| 184 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 184 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
| 185 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 185 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 186 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); | 186 MOCK_METHOD2(Seek, void(base::TimeDelta time, const FilterStatusCB& cb)); |
| 187 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 187 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
| 188 | 188 |
| 189 // VideoDecoder implementation. | 189 // VideoDecoder implementation. |
| 190 MOCK_METHOD3(Initialize, void(DemuxerStream* stream, | 190 MOCK_METHOD3(Initialize, void(DemuxerStream* stream, |
| 191 const base::Closure& callback, | 191 const PipelineStatusCB& callback, |
| 192 const StatisticsCallback& stats_callback)); | 192 const StatisticsCallback& stats_callback)); |
| 193 MOCK_METHOD1(Read, void(const ReadCB& callback)); | 193 MOCK_METHOD1(Read, void(const ReadCB& callback)); |
| 194 MOCK_METHOD0(natural_size, const gfx::Size&()); | 194 MOCK_METHOD0(natural_size, const gfx::Size&()); |
| 195 | 195 |
| 196 protected: | 196 protected: |
| 197 virtual ~MockVideoDecoder(); | 197 virtual ~MockVideoDecoder(); |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); | 200 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); |
| 201 }; | 201 }; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 315 |
| 316 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); | 316 DISALLOW_COPY_AND_ASSIGN(MockFilterCollection); |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 // Helper gmock functions that immediately executes and destroys the | 319 // Helper gmock functions that immediately executes and destroys the |
| 320 // Closure on behalf of the provided filter. Can be used when mocking | 320 // Closure on behalf of the provided filter. Can be used when mocking |
| 321 // the Initialize() and Seek() methods. | 321 // the Initialize() and Seek() methods. |
| 322 void RunFilterCallback(::testing::Unused, const base::Closure& callback); | 322 void RunFilterCallback(::testing::Unused, const base::Closure& callback); |
| 323 void RunFilterStatusCB(::testing::Unused, const FilterStatusCB& cb); | 323 void RunFilterStatusCB(::testing::Unused, const FilterStatusCB& cb); |
| 324 void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb); | 324 void RunPipelineStatusCB(PipelineStatus status, const PipelineStatusCB& cb); |
| 325 void RunPipelineStatusOKCB(const PipelineStatusCB& cb); // Always PIPELINE_OK. |
| 325 void RunFilterCallback3(::testing::Unused, const base::Closure& callback, | 326 void RunFilterCallback3(::testing::Unused, const base::Closure& callback, |
| 326 ::testing::Unused); | 327 ::testing::Unused); |
| 327 | 328 |
| 328 // Helper gmock function that immediately executes the Closure on behalf of the | 329 // Helper gmock function that immediately executes the Closure on behalf of the |
| 329 // provided filter. Can be used when mocking the Stop() method. | 330 // provided filter. Can be used when mocking the Stop() method. |
| 330 void RunStopFilterCallback(const base::Closure& callback); | 331 void RunStopFilterCallback(const base::Closure& callback); |
| 331 | 332 |
| 332 // Helper gmock action that calls SetError() on behalf of the provided filter. | 333 // Helper gmock action that calls SetError() on behalf of the provided filter. |
| 333 ACTION_P2(SetError, filter, error) { | 334 ACTION_P2(SetError, filter, error) { |
| 334 filter->host()->SetError(error); | 335 filter->host()->SetError(error); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 351 public: | 352 public: |
| 352 MockStatisticsCallback(); | 353 MockStatisticsCallback(); |
| 353 ~MockStatisticsCallback(); | 354 ~MockStatisticsCallback(); |
| 354 | 355 |
| 355 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 356 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 356 }; | 357 }; |
| 357 | 358 |
| 358 } // namespace media | 359 } // namespace media |
| 359 | 360 |
| 360 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 361 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |