summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/base/mock_filters.h6
-rw-r--r--media/base/pipeline_impl.cc6
-rw-r--r--media/base/pipeline_impl_unittest.cc16
3 files changed, 20 insertions, 8 deletions
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
index c933bd2..7954aa9 100644
--- a/media/base/mock_filters.h
+++ b/media/base/mock_filters.h
@@ -336,6 +336,12 @@ ACTION_P2(SetError, filter, error) {
filter->host()->SetError(error);
}
+// Helper gmock action that calls SetDuration() on behalf of the provided
+// filter.
+ACTION_P2(SetDuration, filter, duration) {
+ filter->host()->SetDuration(duration);
+}
+
} // namespace media
#endif // MEDIA_BASE_MOCK_FILTERS_H_
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 21b9338..a09c2c7 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -202,7 +202,11 @@ void PipelineImpl::SetVolume(float volume) {
base::TimeDelta PipelineImpl::GetCurrentTime() const {
AutoLock auto_lock(lock_);
- return clock_.Elapsed();
+ base::TimeDelta elapsed = clock_.Elapsed();
+ if (elapsed > duration_) {
+ return duration_;
+ }
+ return elapsed;
}
base::TimeDelta PipelineImpl::GetBufferedTime() const {
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index e745761..7e69ce5 100644
--- a/media/base/pipeline_impl_unittest.cc
+++ b/media/base/pipeline_impl_unittest.cc
@@ -75,10 +75,12 @@ class PipelineImplTest : public ::testing::Test {
// Sets up expectations to allow the demuxer to initialize.
typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector;
- void InitializeDemuxer(MockDemuxerStreamVector* streams) {
+ void InitializeDemuxer(MockDemuxerStreamVector* streams,
+ const base::TimeDelta& duration) {
EXPECT_CALL(*mocks_->demuxer(),
Initialize(mocks_->data_source(), NotNull()))
- .WillOnce(Invoke(&RunFilterCallback));
+ .WillOnce(DoAll(SetDuration(mocks_->data_source(), duration),
+ Invoke(&RunFilterCallback)));
EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams())
.WillRepeatedly(Return(streams->size()));
EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f));
@@ -277,7 +279,7 @@ TEST_F(PipelineImplTest, AudioStream) {
streams.push_back(stream);
InitializeDataSource();
- InitializeDemuxer(&streams);
+ InitializeDemuxer(&streams, base::TimeDelta());
InitializeAudioDecoder(stream);
InitializeAudioRenderer();
@@ -295,7 +297,7 @@ TEST_F(PipelineImplTest, VideoStream) {
streams.push_back(stream);
InitializeDataSource();
- InitializeDemuxer(&streams);
+ InitializeDemuxer(&streams, base::TimeDelta());
InitializeVideoDecoder(stream);
InitializeVideoRenderer();
@@ -316,7 +318,7 @@ TEST_F(PipelineImplTest, AudioVideoStream) {
streams.push_back(video_stream);
InitializeDataSource();
- InitializeDemuxer(&streams);
+ InitializeDemuxer(&streams, base::TimeDelta());
InitializeAudioDecoder(audio_stream);
InitializeAudioRenderer();
InitializeVideoDecoder(video_stream);
@@ -339,7 +341,7 @@ TEST_F(PipelineImplTest, Seek) {
streams.push_back(video_stream);
InitializeDataSource();
- InitializeDemuxer(&streams);
+ InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000));
InitializeAudioDecoder(audio_stream);
InitializeAudioRenderer();
InitializeVideoDecoder(video_stream);
@@ -382,7 +384,7 @@ TEST_F(PipelineImplTest, SetVolume) {
streams.push_back(audio_stream);
InitializeDataSource();
- InitializeDemuxer(&streams);
+ InitializeDemuxer(&streams, base::TimeDelta());
InitializeAudioDecoder(audio_stream);
InitializeAudioRenderer();