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

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.cc

Issue 8417019: Simplify VideoDecodeEngine interface by making everything synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup++ Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
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 e0d2ca2bc87b3505ef6466c8468b2c0e90ec33b2..42053473f7a2aa932565a5f01cf4faae5305cd36 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -103,35 +103,6 @@ class FFmpegVideoDecoderTest : public testing::Test {
message_loop_.RunAllPending();
}
- // Sets up expectations for FFmpegVideoDecodeEngine to preroll after
- // receiving a Seek(). The adjustment on Read() is due to the decoder
- // delaying frame output.
- //
- // TODO(scherkus): this is madness -- there's no reason for a decoder to
- // assume it should preroll anything.
- void ExpectSeekPreroll() {
- EXPECT_CALL(*demuxer_, Read(_))
- .Times(Limits::kMaxVideoFrames + 1)
- .WillRepeatedly(ReturnBuffer(i_frame_buffer_));
- EXPECT_CALL(statistics_callback_, OnStatistics(_))
- .Times(Limits::kMaxVideoFrames);
- EXPECT_CALL(*this, ConsumeVideoFrame(_))
- .Times(Limits::kMaxVideoFrames);
- }
-
- // Sets up expectations for FFmpegVideoDecodeEngine to preroll after
- // receiving a Seek() but for the end of stream case.
- //
- // TODO(scherkus): this is madness -- there's no reason for a decoder to
- // assume it should preroll anything.
- void ExpectSeekPrerollEndOfStream() {
- EXPECT_CALL(*demuxer_, Read(_))
- .Times(Limits::kMaxVideoFrames)
- .WillRepeatedly(ReturnBuffer(end_of_stream_buffer_));
- EXPECT_CALL(statistics_callback_, OnStatistics(_))
- .Times(Limits::kMaxVideoFrames);
- }
-
// Sets up expectations and actions to put FFmpegVideoDecoder in an active
// decoding state.
void EnterDecodingState() {
@@ -145,8 +116,6 @@ class FFmpegVideoDecoderTest : public testing::Test {
// Sets up expectations and actions to put FFmpegVideoDecoder in an end
// of stream state.
void EnterEndOfStreamState() {
- EXPECT_CALL(statistics_callback_, OnStatistics(_));
-
scoped_refptr<VideoFrame> video_frame;
CallProduceVideoFrame(&video_frame);
ASSERT_TRUE(video_frame);
@@ -171,7 +140,9 @@ class FFmpegVideoDecoderTest : public testing::Test {
// Decodes |i_frame_buffer_| and then decodes the data contained in
// the file named |test_file_name|. This function expects both buffers
// to decode to frames that are the same size.
- void DecodeIFrameThenTestFile(const std::string& test_file_name) {
+ void DecodeIFrameThenTestFile(const std::string& test_file_name,
+ size_t expected_width,
+ size_t expected_height) {
Initialize();
scoped_refptr<VideoFrame> video_frame_a;
@@ -191,13 +162,13 @@ class FFmpegVideoDecoderTest : public testing::Test {
CallProduceVideoFrame(&video_frame_a);
CallProduceVideoFrame(&video_frame_b);
- size_t expected_width = static_cast<size_t>(kVisibleRect.width());
- size_t expected_height = static_cast<size_t>(kVisibleRect.height());
+ size_t original_width = static_cast<size_t>(kVisibleRect.width());
+ size_t original_height = static_cast<size_t>(kVisibleRect.height());
ASSERT_TRUE(video_frame_a);
ASSERT_TRUE(video_frame_b);
- EXPECT_EQ(expected_width, video_frame_a->width());
- EXPECT_EQ(expected_height, video_frame_a->height());
+ EXPECT_EQ(original_width, video_frame_a->width());
+ EXPECT_EQ(original_height, video_frame_a->height());
EXPECT_EQ(expected_width, video_frame_b->width());
EXPECT_EQ(expected_height, video_frame_b->height());
}
@@ -323,7 +294,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) {
.WillRepeatedly(ReturnBuffer(end_of_stream_buffer_));
EXPECT_CALL(statistics_callback_, OnStatistics(_))
- .Times(3);
+ .Times(2);
CallProduceVideoFrame(&video_frame_a);
CallProduceVideoFrame(&video_frame_b);
@@ -345,11 +316,17 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeError) {
.WillOnce(ReturnBuffer(corrupt_i_frame_buffer_))
.WillRepeatedly(ReturnBuffer(i_frame_buffer_));
- scoped_refptr<VideoFrame> video_frame;
- CallProduceVideoFrame(&video_frame);
+ // The error is only raised on the second decode attempt, so we expect at
+ // least one successful decode but we don't expect ConsumeVideoFrame() to be
+ // executed as an error is raised instead.
+ EXPECT_CALL(statistics_callback_, OnStatistics(_));
+ EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECODE));
+
+ decoder_->ProduceVideoFrame(VideoFrame::CreateFrame(
+ VideoFrame::YV12, kVisibleRect.width(), kVisibleRect.height(),
+ kNoTimestamp, kNoTimestamp));
- // XXX: SERIOUSLY? This seems broken to call NULL on decoder error.
- EXPECT_FALSE(video_frame);
+ message_loop_.RunAllPending();
}
// Multi-threaded decoders have different behavior than single-threaded
@@ -368,29 +345,29 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeErrorAtEndOfStream) {
}
// Decode |i_frame_buffer_| and then a frame with a larger width and verify
-// the output size didn't change.
+// the output size was adjusted.
// TODO(acolwell): Fix InvalidRead detected by Valgrind
//TEST_F(FFmpegVideoDecoderTest, DecodeFrame_LargerWidth) {
-// DecodeIFrameThenTestFile("vp8-I-frame-640x240");
+// DecodeIFrameThenTestFile("vp8-I-frame-640x240", 640, 240);
//}
// Decode |i_frame_buffer_| and then a frame with a smaller width and verify
-// the output size didn't change.
+// the output size was adjusted.
TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerWidth) {
- DecodeIFrameThenTestFile("vp8-I-frame-160x240");
+ DecodeIFrameThenTestFile("vp8-I-frame-160x240", 160, 240);
}
// Decode |i_frame_buffer_| and then a frame with a larger height and verify
-// the output size didn't change.
+// the output size was adjusted.
// TODO(acolwell): Fix InvalidRead detected by Valgrind
//TEST_F(FFmpegVideoDecoderTest, DecodeFrame_LargerHeight) {
-// DecodeIFrameThenTestFile("vp8-I-frame-320x480");
+// DecodeIFrameThenTestFile("vp8-I-frame-320x480", 320, 480);
//}
// Decode |i_frame_buffer_| and then a frame with a smaller height and verify
-// the output size didn't change.
+// the output size was adjusted.
TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerHeight) {
- DecodeIFrameThenTestFile("vp8-I-frame-320x120");
+ DecodeIFrameThenTestFile("vp8-I-frame-320x120", 320, 120);
}
// Test pausing when decoder has initialized but not decoded.
@@ -428,9 +405,7 @@ TEST_F(FFmpegVideoDecoderTest, Flush_Decoding) {
}
// Test flushing when decoder has hit end of stream.
-//
-// TODO(scherkus): test is disabled until we clean up buffer recycling.
-TEST_F(FFmpegVideoDecoderTest, DISABLED_Flush_EndOfStream) {
+TEST_F(FFmpegVideoDecoderTest, Flush_EndOfStream) {
Initialize();
EnterDecodingState();
EnterEndOfStreamState();
@@ -440,7 +415,6 @@ TEST_F(FFmpegVideoDecoderTest, DISABLED_Flush_EndOfStream) {
// Test seeking when decoder has initialized but not decoded.
TEST_F(FFmpegVideoDecoderTest, Seek_Initialized) {
Initialize();
- ExpectSeekPreroll();
Seek(1000);
}
@@ -448,7 +422,6 @@ TEST_F(FFmpegVideoDecoderTest, Seek_Initialized) {
TEST_F(FFmpegVideoDecoderTest, Seek_Decoding) {
Initialize();
EnterDecodingState();
- ExpectSeekPreroll();
Seek(1000);
}
@@ -457,7 +430,6 @@ TEST_F(FFmpegVideoDecoderTest, Seek_EndOfStream) {
Initialize();
EnterDecodingState();
EnterEndOfStreamState();
- ExpectSeekPrerollEndOfStream();
Seek(1000);
}

Powered by Google App Engine
This is Rietveld 408576698