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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_MOCK_FILTERS_H_
6 #define MEDIA_BASE_MOCK_FILTERS_H_
10 #include "base/callback.h"
11 #include "media/base/audio_decoder.h"
12 #include "media/base/audio_decoder_config.h"
13 #include "media/base/audio_renderer.h"
14 #include "media/base/decoder_buffer.h"
15 #include "media/base/decryptor.h"
16 #include "media/base/demuxer.h"
17 #include "media/base/pipeline_status.h"
18 #include "media/base/renderer.h"
19 #include "media/base/text_track.h"
20 #include "media/base/time_source.h"
21 #include "media/base/video_decoder.h"
22 #include "media/base/video_decoder_config.h"
23 #include "media/base/video_frame.h"
24 #include "media/base/video_renderer.h"
25 #include "testing/gmock/include/gmock/gmock.h"
29 class MockDemuxer
: public Demuxer
{
32 virtual ~MockDemuxer();
34 // Demuxer implementation.
35 MOCK_METHOD3(Initialize
,
36 void(DemuxerHost
* host
, const PipelineStatusCB
& cb
, bool));
37 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
38 MOCK_METHOD2(Seek
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
39 MOCK_METHOD0(Stop
, void());
40 MOCK_METHOD0(OnAudioRendererDisabled
, void());
41 MOCK_METHOD1(GetStream
, DemuxerStream
*(DemuxerStream::Type
));
42 MOCK_CONST_METHOD0(GetStartTime
, base::TimeDelta());
43 MOCK_CONST_METHOD0(GetTimelineOffset
, base::Time());
46 DISALLOW_COPY_AND_ASSIGN(MockDemuxer
);
49 class MockDemuxerStream
: public DemuxerStream
{
51 explicit MockDemuxerStream(DemuxerStream::Type type
);
52 virtual ~MockDemuxerStream();
54 // DemuxerStream implementation.
55 Type
type() const override
;
56 Liveness
liveness() const override
;
57 MOCK_METHOD1(Read
, void(const ReadCB
& read_cb
));
58 AudioDecoderConfig
audio_decoder_config() override
;
59 VideoDecoderConfig
video_decoder_config() override
;
60 MOCK_METHOD0(EnableBitstreamConverter
, void());
61 MOCK_METHOD0(SupportsConfigChanges
, bool());
63 void set_audio_decoder_config(const AudioDecoderConfig
& config
);
64 void set_video_decoder_config(const VideoDecoderConfig
& config
);
65 void set_liveness(Liveness liveness
);
67 VideoRotation
video_rotation() override
;
72 AudioDecoderConfig audio_decoder_config_
;
73 VideoDecoderConfig video_decoder_config_
;
75 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream
);
78 class MockVideoDecoder
: public VideoDecoder
{
81 virtual ~MockVideoDecoder();
83 // VideoDecoder implementation.
84 virtual std::string
GetDisplayName() const;
85 MOCK_METHOD4(Initialize
, void(const VideoDecoderConfig
& config
,
87 const PipelineStatusCB
& status_cb
,
88 const OutputCB
& output_cb
));
89 MOCK_METHOD2(Decode
, void(const scoped_refptr
<DecoderBuffer
>& buffer
,
91 MOCK_METHOD1(Reset
, void(const base::Closure
&));
92 MOCK_CONST_METHOD0(HasAlpha
, bool());
95 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder
);
98 class MockAudioDecoder
: public AudioDecoder
{
101 virtual ~MockAudioDecoder();
103 // AudioDecoder implementation.
104 virtual std::string
GetDisplayName() const;
105 MOCK_METHOD3(Initialize
,
106 void(const AudioDecoderConfig
& config
,
107 const PipelineStatusCB
& status_cb
,
108 const OutputCB
& output_cb
));
110 void(const scoped_refptr
<DecoderBuffer
>& buffer
,
112 MOCK_METHOD1(Reset
, void(const base::Closure
&));
115 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder
);
118 class MockVideoRenderer
: public VideoRenderer
{
121 virtual ~MockVideoRenderer();
123 // VideoRenderer implementation.
124 MOCK_METHOD9(Initialize
,
125 void(DemuxerStream
* stream
,
126 const PipelineStatusCB
& init_cb
,
127 const SetDecryptorReadyCB
& set_decryptor_ready_cb
,
128 const StatisticsCB
& statistics_cb
,
129 const BufferingStateCB
& buffering_state_cb
,
130 const PaintCB
& paint_cb
,
131 const base::Closure
& ended_cb
,
132 const PipelineStatusCB
& error_cb
,
133 const TimeDeltaCB
& get_time_cb
));
134 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
135 MOCK_METHOD1(StartPlayingFrom
, void(base::TimeDelta
));
138 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer
);
141 class MockAudioRenderer
: public AudioRenderer
{
144 virtual ~MockAudioRenderer();
146 // AudioRenderer implementation.
147 MOCK_METHOD7(Initialize
,
148 void(DemuxerStream
* stream
,
149 const PipelineStatusCB
& init_cb
,
150 const SetDecryptorReadyCB
& set_decryptor_ready_cb
,
151 const StatisticsCB
& statistics_cb
,
152 const BufferingStateCB
& buffering_state_cb
,
153 const base::Closure
& ended_cb
,
154 const PipelineStatusCB
& error_cb
));
155 MOCK_METHOD0(GetTimeSource
, TimeSource
*());
156 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
157 MOCK_METHOD0(StartPlaying
, void());
158 MOCK_METHOD1(SetVolume
, void(float volume
));
161 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer
);
164 class MockRenderer
: public Renderer
{
167 virtual ~MockRenderer();
169 // Renderer implementation.
170 MOCK_METHOD7(Initialize
, void(DemuxerStreamProvider
* demuxer_stream_provider
,
171 const PipelineStatusCB
& init_cb
,
172 const StatisticsCB
& statistics_cb
,
173 const BufferingStateCB
& buffering_state_cb
,
174 const PaintCB
& paint_cb
,
175 const base::Closure
& ended_cb
,
176 const PipelineStatusCB
& error_cb
));
177 MOCK_METHOD1(Flush
, void(const base::Closure
& flush_cb
));
178 MOCK_METHOD1(StartPlayingFrom
, void(base::TimeDelta timestamp
));
179 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
180 MOCK_METHOD1(SetVolume
, void(float volume
));
181 MOCK_METHOD0(GetMediaTime
, base::TimeDelta());
182 MOCK_METHOD0(HasAudio
, bool());
183 MOCK_METHOD0(HasVideo
, bool());
185 void(CdmContext
* cdm_context
,
186 const CdmAttachedCB
& cdm_attached_cb
));
189 DISALLOW_COPY_AND_ASSIGN(MockRenderer
);
192 class MockTimeSource
: public TimeSource
{
195 virtual ~MockTimeSource();
197 // TimeSource implementation.
198 MOCK_METHOD0(StartTicking
, void());
199 MOCK_METHOD0(StopTicking
, void());
200 MOCK_METHOD1(SetPlaybackRate
, void(float));
201 MOCK_METHOD1(SetMediaTime
, void(base::TimeDelta
));
202 MOCK_METHOD0(CurrentMediaTime
, base::TimeDelta());
203 MOCK_METHOD0(CurrentMediaTimeForSyncingVideo
, base::TimeDelta());
206 DISALLOW_COPY_AND_ASSIGN(MockTimeSource
);
209 class MockTextTrack
: public TextTrack
{
212 virtual ~MockTextTrack();
214 MOCK_METHOD5(addWebVTTCue
, void(const base::TimeDelta
& start
,
215 const base::TimeDelta
& end
,
216 const std::string
& id
,
217 const std::string
& content
,
218 const std::string
& settings
));
221 DISALLOW_COPY_AND_ASSIGN(MockTextTrack
);
224 class MockDecryptor
: public Decryptor
{
227 virtual ~MockDecryptor();
229 MOCK_METHOD2(RegisterNewKeyCB
, void(StreamType stream_type
,
230 const NewKeyCB
& new_key_cb
));
231 MOCK_METHOD3(Decrypt
, void(StreamType stream_type
,
232 const scoped_refptr
<DecoderBuffer
>& encrypted
,
233 const DecryptCB
& decrypt_cb
));
234 MOCK_METHOD1(CancelDecrypt
, void(StreamType stream_type
));
235 MOCK_METHOD2(InitializeAudioDecoder
,
236 void(const AudioDecoderConfig
& config
,
237 const DecoderInitCB
& init_cb
));
238 MOCK_METHOD2(InitializeVideoDecoder
,
239 void(const VideoDecoderConfig
& config
,
240 const DecoderInitCB
& init_cb
));
241 MOCK_METHOD2(DecryptAndDecodeAudio
,
242 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
243 const AudioDecodeCB
& audio_decode_cb
));
244 MOCK_METHOD2(DecryptAndDecodeVideo
,
245 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
246 const VideoDecodeCB
& video_decode_cb
));
247 MOCK_METHOD1(ResetDecoder
, void(StreamType stream_type
));
248 MOCK_METHOD1(DeinitializeDecoder
, void(StreamType stream_type
));
251 DISALLOW_COPY_AND_ASSIGN(MockDecryptor
);
256 #endif // MEDIA_BASE_MOCK_FILTERS_H_