| 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 912 // Tests the case where underflow evicts all frames in the HAVE_ENOUGH state. |
| 913 TEST_F(VideoRendererImplTest, UnderflowEvictionWhileHaveEnough) { |
| 914 Initialize(); |
| 915 QueueFrames("0 30 60 90 100"); |
| 916 |
| 917 { |
| 918 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 919 WaitableMessageLoopEvent event; |
| 920 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 921 .WillOnce(RunClosure(event.GetClosure())); |
| 922 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(AnyNumber()); |
| 923 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| 924 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); |
| 925 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 926 StartPlayingFrom(0); |
| 927 event.RunAndWait(); |
| 928 } |
| 929 |
| 930 null_video_sink_->set_background_render(true); |
| 931 time_source_.StartTicking(); |
| 932 renderer_->OnTimeStateChanged(true); |
| 933 WaitForPendingDecode(); |
| 934 renderer_->OnTimeStateChanged(false); |
| 935 |
| 936 // Jump time far enough forward that no frames are valid. |
| 937 AdvanceTimeInMs(1000); |
| 938 |
| 939 { |
| 940 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 941 WaitableMessageLoopEvent event; |
| 942 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 943 .WillOnce(RunClosure(event.GetClosure())); |
| 944 QueueFrames("120"); |
| 945 SatisfyPendingDecode(); |
| 946 event.RunAndWait(); |
| 947 } |
| 948 |
| 949 // This should do nothing. |
| 950 renderer_->OnTimeStateChanged(true); |
| 951 |
| 952 // Providing the end of stream packet should remove all frames and exit. |
| 953 SatisfyPendingDecodeWithEndOfStream(); |
| 954 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 955 WaitForEnded(); |
| 956 Destroy(); |
| 957 } |
| 958 |
| 912 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { | 959 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { |
| 913 Initialize(); | 960 Initialize(); |
| 914 QueueFrames("0 30 60 90"); | 961 QueueFrames("0 30 60 90"); |
| 915 | 962 |
| 916 WaitableMessageLoopEvent event; | 963 WaitableMessageLoopEvent event; |
| 917 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); | 964 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); |
| 918 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 965 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 919 .WillOnce(RunClosure(event.GetClosure())); | 966 .WillOnce(RunClosure(event.GetClosure())); |
| 920 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); | 967 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); |
| 921 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); | 968 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 QueueFrames("0 10 20 30"); | 1184 QueueFrames("0 10 20 30"); |
| 1138 StartPlayingFrom(0); | 1185 StartPlayingFrom(0); |
| 1139 Flush(); | 1186 Flush(); |
| 1140 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 1187 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
| 1141 // This frame will be discarded. | 1188 // This frame will be discarded. |
| 1142 frame_ready_cbs_.front().Run(); | 1189 frame_ready_cbs_.front().Run(); |
| 1143 Destroy(); | 1190 Destroy(); |
| 1144 } | 1191 } |
| 1145 | 1192 |
| 1146 } // namespace media | 1193 } // namespace media |
| OLD | NEW |