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

Side by Side Diff: media/filters/decrypting_audio_decoder_unittest.cc

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const & Created 6 years, 4 months 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
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 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 // Use anonymous namespace here to prevent the actions to be defined multiple 49 // Use anonymous namespace here to prevent the actions to be defined multiple
50 // times across multiple test files. Sadly we can't use static for them. 50 // times across multiple test files. Sadly we can't use static for them.
51 namespace { 51 namespace {
52 52
53 ACTION_P(ReturnBuffer, buffer) { 53 ACTION_P(ReturnBuffer, buffer) {
54 return buffer; 54 return buffer;
55 } 55 }
56 56
57 ACTION_P(RunCallbackIfNotNull, param) { 57 ACTION_P2(RunCallbackIfNotNull, p1, p2) {
58 if (!arg0.is_null()) 58 if (!arg0.is_null())
59 arg0.Run(param); 59 arg0.Run(p1, p2);
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 63
64 class DecryptingAudioDecoderTest : public testing::Test { 64 class DecryptingAudioDecoderTest : public testing::Test {
65 public: 65 public:
66 DecryptingAudioDecoderTest() 66 DecryptingAudioDecoderTest()
67 : decoder_(new DecryptingAudioDecoder( 67 : decoder_(new DecryptingAudioDecoder(
68 message_loop_.message_loop_proxy(), 68 message_loop_.message_loop_proxy(),
69 base::Bind( 69 base::Bind(
(...skipping 30 matching lines...) Expand all
100 decoder_->Initialize(config, NewExpectedStatusCB(status), 100 decoder_->Initialize(config, NewExpectedStatusCB(status),
101 base::Bind(&DecryptingAudioDecoderTest::FrameReady, 101 base::Bind(&DecryptingAudioDecoderTest::FrameReady,
102 base::Unretained(this))); 102 base::Unretained(this)));
103 message_loop_.RunUntilIdle(); 103 message_loop_.RunUntilIdle();
104 } 104 }
105 105
106 void Initialize() { 106 void Initialize() {
107 EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) 107 EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _))
108 .Times(AtMost(1)) 108 .Times(AtMost(1))
109 .WillOnce(RunCallback<1>(true)); 109 .WillOnce(RunCallback<1>(true));
110 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 110 EXPECT_CALL(*this, RequestDecryptorNotification(_)).WillOnce(
111 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); 111 RunCallbackIfNotNull(decryptor_.get(), base::Bind(&base::DoNothing)));
ddorwin 2014/07/30 22:35:46 ditto
112 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _)) 112 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _))
113 .WillOnce(SaveArg<1>(&key_added_cb_)); 113 .WillOnce(SaveArg<1>(&key_added_cb_));
114 114
115 config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, 115 config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32,
116 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true, true, 116 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true, true,
117 base::TimeDelta(), 0); 117 base::TimeDelta(), 0);
118 InitializeAndExpectStatus(config_, PIPELINE_OK); 118 InitializeAndExpectStatus(config_, PIPELINE_OK);
119 } 119 }
120 120
121 void Reinitialize() { 121 void Reinitialize() {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 AudioDecoderConfig config(kUnknownAudioCodec, kUnknownSampleFormat, 287 AudioDecoderConfig config(kUnknownAudioCodec, kUnknownSampleFormat,
288 CHANNEL_LAYOUT_STEREO, 0, NULL, 0, true); 288 CHANNEL_LAYOUT_STEREO, 0, NULL, 0, true);
289 289
290 InitializeAndExpectStatus(config, PIPELINE_ERROR_DECODE); 290 InitializeAndExpectStatus(config, PIPELINE_ERROR_DECODE);
291 } 291 }
292 292
293 // Ensure decoder handles unsupported audio configs without crashing. 293 // Ensure decoder handles unsupported audio configs without crashing.
294 TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) { 294 TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) {
295 EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) 295 EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _))
296 .WillOnce(RunCallback<1>(false)); 296 .WillOnce(RunCallback<1>(false));
297 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 297 EXPECT_CALL(*this, RequestDecryptorNotification(_)).WillOnce(
298 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); 298 RunCallbackIfNotNull(decryptor_.get(), base::Bind(&base::DoNothing)));
299 299
300 AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, 300 AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,
301 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true); 301 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true);
302 InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED); 302 InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED);
303 } 303 }
304 304
305 TEST_F(DecryptingAudioDecoderTest, Initialize_NullDecryptor) { 305 TEST_F(DecryptingAudioDecoderTest, Initialize_NullDecryptor) {
306 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 306 EXPECT_CALL(*this, RequestDecryptorNotification(_))
307 .WillRepeatedly(RunCallbackIfNotNull(static_cast<Decryptor*>(NULL))); 307 .WillRepeatedly(RunCallbackIfNotNull(static_cast<Decryptor*>(NULL),
308 base::Bind(&base::DoNothing)));
308 309
309 AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, 310 AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,
310 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true); 311 CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true);
311 InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED); 312 InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED);
312 } 313 }
313 314
314 // Test normal decrypt and decode case. 315 // Test normal decrypt and decode case.
315 TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_Normal) { 316 TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_Normal) {
316 Initialize(); 317 Initialize();
317 EnterNormalDecodingState(); 318 EnterNormalDecodingState();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 463
463 // Test resetting after the decoder has been reset. 464 // Test resetting after the decoder has been reset.
464 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { 465 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) {
465 Initialize(); 466 Initialize();
466 EnterNormalDecodingState(); 467 EnterNormalDecodingState();
467 Reset(); 468 Reset();
468 Reset(); 469 Reset();
469 } 470 }
470 471
471 } // namespace media 472 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698