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