Chromium Code Reviews| 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> |
|
ddorwin
2016/04/21 22:54:54
ditto here and the next three test files.
| |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "media/base/audio_buffer.h" | 14 #include "media/base/audio_buffer.h" |
| 15 #include "media/base/decoder_buffer.h" | 15 #include "media/base/decoder_buffer.h" |
| 16 #include "media/base/decrypt_config.h" | 16 #include "media/base/decrypt_config.h" |
| 17 #include "media/base/gmock_callback_support.h" | 17 #include "media/base/gmock_callback_support.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 36 // configs used in this test. | 36 // configs used in this test. |
| 37 const int kFakeAudioFrameSize = 48; | 37 const int kFakeAudioFrameSize = 48; |
| 38 const uint8_t kFakeKeyId[] = {0x4b, 0x65, 0x79, 0x20, 0x49, 0x44}; | 38 const uint8_t kFakeKeyId[] = {0x4b, 0x65, 0x79, 0x20, 0x49, 0x44}; |
| 39 const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0}; | 39 const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0}; |
| 40 const int kDecodingDelay = 3; | 40 const int kDecodingDelay = 3; |
| 41 | 41 |
| 42 // Create a fake non-empty encrypted buffer. | 42 // Create a fake non-empty encrypted buffer. |
| 43 static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { | 43 static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { |
| 44 const int buffer_size = 16; // Need a non-empty buffer; | 44 const int buffer_size = 16; // Need a non-empty buffer; |
| 45 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); | 45 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); |
| 46 buffer->set_decrypt_config(scoped_ptr<DecryptConfig>(new DecryptConfig( | 46 buffer->set_decrypt_config(std::unique_ptr<DecryptConfig>(new DecryptConfig( |
| 47 std::string(reinterpret_cast<const char*>(kFakeKeyId), | 47 std::string(reinterpret_cast<const char*>(kFakeKeyId), |
| 48 arraysize(kFakeKeyId)), | 48 arraysize(kFakeKeyId)), |
| 49 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), | 49 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), |
| 50 std::vector<SubsampleEntry>()))); | 50 std::vector<SubsampleEntry>()))); |
| 51 return buffer; | 51 return buffer; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Use anonymous namespace here to prevent the actions to be defined multiple | 54 // Use anonymous namespace here to prevent the actions to be defined multiple |
| 55 // times across multiple test files. Sadly we can't use static for them. | 55 // times across multiple test files. Sadly we can't use static for them. |
| 56 namespace { | 56 namespace { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 decoder_.reset(); | 249 decoder_.reset(); |
| 250 message_loop_.RunUntilIdle(); | 250 message_loop_.RunUntilIdle(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 MOCK_METHOD1(FrameReady, void(const scoped_refptr<AudioBuffer>&)); | 253 MOCK_METHOD1(FrameReady, void(const scoped_refptr<AudioBuffer>&)); |
| 254 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); | 254 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
| 255 | 255 |
| 256 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 256 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
| 257 | 257 |
| 258 base::MessageLoop message_loop_; | 258 base::MessageLoop message_loop_; |
| 259 scoped_ptr<DecryptingAudioDecoder> decoder_; | 259 std::unique_ptr<DecryptingAudioDecoder> decoder_; |
| 260 scoped_ptr<StrictMock<MockCdmContext>> cdm_context_; | 260 std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
| 261 scoped_ptr<StrictMock<MockDecryptor>> decryptor_; | 261 std::unique_ptr<StrictMock<MockDecryptor>> decryptor_; |
| 262 AudioDecoderConfig config_; | 262 AudioDecoderConfig config_; |
| 263 | 263 |
| 264 // Variables to help the |decryptor_| to simulate decoding delay and flushing. | 264 // Variables to help the |decryptor_| to simulate decoding delay and flushing. |
| 265 int num_decrypt_and_decode_calls_; | 265 int num_decrypt_and_decode_calls_; |
| 266 int num_frames_in_decryptor_; | 266 int num_frames_in_decryptor_; |
| 267 | 267 |
| 268 Decryptor::DecoderInitCB pending_init_cb_; | 268 Decryptor::DecoderInitCB pending_init_cb_; |
| 269 Decryptor::NewKeyCB key_added_cb_; | 269 Decryptor::NewKeyCB key_added_cb_; |
| 270 Decryptor::AudioDecodeCB pending_audio_decode_cb_; | 270 Decryptor::AudioDecodeCB pending_audio_decode_cb_; |
| 271 | 271 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 | 472 |
| 473 // Test resetting after the decoder has been reset. | 473 // Test resetting after the decoder has been reset. |
| 474 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { | 474 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { |
| 475 Initialize(); | 475 Initialize(); |
| 476 EnterNormalDecodingState(); | 476 EnterNormalDecodingState(); |
| 477 Reset(); | 477 Reset(); |
| 478 Reset(); | 478 Reset(); |
| 479 } | 479 } |
| 480 | 480 |
| 481 } // namespace media | 481 } // namespace media |
| OLD | NEW |