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

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

Issue 297553002: Add callback in VideoDecoder and AudioDecoder to return decoded frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 virtual ~DecryptingVideoDecoderTest() { 81 virtual ~DecryptingVideoDecoderTest() {
82 Stop(); 82 Stop();
83 } 83 }
84 84
85 // Initializes the |decoder_| and expects |status|. Note the initialization 85 // Initializes the |decoder_| and expects |status|. Note the initialization
86 // can succeed or fail. 86 // can succeed or fail.
87 void InitializeAndExpectStatus(const VideoDecoderConfig& config, 87 void InitializeAndExpectStatus(const VideoDecoderConfig& config,
88 PipelineStatus status) { 88 PipelineStatus status) {
89 decoder_->Initialize(config, false, NewExpectedStatusCB(status)); 89 decoder_->Initialize(config, false, NewExpectedStatusCB(status),
90 base::Bind(&DecryptingVideoDecoderTest::FrameReady,
91 base::Unretained(this)));
90 message_loop_.RunUntilIdle(); 92 message_loop_.RunUntilIdle();
91 } 93 }
92 94
93 // Initialize the |decoder_| and expects it to succeed. 95 // Initialize the |decoder_| and expects it to succeed.
94 void Initialize() { 96 void Initialize() {
95 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) 97 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _))
96 .WillOnce(RunCallback<1>(true)); 98 .WillOnce(RunCallback<1>(true));
97 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _)) 99 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _))
98 .WillOnce(SaveArg<1>(&key_added_cb_)); 100 .WillOnce(SaveArg<1>(&key_added_cb_));
99 101
100 InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), PIPELINE_OK); 102 InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), PIPELINE_OK);
101 } 103 }
102 104
103 // Reinitialize the |decoder_| and expects it to succeed. 105 // Reinitialize the |decoder_| and expects it to succeed.
104 void Reinitialize() { 106 void Reinitialize() {
105 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)); 107 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo));
106 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) 108 EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _))
107 .WillOnce(RunCallback<1>(true)); 109 .WillOnce(RunCallback<1>(true));
108 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _)) 110 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _))
109 .WillOnce(SaveArg<1>(&key_added_cb_)); 111 .WillOnce(SaveArg<1>(&key_added_cb_));
110 112
111 InitializeAndExpectStatus(TestVideoConfig::LargeEncrypted(), PIPELINE_OK); 113 InitializeAndExpectStatus(TestVideoConfig::LargeEncrypted(), PIPELINE_OK);
112 } 114 }
113 115
114 void ReadAndExpectFrameReadyWith( 116 void ReadAndExpectFrameReadyWith(
115 const scoped_refptr<DecoderBuffer>& buffer, 117 const scoped_refptr<DecoderBuffer>& buffer,
116 VideoDecoder::Status status, 118 VideoDecoder::Status status,
117 const scoped_refptr<VideoFrame>& video_frame) { 119 const scoped_refptr<VideoFrame>& video_frame) {
118 if (status != VideoDecoder::kOk) 120 if (video_frame.get()) {
119 EXPECT_CALL(*this, FrameReady(status, IsNull())); 121 if (video_frame->end_of_stream()) {
120 else if (video_frame.get() && video_frame->end_of_stream()) 122 EXPECT_CALL(*this, FrameReady(IsEndOfStream()));
121 EXPECT_CALL(*this, FrameReady(status, IsEndOfStream())); 123 } else {
122 else 124 EXPECT_CALL(*this, FrameReady(video_frame));
123 EXPECT_CALL(*this, FrameReady(status, video_frame)); 125 }
126 }
127 EXPECT_CALL(*this, DecodeDone(status));
124 128
125 decoder_->Decode(buffer, 129 decoder_->Decode(buffer,
126 base::Bind(&DecryptingVideoDecoderTest::FrameReady, 130 base::Bind(&DecryptingVideoDecoderTest::DecodeDone,
127 base::Unretained(this))); 131 base::Unretained(this)));
128 message_loop_.RunUntilIdle(); 132 message_loop_.RunUntilIdle();
129 } 133 }
130 134
131 // Sets up expectations and actions to put DecryptingVideoDecoder in an 135 // Sets up expectations and actions to put DecryptingVideoDecoder in an
132 // active normal decoding state. 136 // active normal decoding state.
133 void EnterNormalDecodingState() { 137 void EnterNormalDecodingState() {
134 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) 138 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
135 .WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_video_frame_)) 139 .WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_video_frame_))
136 .WillRepeatedly(RunCallback<1>(Decryptor::kNeedMoreData, 140 .WillRepeatedly(RunCallback<1>(Decryptor::kNeedMoreData,
(...skipping 11 matching lines...) Expand all
148 end_of_stream_video_frame_); 152 end_of_stream_video_frame_);
149 } 153 }
150 154
151 // Make the video decode callback pending by saving and not firing it. 155 // Make the video decode callback pending by saving and not firing it.
152 void EnterPendingDecodeState() { 156 void EnterPendingDecodeState() {
153 EXPECT_TRUE(pending_video_decode_cb_.is_null()); 157 EXPECT_TRUE(pending_video_decode_cb_.is_null());
154 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _)) 158 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _))
155 .WillOnce(SaveArg<1>(&pending_video_decode_cb_)); 159 .WillOnce(SaveArg<1>(&pending_video_decode_cb_));
156 160
157 decoder_->Decode(encrypted_buffer_, 161 decoder_->Decode(encrypted_buffer_,
158 base::Bind(&DecryptingVideoDecoderTest::FrameReady, 162 base::Bind(&DecryptingVideoDecoderTest::DecodeDone,
159 base::Unretained(this))); 163 base::Unretained(this)));
160 message_loop_.RunUntilIdle(); 164 message_loop_.RunUntilIdle();
161 // Make sure the Decode() on the decoder triggers a DecryptAndDecode() on 165 // Make sure the Decode() on the decoder triggers a DecryptAndDecode() on
162 // the decryptor. 166 // the decryptor.
163 EXPECT_FALSE(pending_video_decode_cb_.is_null()); 167 EXPECT_FALSE(pending_video_decode_cb_.is_null());
164 } 168 }
165 169
166 void EnterWaitingForKeyState() { 170 void EnterWaitingForKeyState() {
167 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) 171 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
168 .WillRepeatedly(RunCallback<1>(Decryptor::kNoKey, null_video_frame_)); 172 .WillRepeatedly(RunCallback<1>(Decryptor::kNoKey, null_video_frame_));
169 decoder_->Decode(encrypted_buffer_, 173 decoder_->Decode(encrypted_buffer_,
170 base::Bind(&DecryptingVideoDecoderTest::FrameReady, 174 base::Bind(&DecryptingVideoDecoderTest::DecodeDone,
171 base::Unretained(this))); 175 base::Unretained(this)));
172 message_loop_.RunUntilIdle(); 176 message_loop_.RunUntilIdle();
173 } 177 }
174 178
175 void AbortPendingVideoDecodeCB() { 179 void AbortPendingVideoDecodeCB() {
176 if (!pending_video_decode_cb_.is_null()) { 180 if (!pending_video_decode_cb_.is_null()) {
177 base::ResetAndReturn(&pending_video_decode_cb_).Run( 181 base::ResetAndReturn(&pending_video_decode_cb_).Run(
178 Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL)); 182 Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL));
179 } 183 }
180 } 184 }
(...skipping 21 matching lines...) Expand all
202 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)) 206 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo))
203 .WillRepeatedly(InvokeWithoutArgs( 207 .WillRepeatedly(InvokeWithoutArgs(
204 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs)); 208 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs));
205 209
206 decoder_->Stop(); 210 decoder_->Stop();
207 message_loop_.RunUntilIdle(); 211 message_loop_.RunUntilIdle();
208 } 212 }
209 213
210 MOCK_METHOD1(RequestDecryptorNotification, void(const DecryptorReadyCB&)); 214 MOCK_METHOD1(RequestDecryptorNotification, void(const DecryptorReadyCB&));
211 215
212 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, 216 MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&));
213 const scoped_refptr<VideoFrame>&)); 217 MOCK_METHOD1(DecodeDone, void(VideoDecoder::Status));
214 218
215 base::MessageLoop message_loop_; 219 base::MessageLoop message_loop_;
216 scoped_ptr<DecryptingVideoDecoder> decoder_; 220 scoped_ptr<DecryptingVideoDecoder> decoder_;
217 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; 221 scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
218 222
219 Decryptor::DecoderInitCB pending_init_cb_; 223 Decryptor::DecoderInitCB pending_init_cb_;
220 Decryptor::NewKeyCB key_added_cb_; 224 Decryptor::NewKeyCB key_added_cb_;
221 Decryptor::VideoDecodeCB pending_video_decode_cb_; 225 Decryptor::VideoDecodeCB pending_video_decode_cb_;
222 226
223 // Constant buffer/frames. 227 // Constant buffer/frames.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) { 303 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) {
300 Initialize(); 304 Initialize();
301 305
302 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) 306 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
303 .WillOnce(RunCallback<1>(Decryptor::kNeedMoreData, 307 .WillOnce(RunCallback<1>(Decryptor::kNeedMoreData,
304 scoped_refptr<VideoFrame>())) 308 scoped_refptr<VideoFrame>()))
305 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, 309 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess,
306 decoded_video_frame_)); 310 decoded_video_frame_));
307 311
308 ReadAndExpectFrameReadyWith( 312 ReadAndExpectFrameReadyWith(
309 encrypted_buffer_, VideoDecoder::kNotEnoughData, decoded_video_frame_); 313 encrypted_buffer_, VideoDecoder::kOk, NULL);
310 ReadAndExpectFrameReadyWith( 314 ReadAndExpectFrameReadyWith(
311 encrypted_buffer_, VideoDecoder::kOk, decoded_video_frame_); 315 encrypted_buffer_, VideoDecoder::kOk, decoded_video_frame_);
312 } 316 }
313 317
314 // Test the case where the decryptor receives end-of-stream buffer. 318 // Test the case where the decryptor receives end-of-stream buffer.
315 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_EndOfStream) { 319 TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_EndOfStream) {
316 Initialize(); 320 Initialize();
317 EnterNormalDecodingState(); 321 EnterNormalDecodingState();
318 EnterEndOfStreamState(); 322 EnterEndOfStreamState();
319 } 323 }
320 324
321 // Test the case where the a key is added when the decryptor is in 325 // Test the case where the a key is added when the decryptor is in
322 // kWaitingForKey state. 326 // kWaitingForKey state.
323 TEST_F(DecryptingVideoDecoderTest, KeyAdded_DuringWaitingForKey) { 327 TEST_F(DecryptingVideoDecoderTest, KeyAdded_DuringWaitingForKey) {
324 Initialize(); 328 Initialize();
325 EnterWaitingForKeyState(); 329 EnterWaitingForKeyState();
326 330
327 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) 331 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
328 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, 332 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess,
329 decoded_video_frame_)); 333 decoded_video_frame_));
330 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, decoded_video_frame_)); 334 EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
335 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kOk));
331 key_added_cb_.Run(); 336 key_added_cb_.Run();
332 message_loop_.RunUntilIdle(); 337 message_loop_.RunUntilIdle();
333 } 338 }
334 339
335 // Test the case where the a key is added when the decryptor is in 340 // Test the case where the a key is added when the decryptor is in
336 // kPendingDecode state. 341 // kPendingDecode state.
337 TEST_F(DecryptingVideoDecoderTest, KeyAdded_DruingPendingDecode) { 342 TEST_F(DecryptingVideoDecoderTest, KeyAdded_DruingPendingDecode) {
338 Initialize(); 343 Initialize();
339 EnterPendingDecodeState(); 344 EnterPendingDecodeState();
340 345
341 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) 346 EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
342 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, 347 .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess,
343 decoded_video_frame_)); 348 decoded_video_frame_));
344 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, decoded_video_frame_)); 349 EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
350 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kOk));
345 // The video decode callback is returned after the correct decryption key is 351 // The video decode callback is returned after the correct decryption key is
346 // added. 352 // added.
347 key_added_cb_.Run(); 353 key_added_cb_.Run();
348 base::ResetAndReturn(&pending_video_decode_cb_).Run(Decryptor::kNoKey, 354 base::ResetAndReturn(&pending_video_decode_cb_).Run(Decryptor::kNoKey,
349 null_video_frame_); 355 null_video_frame_);
350 message_loop_.RunUntilIdle(); 356 message_loop_.RunUntilIdle();
351 } 357 }
352 358
353 // Test resetting when the decoder is in kIdle state but has not decoded any 359 // Test resetting when the decoder is in kIdle state but has not decoded any
354 // frame. 360 // frame.
355 TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterInitialization) { 361 TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterInitialization) {
356 Initialize(); 362 Initialize();
357 Reset(); 363 Reset();
358 } 364 }
359 365
360 // Test resetting when the decoder is in kIdle state after it has decoded one 366 // Test resetting when the decoder is in kIdle state after it has decoded one
361 // frame. 367 // frame.
362 TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) { 368 TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) {
363 Initialize(); 369 Initialize();
364 EnterNormalDecodingState(); 370 EnterNormalDecodingState();
365 Reset(); 371 Reset();
366 } 372 }
367 373
368 // Test resetting when the decoder is in kPendingDecode state. 374 // Test resetting when the decoder is in kPendingDecode state.
369 TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) { 375 TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) {
370 Initialize(); 376 Initialize();
371 EnterPendingDecodeState(); 377 EnterPendingDecodeState();
372 378
373 EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull())); 379 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
374 380
375 Reset(); 381 Reset();
376 } 382 }
377 383
378 // Test resetting when the decoder is in kWaitingForKey state. 384 // Test resetting when the decoder is in kWaitingForKey state.
379 TEST_F(DecryptingVideoDecoderTest, Reset_DuringWaitingForKey) { 385 TEST_F(DecryptingVideoDecoderTest, Reset_DuringWaitingForKey) {
380 Initialize(); 386 Initialize();
381 EnterWaitingForKeyState(); 387 EnterWaitingForKeyState();
382 388
383 EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull())); 389 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
384 390
385 Reset(); 391 Reset();
386 } 392 }
387 393
388 // Test resetting when the decoder has hit end of stream and is in 394 // Test resetting when the decoder has hit end of stream and is in
389 // kDecodeFinished state. 395 // kDecodeFinished state.
390 TEST_F(DecryptingVideoDecoderTest, Reset_AfterDecodeFinished) { 396 TEST_F(DecryptingVideoDecoderTest, Reset_AfterDecodeFinished) {
391 Initialize(); 397 Initialize();
392 EnterNormalDecodingState(); 398 EnterNormalDecodingState();
393 EnterEndOfStreamState(); 399 EnterEndOfStreamState();
394 Reset(); 400 Reset();
395 } 401 }
396 402
397 // Test resetting after the decoder has been reset. 403 // Test resetting after the decoder has been reset.
398 TEST_F(DecryptingVideoDecoderTest, Reset_AfterReset) { 404 TEST_F(DecryptingVideoDecoderTest, Reset_AfterReset) {
399 Initialize(); 405 Initialize();
400 EnterNormalDecodingState(); 406 EnterNormalDecodingState();
401 Reset(); 407 Reset();
402 Reset(); 408 Reset();
403 } 409 }
404 410
405 // Test stopping when the decoder is in kDecryptorRequested state. 411 // Test stopping when the decoder is in kDecryptorRequested state.
406 TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) { 412 TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) {
407 DecryptorReadyCB decryptor_ready_cb; 413 DecryptorReadyCB decryptor_ready_cb;
408 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 414 EXPECT_CALL(*this, RequestDecryptorNotification(_))
409 .WillOnce(SaveArg<0>(&decryptor_ready_cb)); 415 .WillOnce(SaveArg<0>(&decryptor_ready_cb));
410 decoder_->Initialize(TestVideoConfig::NormalEncrypted(), false, 416 decoder_->Initialize(TestVideoConfig::NormalEncrypted(),
411 NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED)); 417 false,
418 NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED),
419 base::Bind(&DecryptingVideoDecoderTest::FrameReady,
420 base::Unretained(this)));
412 message_loop_.RunUntilIdle(); 421 message_loop_.RunUntilIdle();
413 // |decryptor_ready_cb| is saved but not called here. 422 // |decryptor_ready_cb| is saved but not called here.
414 EXPECT_FALSE(decryptor_ready_cb.is_null()); 423 EXPECT_FALSE(decryptor_ready_cb.is_null());
415 424
416 // During stop, RequestDecryptorNotification() should be called with a NULL 425 // During stop, RequestDecryptorNotification() should be called with a NULL
417 // callback to cancel the |decryptor_ready_cb|. 426 // callback to cancel the |decryptor_ready_cb|.
418 EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback())) 427 EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback()))
419 .WillOnce(ResetAndRunCallback(&decryptor_ready_cb, 428 .WillOnce(ResetAndRunCallback(&decryptor_ready_cb,
420 reinterpret_cast<Decryptor*>(NULL))); 429 reinterpret_cast<Decryptor*>(NULL)));
421 Stop(); 430 Stop();
(...skipping 24 matching lines...) Expand all
446 Initialize(); 455 Initialize();
447 EnterNormalDecodingState(); 456 EnterNormalDecodingState();
448 Stop(); 457 Stop();
449 } 458 }
450 459
451 // Test stopping when the decoder is in kPendingDecode state. 460 // Test stopping when the decoder is in kPendingDecode state.
452 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecode) { 461 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecode) {
453 Initialize(); 462 Initialize();
454 EnterPendingDecodeState(); 463 EnterPendingDecodeState();
455 464
456 EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull())); 465 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
457 466
458 Stop(); 467 Stop();
459 } 468 }
460 469
461 // Test stopping when the decoder is in kWaitingForKey state. 470 // Test stopping when the decoder is in kWaitingForKey state.
462 TEST_F(DecryptingVideoDecoderTest, Stop_DuringWaitingForKey) { 471 TEST_F(DecryptingVideoDecoderTest, Stop_DuringWaitingForKey) {
463 Initialize(); 472 Initialize();
464 EnterWaitingForKeyState(); 473 EnterWaitingForKeyState();
465 474
466 EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull())); 475 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
467 476
468 Stop(); 477 Stop();
469 } 478 }
470 479
471 // Test stopping when the decoder has hit end of stream and is in 480 // Test stopping when the decoder has hit end of stream and is in
472 // kDecodeFinished state. 481 // kDecodeFinished state.
473 TEST_F(DecryptingVideoDecoderTest, Stop_AfterDecodeFinished) { 482 TEST_F(DecryptingVideoDecoderTest, Stop_AfterDecodeFinished) {
474 Initialize(); 483 Initialize();
475 EnterNormalDecodingState(); 484 EnterNormalDecodingState();
476 EnterEndOfStreamState(); 485 EnterEndOfStreamState();
477 Stop(); 486 Stop();
478 } 487 }
479 488
480 // Test stopping when there is a pending reset on the decoder. 489 // Test stopping when there is a pending reset on the decoder.
481 // Reset is pending because it cannot complete when the video decode callback 490 // Reset is pending because it cannot complete when the video decode callback
482 // is pending. 491 // is pending.
483 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingReset) { 492 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingReset) {
484 Initialize(); 493 Initialize();
485 EnterPendingDecodeState(); 494 EnterPendingDecodeState();
486 495
487 EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo)); 496 EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo));
488 EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull())); 497 EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
489 498
490 decoder_->Reset(NewExpectedClosure()); 499 decoder_->Reset(NewExpectedClosure());
491 Stop(); 500 Stop();
492 } 501 }
493 502
494 // Test stopping after the decoder has been reset. 503 // Test stopping after the decoder has been reset.
495 TEST_F(DecryptingVideoDecoderTest, Stop_AfterReset) { 504 TEST_F(DecryptingVideoDecoderTest, Stop_AfterReset) {
496 Initialize(); 505 Initialize();
497 EnterNormalDecodingState(); 506 EnterNormalDecodingState();
498 Reset(); 507 Reset();
499 Stop(); 508 Stop();
500 } 509 }
501 510
502 // Test stopping after the decoder has been stopped. 511 // Test stopping after the decoder has been stopped.
503 TEST_F(DecryptingVideoDecoderTest, Stop_AfterStop) { 512 TEST_F(DecryptingVideoDecoderTest, Stop_AfterStop) {
504 Initialize(); 513 Initialize();
505 EnterNormalDecodingState(); 514 EnterNormalDecodingState();
506 Stop(); 515 Stop();
507 Stop(); 516 Stop();
508 } 517 }
509 518
510 } // namespace media 519 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698