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(GetStartTime
, base::TimeDelta());
44 DISALLOW_COPY_AND_ASSIGN(MockDemuxer
);
47 class MockDemuxerStream
: public DemuxerStream
{
49 explicit MockDemuxerStream(DemuxerStream::Type type
);
50 virtual ~MockDemuxerStream();
52 // DemuxerStream implementation.
53 virtual Type
type() OVERRIDE
;
54 MOCK_METHOD1(Read
, void(const ReadCB
& read_cb
));
55 virtual AudioDecoderConfig
audio_decoder_config() OVERRIDE
;
56 virtual VideoDecoderConfig
video_decoder_config() OVERRIDE
;
57 MOCK_METHOD0(EnableBitstreamConverter
, void());
59 void set_audio_decoder_config(const AudioDecoderConfig
& config
);
60 void set_video_decoder_config(const VideoDecoderConfig
& config
);
63 DemuxerStream::Type type_
;
64 AudioDecoderConfig audio_decoder_config_
;
65 VideoDecoderConfig video_decoder_config_
;
67 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream
);
70 class MockVideoDecoder
: public VideoDecoder
{
73 virtual ~MockVideoDecoder();
75 // VideoDecoder implementation.
76 MOCK_METHOD2(Initialize
, void(const VideoDecoderConfig
& config
,
77 const PipelineStatusCB
&));
78 MOCK_METHOD2(Decode
, void(const scoped_refptr
<DecoderBuffer
>& buffer
,
80 MOCK_METHOD1(Reset
, void(const base::Closure
&));
81 MOCK_METHOD1(Stop
, void(const base::Closure
&));
82 MOCK_CONST_METHOD0(HasAlpha
, bool());
85 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder
);
88 class MockAudioDecoder
: public AudioDecoder
{
91 virtual ~MockAudioDecoder();
93 // AudioDecoder implementation.
94 MOCK_METHOD2(Initialize
, void(const AudioDecoderConfig
& config
,
95 const PipelineStatusCB
&));
97 void(const scoped_refptr
<DecoderBuffer
>& buffer
,
99 MOCK_METHOD0(bits_per_channel
, int(void));
100 MOCK_METHOD0(channel_layout
, ChannelLayout(void));
101 MOCK_METHOD0(samples_per_second
, int(void));
102 MOCK_METHOD1(Reset
, void(const base::Closure
&));
103 MOCK_METHOD1(Stop
, void(const base::Closure
&));
106 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder
);
109 class MockVideoRenderer
: public VideoRenderer
{
112 virtual ~MockVideoRenderer();
114 // VideoRenderer implementation.
115 MOCK_METHOD8(Initialize
, void(DemuxerStream
* stream
,
116 const PipelineStatusCB
& init_cb
,
117 const StatisticsCB
& statistics_cb
,
118 const TimeCB
& time_cb
,
119 const base::Closure
& ended_cb
,
120 const PipelineStatusCB
& error_cb
,
121 const TimeDeltaCB
& get_time_cb
,
122 const TimeDeltaCB
& get_duration_cb
));
123 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
124 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
125 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
126 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
127 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
128 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
131 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer
);
134 class MockAudioRenderer
: public AudioRenderer
{
137 virtual ~MockAudioRenderer();
139 // AudioRenderer implementation.
140 MOCK_METHOD8(Initialize
, void(DemuxerStream
* stream
,
141 const PipelineStatusCB
& init_cb
,
142 const StatisticsCB
& statistics_cb
,
143 const base::Closure
& underflow_cb
,
144 const TimeCB
& time_cb
,
145 const base::Closure
& ended_cb
,
146 const base::Closure
& disabled_cb
,
147 const PipelineStatusCB
& error_cb
));
148 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
149 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
150 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
151 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
152 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
153 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
154 MOCK_METHOD1(SetVolume
, void(float volume
));
155 MOCK_METHOD0(ResumeAfterUnderflow
, void());
158 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer
);
161 class MockTextTrack
: public TextTrack
{
164 virtual ~MockTextTrack();
166 MOCK_METHOD5(addWebVTTCue
, void(const base::TimeDelta
& start
,
167 const base::TimeDelta
& end
,
168 const std::string
& id
,
169 const std::string
& content
,
170 const std::string
& settings
));
173 DISALLOW_COPY_AND_ASSIGN(MockTextTrack
);
176 class MockDecryptor
: public Decryptor
{
179 virtual ~MockDecryptor();
181 MOCK_METHOD2(RegisterNewKeyCB
, void(StreamType stream_type
,
182 const NewKeyCB
& new_key_cb
));
183 MOCK_METHOD3(Decrypt
, void(StreamType stream_type
,
184 const scoped_refptr
<DecoderBuffer
>& encrypted
,
185 const DecryptCB
& decrypt_cb
));
186 MOCK_METHOD1(CancelDecrypt
, void(StreamType stream_type
));
187 MOCK_METHOD2(InitializeAudioDecoder
,
188 void(const AudioDecoderConfig
& config
,
189 const DecoderInitCB
& init_cb
));
190 MOCK_METHOD2(InitializeVideoDecoder
,
191 void(const VideoDecoderConfig
& config
,
192 const DecoderInitCB
& init_cb
));
193 MOCK_METHOD2(DecryptAndDecodeAudio
,
194 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
195 const AudioDecodeCB
& audio_decode_cb
));
196 MOCK_METHOD2(DecryptAndDecodeVideo
,
197 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
198 const VideoDecodeCB
& video_decode_cb
));
199 MOCK_METHOD1(ResetDecoder
, void(StreamType stream_type
));
200 MOCK_METHOD1(DeinitializeDecoder
, void(StreamType stream_type
));
203 DISALLOW_COPY_AND_ASSIGN(MockDecryptor
);
206 // Helper mock statistics callback.
207 class MockStatisticsCB
{
212 MOCK_METHOD1(OnStatistics
, void(const media::PipelineStatistics
& statistics
));
217 #endif // MEDIA_BASE_MOCK_FILTERS_H_