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/video_decoder.h"
20 #include "media/base/video_decoder_config.h"
21 #include "media/base/video_frame.h"
22 #include "media/base/video_renderer.h"
23 #include "testing/gmock/include/gmock/gmock.h"
27 class MockDemuxer
: public Demuxer
{
30 virtual ~MockDemuxer();
32 // Demuxer implementation.
33 MOCK_METHOD2(Initialize
, void(DemuxerHost
* host
, const PipelineStatusCB
& cb
));
34 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
35 MOCK_METHOD2(Seek
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
36 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
37 MOCK_METHOD0(OnAudioRendererDisabled
, void());
38 MOCK_METHOD1(GetStream
, DemuxerStream
*(DemuxerStream::Type
));
39 MOCK_CONST_METHOD0(GetStartTime
, base::TimeDelta());
42 DISALLOW_COPY_AND_ASSIGN(MockDemuxer
);
45 class MockDemuxerStream
: public DemuxerStream
{
47 explicit MockDemuxerStream(DemuxerStream::Type type
);
48 virtual ~MockDemuxerStream();
50 // DemuxerStream implementation.
51 virtual Type
type() OVERRIDE
;
52 MOCK_METHOD1(Read
, void(const ReadCB
& read_cb
));
53 virtual AudioDecoderConfig
audio_decoder_config() OVERRIDE
;
54 virtual VideoDecoderConfig
video_decoder_config() OVERRIDE
;
55 MOCK_METHOD0(EnableBitstreamConverter
, void());
57 void set_audio_decoder_config(const AudioDecoderConfig
& config
);
58 void set_video_decoder_config(const VideoDecoderConfig
& config
);
61 DemuxerStream::Type type_
;
62 AudioDecoderConfig audio_decoder_config_
;
63 VideoDecoderConfig video_decoder_config_
;
65 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream
);
68 class MockVideoDecoder
: public VideoDecoder
{
71 virtual ~MockVideoDecoder();
73 // VideoDecoder implementation.
74 MOCK_METHOD2(Initialize
, void(const VideoDecoderConfig
& config
,
75 const PipelineStatusCB
&));
76 MOCK_METHOD2(Decode
, void(const scoped_refptr
<DecoderBuffer
>& buffer
,
78 MOCK_METHOD1(Reset
, void(const base::Closure
&));
79 MOCK_METHOD1(Stop
, void(const base::Closure
&));
80 MOCK_CONST_METHOD0(HasAlpha
, bool());
83 DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder
);
86 class MockAudioDecoder
: public AudioDecoder
{
89 virtual ~MockAudioDecoder();
91 // AudioDecoder implementation.
92 MOCK_METHOD3(Initialize
, void(DemuxerStream
*,
93 const PipelineStatusCB
&,
94 const StatisticsCB
&));
95 MOCK_METHOD1(Read
, void(const ReadCB
&));
96 MOCK_METHOD0(bits_per_channel
, int(void));
97 MOCK_METHOD0(channel_layout
, ChannelLayout(void));
98 MOCK_METHOD0(samples_per_second
, int(void));
99 MOCK_METHOD1(Reset
, void(const base::Closure
&));
102 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder
);
105 class MockVideoRenderer
: public VideoRenderer
{
108 virtual ~MockVideoRenderer();
110 // VideoRenderer implementation.
111 MOCK_METHOD9(Initialize
, void(DemuxerStream
* stream
,
112 const PipelineStatusCB
& init_cb
,
113 const StatisticsCB
& statistics_cb
,
114 const TimeCB
& time_cb
,
115 const NaturalSizeChangedCB
& size_changed_cb
,
116 const base::Closure
& ended_cb
,
117 const PipelineStatusCB
& error_cb
,
118 const TimeDeltaCB
& get_time_cb
,
119 const TimeDeltaCB
& get_duration_cb
));
120 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
121 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
122 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
123 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
124 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
125 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
128 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer
);
131 class MockAudioRenderer
: public AudioRenderer
{
134 virtual ~MockAudioRenderer();
136 // AudioRenderer implementation.
137 MOCK_METHOD8(Initialize
, void(DemuxerStream
* stream
,
138 const PipelineStatusCB
& init_cb
,
139 const StatisticsCB
& statistics_cb
,
140 const base::Closure
& underflow_cb
,
141 const TimeCB
& time_cb
,
142 const base::Closure
& ended_cb
,
143 const base::Closure
& disabled_cb
,
144 const PipelineStatusCB
& error_cb
));
145 MOCK_METHOD1(Play
, void(const base::Closure
& callback
));
146 MOCK_METHOD1(Pause
, void(const base::Closure
& callback
));
147 MOCK_METHOD1(Flush
, void(const base::Closure
& callback
));
148 MOCK_METHOD1(Stop
, void(const base::Closure
& callback
));
149 MOCK_METHOD1(SetPlaybackRate
, void(float playback_rate
));
150 MOCK_METHOD2(Preroll
, void(base::TimeDelta time
, const PipelineStatusCB
& cb
));
151 MOCK_METHOD1(SetVolume
, void(float volume
));
152 MOCK_METHOD0(ResumeAfterUnderflow
, void());
155 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer
);
158 class MockDecryptor
: public Decryptor
{
161 virtual ~MockDecryptor();
163 MOCK_METHOD2(RegisterNewKeyCB
, void(StreamType stream_type
,
164 const NewKeyCB
& new_key_cb
));
165 MOCK_METHOD3(Decrypt
, void(StreamType stream_type
,
166 const scoped_refptr
<DecoderBuffer
>& encrypted
,
167 const DecryptCB
& decrypt_cb
));
168 MOCK_METHOD1(CancelDecrypt
, void(StreamType stream_type
));
169 MOCK_METHOD2(InitializeAudioDecoder
,
170 void(const AudioDecoderConfig
& config
,
171 const DecoderInitCB
& init_cb
));
172 MOCK_METHOD2(InitializeVideoDecoder
,
173 void(const VideoDecoderConfig
& config
,
174 const DecoderInitCB
& init_cb
));
175 MOCK_METHOD2(DecryptAndDecodeAudio
,
176 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
177 const AudioDecodeCB
& audio_decode_cb
));
178 MOCK_METHOD2(DecryptAndDecodeVideo
,
179 void(const scoped_refptr
<media::DecoderBuffer
>& encrypted
,
180 const VideoDecodeCB
& video_decode_cb
));
181 MOCK_METHOD1(ResetDecoder
, void(StreamType stream_type
));
182 MOCK_METHOD1(DeinitializeDecoder
, void(StreamType stream_type
));
185 DISALLOW_COPY_AND_ASSIGN(MockDecryptor
);
188 // Helper mock statistics callback.
189 class MockStatisticsCB
{
194 MOCK_METHOD1(OnStatistics
, void(const media::PipelineStatistics
& statistics
));
199 #endif // MEDIA_BASE_MOCK_FILTERS_H_