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/filter_collection.h"
18 #include "media/base/pipeline_status.h"
19 #include "media/base/text_track.h"
20 #include "media/base/video_decoder.h"
21 #include "media/base/video_decoder_config.h"
22 #include "media/base/video_frame.h"
23 #include "media/base/video_renderer.h"
24 #include "testing/gmock/include/gmock/gmock.h"
28 class MockDemuxer
: public Demuxer
{
31 virtual ~MockDemuxer();
33 // Demuxer implementation.
34 MOCK_METHOD3(Initialize
,
35 void(DemuxerHost
* host
, const PipelineStatusCB
& cb
, bool));
36 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
37 MOCK_METHOD2(Seek
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
38 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
39 MOCK_METHOD0(OnAudioRendererDisabled
, void());
40 MOCK_METHOD1(GetStream
, DemuxerStream
*(DemuxerStream::Type
));
41 MOCK_CONST_METHOD0(GetTimelineOffset
, base::Time());
42 MOCK_CONST_METHOD0(GetLiveness
, Liveness());
45 DISALLOW_COPY_AND_ASSIGN(MockDemuxer
);
48 class MockDemuxerStream
: public DemuxerStream
{
50 explicit MockDemuxerStream(DemuxerStream::Type type
);
51 virtual ~MockDemuxerStream();
53 // DemuxerStream implementation.
54 virtual Type
type() OVERRIDE
;
55 MOCK_METHOD1(Read
, void(const ReadCB
& read_cb
));
56 virtual AudioDecoderConfig
audio_decoder_config() OVERRIDE
;
57 virtual VideoDecoderConfig
video_decoder_config() OVERRIDE
;
58 MOCK_METHOD0(EnableBitstreamConverter
, void());
59 MOCK_METHOD0(SupportsConfigChanges
, bool());
61 void set_audio_decoder_config(const AudioDecoderConfig
& config
);
62 void set_video_decoder_config(const VideoDecoderConfig
& config
);
65 DemuxerStream::Type type_
;
66 AudioDecoderConfig audio_decoder_config_
;
67 VideoDecoderConfig video_decoder_config_
;
69 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream
);
72 class MockVideoDecoder
: public VideoDecoder
{
75 virtual ~MockVideoDecoder();
77 // VideoDecoder implementation.
78 MOCK_METHOD4(Initialize
, void(const VideoDecoderConfig
& config
,
80 const PipelineStatusCB
& status_cb
,
81 const OutputCB
& output_cb
));
82 MOCK_METHOD2(Decode
, void(const scoped_refptr
<DecoderBuffer
>& buffer
,
84 MOCK_METHOD1(Reset
, void(const base::Closure
&));
85 MOCK_METHOD0(Stop
, void());
86 MOCK_CONST_METHOD0(HasAlpha
, bool());
89 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder
);
92 class MockAudioDecoder
: public AudioDecoder
{
95 virtual ~MockAudioDecoder();
97 // AudioDecoder implementation.
98 MOCK_METHOD3(Initialize
,
99 void(const AudioDecoderConfig
& config
,
100 const PipelineStatusCB
& status_cb
,
101 const OutputCB
& output_cb
));
103 void(const scoped_refptr
<DecoderBuffer
>& buffer
,
105 MOCK_METHOD1(Reset
, void(const base::Closure
&));
106 MOCK_METHOD0(Stop
, void());
109 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder
);
112 class MockVideoRenderer
: public VideoRenderer
{
115 virtual ~MockVideoRenderer();
117 // VideoRenderer implementation.
118 MOCK_METHOD9(Initialize
, void(DemuxerStream
* stream
,
120 const PipelineStatusCB
& init_cb
,
121 const StatisticsCB
& statistics_cb
,
122 const TimeCB
& time_cb
,
123 const base::Closure
& ended_cb
,
124 const PipelineStatusCB
& error_cb
,
125 const TimeDeltaCB
& get_time_cb
,
126 const TimeDeltaCB
& get_duration_cb
));
127 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
128 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
129 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
130 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
131 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
134 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer
);
137 class MockAudioRenderer
: public AudioRenderer
{
140 virtual ~MockAudioRenderer();
142 // AudioRenderer implementation.
143 MOCK_METHOD7(Initialize
, void(DemuxerStream
* stream
,
144 const PipelineStatusCB
& init_cb
,
145 const StatisticsCB
& statistics_cb
,
146 const base::Closure
& underflow_cb
,
147 const TimeCB
& time_cb
,
148 const base::Closure
& ended_cb
,
149 const PipelineStatusCB
& error_cb
));
150 MOCK_METHOD0(StartRendering
, void());
151 MOCK_METHOD0(StopRendering
, void());
152 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
153 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
154 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
155 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
156 MOCK_METHOD1(SetVolume
, void(float volume
));
157 MOCK_METHOD0(ResumeAfterUnderflow
, void());
160 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer
);
163 class MockTextTrack
: public TextTrack
{
166 virtual ~MockTextTrack();
168 MOCK_METHOD5(addWebVTTCue
, void(const base::TimeDelta
& start
,
169 const base::TimeDelta
& end
,
170 const std::string
& id
,
171 const std::string
& content
,
172 const std::string
& settings
));
175 DISALLOW_COPY_AND_ASSIGN(MockTextTrack
);
178 class MockDecryptor
: public Decryptor
{
181 virtual ~MockDecryptor();
183 MOCK_METHOD2(RegisterNewKeyCB
, void(StreamType stream_type
,
184 const NewKeyCB
& new_key_cb
));
185 MOCK_METHOD3(Decrypt
, void(StreamType stream_type
,
186 const scoped_refptr
<DecoderBuffer
>& encrypted
,
187 const DecryptCB
& decrypt_cb
));
188 MOCK_METHOD1(CancelDecrypt
, void(StreamType stream_type
));
189 MOCK_METHOD2(InitializeAudioDecoder
,
190 void(const AudioDecoderConfig
& config
,
191 const DecoderInitCB
& init_cb
));
192 MOCK_METHOD2(InitializeVideoDecoder
,
193 void(const VideoDecoderConfig
& config
,
194 const DecoderInitCB
& init_cb
));
195 MOCK_METHOD2(DecryptAndDecodeAudio
,
196 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
197 const AudioDecodeCB
& audio_decode_cb
));
198 MOCK_METHOD2(DecryptAndDecodeVideo
,
199 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
200 const VideoDecodeCB
& video_decode_cb
));
201 MOCK_METHOD1(ResetDecoder
, void(StreamType stream_type
));
202 MOCK_METHOD1(DeinitializeDecoder
, void(StreamType stream_type
));
205 DISALLOW_COPY_AND_ASSIGN(MockDecryptor
);
208 // Helper mock statistics callback.
209 class MockStatisticsCB
{
214 MOCK_METHOD1(OnStatistics
, void(const media::PipelineStatistics
& statistics
));
219 #endif // MEDIA_BASE_MOCK_FILTERS_H_