| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 297 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 298 .WillOnce(RunClosure(event.GetClosure())); | 298 .WillOnce(RunClosure(event.GetClosure())); |
| 299 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 299 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 300 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 300 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 301 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 301 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 302 StartPlayingFrom(0); | 302 StartPlayingFrom(0); |
| 303 event.RunAndWait(); | 303 event.RunAndWait(); |
| 304 Mock::VerifyAndClearExpectations(&mock_cb_); | 304 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 305 } | 305 } |
| 306 | 306 |
| 307 renderer_->OnTimeStateChanged(true); | 307 renderer_->TimeStartedProgressing(); |
| 308 | 308 |
| 309 // Advance time slightly, but enough to exceed the duration of the last | 309 // Advance time slightly, but enough to exceed the duration of the last |
| 310 // frame. | 310 // frame. |
| 311 // Frames should be dropped and we should NOT signal having nothing. | 311 // Frames should be dropped and we should NOT signal having nothing. |
| 312 { | 312 { |
| 313 SCOPED_TRACE("Waiting for frame drops"); | 313 SCOPED_TRACE("Waiting for frame drops"); |
| 314 WaitableMessageLoopEvent event; | 314 WaitableMessageLoopEvent event; |
| 315 | 315 |
| 316 // Note: Starting the TimeSource will cause the old VideoRendererImpl to | 316 // Note: Starting the TimeSource will cause the old VideoRendererImpl to |
| 317 // start rendering frames on its own thread, so the first frame may be | 317 // start rendering frames on its own thread, so the first frame may be |
| (...skipping 17 matching lines...) Expand all Loading... |
| 335 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 335 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 336 WaitableMessageLoopEvent event; | 336 WaitableMessageLoopEvent event; |
| 337 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 337 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 338 .WillOnce(RunClosure(event.GetClosure())); | 338 .WillOnce(RunClosure(event.GetClosure())); |
| 339 AdvanceTimeInMs(30); | 339 AdvanceTimeInMs(30); |
| 340 event.RunAndWait(); | 340 event.RunAndWait(); |
| 341 Mock::VerifyAndClearExpectations(&mock_cb_); | 341 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Simulate delayed buffering state callbacks. | 344 // Simulate delayed buffering state callbacks. |
| 345 renderer_->OnTimeStateChanged(false); | 345 renderer_->TimeStoppedProgressing(); |
| 346 renderer_->OnTimeStateChanged(true); | 346 renderer_->TimeStartedProgressing(); |
| 347 | 347 |
| 348 // Receiving end of stream should signal having enough. | 348 // Receiving end of stream should signal having enough. |
| 349 { | 349 { |
| 350 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 350 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 351 WaitableMessageLoopEvent event; | 351 WaitableMessageLoopEvent event; |
| 352 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 352 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 353 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 353 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 354 .WillOnce(RunClosure(event.GetClosure())); | 354 .WillOnce(RunClosure(event.GetClosure())); |
| 355 EXPECT_CALL(mock_cb_, OnEnded()); | 355 EXPECT_CALL(mock_cb_, OnEnded()); |
| 356 SatisfyPendingDecodeWithEndOfStream(); | 356 SatisfyPendingDecodeWithEndOfStream(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 372 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 372 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 373 .WillOnce(RunClosure(event.GetClosure())); | 373 .WillOnce(RunClosure(event.GetClosure())); |
| 374 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 374 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 375 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 375 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 376 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 376 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 377 StartPlayingFrom(0); | 377 StartPlayingFrom(0); |
| 378 event.RunAndWait(); | 378 event.RunAndWait(); |
| 379 Mock::VerifyAndClearExpectations(&mock_cb_); | 379 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 380 } | 380 } |
| 381 | 381 |
| 382 renderer_->OnTimeStateChanged(true); | 382 renderer_->TimeStartedProgressing(); |
| 383 time_source_.StartTicking(); | 383 time_source_.StartTicking(); |
| 384 | 384 |
| 385 // Advance time, this should cause have nothing to be signaled. | 385 // Advance time, this should cause have nothing to be signaled. |
| 386 { | 386 { |
| 387 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 387 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 388 WaitableMessageLoopEvent event; | 388 WaitableMessageLoopEvent event; |
| 389 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 389 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 390 .WillOnce(RunClosure(event.GetClosure())); | 390 .WillOnce(RunClosure(event.GetClosure())); |
| 391 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(20))).Times(1); | 391 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(20))).Times(1); |
| 392 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 392 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 393 AdvanceTimeInMs(20); | 393 AdvanceTimeInMs(20); |
| 394 event.RunAndWait(); | 394 event.RunAndWait(); |
| 395 Mock::VerifyAndClearExpectations(&mock_cb_); | 395 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 396 } | 396 } |
| 397 | 397 |
| 398 AdvanceTimeInMs(59); | 398 AdvanceTimeInMs(59); |
| 399 EXPECT_EQ(3u, renderer_->frames_queued_for_testing()); | 399 EXPECT_EQ(3u, renderer_->frames_queued_for_testing()); |
| 400 time_source_.StopTicking(); | 400 time_source_.StopTicking(); |
| 401 renderer_->OnTimeStateChanged(false); | 401 renderer_->TimeStoppedProgressing(); |
| 402 EXPECT_EQ(0u, renderer_->frames_queued_for_testing()); | 402 EXPECT_EQ(0u, renderer_->frames_queued_for_testing()); |
| 403 ASSERT_TRUE(IsReadPending()); | 403 ASSERT_TRUE(IsReadPending()); |
| 404 | 404 |
| 405 // Queue some frames, satisfy reads, and make sure expired frames are gone | 405 // Queue some frames, satisfy reads, and make sure expired frames are gone |
| 406 // when the renderer paints the first frame. | 406 // when the renderer paints the first frame. |
| 407 { | 407 { |
| 408 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 408 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 409 WaitableMessageLoopEvent event; | 409 WaitableMessageLoopEvent event; |
| 410 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(80))).Times(1); | 410 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(80))).Times(1); |
| 411 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 411 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 { | 522 { |
| 523 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 523 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 524 WaitableMessageLoopEvent event; | 524 WaitableMessageLoopEvent event; |
| 525 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 525 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 526 .WillOnce(RunClosure(event.GetClosure())); | 526 .WillOnce(RunClosure(event.GetClosure())); |
| 527 EXPECT_CALL(mock_cb_, OnEnded()); | 527 EXPECT_CALL(mock_cb_, OnEnded()); |
| 528 SatisfyPendingDecodeWithEndOfStream(); | 528 SatisfyPendingDecodeWithEndOfStream(); |
| 529 event.RunAndWait(); | 529 event.RunAndWait(); |
| 530 } | 530 } |
| 531 // Firing a time state changed to true should be ignored... | 531 // Firing a time state changed to true should be ignored... |
| 532 renderer_->OnTimeStateChanged(true); | 532 renderer_->TimeStartedProgressing(); |
| 533 EXPECT_FALSE(null_video_sink_->is_started()); | 533 EXPECT_FALSE(null_video_sink_->is_started()); |
| 534 Destroy(); | 534 Destroy(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 TEST_F(VideoRendererImplTest, DestroyWhileInitializing) { | 537 TEST_F(VideoRendererImplTest, DestroyWhileInitializing) { |
| 538 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); | 538 CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK); |
| 539 Destroy(); | 539 Destroy(); |
| 540 } | 540 } |
| 541 | 541 |
| 542 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { | 542 TEST_F(VideoRendererImplTest, DestroyWhileFlushing) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will | 608 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will |
| 609 // be called. | 609 // be called. |
| 610 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 610 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 611 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 611 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 612 .Times(testing::AtMost(1)); | 612 .Times(testing::AtMost(1)); |
| 613 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 613 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 614 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 614 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 615 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 615 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 616 | 616 |
| 617 StartPlayingFrom(0); | 617 StartPlayingFrom(0); |
| 618 renderer_->OnTimeStateChanged(true); | 618 renderer_->TimeStartedProgressing(); |
| 619 time_source_.StartTicking(); | 619 time_source_.StartTicking(); |
| 620 AdvanceTimeInMs(10); | 620 AdvanceTimeInMs(10); |
| 621 | 621 |
| 622 QueueFrames("error"); | 622 QueueFrames("error"); |
| 623 SatisfyPendingDecode(); | 623 SatisfyPendingDecode(); |
| 624 WaitForError(PIPELINE_ERROR_DECODE); | 624 WaitForError(PIPELINE_ERROR_DECODE); |
| 625 Destroy(); | 625 Destroy(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { | 628 TEST_F(VideoRendererImplTest, DecodeError_DuringStartPlayingFrom) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 685 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 686 .Times(AnyNumber()); | 686 .Times(AnyNumber()); |
| 687 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 687 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 688 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 688 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 689 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 689 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 690 StartPlayingFrom(10); | 690 StartPlayingFrom(10); |
| 691 | 691 |
| 692 QueueFrames("20"); | 692 QueueFrames("20"); |
| 693 SatisfyPendingDecode(); | 693 SatisfyPendingDecode(); |
| 694 | 694 |
| 695 renderer_->OnTimeStateChanged(true); | 695 renderer_->TimeStartedProgressing(); |
| 696 time_source_.StartTicking(); | 696 time_source_.StartTicking(); |
| 697 | 697 |
| 698 WaitableMessageLoopEvent event; | 698 WaitableMessageLoopEvent event; |
| 699 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(20))) | 699 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(20))) |
| 700 .WillOnce(RunClosure(event.GetClosure())); | 700 .WillOnce(RunClosure(event.GetClosure())); |
| 701 AdvanceTimeInMs(20); | 701 AdvanceTimeInMs(20); |
| 702 event.RunAndWait(); | 702 event.RunAndWait(); |
| 703 | 703 |
| 704 Destroy(); | 704 Destroy(); |
| 705 } | 705 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 789 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 790 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 790 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 791 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 791 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 792 | 792 |
| 793 { | 793 { |
| 794 SCOPED_TRACE("Waiting for sink to stop."); | 794 SCOPED_TRACE("Waiting for sink to stop."); |
| 795 WaitableMessageLoopEvent event; | 795 WaitableMessageLoopEvent event; |
| 796 | 796 |
| 797 null_video_sink_->set_stop_cb(event.GetClosure()); | 797 null_video_sink_->set_stop_cb(event.GetClosure()); |
| 798 StartPlayingFrom(0); | 798 StartPlayingFrom(0); |
| 799 renderer_->OnTimeStateChanged(true); | 799 renderer_->TimeStartedProgressing(); |
| 800 | 800 |
| 801 EXPECT_TRUE(IsReadPending()); | 801 EXPECT_TRUE(IsReadPending()); |
| 802 SatisfyPendingDecodeWithEndOfStream(); | 802 SatisfyPendingDecodeWithEndOfStream(); |
| 803 WaitForEnded(); | 803 WaitForEnded(); |
| 804 | 804 |
| 805 renderer_->OnTimeStateChanged(false); | 805 renderer_->TimeStoppedProgressing(); |
| 806 event.RunAndWait(); | 806 event.RunAndWait(); |
| 807 } | 807 } |
| 808 | 808 |
| 809 Destroy(); | 809 Destroy(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 // Tests the case where the video started and received a single Render() call, | 812 // Tests the case where the video started and received a single Render() call, |
| 813 // then the video was put into the background. | 813 // then the video was put into the background. |
| 814 TEST_F(VideoRendererImplTest, RenderingStartedThenStopped) { | 814 TEST_F(VideoRendererImplTest, RenderingStartedThenStopped) { |
| 815 Initialize(); | 815 Initialize(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 843 EXPECT_EQ(115200, last_pipeline_statistics.video_memory_usage); | 843 EXPECT_EQ(115200, last_pipeline_statistics.video_memory_usage); |
| 844 | 844 |
| 845 // Consider the case that rendering is faster than we setup the test event. | 845 // Consider the case that rendering is faster than we setup the test event. |
| 846 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will | 846 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will |
| 847 // be called. And then during SatisfyPendingDecodeWithEndOfStream, | 847 // be called. And then during SatisfyPendingDecodeWithEndOfStream, |
| 848 // BUFFER_HAVE_ENOUGH will be called again. | 848 // BUFFER_HAVE_ENOUGH will be called again. |
| 849 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 849 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 850 .Times(testing::AtMost(1)); | 850 .Times(testing::AtMost(1)); |
| 851 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 851 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 852 .Times(testing::AtMost(1)); | 852 .Times(testing::AtMost(1)); |
| 853 renderer_->OnTimeStateChanged(true); | 853 renderer_->TimeStartedProgressing(); |
| 854 time_source_.StartTicking(); | 854 time_source_.StartTicking(); |
| 855 | 855 |
| 856 // Suspend all future callbacks and synthetically advance the media time, | 856 // Suspend all future callbacks and synthetically advance the media time, |
| 857 // because this is a background render, we won't underflow by waiting until | 857 // because this is a background render, we won't underflow by waiting until |
| 858 // a pending read is ready. | 858 // a pending read is ready. |
| 859 null_video_sink_->set_background_render(true); | 859 null_video_sink_->set_background_render(true); |
| 860 AdvanceTimeInMs(91); | 860 AdvanceTimeInMs(91); |
| 861 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(90))); | 861 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(90))); |
| 862 WaitForPendingDecode(); | 862 WaitForPendingDecode(); |
| 863 SatisfyPendingDecodeWithEndOfStream(); | 863 SatisfyPendingDecodeWithEndOfStream(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 883 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 883 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 884 StartPlayingFrom(0); | 884 StartPlayingFrom(0); |
| 885 event.RunAndWait(); | 885 event.RunAndWait(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 { | 888 { |
| 889 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 889 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 890 WaitableMessageLoopEvent event; | 890 WaitableMessageLoopEvent event; |
| 891 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 891 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 892 .WillOnce(RunClosure(event.GetClosure())); | 892 .WillOnce(RunClosure(event.GetClosure())); |
| 893 renderer_->OnTimeStateChanged(true); | 893 renderer_->TimeStartedProgressing(); |
| 894 time_source_.StartTicking(); | 894 time_source_.StartTicking(); |
| 895 event.RunAndWait(); | 895 event.RunAndWait(); |
| 896 } | 896 } |
| 897 | 897 |
| 898 WaitForPendingDecode(); | 898 WaitForPendingDecode(); |
| 899 | 899 |
| 900 // Jump time far enough forward that no frames are valid. | 900 // Jump time far enough forward that no frames are valid. |
| 901 renderer_->OnTimeStateChanged(false); | 901 renderer_->TimeStoppedProgressing(); |
| 902 AdvanceTimeInMs(1000); | 902 AdvanceTimeInMs(1000); |
| 903 time_source_.StopTicking(); | 903 time_source_.StopTicking(); |
| 904 | 904 |
| 905 // Providing the end of stream packet should remove all frames and exit. | 905 // Providing the end of stream packet should remove all frames and exit. |
| 906 SatisfyPendingDecodeWithEndOfStream(); | 906 SatisfyPendingDecodeWithEndOfStream(); |
| 907 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 907 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 908 WaitForEnded(); | 908 WaitForEnded(); |
| 909 Destroy(); | 909 Destroy(); |
| 910 } | 910 } |
| 911 | 911 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 922 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(AnyNumber()); | 922 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(AnyNumber()); |
| 923 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 923 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 924 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 924 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 925 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 925 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 926 StartPlayingFrom(0); | 926 StartPlayingFrom(0); |
| 927 event.RunAndWait(); | 927 event.RunAndWait(); |
| 928 } | 928 } |
| 929 | 929 |
| 930 null_video_sink_->set_background_render(true); | 930 null_video_sink_->set_background_render(true); |
| 931 time_source_.StartTicking(); | 931 time_source_.StartTicking(); |
| 932 renderer_->OnTimeStateChanged(true); | 932 renderer_->TimeStartedProgressing(); |
| 933 WaitForPendingDecode(); | 933 WaitForPendingDecode(); |
| 934 renderer_->OnTimeStateChanged(false); | 934 renderer_->TimeStoppedProgressing(); |
| 935 | 935 |
| 936 // Jump time far enough forward that no frames are valid. | 936 // Jump time far enough forward that no frames are valid. |
| 937 AdvanceTimeInMs(1000); | 937 AdvanceTimeInMs(1000); |
| 938 | 938 |
| 939 { | 939 { |
| 940 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 940 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 941 WaitableMessageLoopEvent event; | 941 WaitableMessageLoopEvent event; |
| 942 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 942 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 943 .WillOnce(RunClosure(event.GetClosure())); | 943 .WillOnce(RunClosure(event.GetClosure())); |
| 944 QueueFrames("120"); | 944 QueueFrames("120"); |
| 945 SatisfyPendingDecode(); | 945 SatisfyPendingDecode(); |
| 946 event.RunAndWait(); | 946 event.RunAndWait(); |
| 947 } | 947 } |
| 948 | 948 |
| 949 // This should do nothing. | 949 // This should do nothing. |
| 950 renderer_->OnTimeStateChanged(true); | 950 renderer_->TimeStartedProgressing(); |
| 951 | 951 |
| 952 // Providing the end of stream packet should remove all frames and exit. | 952 // Providing the end of stream packet should remove all frames and exit. |
| 953 SatisfyPendingDecodeWithEndOfStream(); | 953 SatisfyPendingDecodeWithEndOfStream(); |
| 954 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 954 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 955 WaitForEnded(); | 955 WaitForEnded(); |
| 956 Destroy(); | 956 Destroy(); |
| 957 } | 957 } |
| 958 | 958 |
| 959 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { | 959 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { |
| 960 Initialize(); | 960 Initialize(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 null_video_sink_->set_background_render(true); | 997 null_video_sink_->set_background_render(true); |
| 998 QueueFrames("0 10 20"); | 998 QueueFrames("0 10 20"); |
| 999 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 999 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 1000 .Times(testing::AtMost(1)); | 1000 .Times(testing::AtMost(1)); |
| 1001 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); | 1001 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); |
| 1002 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 1002 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 1003 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 1003 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 1004 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 1004 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 1005 StartPlayingFrom(0); | 1005 StartPlayingFrom(0); |
| 1006 | 1006 |
| 1007 renderer_->OnTimeStateChanged(true); | 1007 renderer_->TimeStartedProgressing(); |
| 1008 time_source_.StartTicking(); | 1008 time_source_.StartTicking(); |
| 1009 | 1009 |
| 1010 WaitableMessageLoopEvent event; | 1010 WaitableMessageLoopEvent event; |
| 1011 // Frame "10" should not have been expired. | 1011 // Frame "10" should not have been expired. |
| 1012 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) | 1012 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) |
| 1013 .WillOnce(RunClosure(event.GetClosure())); | 1013 .WillOnce(RunClosure(event.GetClosure())); |
| 1014 AdvanceTimeInMs(10); | 1014 AdvanceTimeInMs(10); |
| 1015 event.RunAndWait(); | 1015 event.RunAndWait(); |
| 1016 | 1016 |
| 1017 Destroy(); | 1017 Destroy(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1042 | 1042 |
| 1043 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 1043 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 1044 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 1044 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 1045 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); | 1045 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 1046 | 1046 |
| 1047 { | 1047 { |
| 1048 // Callback is fired for the first frame. | 1048 // Callback is fired for the first frame. |
| 1049 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(initial_size)); | 1049 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(initial_size)); |
| 1050 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); | 1050 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); |
| 1051 StartPlayingFrom(0); | 1051 StartPlayingFrom(0); |
| 1052 renderer_->OnTimeStateChanged(true); | 1052 renderer_->TimeStartedProgressing(); |
| 1053 time_source_.StartTicking(); | 1053 time_source_.StartTicking(); |
| 1054 } | 1054 } |
| 1055 { | 1055 { |
| 1056 // Callback should be fired once when switching to the larger size. | 1056 // Callback should be fired once when switching to the larger size. |
| 1057 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(larger_size)); | 1057 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(larger_size)); |
| 1058 WaitableMessageLoopEvent event; | 1058 WaitableMessageLoopEvent event; |
| 1059 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) | 1059 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) |
| 1060 .WillOnce(RunClosure(event.GetClosure())); | 1060 .WillOnce(RunClosure(event.GetClosure())); |
| 1061 AdvanceTimeInMs(10); | 1061 AdvanceTimeInMs(10); |
| 1062 event.RunAndWait(); | 1062 event.RunAndWait(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 | 1108 |
| 1109 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 1109 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 1110 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 1110 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 1111 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(frame_size)).Times(1); | 1111 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(frame_size)).Times(1); |
| 1112 | 1112 |
| 1113 { | 1113 { |
| 1114 // Callback is fired for the first frame. | 1114 // Callback is fired for the first frame. |
| 1115 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(false)); | 1115 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(false)); |
| 1116 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); | 1116 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); |
| 1117 StartPlayingFrom(0); | 1117 StartPlayingFrom(0); |
| 1118 renderer_->OnTimeStateChanged(true); | 1118 renderer_->TimeStartedProgressing(); |
| 1119 time_source_.StartTicking(); | 1119 time_source_.StartTicking(); |
| 1120 } | 1120 } |
| 1121 { | 1121 { |
| 1122 // Callback is not fired because opacity does not change. | 1122 // Callback is not fired because opacity does not change. |
| 1123 WaitableMessageLoopEvent event; | 1123 WaitableMessageLoopEvent event; |
| 1124 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) | 1124 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(10))) |
| 1125 .WillOnce(RunClosure(event.GetClosure())); | 1125 .WillOnce(RunClosure(event.GetClosure())); |
| 1126 AdvanceTimeInMs(10); | 1126 AdvanceTimeInMs(10); |
| 1127 event.RunAndWait(); | 1127 event.RunAndWait(); |
| 1128 } | 1128 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 QueueFrames("0 10 20 30"); | 1184 QueueFrames("0 10 20 30"); |
| 1185 StartPlayingFrom(0); | 1185 StartPlayingFrom(0); |
| 1186 Flush(); | 1186 Flush(); |
| 1187 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 1187 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
| 1188 // This frame will be discarded. | 1188 // This frame will be discarded. |
| 1189 frame_ready_cbs_.front().Run(); | 1189 frame_ready_cbs_.front().Run(); |
| 1190 Destroy(); | 1190 Destroy(); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 } // namespace media | 1193 } // namespace media |
| OLD | NEW |