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

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

Issue 10822026: Implement "Key Presence" step in "Encrypted Block Encounted" algorithm in EME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | webkit/media/crypto/ppapi_decryptor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <deque> 5 #include <deque>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // error. 472 // error.
473 VideoDecoder::DecoderStatus status; 473 VideoDecoder::DecoderStatus status;
474 scoped_refptr<VideoFrame> video_frame; 474 scoped_refptr<VideoFrame> video_frame;
475 Read(&status, &video_frame); 475 Read(&status, &video_frame);
476 EXPECT_EQ(VideoDecoder::kDecryptError, status); 476 EXPECT_EQ(VideoDecoder::kDecryptError, status);
477 EXPECT_FALSE(video_frame); 477 EXPECT_FALSE(video_frame);
478 478
479 message_loop_.RunAllPending(); 479 message_loop_.RunAllPending();
480 } 480 }
481 481
482 // Test the case that the decryptor has no key to decrypt the encrypted buffer.
483 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoDecryptionKey) {
484 Initialize();
485
486 // Simulate decoding a single encrypted frame.
487 EXPECT_CALL(*demuxer_, Read(_))
488 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
489 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _))
490 .WillRepeatedly(RunDecryptCB(Decryptor::kNoKey,
491 scoped_refptr<media::DecoderBuffer>()));
492
493 // Our read should still get satisfied with end of stream frame during an
494 // error.
495 VideoDecoder::DecoderStatus status;
496 scoped_refptr<VideoFrame> video_frame;
497 Read(&status, &video_frame);
498 EXPECT_EQ(VideoDecoder::kDecryptError, status);
499 EXPECT_FALSE(video_frame);
500
501 message_loop_.RunAllPending();
502 }
503
482 // Test the case that the decryptor fails to decrypt the encrypted buffer but 504 // Test the case that the decryptor fails to decrypt the encrypted buffer but
483 // cannot detect the decryption error and returns a corrupted buffer. 505 // cannot detect the decryption error and returns a corrupted buffer.
484 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) { 506 TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) {
485 Initialize(); 507 Initialize();
486 508
487 // Simulate decoding a single encrypted frame. 509 // Simulate decoding a single encrypted frame.
488 EXPECT_CALL(*demuxer_, Read(_)) 510 EXPECT_CALL(*demuxer_, Read(_))
489 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); 511 .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
490 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _)) 512 EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _))
491 .WillRepeatedly(RunDecryptCB(Decryptor::kSuccess, 513 .WillRepeatedly(RunDecryptCB(Decryptor::kSuccess,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 650
629 // Signal an aborted demuxer read. 651 // Signal an aborted demuxer read.
630 read_cb.Run(DemuxerStream::kAborted, NULL); 652 read_cb.Run(DemuxerStream::kAborted, NULL);
631 653
632 // Make sure we get a NULL video frame returned. 654 // Make sure we get a NULL video frame returned.
633 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull())); 655 EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
634 message_loop_.RunAllPending(); 656 message_loop_.RunAllPending();
635 } 657 }
636 658
637 } // namespace media 659 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | webkit/media/crypto/ppapi_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698