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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 // error. | 420 // error. |
421 VideoDecoder::DecoderStatus status; | 421 VideoDecoder::DecoderStatus status; |
422 scoped_refptr<VideoFrame> video_frame; | 422 scoped_refptr<VideoFrame> video_frame; |
423 Read(&status, &video_frame); | 423 Read(&status, &video_frame); |
424 EXPECT_EQ(VideoDecoder::kDecryptError, status); | 424 EXPECT_EQ(VideoDecoder::kDecryptError, status); |
425 EXPECT_FALSE(video_frame); | 425 EXPECT_FALSE(video_frame); |
426 | 426 |
427 message_loop_.RunAllPending(); | 427 message_loop_.RunAllPending(); |
428 } | 428 } |
429 | 429 |
| 430 // Test the case that the decryptor has no key to decrypt the encrypted buffer. |
| 431 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoDecryptionKey) { |
| 432 Initialize(); |
| 433 |
| 434 // Simulate decoding a single encrypted frame. |
| 435 EXPECT_CALL(*demuxer_, Read(_)) |
| 436 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); |
| 437 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _)) |
| 438 .WillRepeatedly(RunDecryptCB(Decryptor::kNoKey, |
| 439 scoped_refptr<media::DecoderBuffer>())); |
| 440 |
| 441 // Our read should still get satisfied with end of stream frame during an |
| 442 // error. |
| 443 VideoDecoder::DecoderStatus status; |
| 444 scoped_refptr<VideoFrame> video_frame; |
| 445 Read(&status, &video_frame); |
| 446 EXPECT_EQ(VideoDecoder::kDecryptError, status); |
| 447 EXPECT_FALSE(video_frame); |
| 448 |
| 449 message_loop_.RunAllPending(); |
| 450 } |
| 451 |
430 // Test the case that the decryptor fails to decrypt the encrypted buffer but | 452 // Test the case that the decryptor fails to decrypt the encrypted buffer but |
431 // cannot detect the decryption error and returns a corrupted buffer. | 453 // cannot detect the decryption error and returns a corrupted buffer. |
432 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) { | 454 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) { |
433 Initialize(); | 455 Initialize(); |
434 | 456 |
435 // Simulate decoding a single encrypted frame. | 457 // Simulate decoding a single encrypted frame. |
436 EXPECT_CALL(*demuxer_, Read(_)) | 458 EXPECT_CALL(*demuxer_, Read(_)) |
437 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); | 459 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); |
438 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _)) | 460 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _)) |
439 .WillRepeatedly(RunDecryptCB(Decryptor::kSuccess, | 461 .WillRepeatedly(RunDecryptCB(Decryptor::kSuccess, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 598 |
577 // Signal an aborted demuxer read. | 599 // Signal an aborted demuxer read. |
578 read_cb.Run(DemuxerStream::kAborted, NULL); | 600 read_cb.Run(DemuxerStream::kAborted, NULL); |
579 | 601 |
580 // Make sure we get a NULL video frame returned. | 602 // Make sure we get a NULL video frame returned. |
581 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); | 603 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); |
582 message_loop_.RunAllPending(); | 604 message_loop_.RunAllPending(); |
583 } | 605 } |
584 | 606 |
585 } // namespace media | 607 } // namespace media |
OLD | NEW |