Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 ACTION_P(RunClosure, closure) { | 40 ACTION_P(RunClosure, closure) { |
| 41 closure.Run(); | 41 closure.Run(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 MATCHER_P(HasTimestamp, ms, "") { | 44 MATCHER_P(HasTimestamp, ms, "") { |
| 45 *result_listener << "has timestamp " << arg->timestamp().InMilliseconds(); | 45 *result_listener << "has timestamp " << arg->timestamp().InMilliseconds(); |
| 46 return arg->timestamp().InMilliseconds() == ms; | 46 return arg->timestamp().InMilliseconds() == ms; |
| 47 } | 47 } |
| 48 | 48 |
| 49 class VideoRendererImplTest : public testing::TestWithParam<bool> { | 49 class VideoRendererImplTest |
| 50 : public testing::TestWithParam<bool /* new_video_renderer */> { | |
| 50 public: | 51 public: |
| 51 VideoRendererImplTest() | 52 VideoRendererImplTest() |
| 52 : tick_clock_(new base::SimpleTestTickClock()), | 53 : tick_clock_(new base::SimpleTestTickClock()), |
| 53 decoder_(new MockVideoDecoder()), | 54 decoder_(new MockVideoDecoder()), |
| 54 demuxer_stream_(DemuxerStream::VIDEO) { | 55 demuxer_stream_(DemuxerStream::VIDEO) { |
| 55 ScopedVector<VideoDecoder> decoders; | 56 ScopedVector<VideoDecoder> decoders; |
| 56 decoders.push_back(decoder_); | 57 decoders.push_back(decoder_); |
| 57 | 58 |
| 58 null_video_sink_.reset(new NullVideoSink( | 59 null_video_sink_.reset(new NullVideoSink( |
| 59 false, base::TimeDelta::FromSecondsD(1.0 / 60), | 60 false, base::TimeDelta::FromSecondsD(1.0 / 60), |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 Initialize(); | 481 Initialize(); |
| 481 QueueFrames("50 60 70 80 90"); | 482 QueueFrames("50 60 70 80 90"); |
| 482 | 483 |
| 483 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); | 484 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); |
| 484 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 485 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 485 StartPlayingFrom(61); | 486 StartPlayingFrom(61); |
| 486 Destroy(); | 487 Destroy(); |
| 487 } | 488 } |
| 488 | 489 |
| 489 TEST_P(VideoRendererImplTest, StartPlayingFrom_LowDelay) { | 490 TEST_P(VideoRendererImplTest, StartPlayingFrom_LowDelay) { |
| 490 // In low-delay mode only one frame is required to finish preroll. | 491 // In low-delay mode only one frame is required to finish preroll. But frames |
| 492 // prior to the start time will not be used. | |
| 491 InitializeWithLowDelay(true); | 493 InitializeWithLowDelay(true); |
| 492 QueueFrames("0"); | 494 QueueFrames("0 10"); |
| 493 | 495 |
| 496 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))); | |
| 494 // Expect some amount of have enough/nothing due to only requiring one frame. | 497 // Expect some amount of have enough/nothing due to only requiring one frame. |
| 495 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | |
| 496 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 498 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 497 .Times(AnyNumber()); | 499 .Times(AnyNumber()); |
| 498 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) | 500 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 499 .Times(AnyNumber()); | 501 .Times(AnyNumber()); |
|
xhwang
2015/07/21 20:30:26
When using the old rendering path, we declare HAVE
DaleCurtis
2015/07/21 21:16:50
I was planning to delete the old path this week as
| |
| 500 StartPlayingFrom(0); | 502 StartPlayingFrom(10); |
| 501 | 503 |
| 502 QueueFrames("10"); | 504 QueueFrames("20"); |
| 503 SatisfyPendingRead(); | 505 SatisfyPendingRead(); |
| 504 | 506 |
| 505 renderer_->OnTimeStateChanged(true); | 507 renderer_->OnTimeStateChanged(true); |
| 506 time_source_.StartTicking(); | 508 time_source_.StartTicking(); |
| 507 | 509 |
| 508 WaitableMessageLoopEvent event; | 510 WaitableMessageLoopEvent event; |
| 509 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) | 511 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20))) |
| 510 .WillOnce(RunClosure(event.GetClosure())); | 512 .WillOnce(RunClosure(event.GetClosure())); |
| 511 AdvanceTimeInMs(10); | 513 AdvanceTimeInMs(20); |
| 512 event.RunAndWait(); | 514 event.RunAndWait(); |
| 513 | 515 |
| 514 Destroy(); | 516 Destroy(); |
| 515 } | 517 } |
| 516 | 518 |
| 517 // Verify that a late decoder response doesn't break invariants in the renderer. | 519 // Verify that a late decoder response doesn't break invariants in the renderer. |
| 518 TEST_P(VideoRendererImplTest, DestroyDuringOutstandingRead) { | 520 TEST_P(VideoRendererImplTest, DestroyDuringOutstandingRead) { |
| 519 Initialize(); | 521 Initialize(); |
| 520 QueueFrames("0 10 20 30"); | 522 QueueFrames("0 10 20 30"); |
| 521 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 523 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 } | 748 } |
| 747 | 749 |
| 748 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, | 750 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, |
| 749 VideoRendererImplTest, | 751 VideoRendererImplTest, |
| 750 testing::Values(false)); | 752 testing::Values(false)); |
| 751 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, | 753 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, |
| 752 VideoRendererImplTest, | 754 VideoRendererImplTest, |
| 753 testing::Values(true)); | 755 testing::Values(true)); |
| 754 | 756 |
| 755 } // namespace media | 757 } // namespace media |
| OLD | NEW |