Chromium Code Reviews| Index: media/filters/ffmpeg_video_decoder_unittest.cc |
| diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc |
| index 6367ab248b73b4ac3aec8dd2750809f2a2c806b3..13d08e49197ef5e78d7a9818cecc1c5a0a211c5f 100644 |
| --- a/media/filters/ffmpeg_video_decoder_unittest.cc |
| +++ b/media/filters/ffmpeg_video_decoder_unittest.cc |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include <deque> |
| +#include <string> |
| #include "base/bind.h" |
| #include "base/message_loop.h" |
| @@ -37,9 +38,17 @@ static const gfx::Rect kVisibleRect(320, 240); |
| static const gfx::Size kNaturalSize(522, 288); |
| static const AVRational kFrameRate = { 100, 1 }; |
| static const AVRational kAspectRatio = { 1, 1 }; |
| -static const unsigned char kRawKey[] = "A wonderful key!"; |
| -static const unsigned char kWrongKey[] = "I'm a wrong key."; |
| -static const unsigned char kKeyId[] = "A normal key ID."; |
| +static const uint8 kRawKey[] = { |
|
ddorwin
2012/06/11 21:02:40
What is "raw key"? Should it by kRightKey like the
xhwang
2012/06/12 19:01:15
Done.
|
| + // A wonderful key! |
| + 0x41, 0x20, 0x77, 0x6f, 0x6e, 0x64, 0x65, 0x72, |
|
scherkus (not reviewing)
2012/06/12 03:15:58
2 spaace indent
xhwang
2012/06/12 19:01:15
Done.
|
| + 0x66, 0x75, 0x6c, 0x20, 0x6b, 0x65, 0x79, 0x21 |
| +}; |
| +static const uint8 kWrongKey[] = { |
| + // I'm a wrong key. |
| + 0x49, 0x27, 0x6d, 0x20, 0x61, 0x20, 0x77, 0x72, |
| + 0x6f, 0x6e, 0x67, 0x20, 0x6b, 0x65, 0x79, 0x2e |
| +}; |
| +static const uint8 kKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 }; |
| ACTION_P(ReturnBuffer, buffer) { |
| arg0.Run(buffer); |
| @@ -48,7 +57,8 @@ ACTION_P(ReturnBuffer, buffer) { |
| class FFmpegVideoDecoderTest : public testing::Test { |
| public: |
| FFmpegVideoDecoderTest() |
| - : decryptor_(new AesDecryptor()), |
| + : decryptor_client_(new MockDecryptorClient()), |
| + decryptor_(new AesDecryptor()), |
| decoder_(new FFmpegVideoDecoder(base::Bind(&Identity<MessageLoop*>, |
| &message_loop_))), |
| demuxer_(new StrictMock<MockDemuxerStream>()), |
| @@ -56,6 +66,7 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| base::Unretained(this))) { |
| CHECK(FFmpegGlue::GetInstance()); |
| + decryptor_->Init(decryptor_client_.get()); |
| decoder_->set_decryptor(decryptor_.get()); |
| // Initialize various test buffers. |
| @@ -197,6 +208,7 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| scoped_refptr<VideoFrame>)); |
| MessageLoop message_loop_; |
| + scoped_ptr<MockDecryptorClient> decryptor_client_; |
|
ddorwin
2012/06/11 21:02:40
Is there a reason it's not just a member like in A
xhwang
2012/06/12 19:01:15
Done.
|
| scoped_ptr<AesDecryptor> decryptor_; |
| scoped_refptr<FFmpegVideoDecoder> decoder_; |
| scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
| @@ -375,12 +387,13 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerHeight) { |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) { |
| Initialize(); |
| - decryptor_->AddKey(kKeyId, arraysize(kKeyId) - 1, |
| - kRawKey, arraysize(kRawKey) - 1); |
| + EXPECT_CALL(*decryptor_client_, KeyAdded("", "")); |
| + decryptor_->AddKey("", kRawKey, arraysize(kRawKey), |
|
ddorwin
2012/06/11 21:02:40
should we use real key system and session ID strin
xhwang
2012/06/12 19:01:15
Done.
|
| + kKeyId, arraysize(kKeyId), ""); |
| // Simulate decoding a single encrypted frame. |
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>( |
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1))); |
| + new DecryptConfig(kKeyId, arraysize(kKeyId)))); |
| VideoDecoder::DecoderStatus status; |
| scoped_refptr<VideoFrame> video_frame; |
| DecodeSingleFrame(encrypted_i_frame_buffer_, &status, &video_frame); |
| @@ -396,7 +409,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) { |
| // Simulate decoding a single encrypted frame. |
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>( |
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1))); |
| + new DecryptConfig(kKeyId, arraysize(kKeyId)))); |
| EXPECT_CALL(*demuxer_, Read(_)) |
| .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); |
| @@ -415,11 +428,12 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) { |
| // Test decrypting an encrypted frame with a wrong key. |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) { |
| Initialize(); |
| - decryptor_->AddKey(kKeyId, arraysize(kKeyId) - 1, |
| - kWrongKey, arraysize(kWrongKey) - 1); |
| + EXPECT_CALL(*decryptor_client_, KeyAdded("", "")); |
| + decryptor_->AddKey("", kWrongKey, arraysize(kWrongKey), |
| + kKeyId, arraysize(kKeyId), ""); |
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>( |
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1))); |
| + new DecryptConfig(kKeyId, arraysize(kKeyId)))); |
| EXPECT_CALL(*demuxer_, Read(_)) |
| .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_)); |