Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1498)

Side by Side Diff: media/renderers/video_renderer_impl_unittest.cc

Issue 2570013003: Fix underflow correction occurring during normal rendering. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_->OnTimeProgressing(); 893 renderer_->OnTimeProgressing();
894 time_source_.StartTicking(); 894 time_source_.StartTicking();
895 // Jump time far enough forward that no frames are valid.
896 AdvanceTimeInMs(1000);
895 event.RunAndWait(); 897 event.RunAndWait();
896 } 898 }
897 899
898 WaitForPendingDecode(); 900 WaitForPendingDecode();
899 901
900 // Jump time far enough forward that no frames are valid.
901 renderer_->OnTimeStopped(); 902 renderer_->OnTimeStopped();
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. 912 // Tests the case where underflow evicts all frames in the HAVE_ENOUGH state.
913 TEST_F(VideoRendererImplTest, UnderflowEvictionWhileHaveEnough) { 913 TEST_F(VideoRendererImplTest, UnderflowEvictionWhileHaveEnough) {
914 Initialize(); 914 Initialize();
915 QueueFrames("0 30 60 90 100"); 915 QueueFrames("0 30 60 90 100");
916 916
917 { 917 {
918 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); 918 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH");
919 WaitableMessageLoopEvent event; 919 WaitableMessageLoopEvent event;
920 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 920 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
921 .WillOnce(RunClosure(event.GetClosure())); 921 .WillOnce(RunClosure(event.GetClosure()));
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 // Now wait until we have no effective frames.
931 time_source_.StartTicking(); 931 {
932 renderer_->OnTimeProgressing(); 932 SCOPED_TRACE("Waiting for zero effective frames.");
933 WaitForPendingDecode(); 933 WaitableMessageLoopEvent event;
934 renderer_->OnTimeStopped(); 934 null_video_sink_->set_background_render(true);
935 time_source_.StartTicking();
936 AdvanceTimeInMs(1000);
937 renderer_->OnTimeProgressing();
938 EXPECT_CALL(mock_cb_, FrameReceived(_))
939 .WillOnce(RunClosure(event.GetClosure()));
940 event.RunAndWait();
941 ASSERT_EQ(renderer_->effective_frames_queued_for_testing(), 0u);
942 }
935 943
936 // Jump time far enough forward that no frames are valid. 944 // When OnTimeStopped() is called it should transition to HAVE_NOTHING.
937 AdvanceTimeInMs(1000);
938
939 { 945 {
940 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); 946 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING");
941 WaitableMessageLoopEvent event; 947 WaitableMessageLoopEvent event;
942 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) 948 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
943 .WillOnce(RunClosure(event.GetClosure())); 949 .WillOnce(RunClosure(event.GetClosure()));
944 QueueFrames("120"); 950 renderer_->OnTimeStopped();
945 SatisfyPendingDecode();
946 event.RunAndWait(); 951 event.RunAndWait();
947 } 952 }
948 953
949 // This should do nothing.
950 renderer_->OnTimeProgressing();
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(); 954 Destroy();
957 } 955 }
958 956
959 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { 957 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) {
960 Initialize(); 958 Initialize();
961 QueueFrames("0 30 60 90"); 959 QueueFrames("0 30 60 90");
962 960
963 WaitableMessageLoopEvent event; 961 WaitableMessageLoopEvent event;
964 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0))); 962 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0)));
965 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 963 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 QueueFrames("0 10 20 30"); 1182 QueueFrames("0 10 20 30");
1185 StartPlayingFrom(0); 1183 StartPlayingFrom(0);
1186 Flush(); 1184 Flush();
1187 ASSERT_EQ(1u, frame_ready_cbs_.size()); 1185 ASSERT_EQ(1u, frame_ready_cbs_.size());
1188 // This frame will be discarded. 1186 // This frame will be discarded.
1189 frame_ready_cbs_.front().Run(); 1187 frame_ready_cbs_.front().Run();
1190 Destroy(); 1188 Destroy();
1191 } 1189 }
1192 1190
1193 } // namespace media 1191 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698