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 be32dac8d8c92589d8ba47aa3679e6bf119ee155..113bb0cf4deb61bef85522f3b84e54300674278f 100644 |
| --- a/media/filters/ffmpeg_video_decoder_unittest.cc |
| +++ b/media/filters/ffmpeg_video_decoder_unittest.cc |
| @@ -88,15 +88,21 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240"); |
| corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame"); |
| encrypted_i_frame_buffer_ = CreateFakeEncryptedBuffer(); |
| - |
| - config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| - kVideoFormat, kCodedSize, kVisibleRect, kNaturalSize, |
| - NULL, 0, true); |
| } |
| virtual ~FFmpegVideoDecoderTest() {} |
| void Initialize() { |
| + config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
| + kCodedSize, kVisibleRect, kNaturalSize, |
| + NULL, 0, false, true); |
| + InitializeWithConfig(config_); |
| + } |
| + |
| + void InitializeWithEncryptedConfig() { |
| + config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
| + kCodedSize, kVisibleRect, kNaturalSize, |
| + NULL, 0, true, true); |
| InitializeWithConfig(config_); |
| } |
| @@ -133,7 +139,7 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| scoped_refptr<VideoFrame> video_frame; |
| DecodeSingleFrame(i_frame_buffer_, &status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
|
xhwang
2012/09/17 19:42:25
Changed the order here since otherwise it gives fu
|
| ASSERT_TRUE(video_frame); |
| EXPECT_FALSE(video_frame->IsEndOfStream()); |
| } |
| @@ -144,7 +150,7 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| scoped_refptr<VideoFrame> video_frame; |
| VideoDecoder::Status status; |
| Read(&status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
| ASSERT_TRUE(video_frame); |
| EXPECT_TRUE(video_frame->IsEndOfStream()); |
| } |
| @@ -192,8 +198,8 @@ class FFmpegVideoDecoderTest : public testing::Test { |
| Read(&status_b, &video_frame_b); |
| gfx::Size original_size = kVisibleRect.size(); |
| - EXPECT_EQ(status_a, VideoDecoder::kOk); |
| - EXPECT_EQ(status_b, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status_a); |
| + EXPECT_EQ(VideoDecoder::kOk, status_b); |
| ASSERT_TRUE(video_frame_a); |
| ASSERT_TRUE(video_frame_b); |
| EXPECT_EQ(original_size.width(), video_frame_a->data_size().width()); |
| @@ -247,7 +253,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedDecoder) { |
| VideoDecoderConfig config(kUnknownVideoCodec, VIDEO_CODEC_PROFILE_UNKNOWN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, kNaturalSize, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -256,7 +262,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedPixelFormat) { |
| VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| VideoFrame::INVALID, |
| kCodedSize, kVisibleRect, kNaturalSize, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -265,7 +271,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_OpenDecoderFails) { |
| VideoDecoderConfig config(kCodecTheora, VIDEO_CODEC_PROFILE_UNKNOWN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, kNaturalSize, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -274,7 +280,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorZero) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -283,7 +289,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorZero) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -292,7 +298,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorNegative) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -301,7 +307,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorNegative) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -312,7 +318,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorTooLarge) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -322,7 +328,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorTooLarge) { |
| VideoDecoderConfig config(kCodecVP8, VP8PROFILE_MAIN, |
| kVideoFormat, |
| kCodedSize, kVisibleRect, natural_size, |
| - NULL, 0); |
| + NULL, 0, false); |
| InitializeWithConfigAndStatus(config, PIPELINE_ERROR_DECODE); |
| } |
| @@ -334,7 +340,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_Normal) { |
| scoped_refptr<VideoFrame> video_frame; |
| DecodeSingleFrame(i_frame_buffer_, &status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
| ASSERT_TRUE(video_frame); |
| EXPECT_FALSE(video_frame->IsEndOfStream()); |
| } |
| @@ -366,9 +372,9 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) { |
| Read(&status_b, &video_frame_b); |
| Read(&status_c, &video_frame_c); |
| - EXPECT_EQ(status_a, VideoDecoder::kOk); |
| - EXPECT_EQ(status_b, VideoDecoder::kOk); |
| - EXPECT_EQ(status_c, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status_a); |
| + EXPECT_EQ(VideoDecoder::kOk, status_b); |
| + EXPECT_EQ(VideoDecoder::kOk, status_c); |
| ASSERT_TRUE(video_frame_a); |
| ASSERT_TRUE(video_frame_b); |
| @@ -396,7 +402,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeError) { |
| VideoDecoder::Status status; |
| scoped_refptr<VideoFrame> video_frame; |
| Read(&status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kDecodeError); |
| + EXPECT_EQ(VideoDecoder::kDecodeError, status); |
| EXPECT_FALSE(video_frame); |
| message_loop_.RunAllPending(); |
| @@ -414,7 +420,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeErrorAtEndOfStream) { |
| scoped_refptr<VideoFrame> video_frame; |
| DecodeSingleFrame(corrupt_i_frame_buffer_, &status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
| ASSERT_TRUE(video_frame); |
| EXPECT_TRUE(video_frame->IsEndOfStream()); |
| } |
| @@ -444,7 +450,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerHeight) { |
| } |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) { |
| - Initialize(); |
| + InitializeWithEncryptedConfig(); |
| // Simulate decoding a single encrypted frame. |
| EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _)) |
| @@ -454,14 +460,14 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) { |
| scoped_refptr<VideoFrame> video_frame; |
| DecodeSingleFrame(encrypted_i_frame_buffer_, &status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
| ASSERT_TRUE(video_frame); |
| EXPECT_FALSE(video_frame->IsEndOfStream()); |
| } |
| // Test the case that the decryptor fails to decrypt the encrypted buffer. |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_DecryptError) { |
| - Initialize(); |
| + InitializeWithEncryptedConfig(); |
| // Simulate decoding a single encrypted frame. |
| EXPECT_CALL(*demuxer_, Read(_)) |
| @@ -483,7 +489,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_DecryptError) { |
| // Test the case that the decryptor has no key to decrypt the encrypted buffer. |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoDecryptionKey) { |
| - Initialize(); |
| + InitializeWithEncryptedConfig(); |
| // Simulate decoding a single encrypted frame. |
| EXPECT_CALL(*demuxer_, Read(_)) |
| @@ -506,7 +512,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoDecryptionKey) { |
| // Test the case that the decryptor fails to decrypt the encrypted buffer but |
| // cannot detect the decryption error and returns a corrupted buffer. |
| TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) { |
| - Initialize(); |
| + InitializeWithEncryptedConfig(); |
| // Simulate decoding a single encrypted frame. |
| EXPECT_CALL(*demuxer_, Read(_)) |
| @@ -628,7 +634,7 @@ TEST_F(FFmpegVideoDecoderTest, AbortPendingRead) { |
| Read(&status, &video_frame); |
| - EXPECT_EQ(status, VideoDecoder::kOk); |
| + EXPECT_EQ(VideoDecoder::kOk, status); |
| EXPECT_FALSE(video_frame); |
| } |