Chromium Code Reviews| 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 f6540fade03931ee1a91dd3a0623991bf72f2ae7..9dffcecb21b56e2055f63ee19e21f99f584c9e5d 100644 |
| --- a/content/renderer/media/rtc_video_decoder_unittest.cc |
| +++ b/content/renderer/media/rtc_video_decoder_unittest.cc |
| @@ -21,13 +21,15 @@ using ::testing::_; |
| using ::testing::Invoke; |
| using ::testing::Return; |
| using ::testing::SaveArg; |
| +using ::testing::Values; |
| using ::testing::WithArgs; |
| namespace content { |
| // TODO(wuchengli): add MockSharedMemroy so more functions can be tested. |
| -class RTCVideoDecoderTest : public ::testing::Test, |
| - webrtc::DecodedImageCallback { |
| +class RTCVideoDecoderTest |
| + : public ::testing::TestWithParam<webrtc::VideoCodecType>, |
| + webrtc::DecodedImageCallback { |
| public: |
| RTCVideoDecoderTest() |
| : mock_gpu_factories_( |
| @@ -101,6 +103,14 @@ class RTCVideoDecoderTest : public ::testing::Test, |
| base::Unretained(rtc_decoder_.get()))); |
| } |
| + void NotifyError(media::VideoDecodeAccelerator::Error error) { |
| + DVLOG(2) << "NotifyError"; |
| + vda_task_runner_->PostTask( |
| + FROM_HERE, |
| + base::Bind(&RTCVideoDecoder::NotifyError, |
| + base::Unretained(rtc_decoder_.get()), error)); |
| + } |
| + |
| void RunUntilIdle() { |
| DVLOG(2) << "RunUntilIdle"; |
| vda_task_runner_->PostTask(FROM_HERE, |
| @@ -109,9 +119,21 @@ class RTCVideoDecoderTest : public ::testing::Test, |
| idle_waiter_.Wait(); |
| } |
| + void SetUpResetVDA() { |
| + mock_reset_vda_ = new media::MockVideoDecodeAccelerator; |
| + EXPECT_CALL(*mock_gpu_factories_.get(), DoCreateVideoDecodeAccelerator()) |
| + .WillRepeatedly(Return(mock_reset_vda_)); |
| + EXPECT_CALL(*mock_reset_vda_, Initialize(_, _)) |
| + .Times(1) |
| + .WillRepeatedly(Return(true)); |
| + EXPECT_CALL(*mock_reset_vda_, Reset()).Times(1); |
| + EXPECT_CALL(*mock_reset_vda_, Destroy()).Times(1); |
| + } |
| + |
| protected: |
| scoped_ptr<media::MockGpuVideoAcceleratorFactories> mock_gpu_factories_; |
| media::MockVideoDecodeAccelerator* mock_vda_; |
| + media::MockVideoDecodeAccelerator* mock_reset_vda_; |
| scoped_ptr<RTCVideoDecoder> rtc_decoder_; |
| webrtc::VideoCodec codec_; |
| base::Thread vda_thread_; |
| @@ -131,8 +153,9 @@ TEST_F(RTCVideoDecoderTest, CreateReturnsNullOnUnsupportedCodec) { |
| EXPECT_EQ(NULL, null_rtc_decoder.get()); |
| } |
| -TEST_F(RTCVideoDecoderTest, CreateAndInitSucceedsForH264Codec) { |
| - CreateDecoder(webrtc::kVideoCodecH264); |
| +TEST_P(RTCVideoDecoderTest, CreateAndInitSucceeds) { |
| + const webrtc::VideoCodecType codec_type = GetParam(); |
| + CreateDecoder(codec_type); |
| EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, rtc_decoder_->InitDecode(&codec_, 1)); |
| } |
| @@ -237,4 +260,35 @@ TEST_F(RTCVideoDecoderTest, IsFirstBufferAfterReset) { |
| rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); |
| } |
| + |
| +TEST_P(RTCVideoDecoderTest, DecodeResetsAfterError) { |
| + const webrtc::VideoCodecType codec_type = GetParam(); |
| + CreateDecoder(codec_type); |
| + Initialize(); |
| + |
| + const gfx::Size kInputFrameSize(16, 16); |
|
tommi (sloooow) - chröme
2016/03/19 09:25:49
This isn't a compile time constant (static), so sh
emircan
2016/03/21 19:25:10
I will put them as const static vars.
|
| + webrtc::EncodedImage input_image; |
| + input_image._completeFrame = true; |
| + input_image._encodedWidth = kInputFrameSize.width(); |
| + input_image._encodedHeight = kInputFrameSize.height(); |
| + input_image._frameType = webrtc::kVideoFrameDelta; |
| + EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| + rtc_decoder_->Decode(input_image, false, NULL, NULL, 0)); |
|
tommi (sloooow) - chröme
2016/03/19 09:25:49
Nit: nullptr
emircan
2016/03/21 19:25:10
Done, changing here and rest of the class.
|
| + RunUntilIdle(); |
| + |
| + // Notify the decoder about a platform error. |
| + NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| + RunUntilIdle(); |
| + |
| + // Expect decode call to reset decoder, and set up a new VDA to track it. |
| + SetUpResetVDA(); |
| + EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| + rtc_decoder_->Decode(input_image, false, NULL, NULL, 0)); |
| +} |
| + |
| +INSTANTIATE_TEST_CASE_P(, |
|
tommi (sloooow) - chröme
2016/03/19 09:25:50
Intentionally empty?
emircan
2016/03/21 19:25:10
Yes, but I guess it would be better to write out t
|
| + RTCVideoDecoderTest, |
| + Values(webrtc::kVideoCodecVP8, |
| + webrtc::kVideoCodecH264)); |
| + |
| } // content |