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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), | 43 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), |
44 std::vector<SubsampleEntry>()))); | 44 std::vector<SubsampleEntry>()))); |
45 return buffer; | 45 return buffer; |
46 } | 46 } |
47 | 47 |
48 class DecryptingVideoDecoderTest : public testing::Test { | 48 class DecryptingVideoDecoderTest : public testing::Test { |
49 public: | 49 public: |
50 DecryptingVideoDecoderTest() | 50 DecryptingVideoDecoderTest() |
51 : decoder_(new DecryptingVideoDecoder( | 51 : decoder_(new DecryptingVideoDecoder( |
52 message_loop_.task_runner(), | 52 message_loop_.task_runner(), |
53 new MediaLog(), | 53 &media_log_, |
54 base::Bind(&DecryptingVideoDecoderTest::OnWaitingForDecryptionKey, | 54 base::Bind(&DecryptingVideoDecoderTest::OnWaitingForDecryptionKey, |
55 base::Unretained(this)))), | 55 base::Unretained(this)))), |
56 cdm_context_(new StrictMock<MockCdmContext>()), | 56 cdm_context_(new StrictMock<MockCdmContext>()), |
57 decryptor_(new StrictMock<MockDecryptor>()), | 57 decryptor_(new StrictMock<MockDecryptor>()), |
58 num_decrypt_and_decode_calls_(0), | 58 num_decrypt_and_decode_calls_(0), |
59 num_frames_in_decryptor_(0), | 59 num_frames_in_decryptor_(0), |
60 encrypted_buffer_(CreateFakeEncryptedBuffer()), | 60 encrypted_buffer_(CreateFakeEncryptedBuffer()), |
61 decoded_video_frame_( | 61 decoded_video_frame_( |
62 VideoFrame::CreateBlackFrame(TestVideoConfig::NormalCodedSize())), | 62 VideoFrame::CreateBlackFrame(TestVideoConfig::NormalCodedSize())), |
63 null_video_frame_(scoped_refptr<VideoFrame>()) {} | 63 null_video_frame_(scoped_refptr<VideoFrame>()) {} |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 decoder_.reset(); | 216 decoder_.reset(); |
217 base::RunLoop().RunUntilIdle(); | 217 base::RunLoop().RunUntilIdle(); |
218 } | 218 } |
219 | 219 |
220 MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&)); | 220 MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&)); |
221 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); | 221 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
222 | 222 |
223 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 223 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
224 | 224 |
225 base::MessageLoop message_loop_; | 225 base::MessageLoop message_loop_; |
| 226 MediaLog media_log_; |
226 std::unique_ptr<DecryptingVideoDecoder> decoder_; | 227 std::unique_ptr<DecryptingVideoDecoder> decoder_; |
227 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; | 228 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
228 std::unique_ptr<StrictMock<MockDecryptor>> decryptor_; | 229 std::unique_ptr<StrictMock<MockDecryptor>> decryptor_; |
229 | 230 |
230 // Variables to help the |decryptor_| to simulate decoding delay and flushing. | 231 // Variables to help the |decryptor_| to simulate decoding delay and flushing. |
231 int num_decrypt_and_decode_calls_; | 232 int num_decrypt_and_decode_calls_; |
232 int num_frames_in_decryptor_; | 233 int num_frames_in_decryptor_; |
233 | 234 |
234 Decryptor::DecoderInitCB pending_init_cb_; | 235 Decryptor::DecoderInitCB pending_init_cb_; |
235 Decryptor::NewKeyCB key_added_cb_; | 236 Decryptor::NewKeyCB key_added_cb_; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 476 |
476 // Test destruction after the decoder has been reset. | 477 // Test destruction after the decoder has been reset. |
477 TEST_F(DecryptingVideoDecoderTest, Destroy_AfterReset) { | 478 TEST_F(DecryptingVideoDecoderTest, Destroy_AfterReset) { |
478 Initialize(); | 479 Initialize(); |
479 EnterNormalDecodingState(); | 480 EnterNormalDecodingState(); |
480 Reset(); | 481 Reset(); |
481 Destroy(); | 482 Destroy(); |
482 } | 483 } |
483 | 484 |
484 } // namespace media | 485 } // namespace media |
OLD | NEW |