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

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

Issue 2554163002: media: Add MockCdmClient (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | media/base/mock_filters.cc » ('j') | media/cdm/aes_decryptor_unittest.cc » ('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 #ifndef MEDIA_BASE_MOCK_FILTERS_H_ 5 #ifndef MEDIA_BASE_MOCK_FILTERS_H_
6 #define MEDIA_BASE_MOCK_FILTERS_H_ 6 #define MEDIA_BASE_MOCK_FILTERS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "media/base/audio_decoder.h" 15 #include "media/base/audio_decoder.h"
16 #include "media/base/audio_decoder_config.h" 16 #include "media/base/audio_decoder_config.h"
17 #include "media/base/audio_renderer.h" 17 #include "media/base/audio_renderer.h"
18 #include "media/base/cdm_context.h" 18 #include "media/base/cdm_context.h"
19 #include "media/base/cdm_key_information.h"
19 #include "media/base/decoder_buffer.h" 20 #include "media/base/decoder_buffer.h"
20 #include "media/base/decryptor.h" 21 #include "media/base/decryptor.h"
21 #include "media/base/demuxer.h" 22 #include "media/base/demuxer.h"
23 #include "media/base/media_keys.h"
22 #include "media/base/media_track.h" 24 #include "media/base/media_track.h"
23 #include "media/base/pipeline.h" 25 #include "media/base/pipeline.h"
24 #include "media/base/pipeline_status.h" 26 #include "media/base/pipeline_status.h"
25 #include "media/base/renderer.h" 27 #include "media/base/renderer.h"
26 #include "media/base/renderer_client.h" 28 #include "media/base/renderer_client.h"
27 #include "media/base/stream_parser.h" 29 #include "media/base/stream_parser.h"
28 #include "media/base/text_track.h" 30 #include "media/base/text_track.h"
29 #include "media/base/text_track_config.h" 31 #include "media/base/text_track_config.h"
30 #include "media/base/time_source.h" 32 #include "media/base/time_source.h"
31 #include "media/base/video_decoder.h" 33 #include "media/base/video_decoder.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 MOCK_METHOD5(addWebVTTCue, void(const base::TimeDelta& start, 326 MOCK_METHOD5(addWebVTTCue, void(const base::TimeDelta& start,
325 const base::TimeDelta& end, 327 const base::TimeDelta& end,
326 const std::string& id, 328 const std::string& id,
327 const std::string& content, 329 const std::string& content,
328 const std::string& settings)); 330 const std::string& settings));
329 331
330 private: 332 private:
331 DISALLOW_COPY_AND_ASSIGN(MockTextTrack); 333 DISALLOW_COPY_AND_ASSIGN(MockTextTrack);
332 }; 334 };
333 335
336 // Mock CDM callbacks.
337 // TODO(xhwang): This could be a subclass of CdmClient if we plan to add one.
338 // See http://crbug.com/657940
339 class MockCdmClient {
340 public:
341 MockCdmClient();
342 virtual ~MockCdmClient();
343
344 MOCK_METHOD3(OnSessionMessage,
345 void(const std::string& session_id,
346 MediaKeys::MessageType message_type,
347 const std::vector<uint8_t>& message));
348 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id));
349
350 // MOCK methods don't work with move-only types like CdmKeysInfo. Add an extra
351 // OnSessionKeysChangeCalled() function to work around this.
352 MOCK_METHOD2(OnSessionKeysChangeCalled,
353 void(const std::string& session_id,
354 bool has_additional_usable_key));
355 void OnSessionKeysChange(const std::string& session_id,
356 bool has_additional_usable_key,
357 CdmKeysInfo keys_info) {
358 keys_info_.swap(keys_info);
359 OnSessionKeysChangeCalled(session_id, has_additional_usable_key);
360 }
361
362 MOCK_METHOD2(OnSessionExpirationUpdate,
363 void(const std::string& session_id, base::Time new_expiry_time));
364
365 const CdmKeysInfo& keys_info() const { return keys_info_; }
366
367 private:
368 CdmKeysInfo keys_info_;
369 };
370
334 class MockDecryptor : public Decryptor { 371 class MockDecryptor : public Decryptor {
335 public: 372 public:
336 MockDecryptor(); 373 MockDecryptor();
337 virtual ~MockDecryptor(); 374 virtual ~MockDecryptor();
338 375
339 MOCK_METHOD2(RegisterNewKeyCB, void(StreamType stream_type, 376 MOCK_METHOD2(RegisterNewKeyCB, void(StreamType stream_type,
340 const NewKeyCB& new_key_cb)); 377 const NewKeyCB& new_key_cb));
341 MOCK_METHOD3(Decrypt, void(StreamType stream_type, 378 MOCK_METHOD3(Decrypt, void(StreamType stream_type,
342 const scoped_refptr<DecoderBuffer>& encrypted, 379 const scoped_refptr<DecoderBuffer>& encrypted,
343 const DecryptCB& decrypt_cb)); 380 const DecryptCB& decrypt_cb));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 MOCK_METHOD0(Flush, void()); 433 MOCK_METHOD0(Flush, void());
397 MOCK_METHOD2(Parse, bool(const uint8_t*, int)); 434 MOCK_METHOD2(Parse, bool(const uint8_t*, int));
398 435
399 private: 436 private:
400 DISALLOW_COPY_AND_ASSIGN(MockStreamParser); 437 DISALLOW_COPY_AND_ASSIGN(MockStreamParser);
401 }; 438 };
402 439
403 } // namespace media 440 } // namespace media
404 441
405 #endif // MEDIA_BASE_MOCK_FILTERS_H_ 442 #endif // MEDIA_BASE_MOCK_FILTERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/mock_filters.cc » ('j') | media/cdm/aes_decryptor_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698