Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: media/base/mock_filters.h

Issue 10796074: Move VideoRenderer out of Filter heirarchy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // A new breed of mock media filters, this time using gmock! Feel free to add 5 // A new breed of mock media filters, this time using gmock! Feel free to add
6 // actions if you need interesting side-effects. 6 // actions if you need interesting side-effects.
7 // 7 //
8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock 8 // Don't forget you can use StrictMock<> and NiceMock<> if you want the mock
9 // filters to fail the test or do nothing when an unexpected method is called. 9 // filters to fail the test or do nothing when an unexpected method is called.
10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks 10 // http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks
11 11
12 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ 12 #ifndef MEDIA_BASE_MOCK_FILTERS_H_
13 #define MEDIA_BASE_MOCK_FILTERS_H_ 13 #define MEDIA_BASE_MOCK_FILTERS_H_
14 14
15 #include <string> 15 #include <string>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "media/base/audio_decoder.h" 18 #include "media/base/audio_decoder.h"
19 #include "media/base/audio_decoder_config.h" 19 #include "media/base/audio_decoder_config.h"
20 #include "media/base/audio_renderer.h" 20 #include "media/base/audio_renderer.h"
21 #include "media/base/decoder_buffer.h" 21 #include "media/base/decoder_buffer.h"
22 #include "media/base/decryptor.h" 22 #include "media/base/decryptor.h"
23 #include "media/base/decryptor_client.h" 23 #include "media/base/decryptor_client.h"
24 #include "media/base/demuxer.h" 24 #include "media/base/demuxer.h"
25 #include "media/base/filters.h"
26 #include "media/base/filter_collection.h" 25 #include "media/base/filter_collection.h"
27 #include "media/base/pipeline.h" 26 #include "media/base/pipeline_status.h"
28 #include "media/base/video_decoder.h" 27 #include "media/base/video_decoder.h"
29 #include "media/base/video_decoder_config.h" 28 #include "media/base/video_decoder_config.h"
30 #include "media/base/video_frame.h" 29 #include "media/base/video_frame.h"
31 #include "media/base/video_renderer.h" 30 #include "media/base/video_renderer.h"
32 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
33 32
34 namespace media { 33 namespace media {
35 34
36 // Use this template to test for object destruction by setting expectations on 35 // Use this template to test for object destruction by setting expectations on
37 // the method OnDestroy(). 36 // the method OnDestroy().
38 // 37 //
39 // TODO(scherkus): not sure about the naming... perhaps contribute this back 38 // TODO(scherkus): not sure about the naming... perhaps contribute this back
40 // to gmock itself! 39 // to gmock itself!
41 template<class MockClass> 40 template<class MockClass>
42 class Destroyable : public MockClass { 41 class Destroyable : public MockClass {
43 public: 42 public:
44 Destroyable() {} 43 Destroyable() {}
45 44
46 MOCK_METHOD0(OnDestroy, void()); 45 MOCK_METHOD0(OnDestroy, void());
47 46
48 protected: 47 protected:
49 virtual ~Destroyable() { 48 virtual ~Destroyable() {
50 OnDestroy(); 49 OnDestroy();
51 } 50 }
52 51
53 private: 52 private:
54 DISALLOW_COPY_AND_ASSIGN(Destroyable); 53 DISALLOW_COPY_AND_ASSIGN(Destroyable);
55 }; 54 };
56 55
57 // TODO(scherkus): remove when CompositeFilter is removed, see
58 // http://crbug.com/126069
59 class MockFilter : public Filter {
60 public:
61 MockFilter();
62
63 // Filter implementation.
64 void SetHost(FilterHost* host) OVERRIDE;
65 MOCK_METHOD1(Play, void(const base::Closure& callback));
66 MOCK_METHOD1(Pause, void(const base::Closure& callback));
67 MOCK_METHOD1(Flush, void(const base::Closure& callback));
68 MOCK_METHOD1(Stop, void(const base::Closure& callback));
69 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
70 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
71
72 FilterHost* host() { return host_; }
73
74 protected:
75 virtual ~MockFilter();
76
77 private:
78 FilterHost* host_;
79
80 DISALLOW_COPY_AND_ASSIGN(MockFilter);
81 };
82
83 class MockDemuxer : public Demuxer { 56 class MockDemuxer : public Demuxer {
84 public: 57 public:
85 MockDemuxer(); 58 MockDemuxer();
86 59
87 // Demuxer implementation. 60 // Demuxer implementation.
88 MOCK_METHOD2(Initialize, void(DemuxerHost* host, const PipelineStatusCB& cb)); 61 MOCK_METHOD2(Initialize, void(DemuxerHost* host, const PipelineStatusCB& cb));
89 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); 62 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
90 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb)); 63 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
91 MOCK_METHOD1(Stop, void(const base::Closure& callback)); 64 MOCK_METHOD1(Stop, void(const base::Closure& callback));
92 MOCK_METHOD0(OnAudioRendererDisabled, void()); 65 MOCK_METHOD0(OnAudioRendererDisabled, void());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 virtual ~MockAudioDecoder(); 133 virtual ~MockAudioDecoder();
161 134
162 private: 135 private:
163 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); 136 DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder);
164 }; 137 };
165 138
166 class MockVideoRenderer : public VideoRenderer { 139 class MockVideoRenderer : public VideoRenderer {
167 public: 140 public:
168 MockVideoRenderer(); 141 MockVideoRenderer();
169 142
170 // Filter implementation. 143 // VideoRenderer implementation.
171 MOCK_METHOD1(SetHost, void(FilterHost* host)); 144 MOCK_METHOD9(Initialize, void(const scoped_refptr<VideoDecoder>& decoder,
145 const PipelineStatusCB& status_cb,
146 const StatisticsCB& statistics_cb,
147 const TimeCB& time_cb,
148 const NaturalSizeChangedCB& size_changed_cb,
149 const base::Closure& ended_cb,
150 const PipelineStatusCB& error_cb,
151 const TimeDeltaCB& get_time_cb,
152 const TimeDeltaCB& get_duration_cb));
172 MOCK_METHOD1(Play, void(const base::Closure& callback)); 153 MOCK_METHOD1(Play, void(const base::Closure& callback));
173 MOCK_METHOD1(Pause, void(const base::Closure& callback)); 154 MOCK_METHOD1(Pause, void(const base::Closure& callback));
174 MOCK_METHOD1(Flush, void(const base::Closure& callback)); 155 MOCK_METHOD1(Flush, void(const base::Closure& callback));
156 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
175 MOCK_METHOD1(Stop, void(const base::Closure& callback)); 157 MOCK_METHOD1(Stop, void(const base::Closure& callback));
176 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); 158 MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
177 MOCK_METHOD2(Seek, void(base::TimeDelta time, const PipelineStatusCB& cb));
178
179 // VideoRenderer implementation.
180 MOCK_METHOD4(Initialize, void(const scoped_refptr<VideoDecoder>& decoder,
181 const PipelineStatusCB& status_cb,
182 const StatisticsCB& statistics_cb,
183 const TimeCB& time_cb));
184
185 MOCK_METHOD0(HasEnded, bool()); 159 MOCK_METHOD0(HasEnded, bool());
186 160
187 // TODO(scherkus): although VideoRendererBase defines this method, this really
188 // shouldn't be here OR should be renamed.
189 MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame));
190
191 protected: 161 protected:
192 virtual ~MockVideoRenderer(); 162 virtual ~MockVideoRenderer();
193 163
194 private: 164 private:
195 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); 165 DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer);
196 }; 166 };
197 167
198 class MockAudioRenderer : public AudioRenderer { 168 class MockAudioRenderer : public AudioRenderer {
199 public: 169 public:
200 MockAudioRenderer(); 170 MockAudioRenderer();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 public: 299 public:
330 MockStatisticsCB(); 300 MockStatisticsCB();
331 ~MockStatisticsCB(); 301 ~MockStatisticsCB();
332 302
333 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); 303 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics));
334 }; 304 };
335 305
336 } // namespace media 306 } // namespace media
337 307
338 #endif // MEDIA_BASE_MOCK_FILTERS_H_ 308 #endif // MEDIA_BASE_MOCK_FILTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698