| Index: media/filters/video_renderer_impl_unittest.cc
|
| diff --git a/media/filters/video_renderer_impl_unittest.cc b/media/filters/video_renderer_impl_unittest.cc
|
| index 1df10624094b70c87c7b5e73156b8f0066ccfc8e..592090cfd638677914cc1de9734113d886cad3ab 100644
|
| --- a/media/filters/video_renderer_impl_unittest.cc
|
| +++ b/media/filters/video_renderer_impl_unittest.cc
|
| @@ -43,6 +43,10 @@
|
| return arg->timestamp().InMilliseconds() == ms;
|
| }
|
|
|
| +// Arbitrary value. Has to be larger to cover any timestamp value used in tests
|
| +// and kTimeToDeclareHaveNothing.
|
| +static const int kVideoDurationInMs = 10000;
|
| +
|
| class VideoRendererImplTest : public ::testing::Test {
|
| public:
|
| VideoRendererImplTest()
|
| @@ -67,9 +71,14 @@
|
| scoped_refptr<DecoderBuffer>(new DecoderBuffer(0))));
|
| EXPECT_CALL(statistics_cb_object_, OnStatistics(_))
|
| .Times(AnyNumber());
|
| + EXPECT_CALL(*this, OnTimeUpdate(_))
|
| + .Times(AnyNumber());
|
| }
|
|
|
| virtual ~VideoRendererImplTest() {}
|
| +
|
| + // Callbacks passed into Initialize().
|
| + MOCK_METHOD1(OnTimeUpdate, void(base::TimeDelta));
|
|
|
| void Initialize() {
|
| InitializeWithLowDelay(false);
|
| @@ -105,11 +114,15 @@
|
| status_cb,
|
| base::Bind(&MockStatisticsCB::OnStatistics,
|
| base::Unretained(&statistics_cb_object_)),
|
| + base::Bind(&VideoRendererImplTest::OnTimeUpdate,
|
| + base::Unretained(this)),
|
| base::Bind(&StrictMock<MockCB>::BufferingStateChange,
|
| base::Unretained(&mock_cb_)),
|
| ended_event_.GetClosure(),
|
| error_event_.GetPipelineStatusCB(),
|
| - base::Bind(&VideoRendererImplTest::GetTime, base::Unretained(this)));
|
| + base::Bind(&VideoRendererImplTest::GetTime, base::Unretained(this)),
|
| + base::Bind(&VideoRendererImplTest::GetDuration,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void StartPlaying() {
|
| @@ -244,6 +257,7 @@
|
| DCHECK_EQ(&message_loop_, base::MessageLoop::current());
|
| base::AutoLock l(lock_);
|
| time_ += base::TimeDelta::FromMilliseconds(time_ms);
|
| + DCHECK_LE(time_.InMicroseconds(), GetDuration().InMicroseconds());
|
| }
|
|
|
| protected:
|
| @@ -267,6 +281,10 @@
|
| return time_;
|
| }
|
|
|
| + base::TimeDelta GetDuration() {
|
| + return base::TimeDelta::FromMilliseconds(kVideoDurationInMs);
|
| + }
|
| +
|
| void DecodeRequested(const scoped_refptr<DecoderBuffer>& buffer,
|
| const VideoDecoder::DecodeCB& decode_cb) {
|
| DCHECK_EQ(&message_loop_, base::MessageLoop::current());
|
| @@ -372,6 +390,29 @@
|
| // We shouldn't expect a buffering state change since we never reached
|
| // BUFFERING_HAVE_ENOUGH.
|
| Flush();
|
| + Destroy();
|
| +}
|
| +
|
| +TEST_F(VideoRendererImplTest, EndOfStream_ClipDuration) {
|
| + Initialize();
|
| + QueueFrames("0");
|
| + EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)));
|
| + EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
|
| + StartPlaying();
|
| +
|
| + // Next frame has timestamp way past duration. Its timestamp will be adjusted
|
| + // to match the duration of the video.
|
| + QueueFrames(base::IntToString(kVideoDurationInMs + 1000));
|
| + SatisfyPendingRead();
|
| + WaitForPendingRead();
|
| +
|
| + // Queue the end of stream frame and wait for the last frame to be rendered.
|
| + SatisfyPendingReadWithEndOfStream();
|
| +
|
| + EXPECT_CALL(mock_cb_, Display(HasTimestamp(kVideoDurationInMs)));
|
| + AdvanceTimeInMs(kVideoDurationInMs);
|
| + WaitForEnded();
|
| +
|
| Destroy();
|
| }
|
|
|
|
|