xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | 1323b9c2 | 2015-12-23 06:22:36 | [diff] [blame] | 5 | #include <stdint.h> |
| 6 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
| 10 | #include "base/bind.h" |
| 11 | #include "base/callback_helpers.h" |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 12 | #include "base/run_loop.h" |
Avi Drissman | fa9bed4 | 2018-12-25 20:26:39 | [diff] [blame] | 13 | #include "base/stl_util.h" |
Marijn Kruisselbrink | 52a3524 | 2019-06-05 22:58:29 | [diff] [blame] | 14 | #include "base/test/gmock_callback_support.h" |
Gabriel Charette | c710874 | 2019-08-23 03:31:40 | [diff] [blame] | 15 | #include "base/test/task_environment.h" |
jrummell@chromium.org | 47b37a6 | 2013-07-10 03:56:10 | [diff] [blame] | 16 | #include "media/base/audio_buffer.h" |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 17 | #include "media/base/decoder_buffer.h" |
| 18 | #include "media/base/decrypt_config.h" |
chcunningham | 9812dd8 | 2015-10-20 01:42:09 | [diff] [blame] | 19 | #include "media/base/media_util.h" |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 20 | #include "media/base/mock_filters.h" |
scherkus@chromium.org | 1848da0 | 2012-12-06 06:58:38 | [diff] [blame] | 21 | #include "media/base/test_helpers.h" |
watk | 9f9dfdc9 | 2015-09-04 21:33:29 | [diff] [blame] | 22 | #include "media/base/timestamp_constants.h" |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 23 | #include "media/filters/decrypting_audio_decoder.h" |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 24 | #include "testing/gmock/include/gmock/gmock.h" |
| 25 | |
Marijn Kruisselbrink | 52a3524 | 2019-06-05 22:58:29 | [diff] [blame] | 26 | using ::base::test::RunCallback; |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 27 | using ::base::test::RunOnceCallback; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 28 | using ::testing::_; |
| 29 | using ::testing::AtMost; |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 30 | using ::testing::Return; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 31 | using ::testing::SaveArg; |
| 32 | using ::testing::StrictMock; |
| 33 | |
| 34 | namespace media { |
| 35 | |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 36 | const int kSampleRate = 44100; |
rileya@chromium.org | 16ecd5f | 2014-03-20 05:41:07 | [diff] [blame] | 37 | |
xhwang@chromium.org | ecf1691 | 2013-01-12 16:55:22 | [diff] [blame] | 38 | // Make sure the kFakeAudioFrameSize is a valid frame size for all audio decoder |
| 39 | // configs used in this test. |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 40 | const int kFakeAudioFrameSize = 48; |
Avi Drissman | 97785ea | 2015-12-19 01:11:31 | [diff] [blame] | 41 | const uint8_t kFakeKeyId[] = {0x4b, 0x65, 0x79, 0x20, 0x49, 0x44}; |
| 42 | const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0}; |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 43 | const int kDecodingDelay = 3; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 44 | |
| 45 | // Create a fake non-empty encrypted buffer. |
| 46 | static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() { |
| 47 | const int buffer_size = 16; // Need a non-empty buffer; |
| 48 | scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); |
John Rummell | 9044a76 | 2018-04-19 01:24:07 | [diff] [blame] | 49 | buffer->set_decrypt_config(DecryptConfig::CreateCencConfig( |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 50 | std::string(reinterpret_cast<const char*>(kFakeKeyId), |
Avi Drissman | fa9bed4 | 2018-12-25 20:26:39 | [diff] [blame] | 51 | base::size(kFakeKeyId)), |
| 52 | std::string(reinterpret_cast<const char*>(kFakeIv), base::size(kFakeIv)), |
John Rummell | 9044a76 | 2018-04-19 01:24:07 | [diff] [blame] | 53 | std::vector<SubsampleEntry>())); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 54 | return buffer; |
| 55 | } |
| 56 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 57 | class DecryptingAudioDecoderTest : public testing::Test { |
| 58 | public: |
| 59 | DecryptingAudioDecoderTest() |
Carlos Caballero | 9de7c72 | 2019-05-31 21:25:07 | [diff] [blame] | 60 | : decoder_(new DecryptingAudioDecoder( |
Gabriel Charette | dfa3604 | 2019-08-19 17:30:11 | [diff] [blame] | 61 | task_environment_.GetMainThreadTaskRunner(), |
Carlos Caballero | 9de7c72 | 2019-05-31 21:25:07 | [diff] [blame] | 62 | &media_log_)), |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 63 | cdm_context_(new StrictMock<MockCdmContext>()), |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 64 | decryptor_(new StrictMock<MockDecryptor>()), |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 65 | num_decrypt_and_decode_calls_(0), |
| 66 | num_frames_in_decryptor_(0), |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 67 | encrypted_buffer_(CreateFakeEncryptedBuffer()), |
kylechar | 938dc44 | 2019-10-29 14:40:24 | [diff] [blame] | 68 | decoded_frame_(nullptr), |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 69 | decoded_frame_list_() {} |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 70 | |
Daniel Cheng | 9f0b701 | 2018-04-26 21:09:05 | [diff] [blame] | 71 | ~DecryptingAudioDecoderTest() override { Destroy(); } |
rileya@chromium.org | b960fd0 | 2014-01-23 04:48:54 | [diff] [blame] | 72 | |
xhwang | 59c321f | 2015-06-05 23:46:55 | [diff] [blame] | 73 | void InitializeAndExpectResult(const AudioDecoderConfig& config, |
| 74 | bool success) { |
dalecurtis@google.com | e81f5f9d | 2014-03-29 01:32:16 | [diff] [blame] | 75 | // Initialize data now that the config is known. Since the code uses |
| 76 | // invalid values (that CreateEmptyBuffer() doesn't support), tweak them |
| 77 | // just for CreateEmptyBuffer(). |
| 78 | int channels = ChannelLayoutToChannelCount(config.channel_layout()); |
| 79 | if (channels < 0) |
| 80 | channels = 0; |
dalecurtis | 39a7f93 | 2016-07-19 18:34:59 | [diff] [blame] | 81 | decoded_frame_ = AudioBuffer::CreateEmptyBuffer( |
| 82 | config.channel_layout(), channels, kSampleRate, kFakeAudioFrameSize, |
| 83 | kNoTimestamp); |
jrummell@chromium.org | 47b37a6 | 2013-07-10 03:56:10 | [diff] [blame] | 84 | decoded_frame_list_.push_back(decoded_frame_); |
| 85 | |
Ted Meyer | 2a41e24 | 2020-03-20 08:01:27 | [diff] [blame] | 86 | decoder_->Initialize(config, cdm_context_.get(), |
| 87 | base::BindOnce( |
| 88 | [](bool success, Status status) { |
| 89 | EXPECT_EQ(status.is_ok(), success); |
| 90 | }, |
| 91 | success), |
Xiaohan Wang | 640b41d | 2018-12-18 19:00:46 | [diff] [blame] | 92 | base::Bind(&DecryptingAudioDecoderTest::FrameReady, |
| 93 | base::Unretained(this)), |
| 94 | base::Bind(&DecryptingAudioDecoderTest::OnWaiting, |
| 95 | base::Unretained(this))); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 96 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 97 | } |
| 98 | |
xhwang | a935e44 | 2016-02-11 02:22:45 | [diff] [blame] | 99 | enum CdmType { CDM_WITHOUT_DECRYPTOR, CDM_WITH_DECRYPTOR }; |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 100 | |
| 101 | void SetCdmType(CdmType cdm_type) { |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 102 | const bool has_decryptor = cdm_type == CDM_WITH_DECRYPTOR; |
xhwang | a935e44 | 2016-02-11 02:22:45 | [diff] [blame] | 103 | EXPECT_CALL(*cdm_context_, GetDecryptor()) |
| 104 | .WillRepeatedly(Return(has_decryptor ? decryptor_.get() : nullptr)); |
jrummell@chromium.org | 9ebc3b03 | 2014-08-13 04:01:23 | [diff] [blame] | 105 | } |
| 106 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 107 | void Initialize() { |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 108 | SetCdmType(CDM_WITH_DECRYPTOR); |
xhwang@chromium.org | a3e2867 | 2013-03-14 14:54:59 | [diff] [blame] | 109 | EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 110 | .Times(AtMost(1)) |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 111 | .WillOnce(RunOnceCallback<1>(true)); |
Xiaohan Wang | d72ce5d | 2020-07-14 01:34:43 | [diff] [blame^] | 112 | EXPECT_CALL(*cdm_context_, RegisterEventCB(_)).WillOnce([&](auto cb) { |
| 113 | event_cb_ = cb; |
| 114 | return std::make_unique<CallbackRegistration>(); |
| 115 | }); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 116 | |
xhwang@chromium.org | 7c39486c | 2013-01-06 15:36:09 | [diff] [blame] | 117 | config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, |
chcunningham | 9812dd8 | 2015-10-20 01:42:09 | [diff] [blame] | 118 | CHANNEL_LAYOUT_STEREO, kSampleRate, EmptyExtraData(), |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 119 | EncryptionScheme::kCenc, base::TimeDelta(), 0); |
xhwang | 59c321f | 2015-06-05 23:46:55 | [diff] [blame] | 120 | InitializeAndExpectResult(config_, true); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 121 | } |
| 122 | |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 123 | void Reinitialize() { ReinitializeConfigChange(config_); } |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 124 | |
dalecurtis@google.com | 6fb8654 | 2014-04-18 19:58:13 | [diff] [blame] | 125 | void ReinitializeConfigChange(const AudioDecoderConfig& new_config) { |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 126 | EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio)); |
| 127 | EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 128 | .WillOnce(RunOnceCallback<1>(true)); |
Ted Meyer | 2a41e24 | 2020-03-20 08:01:27 | [diff] [blame] | 129 | decoder_->Initialize( |
| 130 | new_config, cdm_context_.get(), |
| 131 | base::BindOnce([](Status status) { EXPECT_TRUE(status.is_ok()); }), |
| 132 | base::Bind(&DecryptingAudioDecoderTest::FrameReady, |
| 133 | base::Unretained(this)), |
| 134 | base::Bind(&DecryptingAudioDecoderTest::OnWaiting, |
| 135 | base::Unretained(this))); |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 136 | } |
| 137 | |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 138 | // Decode |buffer| and expect DecodeDone to get called with |status|. |
Dale Curtis | ca8ad98 | 2018-04-09 20:23:14 | [diff] [blame] | 139 | void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 140 | DecodeStatus status) { |
sergeyu@chromium.org | 49cea86 | 2014-06-11 11:11:50 | [diff] [blame] | 141 | EXPECT_CALL(*this, DecodeDone(status)); |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 142 | decoder_->Decode(buffer, base::Bind(&DecryptingAudioDecoderTest::DecodeDone, |
| 143 | base::Unretained(this))); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 144 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 145 | } |
| 146 | |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 147 | // Helper function to simulate the decrypting and decoding process in the |
| 148 | // |decryptor_| with a decoding delay of kDecodingDelay buffers. |
Dale Curtis | ca8ad98 | 2018-04-09 20:23:14 | [diff] [blame] | 149 | void DecryptAndDecodeAudio(scoped_refptr<DecoderBuffer> encrypted, |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 150 | const Decryptor::AudioDecodeCB& audio_decode_cb) { |
| 151 | num_decrypt_and_decode_calls_++; |
| 152 | if (!encrypted->end_of_stream()) |
| 153 | num_frames_in_decryptor_++; |
| 154 | |
| 155 | if (num_decrypt_and_decode_calls_ <= kDecodingDelay || |
| 156 | num_frames_in_decryptor_ == 0) { |
anujk.sharma | f1cb600a | 2015-01-07 19:11:13 | [diff] [blame] | 157 | audio_decode_cb.Run(Decryptor::kNeedMoreData, Decryptor::AudioFrames()); |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 158 | return; |
| 159 | } |
| 160 | |
| 161 | num_frames_in_decryptor_--; |
| 162 | audio_decode_cb.Run(Decryptor::kSuccess, |
anujk.sharma | f1cb600a | 2015-01-07 19:11:13 | [diff] [blame] | 163 | Decryptor::AudioFrames(1, decoded_frame_)); |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 164 | } |
| 165 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 166 | // Sets up expectations and actions to put DecryptingAudioDecoder in an |
| 167 | // active normal decoding state. |
| 168 | void EnterNormalDecodingState() { |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 169 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
| 170 | .WillRepeatedly( |
| 171 | Invoke(this, &DecryptingAudioDecoderTest::DecryptAndDecodeAudio)); |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 172 | EXPECT_CALL(*this, FrameReady(decoded_frame_)); |
| 173 | for (int i = 0; i < kDecodingDelay + 1; ++i) |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 174 | DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | // Sets up expectations and actions to put DecryptingAudioDecoder in an end |
| 178 | // of stream state. This function must be called after |
| 179 | // EnterNormalDecodingState() to work. |
| 180 | void EnterEndOfStreamState() { |
xhwang@chromium.org | ff75703 | 2014-06-19 01:42:24 | [diff] [blame] | 181 | // The codec in the |decryptor_| will be flushed. |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 182 | EXPECT_CALL(*this, FrameReady(decoded_frame_)).Times(kDecodingDelay); |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 183 | DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK); |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 184 | EXPECT_EQ(0, num_frames_in_decryptor_); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | // Make the audio decode callback pending by saving and not firing it. |
| 188 | void EnterPendingDecodeState() { |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 189 | EXPECT_TRUE(!pending_audio_decode_cb_); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 190 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(encrypted_buffer_, _)) |
| 191 | .WillOnce(SaveArg<1>(&pending_audio_decode_cb_)); |
| 192 | |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 193 | decoder_->Decode(encrypted_buffer_, |
sergeyu@chromium.org | 49cea86 | 2014-06-11 11:11:50 | [diff] [blame] | 194 | base::Bind(&DecryptingAudioDecoderTest::DecodeDone, |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 195 | base::Unretained(this))); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 196 | base::RunLoop().RunUntilIdle(); |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 197 | // Make sure the Decode() on the decoder triggers a DecryptAndDecode() on |
| 198 | // the decryptor. |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 199 | EXPECT_FALSE(!pending_audio_decode_cb_); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void EnterWaitingForKeyState() { |
xhwang@chromium.org | 2b454ff8 | 2012-11-15 03:57:58 | [diff] [blame] | 203 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(encrypted_buffer_, _)) |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 204 | .WillRepeatedly( |
| 205 | RunCallback<1>(Decryptor::kNoKey, Decryptor::AudioFrames())); |
Xiaohan Wang | 640b41d | 2018-12-18 19:00:46 | [diff] [blame] | 206 | EXPECT_CALL(*this, OnWaiting(WaitingReason::kNoDecryptionKey)); |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 207 | decoder_->Decode(encrypted_buffer_, |
sergeyu@chromium.org | 49cea86 | 2014-06-11 11:11:50 | [diff] [blame] | 208 | base::Bind(&DecryptingAudioDecoderTest::DecodeDone, |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 209 | base::Unretained(this))); |
Xiaohan Wang | 689cd428 | 2017-08-04 07:54:55 | [diff] [blame] | 210 | |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 211 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | void AbortPendingAudioDecodeCB() { |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 215 | if (pending_audio_decode_cb_) { |
| 216 | std::move(pending_audio_decode_cb_) |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 217 | .Run(Decryptor::kSuccess, Decryptor::AudioFrames()); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
rileya@chromium.org | b960fd0 | 2014-01-23 04:48:54 | [diff] [blame] | 221 | void AbortAllPendingCBs() { |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 222 | if (pending_init_cb_) { |
| 223 | ASSERT_TRUE(!pending_audio_decode_cb_); |
| 224 | std::move(pending_init_cb_).Run(false); |
rileya@chromium.org | b960fd0 | 2014-01-23 04:48:54 | [diff] [blame] | 225 | return; |
| 226 | } |
| 227 | |
| 228 | AbortPendingAudioDecodeCB(); |
| 229 | } |
| 230 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 231 | void Reset() { |
| 232 | EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kAudio)) |
| 233 | .WillRepeatedly(InvokeWithoutArgs( |
| 234 | this, &DecryptingAudioDecoderTest::AbortPendingAudioDecodeCB)); |
| 235 | |
| 236 | decoder_->Reset(NewExpectedClosure()); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 237 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 238 | } |
| 239 | |
xhwang@chromium.org | 83fb2a9e | 2014-07-16 23:36:41 | [diff] [blame] | 240 | void Destroy() { |
rileya@chromium.org | b960fd0 | 2014-01-23 04:48:54 | [diff] [blame] | 241 | EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio)) |
| 242 | .WillRepeatedly(InvokeWithoutArgs( |
| 243 | this, &DecryptingAudioDecoderTest::AbortAllPendingCBs)); |
| 244 | |
xhwang@chromium.org | 83fb2a9e | 2014-07-16 23:36:41 | [diff] [blame] | 245 | decoder_.reset(); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 246 | base::RunLoop().RunUntilIdle(); |
rileya@chromium.org | b960fd0 | 2014-01-23 04:48:54 | [diff] [blame] | 247 | } |
| 248 | |
John Rummell | 1b2b63d | 2019-04-26 20:45:57 | [diff] [blame] | 249 | MOCK_METHOD1(FrameReady, void(scoped_refptr<AudioBuffer>)); |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 250 | MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 251 | |
Xiaohan Wang | 640b41d | 2018-12-18 19:00:46 | [diff] [blame] | 252 | MOCK_METHOD1(OnWaiting, void(WaitingReason)); |
jrummell | 74fc4f94 | 2015-03-02 22:48:27 | [diff] [blame] | 253 | |
Gabriel Charette | 311b0e9 | 2019-09-09 20:01:25 | [diff] [blame] | 254 | base::test::SingleThreadTaskEnvironment task_environment_; |
Xiaohan Wang | 14b3166d | 2018-12-28 21:05:46 | [diff] [blame] | 255 | NullMediaLog media_log_; |
dcheng | 254c536 | 2016-04-22 01:12:48 | [diff] [blame] | 256 | std::unique_ptr<DecryptingAudioDecoder> decoder_; |
| 257 | std::unique_ptr<StrictMock<MockCdmContext>> cdm_context_; |
| 258 | std::unique_ptr<StrictMock<MockDecryptor>> decryptor_; |
xhwang@chromium.org | 7c39486c | 2013-01-06 15:36:09 | [diff] [blame] | 259 | AudioDecoderConfig config_; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 260 | |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 261 | // Variables to help the |decryptor_| to simulate decoding delay and flushing. |
| 262 | int num_decrypt_and_decode_calls_; |
| 263 | int num_frames_in_decryptor_; |
| 264 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 265 | Decryptor::DecoderInitCB pending_init_cb_; |
Xiaohan Wang | d72ce5d | 2020-07-14 01:34:43 | [diff] [blame^] | 266 | CdmContext::EventCB event_cb_; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 267 | Decryptor::AudioDecodeCB pending_audio_decode_cb_; |
| 268 | |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 269 | // Constant buffer/frames, to be used/returned by |decoder_| and |decryptor_|. |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 270 | scoped_refptr<DecoderBuffer> encrypted_buffer_; |
jrummell@chromium.org | 47b37a6 | 2013-07-10 03:56:10 | [diff] [blame] | 271 | scoped_refptr<AudioBuffer> decoded_frame_; |
anujk.sharma | f1cb600a | 2015-01-07 19:11:13 | [diff] [blame] | 272 | Decryptor::AudioFrames decoded_frame_list_; |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 273 | |
| 274 | private: |
| 275 | DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoderTest); |
| 276 | }; |
| 277 | |
| 278 | TEST_F(DecryptingAudioDecoderTest, Initialize_Normal) { |
| 279 | Initialize(); |
| 280 | } |
| 281 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 282 | // Ensure decoder handles invalid audio configs without crashing. |
| 283 | TEST_F(DecryptingAudioDecoderTest, Initialize_InvalidAudioConfig) { |
dalecurtis@google.com | b5eca3c | 2013-01-04 20:20:15 | [diff] [blame] | 284 | AudioDecoderConfig config(kUnknownAudioCodec, kUnknownSampleFormat, |
dougsteed | 8d5275f | 2016-03-12 00:04:30 | [diff] [blame] | 285 | CHANNEL_LAYOUT_STEREO, 0, EmptyExtraData(), |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 286 | EncryptionScheme::kCenc); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 287 | |
xhwang | 59c321f | 2015-06-05 23:46:55 | [diff] [blame] | 288 | InitializeAndExpectResult(config, false); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | // Ensure decoder handles unsupported audio configs without crashing. |
| 292 | TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) { |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 293 | SetCdmType(CDM_WITH_DECRYPTOR); |
Xiaohan Wang | d72ce5d | 2020-07-14 01:34:43 | [diff] [blame^] | 294 | EXPECT_CALL(*cdm_context_, RegisterEventCB(_)).WillOnce([&](auto cb) { |
| 295 | event_cb_ = cb; |
| 296 | return std::make_unique<CallbackRegistration>(); |
| 297 | }); |
xhwang@chromium.org | a3e2867 | 2013-03-14 14:54:59 | [diff] [blame] | 298 | EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 299 | .WillOnce(RunOnceCallback<1>(false)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 300 | |
dalecurtis@google.com | b5eca3c | 2013-01-04 20:20:15 | [diff] [blame] | 301 | AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, |
chcunningham | 9812dd8 | 2015-10-20 01:42:09 | [diff] [blame] | 302 | CHANNEL_LAYOUT_STEREO, kSampleRate, |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 303 | EmptyExtraData(), EncryptionScheme::kCenc); |
xhwang | 59c321f | 2015-06-05 23:46:55 | [diff] [blame] | 304 | InitializeAndExpectResult(config, false); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 305 | } |
| 306 | |
xhwang | 00f69db7 | 2015-11-12 07:32:37 | [diff] [blame] | 307 | TEST_F(DecryptingAudioDecoderTest, Initialize_CdmWithoutDecryptor) { |
| 308 | SetCdmType(CDM_WITHOUT_DECRYPTOR); |
xhwang@chromium.org | 699b64a | 2013-06-19 07:36:05 | [diff] [blame] | 309 | AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, |
chcunningham | 9812dd8 | 2015-10-20 01:42:09 | [diff] [blame] | 310 | CHANNEL_LAYOUT_STEREO, kSampleRate, |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 311 | EmptyExtraData(), EncryptionScheme::kCenc); |
xhwang | 59c321f | 2015-06-05 23:46:55 | [diff] [blame] | 312 | InitializeAndExpectResult(config, false); |
xhwang@chromium.org | 699b64a | 2013-06-19 07:36:05 | [diff] [blame] | 313 | } |
| 314 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 315 | // Test normal decrypt and decode case. |
| 316 | TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_Normal) { |
| 317 | Initialize(); |
| 318 | EnterNormalDecodingState(); |
| 319 | } |
| 320 | |
| 321 | // Test the case where the decryptor returns error when doing decrypt and |
| 322 | // decode. |
| 323 | TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_DecodeError) { |
| 324 | Initialize(); |
| 325 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 326 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 327 | .WillRepeatedly( |
| 328 | RunCallback<1>(Decryptor::kError, Decryptor::AudioFrames())); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 329 | |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 330 | DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | // Test the case where the decryptor returns multiple decoded frames. |
| 334 | TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) { |
| 335 | Initialize(); |
| 336 | |
jrummell@chromium.org | 47b37a6 | 2013-07-10 03:56:10 | [diff] [blame] | 337 | scoped_refptr<AudioBuffer> frame_a = AudioBuffer::CreateEmptyBuffer( |
rileya@chromium.org | 16ecd5f | 2014-03-20 05:41:07 | [diff] [blame] | 338 | config_.channel_layout(), |
dalecurtis | 39a7f93 | 2016-07-19 18:34:59 | [diff] [blame] | 339 | ChannelLayoutToChannelCount(config_.channel_layout()), kSampleRate, |
| 340 | kFakeAudioFrameSize, kNoTimestamp); |
jrummell@chromium.org | 47b37a6 | 2013-07-10 03:56:10 | [diff] [blame] | 341 | scoped_refptr<AudioBuffer> frame_b = AudioBuffer::CreateEmptyBuffer( |
rileya@chromium.org | 16ecd5f | 2014-03-20 05:41:07 | [diff] [blame] | 342 | config_.channel_layout(), |
dalecurtis | 39a7f93 | 2016-07-19 18:34:59 | [diff] [blame] | 343 | ChannelLayoutToChannelCount(config_.channel_layout()), kSampleRate, |
| 344 | kFakeAudioFrameSize, kNoTimestamp); |
xhwang@chromium.org | ecbb976 | 2012-10-24 22:33:54 | [diff] [blame] | 345 | decoded_frame_list_.push_back(frame_a); |
| 346 | decoded_frame_list_.push_back(frame_b); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 347 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 348 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
xhwang@chromium.org | 8b10f222 | 2012-11-13 05:49:48 | [diff] [blame] | 349 | .WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 350 | |
xhwang@chromium.org | 5c5e9b7 | 2014-06-17 19:21:12 | [diff] [blame] | 351 | EXPECT_CALL(*this, FrameReady(decoded_frame_)); |
| 352 | EXPECT_CALL(*this, FrameReady(frame_a)); |
| 353 | EXPECT_CALL(*this, FrameReady(frame_b)); |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 354 | DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | // Test the case where the decryptor receives end-of-stream buffer. |
| 358 | TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_EndOfStream) { |
| 359 | Initialize(); |
| 360 | EnterNormalDecodingState(); |
| 361 | EnterEndOfStreamState(); |
| 362 | } |
| 363 | |
xhwang | 65c2303 | 2017-02-17 04:37:42 | [diff] [blame] | 364 | // Test reinitializing decode with a new encrypted config. |
| 365 | TEST_F(DecryptingAudioDecoderTest, Reinitialize_EncryptedToEncrypted) { |
xhwang@chromium.org | 7c39486c | 2013-01-06 15:36:09 | [diff] [blame] | 366 | Initialize(); |
| 367 | |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 368 | EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) |
| 369 | .Times(AtMost(1)) |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 370 | .WillOnce(RunOnceCallback<1>(true)); |
xhwang@chromium.org | 7c39486c | 2013-01-06 15:36:09 | [diff] [blame] | 371 | |
xhwang@chromium.org | ecf1691 | 2013-01-12 16:55:22 | [diff] [blame] | 372 | // The new config is different from the initial config in bits-per-channel, |
| 373 | // channel layout and samples_per_second. |
| 374 | AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarS16, |
chcunningham | 9812dd8 | 2015-10-20 01:42:09 | [diff] [blame] | 375 | CHANNEL_LAYOUT_5_1, 88200, EmptyExtraData(), |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 376 | EncryptionScheme::kCenc); |
xhwang@chromium.org | ecf1691 | 2013-01-12 16:55:22 | [diff] [blame] | 377 | EXPECT_NE(new_config.bits_per_channel(), config_.bits_per_channel()); |
| 378 | EXPECT_NE(new_config.channel_layout(), config_.channel_layout()); |
| 379 | EXPECT_NE(new_config.samples_per_second(), config_.samples_per_second()); |
xhwang | 65c2303 | 2017-02-17 04:37:42 | [diff] [blame] | 380 | ASSERT_TRUE(new_config.is_encrypted()); |
| 381 | |
| 382 | ReinitializeConfigChange(new_config); |
| 383 | base::RunLoop().RunUntilIdle(); |
| 384 | } |
| 385 | |
| 386 | // Test reinitializing decode with a new clear config. |
| 387 | TEST_F(DecryptingAudioDecoderTest, Reinitialize_EncryptedToClear) { |
| 388 | Initialize(); |
| 389 | |
| 390 | EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) |
| 391 | .Times(AtMost(1)) |
Jose Lopes | 109230ec | 2020-02-24 10:28:12 | [diff] [blame] | 392 | .WillOnce(RunOnceCallback<1>(true)); |
xhwang | 65c2303 | 2017-02-17 04:37:42 | [diff] [blame] | 393 | |
| 394 | // The new config is different from the initial config in bits-per-channel, |
| 395 | // channel layout and samples_per_second. |
| 396 | AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarS16, |
| 397 | CHANNEL_LAYOUT_5_1, 88200, EmptyExtraData(), |
Yuchen Liu | b33bfc1 | 2019-11-08 20:16:12 | [diff] [blame] | 398 | EncryptionScheme::kUnencrypted); |
xhwang | 65c2303 | 2017-02-17 04:37:42 | [diff] [blame] | 399 | EXPECT_NE(new_config.bits_per_channel(), config_.bits_per_channel()); |
| 400 | EXPECT_NE(new_config.channel_layout(), config_.channel_layout()); |
| 401 | EXPECT_NE(new_config.samples_per_second(), config_.samples_per_second()); |
| 402 | ASSERT_FALSE(new_config.is_encrypted()); |
xhwang@chromium.org | ecf1691 | 2013-01-12 16:55:22 | [diff] [blame] | 403 | |
rileya@chromium.org | d7015779 | 2014-03-17 21:45:03 | [diff] [blame] | 404 | ReinitializeConfigChange(new_config); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 405 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 7c39486c | 2013-01-06 15:36:09 | [diff] [blame] | 406 | } |
| 407 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 408 | // Test the case where the a key is added when the decryptor is in |
| 409 | // kWaitingForKey state. |
| 410 | TEST_F(DecryptingAudioDecoderTest, KeyAdded_DuringWaitingForKey) { |
| 411 | Initialize(); |
| 412 | EnterWaitingForKeyState(); |
| 413 | |
| 414 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
xhwang@chromium.org | 8b10f222 | 2012-11-13 05:49:48 | [diff] [blame] | 415 | .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_)); |
sergeyu@chromium.org | 49cea86 | 2014-06-11 11:11:50 | [diff] [blame] | 416 | EXPECT_CALL(*this, FrameReady(decoded_frame_)); |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 417 | EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK)); |
Xiaohan Wang | d72ce5d | 2020-07-14 01:34:43 | [diff] [blame^] | 418 | event_cb_.Run(CdmContext::Event::kHasAdditionalUsableKey); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 419 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | // Test the case where the a key is added when the decryptor is in |
| 423 | // kPendingDecode state. |
| 424 | TEST_F(DecryptingAudioDecoderTest, KeyAdded_DruingPendingDecode) { |
| 425 | Initialize(); |
| 426 | EnterPendingDecodeState(); |
| 427 | |
| 428 | EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
xhwang@chromium.org | 8b10f222 | 2012-11-13 05:49:48 | [diff] [blame] | 429 | .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_)); |
sergeyu@chromium.org | 49cea86 | 2014-06-11 11:11:50 | [diff] [blame] | 430 | EXPECT_CALL(*this, FrameReady(decoded_frame_)); |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 431 | EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 432 | // The audio decode callback is returned after the correct decryption key is |
| 433 | // added. |
Xiaohan Wang | d72ce5d | 2020-07-14 01:34:43 | [diff] [blame^] | 434 | event_cb_.Run(CdmContext::Event::kHasAdditionalUsableKey); |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 435 | std::move(pending_audio_decode_cb_) |
Xiaohan Wang | c03ce23 | 2018-05-30 21:07:58 | [diff] [blame] | 436 | .Run(Decryptor::kNoKey, Decryptor::AudioFrames()); |
fdoray | f920dcf | 2016-06-27 17:16:59 | [diff] [blame] | 437 | base::RunLoop().RunUntilIdle(); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | // Test resetting when the decoder is in kIdle state but has not decoded any |
| 441 | // frame. |
| 442 | TEST_F(DecryptingAudioDecoderTest, Reset_DuringIdleAfterInitialization) { |
| 443 | Initialize(); |
| 444 | Reset(); |
| 445 | } |
| 446 | |
| 447 | // Test resetting when the decoder is in kIdle state after it has decoded one |
| 448 | // frame. |
| 449 | TEST_F(DecryptingAudioDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) { |
| 450 | Initialize(); |
| 451 | EnterNormalDecodingState(); |
| 452 | Reset(); |
| 453 | } |
| 454 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 455 | // Test resetting when the decoder is in kPendingDecode state. |
| 456 | TEST_F(DecryptingAudioDecoderTest, Reset_DuringPendingDecode) { |
| 457 | Initialize(); |
| 458 | EnterPendingDecodeState(); |
| 459 | |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 460 | EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 461 | |
| 462 | Reset(); |
| 463 | } |
| 464 | |
| 465 | // Test resetting when the decoder is in kWaitingForKey state. |
| 466 | TEST_F(DecryptingAudioDecoderTest, Reset_DuringWaitingForKey) { |
| 467 | Initialize(); |
| 468 | EnterWaitingForKeyState(); |
| 469 | |
dalecurtis | 8f75b99 | 2016-03-30 17:54:59 | [diff] [blame] | 470 | EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED)); |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 471 | |
| 472 | Reset(); |
| 473 | } |
| 474 | |
| 475 | // Test resetting when the decoder has hit end of stream and is in |
| 476 | // kDecodeFinished state. |
| 477 | TEST_F(DecryptingAudioDecoderTest, Reset_AfterDecodeFinished) { |
| 478 | Initialize(); |
| 479 | EnterNormalDecodingState(); |
| 480 | EnterEndOfStreamState(); |
| 481 | Reset(); |
| 482 | } |
| 483 | |
| 484 | // Test resetting after the decoder has been reset. |
| 485 | TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { |
| 486 | Initialize(); |
| 487 | EnterNormalDecodingState(); |
| 488 | Reset(); |
| 489 | Reset(); |
| 490 | } |
| 491 | |
xhwang@chromium.org | 97a9ce4 | 2012-10-19 10:06:43 | [diff] [blame] | 492 | } // namespace media |