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

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

Issue 10534096: Generalize AesDecryptor to make it more spec compliant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | media/base/mock_filters.cc » ('j') | media/crypto/aes_decryptor.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/demuxer.h" 21 #include "media/base/demuxer.h"
22 #include "media/base/filters.h" 22 #include "media/base/filters.h"
23 #include "media/base/filter_collection.h" 23 #include "media/base/filter_collection.h"
24 #include "media/base/pipeline.h" 24 #include "media/base/pipeline.h"
25 #include "media/base/video_decoder.h" 25 #include "media/base/video_decoder.h"
26 #include "media/base/video_decoder_config.h" 26 #include "media/base/video_decoder_config.h"
27 #include "media/base/video_frame.h" 27 #include "media/base/video_frame.h"
28 #include "media/base/video_renderer.h" 28 #include "media/base/video_renderer.h"
29 #include "media/crypto/decryptor_client.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 31
31 namespace media { 32 namespace media {
32 33
33 // Use this template to test for object destruction by setting expectations on 34 // Use this template to test for object destruction by setting expectations on
34 // the method OnDestroy(). 35 // the method OnDestroy().
35 // 36 //
36 // TODO(scherkus): not sure about the naming... perhaps contribute this back 37 // TODO(scherkus): not sure about the naming... perhaps contribute this back
37 // to gmock itself! 38 // to gmock itself!
38 template<class MockClass> 39 template<class MockClass>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 203
203 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio)); 204 MOCK_METHOD1(ResumeAfterUnderflow, void(bool buffer_more_audio));
204 205
205 protected: 206 protected:
206 virtual ~MockAudioRenderer(); 207 virtual ~MockAudioRenderer();
207 208
208 private: 209 private:
209 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); 210 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer);
210 }; 211 };
211 212
213 class MockDecryptorClient : public DecryptorClient {
214 public:
215 MockDecryptorClient();
216 virtual ~MockDecryptorClient();
217
218 MOCK_METHOD2(KeyAdded, void(const std::string&, const std::string&));
219 MOCK_METHOD4(KeyError, void(const std::string&, const std::string&,
220 AesDecryptor::KeyError, int));
221 // TODO(xhwang): This is a workaround of the issue that move-only parameters
222 // are not supported in mocked methods. Remove this when the issue is fixed.
223 // See http://code.google.com/p/googletest/issues/detail?id=395
scherkus (not reviewing) 2012/06/12 03:15:58 AFAIK this is also due to scoped_array<uint8> -- m
xhwang 2012/06/12 19:01:15 Done.
224 MOCK_METHOD5(KeyMessageMock, void(const std::string& key_system,
225 const std::string& session_id,
226 const uint8* message,
227 int message_length,
228 const std::string& default_url));
229 MOCK_METHOD4(KeyNeededMock, void(const std::string& key_system,
230 const std::string& session_id,
231 const uint8* init_data,
232 int init_data_length));
233 virtual void KeyMessage(const std::string& key_system,
234 const std::string& session_id,
235 scoped_array<uint8> message,
236 int message_length,
237 const std::string& default_url) OVERRIDE;
238 virtual void KeyNeeded(const std::string& key_system,
239 const std::string& session_id,
240 scoped_array<uint8> init_data,
241 int init_data_length) OVERRIDE;
242
243 private:
244 DISALLOW_COPY_AND_ASSIGN(MockDecryptorClient);
245 };
246
212 // FilterFactory that returns canned instances of mock filters. You can set 247 // FilterFactory that returns canned instances of mock filters. You can set
213 // expectations on the filters and then pass the collection into a pipeline. 248 // expectations on the filters and then pass the collection into a pipeline.
214 class MockFilterCollection { 249 class MockFilterCollection {
215 public: 250 public:
216 MockFilterCollection(); 251 MockFilterCollection();
217 virtual ~MockFilterCollection(); 252 virtual ~MockFilterCollection();
218 253
219 // Mock accessors. 254 // Mock accessors.
220 MockDemuxer* demuxer() const { return demuxer_; } 255 MockDemuxer* demuxer() const { return demuxer_; }
221 MockVideoDecoder* video_decoder() const { return video_decoder_; } 256 MockVideoDecoder* video_decoder() const { return video_decoder_; }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 public: 306 public:
272 MockStatisticsCB(); 307 MockStatisticsCB();
273 ~MockStatisticsCB(); 308 ~MockStatisticsCB();
274 309
275 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics)); 310 MOCK_METHOD1(OnStatistics, void(const media::PipelineStatistics& statistics));
276 }; 311 };
277 312
278 } // namespace media 313 } // namespace media
279 314
280 #endif // MEDIA_BASE_MOCK_FILTERS_H_ 315 #endif // MEDIA_BASE_MOCK_FILTERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/mock_filters.cc » ('j') | media/crypto/aes_decryptor.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698