OLD | NEW |
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 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace media { | 29 namespace media { |
30 | 30 |
31 const uint8_t kFakeKeyId[] = {0x4b, 0x65, 0x79, 0x20, 0x49, 0x44}; | 31 const uint8_t kFakeKeyId[] = {0x4b, 0x65, 0x79, 0x20, 0x49, 0x44}; |
32 const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0}; | 32 const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0}; |
33 const int kDecodingDelay = 3; | 33 const int kDecodingDelay = 3; |
34 | 34 |
35 // Create a fake non-empty encrypted buffer. | 35 // Create a fake non-empty encrypted buffer. |
36 static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { | 36 static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { |
37 const int buffer_size = 16; // Need a non-empty buffer; | 37 const int buffer_size = 16; // Need a non-empty buffer; |
38 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); | 38 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); |
39 buffer->set_decrypt_config(scoped_ptr<DecryptConfig>(new DecryptConfig( | 39 buffer->set_decrypt_config(std::unique_ptr<DecryptConfig>(new DecryptConfig( |
40 std::string(reinterpret_cast<const char*>(kFakeKeyId), | 40 std::string(reinterpret_cast<const char*>(kFakeKeyId), |
41 arraysize(kFakeKeyId)), | 41 arraysize(kFakeKeyId)), |
42 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), | 42 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), |
43 std::vector<SubsampleEntry>()))); | 43 std::vector<SubsampleEntry>()))); |
44 return buffer; | 44 return buffer; |
45 } | 45 } |
46 | 46 |
47 // Use anonymous namespace here to prevent the actions to be defined multiple | 47 // Use anonymous namespace here to prevent the actions to be defined multiple |
48 // times across multiple test files. Sadly we can't use static for them. | 48 // times across multiple test files. Sadly we can't use static for them. |
49 namespace { | 49 namespace { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 decoder_.reset(); | 225 decoder_.reset(); |
226 message_loop_.RunUntilIdle(); | 226 message_loop_.RunUntilIdle(); |
227 } | 227 } |
228 | 228 |
229 MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&)); | 229 MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&)); |
230 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); | 230 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
231 | 231 |
232 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 232 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
233 | 233 |
234 base::MessageLoop message_loop_; | 234 base::MessageLoop message_loop_; |
235 scoped_ptr<DecryptingVideoDecoder> decoder_; | 235 std::unique_ptr<DecryptingVideoDecoder> decoder_; |
236 scoped_ptr<StrictMock<MockCdmContext>> cdm_context_; | 236 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
237 scoped_ptr<StrictMock<MockDecryptor>> decryptor_; | 237 std::unique_ptr<StrictMock<MockDecryptor>> decryptor_; |
238 | 238 |
239 // Variables to help the |decryptor_| to simulate decoding delay and flushing. | 239 // Variables to help the |decryptor_| to simulate decoding delay and flushing. |
240 int num_decrypt_and_decode_calls_; | 240 int num_decrypt_and_decode_calls_; |
241 int num_frames_in_decryptor_; | 241 int num_frames_in_decryptor_; |
242 | 242 |
243 Decryptor::DecoderInitCB pending_init_cb_; | 243 Decryptor::DecoderInitCB pending_init_cb_; |
244 Decryptor::NewKeyCB key_added_cb_; | 244 Decryptor::NewKeyCB key_added_cb_; |
245 Decryptor::VideoDecodeCB pending_video_decode_cb_; | 245 Decryptor::VideoDecodeCB pending_video_decode_cb_; |
246 | 246 |
247 // Constant buffer/frames. | 247 // Constant buffer/frames. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 477 |
478 // Test destruction after the decoder has been reset. | 478 // Test destruction after the decoder has been reset. |
479 TEST_F(DecryptingVideoDecoderTest, Destroy_AfterReset) { | 479 TEST_F(DecryptingVideoDecoderTest, Destroy_AfterReset) { |
480 Initialize(); | 480 Initialize(); |
481 EnterNormalDecodingState(); | 481 EnterNormalDecodingState(); |
482 Reset(); | 482 Reset(); |
483 Destroy(); | 483 Destroy(); |
484 } | 484 } |
485 | 485 |
486 } // namespace media | 486 } // namespace media |
OLD | NEW |