| OLD | NEW |
| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 746 |
| 747 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 747 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 748 InitializeDemuxer(&streams, kDuration); | 748 InitializeDemuxer(&streams, kDuration); |
| 749 InitializeVideoRenderer(video_stream()); | 749 InitializeVideoRenderer(video_stream()); |
| 750 | 750 |
| 751 InitializePipeline(PIPELINE_OK); | 751 InitializePipeline(PIPELINE_OK); |
| 752 EXPECT_FALSE(metadata_.has_audio); | 752 EXPECT_FALSE(metadata_.has_audio); |
| 753 EXPECT_TRUE(metadata_.has_video); | 753 EXPECT_TRUE(metadata_.has_video); |
| 754 | 754 |
| 755 EXPECT_EQ(base::TimeDelta(), pipeline_->GetMediaTime()); | 755 EXPECT_EQ(base::TimeDelta(), pipeline_->GetMediaTime()); |
| 756 const base::TimeDelta kSeekPoint = kDuration / 2; |
| 757 ExpectSeek(kSeekPoint); |
| 758 DoSeek(kSeekPoint); |
| 756 } | 759 } |
| 757 | 760 |
| 758 TEST_F(PipelineTest, StartTimeIsNonZero) { | 761 TEST_F(PipelineTest, StartTimeIsNonZero) { |
| 759 const base::TimeDelta kStartTime = base::TimeDelta::FromSeconds(4); | 762 const base::TimeDelta kStartTime = base::TimeDelta::FromSeconds(4); |
| 760 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 763 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 761 | 764 |
| 762 EXPECT_CALL(*demuxer_, GetStartTime()) | 765 EXPECT_CALL(*demuxer_, GetStartTime()) |
| 763 .WillRepeatedly(Return(kStartTime)); | 766 .WillRepeatedly(Return(kStartTime)); |
| 764 | 767 |
| 765 CreateVideoStream(); | 768 CreateVideoStream(); |
| 766 MockDemuxerStreamVector streams; | 769 MockDemuxerStreamVector streams; |
| 767 streams.push_back(video_stream()); | 770 streams.push_back(video_stream()); |
| 768 | 771 |
| 769 InitializeDemuxer(&streams, kDuration); | 772 InitializeDemuxer(&streams, kDuration); |
| 770 InitializeVideoRenderer(video_stream()); | 773 InitializeVideoRenderer(video_stream()); |
| 771 | 774 |
| 772 InitializePipeline(PIPELINE_OK); | 775 InitializePipeline(PIPELINE_OK); |
| 773 EXPECT_FALSE(metadata_.has_audio); | 776 EXPECT_FALSE(metadata_.has_audio); |
| 774 EXPECT_TRUE(metadata_.has_video); | 777 EXPECT_TRUE(metadata_.has_video); |
| 775 | 778 |
| 776 EXPECT_EQ(kStartTime, pipeline_->GetMediaTime()); | 779 EXPECT_EQ(kStartTime, pipeline_->GetMediaTime()); |
| 780 const base::TimeDelta kSeekPoint = kDuration / 2; |
| 781 ExpectSeek(kSeekPoint + kStartTime); |
| 782 DoSeek(kSeekPoint); |
| 783 } |
| 784 |
| 785 TEST_F(PipelineTest, StartTimeIsNegative) { |
| 786 const base::TimeDelta kStartTime = base::TimeDelta::FromSeconds(-4); |
| 787 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 788 |
| 789 EXPECT_CALL(*demuxer_, GetStartTime()) |
| 790 .WillRepeatedly(Return(kStartTime)); |
| 791 |
| 792 CreateVideoStream(); |
| 793 MockDemuxerStreamVector streams; |
| 794 streams.push_back(video_stream()); |
| 795 |
| 796 InitializeDemuxer(&streams, kDuration); |
| 797 InitializeVideoRenderer(video_stream()); |
| 798 |
| 799 InitializePipeline(PIPELINE_OK); |
| 800 EXPECT_FALSE(metadata_.has_audio); |
| 801 EXPECT_TRUE(metadata_.has_video); |
| 802 |
| 803 // The media time should be clamped to zero. |
| 804 EXPECT_EQ(base::TimeDelta(), pipeline_->GetMediaTime()); |
| 805 const base::TimeDelta kSeekPoint = kDuration / 2; |
| 806 ExpectSeek(kSeekPoint + kStartTime); |
| 807 DoSeek(kSeekPoint); |
| 777 } | 808 } |
| 778 | 809 |
| 779 static void RunTimeCB(const AudioRenderer::TimeCB& time_cb, | 810 static void RunTimeCB(const AudioRenderer::TimeCB& time_cb, |
| 780 int time_in_ms, | 811 int time_in_ms, |
| 781 int max_time_in_ms) { | 812 int max_time_in_ms) { |
| 782 time_cb.Run(base::TimeDelta::FromMilliseconds(time_in_ms), | 813 time_cb.Run(base::TimeDelta::FromMilliseconds(time_in_ms), |
| 783 base::TimeDelta::FromMilliseconds(max_time_in_ms)); | 814 base::TimeDelta::FromMilliseconds(max_time_in_ms)); |
| 784 } | 815 } |
| 785 | 816 |
| 786 TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) { | 817 TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); | 1179 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); |
| 1149 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); | 1180 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); |
| 1150 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1181 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
| 1151 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1182 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1152 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); | 1183 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); |
| 1153 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1184 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1154 | 1185 |
| 1155 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); | 1186 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); |
| 1156 | 1187 |
| 1157 } // namespace media | 1188 } // namespace media |
| OLD | NEW |