Chromium Code Reviews| Index: media/filters/fake_video_decoder_unittest.cc |
| diff --git a/media/filters/fake_video_decoder_unittest.cc b/media/filters/fake_video_decoder_unittest.cc |
| index d05a31f980bab78b160393712f09436714098ca6..24466e5cb3928758cc29a1791516f07ec380980e 100644 |
| --- a/media/filters/fake_video_decoder_unittest.cc |
| +++ b/media/filters/fake_video_decoder_unittest.cc |
| @@ -22,10 +22,10 @@ class FakeVideoDecoderTest : public testing::Test, |
| public testing::WithParamInterface<int> { |
| public: |
| FakeVideoDecoderTest() |
| - : decoder_(new FakeVideoDecoder(kDecodingDelay, false, GetParam())), |
| + : decoder_(new FakeVideoDecoder(kDecodingDelay, GetParam())), |
| num_input_buffers_(0), |
| num_decoded_frames_(0), |
| - last_decode_status_(VideoDecoder::kNotEnoughData), |
| + last_decode_status_(VideoDecoder::kOk), |
| pending_decode_requests_(0), |
| is_reset_pending_(false) {} |
| @@ -34,7 +34,9 @@ class FakeVideoDecoderTest : public testing::Test, |
| } |
| void InitializeWithConfig(const VideoDecoderConfig& config) { |
| - decoder_->Initialize(config, false, NewExpectedStatusCB(PIPELINE_OK)); |
| + decoder_->Initialize( |
| + config, false, NewExpectedStatusCB(PIPELINE_OK), |
| + base::Bind(&FakeVideoDecoderTest::FrameReady, base::Unretained(this))); |
| message_loop_.RunUntilIdle(); |
| current_config_ = config; |
| } |
| @@ -53,16 +55,17 @@ class FakeVideoDecoderTest : public testing::Test, |
| message_loop_.RunUntilIdle(); |
| } |
| - // Callback for VideoDecoder::Read(). |
| - void FrameReady(VideoDecoder::Status status, |
| - const scoped_refptr<VideoFrame>& frame) { |
| + // Callback for VideoDecoder::Decode(). |
| + void DecodeDone(VideoDecoder::Status status) { |
| + LOG(ERROR) << "DONE"; |
| DCHECK_GT(pending_decode_requests_, 0); |
| - |
| --pending_decode_requests_; |
| last_decode_status_ = status; |
| - last_decoded_frame_ = frame; |
| + } |
| - if (frame && !frame->end_of_stream()) |
| + void FrameReady(const scoped_refptr<VideoFrame>& frame) { |
| + last_decoded_frame_ = frame; |
| + if (!frame->end_of_stream()) |
| num_decoded_frames_++; |
| } |
| @@ -87,7 +90,7 @@ class FakeVideoDecoderTest : public testing::Test, |
| break; |
| case NOT_ENOUGH_DATA: |
| EXPECT_EQ(0, pending_decode_requests_); |
| - ASSERT_EQ(VideoDecoder::kNotEnoughData, last_decode_status_); |
| + ASSERT_EQ(VideoDecoder::kOk, last_decode_status_); |
| ASSERT_FALSE(last_decoded_frame_); |
| break; |
| case ABORTED: |
| @@ -107,6 +110,7 @@ class FakeVideoDecoderTest : public testing::Test, |
| void Decode() { |
| scoped_refptr<DecoderBuffer> buffer; |
| + LOG(ERROR) << "Dec " << num_input_buffers_; |
|
xhwang
2014/06/05 21:53:50
remove?
Sergey Ulanov
2014/06/06 22:49:40
Done.
|
| if (num_input_buffers_ < kTotalBuffers) { |
| buffer = CreateFakeVideoBufferForTest( |
| current_config_, |
| @@ -121,15 +125,15 @@ class FakeVideoDecoderTest : public testing::Test, |
| decoder_->Decode( |
| buffer, |
| - base::Bind(&FakeVideoDecoderTest::FrameReady, base::Unretained(this))); |
| + base::Bind(&FakeVideoDecoderTest::DecodeDone, base::Unretained(this))); |
| message_loop_.RunUntilIdle(); |
| } |
| void ReadOneFrame() { |
| + last_decoded_frame_ = NULL; |
| do { |
| Decode(); |
| - } while (last_decode_status_ == VideoDecoder::kNotEnoughData && |
| - pending_decode_requests_ == 0); |
| + } while (!last_decoded_frame_ && pending_decode_requests_ == 0); |
| } |
| void ReadUntilEOS() { |
| @@ -142,6 +146,7 @@ class FakeVideoDecoderTest : public testing::Test, |
| // Pass the initial NOT_ENOUGH_DATA stage. |
| ReadOneFrame(); |
| decoder_->HoldDecode(); |
| + LOG(ERROR) << "WTF"; |
|
xhwang
2014/06/05 21:53:50
remove :)
Sergey Ulanov
2014/06/06 22:49:40
Done.
|
| ReadOneFrame(); |
| ExpectReadResult(PENDING); |
| } |
| @@ -248,7 +253,7 @@ TEST_P(FakeVideoDecoderTest, Read_DecodingDelay) { |
| } |
| TEST_P(FakeVideoDecoderTest, Read_ZeroDelay) { |
| - decoder_.reset(new FakeVideoDecoder(0, false, 1)); |
| + decoder_.reset(new FakeVideoDecoder(0, 1)); |
| Initialize(); |
| while (num_input_buffers_ < kTotalBuffers) { |
| @@ -263,11 +268,13 @@ TEST_P(FakeVideoDecoderTest, Read_Pending_NotEnoughData) { |
| ReadOneFrame(); |
| ExpectReadResult(PENDING); |
| SatisfyReadAndExpect(NOT_ENOUGH_DATA); |
| + |
| + // Verify that FrameReady() hasn't been called. |
| + EXPECT_FALSE(last_decoded_frame_); |
| } |
| TEST_P(FakeVideoDecoderTest, Read_Pending_OK) { |
| Initialize(); |
| - ReadOneFrame(); |
| EnterPendingReadState(); |
| SatisfyReadAndExpect(OK); |
| } |
| @@ -278,14 +285,13 @@ TEST_P(FakeVideoDecoderTest, Read_Parallel) { |
| return; |
| Initialize(); |
| - ReadOneFrame(); |
| decoder_->HoldDecode(); |
| for (int i = 0; i < max_decode_requests; ++i) { |
| ReadOneFrame(); |
| ExpectReadResult(PENDING); |
| } |
| EXPECT_EQ(max_decode_requests, pending_decode_requests_); |
| - SatisfyReadAndExpect(OK); |
| + SatisfyReadAndExpect(NOT_ENOUGH_DATA); |
|
xhwang
2014/06/05 21:53:50
hmm, if max_decode_requests > decoding_delay, shou
Sergey Ulanov
2014/06/06 22:49:40
Yes, but we didn't have tests with max_decode_requ
|
| } |
| TEST_P(FakeVideoDecoderTest, ReadWithHold_DecodingDelay) { |
| @@ -381,16 +387,4 @@ TEST_P(FakeVideoDecoderTest, Stop_DuringPendingReadAndPendingReset) { |
| Stop(); |
| } |
| -TEST_P(FakeVideoDecoderTest, GetDecodeOutput) { |
| - decoder_.reset(new FakeVideoDecoder(kDecodingDelay, true, 1)); |
| - Initialize(); |
| - |
| - while (num_input_buffers_ < kTotalBuffers) { |
| - ReadOneFrame(); |
| - while (decoder_->GetDecodeOutput()) |
| - ++num_decoded_frames_; |
| - EXPECT_EQ(num_input_buffers_, num_decoded_frames_); |
| - } |
| -} |
| - |
| } // namespace media |