| 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 // | |
| 5 // A new breed of mock media filters, this time using gmock! Feel free to add | |
| 6 // actions if you need interesting side-effects. | |
| 7 // | |
| 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. | |
| 10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks | |
| 11 | 4 |
| 12 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ | 5 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ |
| 13 #define MEDIA_BASE_MOCK_FILTERS_H_ | 6 #define MEDIA_BASE_MOCK_FILTERS_H_ |
| 14 | 7 |
| 15 #include <string> | 8 #include <string> |
| 16 | 9 |
| 17 #include "base/callback.h" | 10 #include "base/callback.h" |
| 18 #include "media/base/audio_decoder.h" | 11 #include "media/base/audio_decoder.h" |
| 19 #include "media/base/audio_decoder_config.h" | 12 #include "media/base/audio_decoder_config.h" |
| 20 #include "media/base/audio_renderer.h" | 13 #include "media/base/audio_renderer.h" |
| 21 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
| 22 #include "media/base/decryptor.h" | 15 #include "media/base/decryptor.h" |
| 23 #include "media/base/demuxer.h" | 16 #include "media/base/demuxer.h" |
| 24 #include "media/base/filter_collection.h" | 17 #include "media/base/filter_collection.h" |
| 25 #include "media/base/pipeline_status.h" | 18 #include "media/base/pipeline_status.h" |
| 26 #include "media/base/video_decoder.h" | 19 #include "media/base/video_decoder.h" |
| 27 #include "media/base/video_decoder_config.h" | 20 #include "media/base/video_decoder_config.h" |
| 28 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 29 #include "media/base/video_renderer.h" | 22 #include "media/base/video_renderer.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 31 | 24 |
| 32 namespace media { | 25 namespace media { |
| 33 | 26 |
| 34 // Use this template to test for object destruction by setting expectations on | |
| 35 // the method OnDestroy(). | |
| 36 // | |
| 37 // TODO(scherkus): not sure about the naming... perhaps contribute this back | |
| 38 // to gmock itself! | |
| 39 template<class MockClass> | |
| 40 class Destroyable : public MockClass { | |
| 41 public: | |
| 42 Destroyable() {} | |
| 43 | |
| 44 MOCK_METHOD0(OnDestroy, void()); | |
| 45 | |
| 46 protected: | |
| 47 virtual ~Destroyable() { | |
| 48 OnDestroy(); | |
| 49 } | |
| 50 | |
| 51 private: | |
| 52 DISALLOW_COPY_AND_ASSIGN(Destroyable); | |
| 53 }; | |
| 54 | |
| 55 class MockDemuxer : public Demuxer { | 27 class MockDemuxer : public Demuxer { |
| 56 public: | 28 public: |
| 57 MockDemuxer(); | 29 MockDemuxer(); |
| 58 | 30 |
| 59 // Demuxer implementation. | 31 // Demuxer implementation. |
| 60 MOCK_METHOD2(Initialize, void(DemuxerHost* host, const PipelineStatusCB& cb)); | 32 MOCK_METHOD2(Initialize, void(DemuxerHost* host, const PipelineStatusCB& cb)); |
| 61 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); | 33 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); |
| 62 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); | 34 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); |
| 63 MOCK_METHOD1(Stop, void(const base::Closure& callback)); | 35 MOCK_METHOD1(Stop, void(const base::Closure& callback)); |
| 64 MOCK_METHOD0(OnAudioRendererDisabled, void()); | 36 MOCK_METHOD0(OnAudioRendererDisabled, void()); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 public: | 203 public: |
| 232 MockStatisticsCB(); | 204 MockStatisticsCB(); |
| 233 ~MockStatisticsCB(); | 205 ~MockStatisticsCB(); |
| 234 | 206 |
| 235 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); | 207 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); |
| 236 }; | 208 }; |
| 237 | 209 |
| 238 } // namespace media | 210 } // namespace media |
| 239 | 211 |
| 240 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 212 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |