Chromium Code Reviews| 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 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ | 5 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ |
| 6 #define MEDIA_BASE_MOCK_FILTERS_H_ | 6 #define MEDIA_BASE_MOCK_FILTERS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "media/base/audio_decoder.h" | 14 #include "media/base/audio_decoder.h" |
| 15 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
| 16 #include "media/base/audio_renderer.h" | 16 #include "media/base/audio_renderer.h" |
| 17 #include "media/base/cdm_context.h" | 17 #include "media/base/cdm_context.h" |
| 18 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
| 19 #include "media/base/decryptor.h" | 19 #include "media/base/decryptor.h" |
| 20 #include "media/base/demuxer.h" | 20 #include "media/base/demuxer.h" |
| 21 #include "media/base/pipeline.h" | |
| 21 #include "media/base/pipeline_status.h" | 22 #include "media/base/pipeline_status.h" |
| 22 #include "media/base/renderer.h" | 23 #include "media/base/renderer.h" |
| 23 #include "media/base/text_track.h" | 24 #include "media/base/text_track.h" |
| 24 #include "media/base/time_source.h" | 25 #include "media/base/time_source.h" |
| 25 #include "media/base/video_decoder.h" | 26 #include "media/base/video_decoder.h" |
| 26 #include "media/base/video_decoder_config.h" | 27 #include "media/base/video_decoder_config.h" |
| 27 #include "media/base/video_frame.h" | 28 #include "media/base/video_frame.h" |
| 28 #include "media/base/video_renderer.h" | 29 #include "media/base/video_renderer.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 | 31 |
| 31 namespace media { | 32 namespace media { |
| 32 | 33 |
| 34 class MockPipeline : public Pipeline { | |
| 35 public: | |
| 36 MockPipeline(); | |
| 37 virtual ~MockPipeline(); | |
| 38 | |
| 39 // Note: Start() and Resume() declarations are not actually overrides; they | |
| 40 // take scoped_ptr* instead of scoped_ptr so that they can be mock methods. | |
| 41 // Private stubs for Start() and Resume() implement the actual Pipeline | |
| 42 // interface by forwarding to these mock methods. | |
| 43 MOCK_METHOD10(Start, | |
| 44 void(Demuxer*, | |
| 45 scoped_ptr<Renderer>*, | |
| 46 const base::Closure&, | |
| 47 const PipelineStatusCB&, | |
| 48 const PipelineStatusCB&, | |
| 49 const PipelineMetadataCB&, | |
| 50 const BufferingStateCB&, | |
| 51 const base::Closure&, | |
| 52 const AddTextTrackCB&, | |
| 53 const base::Closure&)); | |
| 54 MOCK_METHOD1(Stop, void(const base::Closure&)); | |
| 55 MOCK_METHOD2(Seek, void(base::TimeDelta, const PipelineStatusCB&)); | |
| 56 MOCK_METHOD1(Suspend, void(const PipelineStatusCB&)); | |
| 57 MOCK_METHOD3(Resume, | |
| 58 void(scoped_ptr<Renderer>*, | |
| 59 base::TimeDelta, | |
| 60 const PipelineStatusCB&)); | |
| 61 | |
| 62 // TODO(sandersd): This should automatically return true between Start() and | |
| 63 // Stop(). (Or better, remove it from the interface entirely.) | |
| 64 MOCK_CONST_METHOD0(IsRunning, bool()); | |
| 65 | |
| 66 // TODO(sandersd): These should be regular getters/setters. | |
| 67 MOCK_CONST_METHOD0(GetPlaybackRate, double()); | |
| 68 MOCK_METHOD1(SetPlaybackRate, void(double)); | |
| 69 MOCK_CONST_METHOD0(GetVolume, float()); | |
| 70 MOCK_METHOD1(SetVolume, void(float)); | |
| 71 | |
| 72 // TODO(sandersd): These should probably have setters to. | |
|
wolenetz
2016/02/26 02:30:11
nit: too
sandersd (OOO until July 31)
2016/02/26 22:10:48
Done.
| |
| 73 MOCK_CONST_METHOD0(GetMediaTime, base::TimeDelta()); | |
| 74 MOCK_CONST_METHOD0(GetBufferedTimeRanges, Ranges<base::TimeDelta>()); | |
| 75 MOCK_CONST_METHOD0(GetMediaDuration, base::TimeDelta()); | |
| 76 MOCK_METHOD0(DidLoadingProgress, bool()); | |
| 77 MOCK_CONST_METHOD0(GetStatistics, PipelineStatistics()); | |
| 78 | |
| 79 MOCK_METHOD2(SetCdm, void(CdmContext*, const CdmAttachedCB&)); | |
| 80 | |
| 81 private: | |
| 82 // Forwarding stubs (see comment above). | |
| 83 void Start(Demuxer* demuxer, | |
| 84 scoped_ptr<Renderer> renderer, | |
| 85 const base::Closure& ended_cb, | |
| 86 const PipelineStatusCB& error_cb, | |
| 87 const PipelineStatusCB& seek_cb, | |
| 88 const PipelineMetadataCB& metadata_cb, | |
| 89 const BufferingStateCB& buffering_state_cb, | |
| 90 const base::Closure& duration_change_cb, | |
| 91 const AddTextTrackCB& add_text_track_cb, | |
| 92 const base::Closure& waiting_for_decryption_key_cb) override; | |
| 93 void Resume(scoped_ptr<Renderer> renderer, | |
| 94 base::TimeDelta timestamp, | |
| 95 const PipelineStatusCB& seek_cb) override; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(MockPipeline); | |
| 98 }; | |
| 99 | |
| 33 class MockDemuxer : public Demuxer { | 100 class MockDemuxer : public Demuxer { |
| 34 public: | 101 public: |
| 35 MockDemuxer(); | 102 MockDemuxer(); |
| 36 virtual ~MockDemuxer(); | 103 virtual ~MockDemuxer(); |
| 37 | 104 |
| 38 // Demuxer implementation. | 105 // Demuxer implementation. |
| 39 virtual std::string GetDisplayName() const; | 106 virtual std::string GetDisplayName() const; |
| 40 MOCK_METHOD3(Initialize, | 107 MOCK_METHOD3(Initialize, |
| 41 void(DemuxerHost* host, const PipelineStatusCB& cb, bool)); | 108 void(DemuxerHost* host, const PipelineStatusCB& cb, bool)); |
| 42 MOCK_METHOD1(SetPlaybackRate, void(double playback_rate)); | 109 MOCK_METHOD1(SetPlaybackRate, void(double playback_rate)); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 MOCK_METHOD0(GetDecryptor, Decryptor*()); | 341 MOCK_METHOD0(GetDecryptor, Decryptor*()); |
| 275 int GetCdmId() const override; | 342 int GetCdmId() const override; |
| 276 | 343 |
| 277 private: | 344 private: |
| 278 DISALLOW_COPY_AND_ASSIGN(MockCdmContext); | 345 DISALLOW_COPY_AND_ASSIGN(MockCdmContext); |
| 279 }; | 346 }; |
| 280 | 347 |
| 281 } // namespace media | 348 } // namespace media |
| 282 | 349 |
| 283 #endif // MEDIA_BASE_MOCK_FILTERS_H_ | 350 #endif // MEDIA_BASE_MOCK_FILTERS_H_ |
| OLD | NEW |