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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 2269313002: Fix DCHECK when track status changes in non-playing state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a unit test for track changes in suspended state Created 4 years, 3 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/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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 916
917 Play(); 917 Play();
918 918
919 ASSERT_TRUE(WaitUntilOnEnded()); 919 ASSERT_TRUE(WaitUntilOnEnded());
920 920
921 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); 921 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
922 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); 922 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
923 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); 923 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null());
924 } 924 }
925 925
926 base::TimeDelta TimestampMs(int milliseconds) {
927 return base::TimeDelta::FromMilliseconds(milliseconds);
928 }
929
926 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { 930 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) {
927 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); 931 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
928 932
929 // Disable audio. 933 // Disable audio.
930 std::vector<MediaTrack::Id> empty; 934 std::vector<MediaTrack::Id> empty;
931 pipeline_->OnEnabledAudioTracksChanged(empty); 935 pipeline_->OnEnabledAudioTracksChanged(empty);
932 base::RunLoop().RunUntilIdle(); 936 base::RunLoop().RunUntilIdle();
933 937
934 // Seek to flush the pipeline and ensure there's no prerolled audio data. 938 // Seek to flush the pipeline and ensure there's no prerolled audio data.
935 ASSERT_TRUE(Seek(base::TimeDelta())); 939 ASSERT_TRUE(Seek(base::TimeDelta()));
936 940
937 Play(); 941 Play();
938 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); 942 const base::TimeDelta k500ms = TimestampMs(500);
939 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); 943 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
940 Pause(); 944 Pause();
941 945
942 // Verify that no audio has been played, since we disabled audio tracks. 946 // Verify that no audio has been played, since we disabled audio tracks.
943 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); 947 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash());
944 948
945 // Re-enable audio. 949 // Re-enable audio.
946 std::vector<MediaTrack::Id> audioTrackId; 950 std::vector<MediaTrack::Id> audioTrackId;
947 audioTrackId.push_back("2"); 951 audioTrackId.push_back("2");
948 pipeline_->OnEnabledAudioTracksChanged(audioTrackId); 952 pipeline_->OnEnabledAudioTracksChanged(audioTrackId);
(...skipping 17 matching lines...) Expand all
966 base::RunLoop().RunUntilIdle(); 970 base::RunLoop().RunUntilIdle();
967 971
968 // Seek to flush the pipeline and ensure there's no prerolled video data. 972 // Seek to flush the pipeline and ensure there's no prerolled video data.
969 ASSERT_TRUE(Seek(base::TimeDelta())); 973 ASSERT_TRUE(Seek(base::TimeDelta()));
970 974
971 // Reset the video hash in case some of the prerolled video frames have been 975 // Reset the video hash in case some of the prerolled video frames have been
972 // hashed already. 976 // hashed already.
973 ResetVideoHash(); 977 ResetVideoHash();
974 978
975 Play(); 979 Play();
976 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); 980 const base::TimeDelta k500ms = TimestampMs(500);
977 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); 981 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
978 Pause(); 982 Pause();
979 983
980 // Verify that no video has been rendered, since we disabled video tracks. 984 // Verify that no video has been rendered, since we disabled video tracks.
981 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); 985 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash());
982 986
983 // Re-enable video. 987 // Re-enable video.
984 std::vector<MediaTrack::Id> videoTrackId; 988 std::vector<MediaTrack::Id> videoTrackId;
985 videoTrackId.push_back("1"); 989 videoTrackId.push_back("1");
986 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); 990 pipeline_->OnSelectedVideoTrackChanged(videoTrackId);
987 base::RunLoop().RunUntilIdle(); 991 base::RunLoop().RunUntilIdle();
988 992
989 // Seek to flush video pipeline and reset the video hash again to clear state 993 // Seek to flush video pipeline and reset the video hash again to clear state
990 // if some prerolled frames got hashed after enabling video. 994 // if some prerolled frames got hashed after enabling video.
991 ASSERT_TRUE(Seek(base::TimeDelta())); 995 ASSERT_TRUE(Seek(base::TimeDelta()));
992 ResetVideoHash(); 996 ResetVideoHash();
993 997
994 // Restart playback from 500ms position. 998 // Restart playback from 500ms position.
995 ASSERT_TRUE(Seek(k500ms)); 999 ASSERT_TRUE(Seek(k500ms));
996 Play(); 1000 Play();
997 ASSERT_TRUE(WaitUntilOnEnded()); 1001 ASSERT_TRUE(WaitUntilOnEnded());
998 1002
999 // Verify that video has been rendered after being enabled. 1003 // Verify that video has been rendered after being enabled.
1000 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); 1004 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash());
1001 } 1005 }
1002 1006
1007 TEST_F(PipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) {
1008 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
1009 Play();
1010 ASSERT_TRUE(WaitUntilOnEnded());
1011 std::vector<MediaTrack::Id> track_ids;
1012 // Disable audio track.
1013 pipeline_->OnEnabledAudioTracksChanged(track_ids);
1014 // Re-enable audio track.
1015 track_ids.push_back("2");
1016 pipeline_->OnEnabledAudioTracksChanged(track_ids);
1017 // Disable video track.
1018 track_ids.clear();
1019 pipeline_->OnSelectedVideoTrackChanged(track_ids);
1020 // Re-enable video track.
1021 track_ids.push_back("1");
1022 pipeline_->OnSelectedVideoTrackChanged(track_ids);
1023 }
1024
1025 TEST_F(PipelineIntegrationTest, TrackStatusChangesWhileSuspended) {
1026 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
1027 Play();
1028
1029 ASSERT_TRUE(Suspend());
1030
1031 // These get triggered every time playback is resumed.
1032 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240)))
1033 .Times(AnyNumber());
1034 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber());
1035
1036 std::vector<MediaTrack::Id> track_ids;
1037
1038 // Disable audio track.
1039 pipeline_->OnEnabledAudioTracksChanged(track_ids);
1040 ASSERT_TRUE(Resume(TimestampMs(100)));
1041 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200)));
1042 ASSERT_TRUE(Suspend());
1043
1044 // Re-enable audio track.
1045 track_ids.push_back("2");
1046 pipeline_->OnEnabledAudioTracksChanged(track_ids);
1047 ASSERT_TRUE(Resume(TimestampMs(200)));
1048 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(300)));
1049 ASSERT_TRUE(Suspend());
1050
1051 // Disable video track.
1052 track_ids.clear();
1053 pipeline_->OnSelectedVideoTrackChanged(track_ids);
1054 ASSERT_TRUE(Resume(TimestampMs(300)));
1055 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400)));
1056 ASSERT_TRUE(Suspend());
1057
1058 // Re-enable video track.
1059 track_ids.push_back("1");
1060 pipeline_->OnSelectedVideoTrackChanged(track_ids);
1061 ASSERT_TRUE(Resume(TimestampMs(400)));
1062 ASSERT_TRUE(WaitUntilOnEnded());
1063 }
1064
1003 TEST_F(PipelineIntegrationTest, 1065 TEST_F(PipelineIntegrationTest,
1004 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { 1066 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) {
1005 ASSERT_EQ(PIPELINE_OK, 1067 ASSERT_EQ(PIPELINE_OK,
1006 Start("opus-trimming-test.webm", kHashed | kClockless)); 1068 Start("opus-trimming-test.webm", kHashed | kClockless));
1007 1069
1008 Play(); 1070 Play();
1009 1071
1010 ASSERT_TRUE(WaitUntilOnEnded()); 1072 ASSERT_TRUE(WaitUntilOnEnded());
1011 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); 1073 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash());
1012 1074
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 2439
2378 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2440 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2379 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2441 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2380 Play(); 2442 Play();
2381 ASSERT_TRUE(WaitUntilOnEnded()); 2443 ASSERT_TRUE(WaitUntilOnEnded());
2382 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2444 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2383 demuxer_->GetStartTime()); 2445 demuxer_->GetStartTime());
2384 } 2446 }
2385 2447
2386 } // namespace media 2448 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698