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

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

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove ios call sites Created 4 years, 5 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
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/location.h"
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
16 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
17 #include "base/run_loop.h" 16 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
21 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
22 #include "build/build_config.h" 20 #include "build/build_config.h"
23 #include "media/base/cdm_callback_promise.h" 21 #include "media/base/cdm_callback_promise.h"
24 #include "media/base/cdm_context.h" 22 #include "media/base/cdm_context.h"
25 #include "media/base/cdm_key_information.h" 23 #include "media/base/cdm_key_information.h"
26 #include "media/base/decoder_buffer.h" 24 #include "media/base/decoder_buffer.h"
27 #include "media/base/media.h" 25 #include "media/base/media.h"
28 #include "media/base/media_keys.h" 26 #include "media/base/media_keys.h"
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); 942 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
945 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); 943 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null());
946 } 944 }
947 945
948 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { 946 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) {
949 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); 947 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
950 948
951 // Disable audio. 949 // Disable audio.
952 std::vector<MediaTrack::Id> empty; 950 std::vector<MediaTrack::Id> empty;
953 pipeline_->OnEnabledAudioTracksChanged(empty); 951 pipeline_->OnEnabledAudioTracksChanged(empty);
954 message_loop_.RunUntilIdle(); 952 base::RunLoop().RunUntilIdle();
955 953
956 // Seek to flush the pipeline and ensure there's no prerolled audio data. 954 // Seek to flush the pipeline and ensure there's no prerolled audio data.
957 ASSERT_TRUE(Seek(base::TimeDelta())); 955 ASSERT_TRUE(Seek(base::TimeDelta()));
958 956
959 Play(); 957 Play();
960 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); 958 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500);
961 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); 959 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
962 Pause(); 960 Pause();
963 961
964 // Verify that no audio has been played, since we disabled audio tracks. 962 // Verify that no audio has been played, since we disabled audio tracks.
965 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); 963 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash());
966 964
967 // Re-enable audio. 965 // Re-enable audio.
968 std::vector<MediaTrack::Id> audioTrackId; 966 std::vector<MediaTrack::Id> audioTrackId;
969 audioTrackId.push_back("2"); 967 audioTrackId.push_back("2");
970 pipeline_->OnEnabledAudioTracksChanged(audioTrackId); 968 pipeline_->OnEnabledAudioTracksChanged(audioTrackId);
971 message_loop_.RunUntilIdle(); 969 base::RunLoop().RunUntilIdle();
972 970
973 // Restart playback from 500ms position. 971 // Restart playback from 500ms position.
974 ASSERT_TRUE(Seek(k500ms)); 972 ASSERT_TRUE(Seek(k500ms));
975 Play(); 973 Play();
976 ASSERT_TRUE(WaitUntilOnEnded()); 974 ASSERT_TRUE(WaitUntilOnEnded());
977 975
978 // Verify that audio has been playing after being enabled. 976 // Verify that audio has been playing after being enabled.
979 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); 977 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash());
980 } 978 }
981 979
982 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { 980 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) {
983 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); 981 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
984 982
985 // Disable video. 983 // Disable video.
986 std::vector<MediaTrack::Id> empty; 984 std::vector<MediaTrack::Id> empty;
987 pipeline_->OnSelectedVideoTrackChanged(empty); 985 pipeline_->OnSelectedVideoTrackChanged(empty);
988 message_loop_.RunUntilIdle(); 986 base::RunLoop().RunUntilIdle();
989 987
990 // Seek to flush the pipeline and ensure there's no prerolled video data. 988 // Seek to flush the pipeline and ensure there's no prerolled video data.
991 ASSERT_TRUE(Seek(base::TimeDelta())); 989 ASSERT_TRUE(Seek(base::TimeDelta()));
992 990
993 // Reset the video hash in case some of the prerolled video frames have been 991 // Reset the video hash in case some of the prerolled video frames have been
994 // hashed already. 992 // hashed already.
995 ResetVideoHash(); 993 ResetVideoHash();
996 994
997 Play(); 995 Play();
998 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); 996 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500);
999 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); 997 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
1000 Pause(); 998 Pause();
1001 999
1002 // Verify that no video has been rendered, since we disabled video tracks. 1000 // Verify that no video has been rendered, since we disabled video tracks.
1003 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); 1001 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash());
1004 1002
1005 // Re-enable video. 1003 // Re-enable video.
1006 std::vector<MediaTrack::Id> videoTrackId; 1004 std::vector<MediaTrack::Id> videoTrackId;
1007 videoTrackId.push_back("1"); 1005 videoTrackId.push_back("1");
1008 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); 1006 pipeline_->OnSelectedVideoTrackChanged(videoTrackId);
1009 message_loop_.RunUntilIdle(); 1007 base::RunLoop().RunUntilIdle();
1010 1008
1011 // Seek to flush video pipeline and reset the video hash again to clear state 1009 // Seek to flush video pipeline and reset the video hash again to clear state
1012 // if some prerolled frames got hashed after enabling video. 1010 // if some prerolled frames got hashed after enabling video.
1013 ASSERT_TRUE(Seek(base::TimeDelta())); 1011 ASSERT_TRUE(Seek(base::TimeDelta()));
1014 ResetVideoHash(); 1012 ResetVideoHash();
1015 1013
1016 // Restart playback from 500ms position. 1014 // Restart playback from 500ms position.
1017 ASSERT_TRUE(Seek(k500ms)); 1015 ASSERT_TRUE(Seek(k500ms));
1018 Play(); 1016 Play();
1019 ASSERT_TRUE(WaitUntilOnEnded()); 1017 ASSERT_TRUE(WaitUntilOnEnded());
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 1751
1754 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); 1752 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1);
1755 scoped_refptr<DecoderBuffer> second_file = 1753 scoped_refptr<DecoderBuffer> second_file =
1756 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); 1754 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
1757 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), 1755 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
1758 second_file->data(), 1756 second_file->data(),
1759 second_file->data_size())); 1757 second_file->data_size()));
1760 1758
1761 source.EndOfStream(); 1759 source.EndOfStream();
1762 1760
1763 message_loop_.Run(); 1761 message_loop_.Run();
chcunningham 2016/07/08 19:39:12 Should this use RunLoop?
fdoray 2016/07/08 20:19:04 yes, fixed in the latest patch set
1764 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_); 1762 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_);
1765 1763
1766 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1764 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1767 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1765 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1768 // The second video was not added, so its time has not been added. 1766 // The second video was not added, so its time has not been added.
1769 EXPECT_EQ(k640IsoFileDurationMs, 1767 EXPECT_EQ(k640IsoFileDurationMs,
1770 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1768 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1771 1769
1772 Play(); 1770 Play();
1773 1771
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2397
2400 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2398 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2401 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2399 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2402 Play(); 2400 Play();
2403 ASSERT_TRUE(WaitUntilOnEnded()); 2401 ASSERT_TRUE(WaitUntilOnEnded());
2404 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2402 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2405 demuxer_->GetStartTime()); 2403 demuxer_->GetStartTime());
2406 } 2404 }
2407 2405
2408 } // namespace media 2406 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698