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

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

Issue 2371833005: Merge M54: "Transition to have nothing if background rendering evicts all frames." (Closed)
Patch Set: Created 4 years, 2 months 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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 AdvanceTimeInMs(1000); 906 AdvanceTimeInMs(1000);
907 time_source_.StopTicking(); 907 time_source_.StopTicking();
908 908
909 // Providing the end of stream packet should remove all frames and exit. 909 // Providing the end of stream packet should remove all frames and exit.
910 SatisfyPendingDecodeWithEndOfStream(); 910 SatisfyPendingDecodeWithEndOfStream();
911 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 911 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
912 WaitForEnded(); 912 WaitForEnded();
913 Destroy(); 913 Destroy();
914 } 914 }
915 915
916 // Tests the case where underflow evicts all frames in the HAVE_ENOUGH state.
917 TEST_F(VideoRendererImplTest, UnderflowEvictionWhileHaveEnough) {
918 Initialize();
919 QueueFrames("0 30 60 90 100");
920
921 {
922 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH");
923 WaitableMessageLoopEvent event;
924 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
925 .WillOnce(RunClosure(event.GetClosure()));
926 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(AnyNumber());
927 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
928 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
929 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
930 StartPlayingFrom(0);
931 event.RunAndWait();
932 }
933
934 null_video_sink_->set_background_render(true);
935 time_source_.StartTicking();
936 renderer_->OnTimeStateChanged(true);
937 WaitForPendingDecode();
938 renderer_->OnTimeStateChanged(false);
939
940 // Jump time far enough forward that no frames are valid.
941 AdvanceTimeInMs(1000);
942
943 {
944 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING");
945 WaitableMessageLoopEvent event;
946 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
947 .WillOnce(RunClosure(event.GetClosure()));
948 QueueFrames("120");
949 SatisfyPendingDecode();
950 event.RunAndWait();
951 }
952
953 // This should do nothing.
954 renderer_->OnTimeStateChanged(true);
955
956 // Providing the end of stream packet should remove all frames and exit.
957 SatisfyPendingDecodeWithEndOfStream();
958 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
959 WaitForEnded();
960 Destroy();
961 }
962
916 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { 963 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) {
917 Initialize(); 964 Initialize();
918 QueueFrames("0 30 60 90"); 965 QueueFrames("0 30 60 90");
919 966
920 WaitableMessageLoopEvent event; 967 WaitableMessageLoopEvent event;
921 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); 968 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
922 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 969 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
923 .WillOnce(RunClosure(event.GetClosure())); 970 .WillOnce(RunClosure(event.GetClosure()));
924 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); 971 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
925 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 972 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 QueueFrames("0 10 20 30"); 1188 QueueFrames("0 10 20 30");
1142 StartPlayingFrom(0); 1189 StartPlayingFrom(0);
1143 Flush(); 1190 Flush();
1144 ASSERT_EQ(1u, frame_ready_cbs_.size()); 1191 ASSERT_EQ(1u, frame_ready_cbs_.size());
1145 // This frame will be discarded. 1192 // This frame will be discarded.
1146 frame_ready_cbs_.front().Run(); 1193 frame_ready_cbs_.front().Run();
1147 Destroy(); 1194 Destroy();
1148 } 1195 }
1149 1196
1150 } // namespace media 1197 } // 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