Index: content/renderer/media/rtc_video_decoder_unittest.cc |
diff --git a/content/renderer/media/rtc_video_decoder_unittest.cc b/content/renderer/media/rtc_video_decoder_unittest.cc |
index 441d9c87a87e6202144ed12e3ef0c903c5c11320..6bfe588fe60d5e2f7e8a70406ee92d0bbd907822 100644 |
--- a/content/renderer/media/rtc_video_decoder_unittest.cc |
+++ b/content/renderer/media/rtc_video_decoder_unittest.cc |
@@ -222,6 +222,11 @@ class RTCVideoDecoderTest : public testing::Test { |
base::Unretained(&statistics_cb_)); |
} |
+ void RenderFrame() { |
+ NullVideoFrame video_frame; |
+ decoder_->RenderFrame(&video_frame); |
+ } |
+ |
MOCK_METHOD2(FrameReady, void(media::VideoDecoder::DecoderStatus status, |
const scoped_refptr<media::VideoFrame>&)); |
@@ -241,19 +246,31 @@ const int RTCVideoDecoderTest::kWidth = 640; |
const int RTCVideoDecoderTest::kHeight = 480; |
const PipelineStatistics RTCVideoDecoderTest::kStatistics; |
+MATCHER_P2(HasSize, width, height, "") { |
+ EXPECT_EQ(arg->data_size().width(), width); |
+ EXPECT_EQ(arg->data_size().height(), height); |
+ EXPECT_EQ(arg->natural_size().width(), width); |
+ EXPECT_EQ(arg->natural_size().height(), height); |
+ return (arg->data_size().width() == width) && |
+ (arg->data_size().height() == height) && |
+ (arg->natural_size().width() == width) && |
+ (arg->natural_size().height() == height); |
+} |
+ |
TEST_F(RTCVideoDecoderTest, Initialize_Successful) { |
InitializeDecoderSuccessfully(); |
- // Test that the output media format is an uncompressed video surface that |
- // matches the dimensions specified by RTC. |
- EXPECT_EQ(kWidth, decoder_->natural_size().width()); |
- EXPECT_EQ(kHeight, decoder_->natural_size().height()); |
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, |
+ HasSize(kWidth, kHeight))); |
+ decoder_->Read(read_cb_); |
+ RenderFrame(); |
} |
TEST_F(RTCVideoDecoderTest, DoReset) { |
InitializeDecoderSuccessfully(); |
- EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _)); |
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, |
+ scoped_refptr<media::VideoFrame>())); |
decoder_->Read(read_cb_); |
decoder_->Reset(media::NewExpectedClosure()); |
@@ -264,11 +281,8 @@ TEST_F(RTCVideoDecoderTest, DoReset) { |
TEST_F(RTCVideoDecoderTest, DoRenderFrame) { |
InitializeDecoderSuccessfully(); |
- NullVideoFrame video_frame; |
- |
- for (size_t i = 0; i < media::limits::kMaxVideoFrames; ++i) { |
- decoder_->RenderFrame(&video_frame); |
- } |
+ for (size_t i = 0; i < media::limits::kMaxVideoFrames; ++i) |
+ RenderFrame(); |
message_loop_.RunAllPending(); |
EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); |
@@ -277,15 +291,20 @@ TEST_F(RTCVideoDecoderTest, DoRenderFrame) { |
TEST_F(RTCVideoDecoderTest, DoSetSize) { |
InitializeDecoderSuccessfully(); |
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, |
+ HasSize(kWidth, kHeight))); |
+ decoder_->Read(read_cb_); |
+ RenderFrame(); |
+ message_loop_.RunAllPending(); |
+ |
int new_width = kWidth * 2; |
int new_height = kHeight * 2; |
- gfx::Size new_natural_size(new_width, new_height); |
- |
decoder_->SetSize(new_width, new_height); |
- EXPECT_EQ(new_width, decoder_->natural_size().width()); |
- EXPECT_EQ(new_height, decoder_->natural_size().height()); |
- |
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, |
+ HasSize(new_width, new_height))); |
+ decoder_->Read(read_cb_); |
+ RenderFrame(); |
message_loop_.RunAllPending(); |
} |
@@ -294,7 +313,8 @@ TEST_F(RTCVideoDecoderTest, ReadAndShutdown) { |
// teardown the pipeline) even when there's no input frame. |
InitializeDecoderSuccessfully(); |
- EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, _)).Times(2); |
+ EXPECT_CALL(*this, FrameReady(media::VideoDecoder::kOk, |
+ scoped_refptr<media::VideoFrame>())).Times(2); |
decoder_->Read(read_cb_); |
EXPECT_FALSE(decoder_->shutting_down_); |
decoder_->PrepareForShutdownHack(); |