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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 last_pipeline_statistics_.video_frames_dropped = 1; | 670 last_pipeline_statistics_.video_frames_dropped = 1; |
671 { | 671 { |
672 WaitableMessageLoopEvent event; | 672 WaitableMessageLoopEvent event; |
673 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 673 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
674 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))) | 674 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))) |
675 .WillOnce(RunClosure(event.GetClosure())); | 675 .WillOnce(RunClosure(event.GetClosure())); |
676 StartPlayingFrom(0); | 676 StartPlayingFrom(0); |
677 event.RunAndWait(); | 677 event.RunAndWait(); |
678 Mock::VerifyAndClearExpectations(&mock_cb_); | 678 Mock::VerifyAndClearExpectations(&mock_cb_); |
679 EXPECT_EQ(0u, last_pipeline_statistics_.video_frames_dropped); | 679 EXPECT_EQ(0u, last_pipeline_statistics_.video_frames_dropped); |
| 680 EXPECT_EQ(460800, last_pipeline_statistics_.video_memory_usage); |
680 } | 681 } |
681 | 682 |
682 // Consider the case that rendering is faster than we setup the test event. | 683 // Consider the case that rendering is faster than we setup the test event. |
683 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will | 684 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will |
684 // be called. And then during SatisfyPendingReadWithEndOfStream, | 685 // be called. And then during SatisfyPendingReadWithEndOfStream, |
685 // BUFFER_HAVE_ENOUGH will be called again. | 686 // BUFFER_HAVE_ENOUGH will be called again. |
686 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 687 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
687 .Times(testing::AtMost(1)); | 688 .Times(testing::AtMost(1)); |
688 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) | 689 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) |
689 .Times(testing::AtMost(1)); | 690 .Times(testing::AtMost(1)); |
690 renderer_->OnTimeStateChanged(true); | 691 renderer_->OnTimeStateChanged(true); |
691 time_source_.StartTicking(); | 692 time_source_.StartTicking(); |
692 | 693 |
693 // Suspend all future callbacks and synthetically advance the media time, | 694 // Suspend all future callbacks and synthetically advance the media time, |
694 // because this is a background render, we won't underflow by waiting until | 695 // because this is a background render, we won't underflow by waiting until |
695 // a pending read is ready. | 696 // a pending read is ready. |
696 null_video_sink_->set_background_render(true); | 697 null_video_sink_->set_background_render(true); |
697 AdvanceTimeInMs(91); | 698 AdvanceTimeInMs(91); |
698 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(90))); | 699 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(90))); |
699 WaitForPendingRead(); | 700 WaitForPendingRead(); |
700 SatisfyPendingReadWithEndOfStream(); | 701 SatisfyPendingReadWithEndOfStream(); |
701 | 702 |
702 // If this wasn't background rendering mode, this would result in two frames | 703 // If this wasn't background rendering mode, this would result in two frames |
703 // being dropped, but since we set background render to true, none should be | 704 // being dropped, but since we set background render to true, none should be |
704 // reported | 705 // reported |
705 EXPECT_EQ(0u, last_pipeline_statistics_.video_frames_dropped); | 706 EXPECT_EQ(0u, last_pipeline_statistics_.video_frames_dropped); |
706 EXPECT_EQ(4u, last_pipeline_statistics_.video_frames_decoded); | 707 EXPECT_EQ(4u, last_pipeline_statistics_.video_frames_decoded); |
| 708 EXPECT_EQ(460800, last_pipeline_statistics_.video_memory_usage); |
707 | 709 |
708 AdvanceTimeInMs(30); | 710 AdvanceTimeInMs(30); |
709 WaitForEnded(); | 711 WaitForEnded(); |
710 Destroy(); | 712 Destroy(); |
711 } | 713 } |
712 | 714 |
713 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { | 715 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { |
714 Initialize(); | 716 Initialize(); |
715 QueueFrames("0 30 60 90"); | 717 QueueFrames("0 30 60 90"); |
716 | 718 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 QueueFrames("0 10 20 30"); | 773 QueueFrames("0 10 20 30"); |
772 StartPlayingFrom(0); | 774 StartPlayingFrom(0); |
773 Flush(); | 775 Flush(); |
774 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 776 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
775 // This frame will be discarded. | 777 // This frame will be discarded. |
776 frame_ready_cbs_.front().Run(); | 778 frame_ready_cbs_.front().Run(); |
777 Destroy(); | 779 Destroy(); |
778 } | 780 } |
779 | 781 |
780 } // namespace media | 782 } // namespace media |
OLD | NEW |