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_METHOD3(Initialize
, void(DemuxerStream
*,
95 const PipelineStatusCB
&,
96 const StatisticsCB
&));
97 MOCK_METHOD1(Read
, void(const ReadCB
&));
98 MOCK_METHOD0(bits_per_channel
, int(void));
99 MOCK_METHOD0(channel_layout
, ChannelLayout(void));
100 MOCK_METHOD0(samples_per_second
, int(void));
101 MOCK_METHOD1(Reset
, void(const base::Closure
&));
104 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder
);
107 class MockVideoRenderer
: public VideoRenderer
{
110 virtual ~MockVideoRenderer();
112 // VideoRenderer implementation.
113 MOCK_METHOD8(Initialize
, void(DemuxerStream
* stream
,
114 const PipelineStatusCB
& init_cb
,
115 const StatisticsCB
& statistics_cb
,
116 const TimeCB
& time_cb
,
117 const base::Closure
& ended_cb
,
118 const PipelineStatusCB
& error_cb
,
119 const TimeDeltaCB
& get_time_cb
,
120 const TimeDeltaCB
& get_duration_cb
));
121 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
122 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
123 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
124 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
125 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
126 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
129 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer
);
132 class MockAudioRenderer
: public AudioRenderer
{
135 virtual ~MockAudioRenderer();
137 // AudioRenderer implementation.
138 MOCK_METHOD8(Initialize
, void(DemuxerStream
* stream
,
139 const PipelineStatusCB
& init_cb
,
140 const StatisticsCB
& statistics_cb
,
141 const base::Closure
& underflow_cb
,
142 const TimeCB
& time_cb
,
143 const base::Closure
& ended_cb
,
144 const base::Closure
& disabled_cb
,
145 const PipelineStatusCB
& error_cb
));
146 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
147 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
148 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
149 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
150 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
151 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
152 MOCK_METHOD1(SetVolume
, void(float volume
));
153 MOCK_METHOD0(ResumeAfterUnderflow
, void());
156 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer
);
159 class MockTextTrack
: public TextTrack
{
162 virtual ~MockTextTrack();
164 MOCK_METHOD5(addWebVTTCue
, void(const base::TimeDelta
& start
,
165 const base::TimeDelta
& end
,
166 const std::string
& id
,
167 const std::string
& content
,
168 const std::string
& settings
));
171 DISALLOW_COPY_AND_ASSIGN(MockTextTrack
);
174 class MockDecryptor
: public Decryptor
{
177 virtual ~MockDecryptor();
179 MOCK_METHOD2(RegisterNewKeyCB
, void(StreamType stream_type
,
180 const NewKeyCB
& new_key_cb
));
181 MOCK_METHOD3(Decrypt
, void(StreamType stream_type
,
182 const scoped_refptr
<DecoderBuffer
>& encrypted
,
183 const DecryptCB
& decrypt_cb
));
184 MOCK_METHOD1(CancelDecrypt
, void(StreamType stream_type
));
185 MOCK_METHOD2(InitializeAudioDecoder
,
186 void(const AudioDecoderConfig
& config
,
187 const DecoderInitCB
& init_cb
));
188 MOCK_METHOD2(InitializeVideoDecoder
,
189 void(const VideoDecoderConfig
& config
,
190 const DecoderInitCB
& init_cb
));
191 MOCK_METHOD2(DecryptAndDecodeAudio
,
192 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
193 const AudioDecodeCB
& audio_decode_cb
));
194 MOCK_METHOD2(DecryptAndDecodeVideo
,
195 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
196 const VideoDecodeCB
& video_decode_cb
));
197 MOCK_METHOD1(ResetDecoder
, void(StreamType stream_type
));
198 MOCK_METHOD1(DeinitializeDecoder
, void(StreamType stream_type
));
201 DISALLOW_COPY_AND_ASSIGN(MockDecryptor
);
204 // Helper mock statistics callback.
205 class MockStatisticsCB
{
210 MOCK_METHOD1(OnStatistics
, void(const media::PipelineStatistics
& statistics
));
215 #endif // MEDIA_BASE_MOCK_FILTERS_H_