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

Side by Side Diff: media/base/pipeline_unittest.cc

Issue 575643002: Initialize media timeline correctly for positive start times. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 6 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/base/pipeline.cc ('k') | media/filters/chunk_demuxer.h » ('j') | 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 <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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 .WillRepeatedly(Return(null_pointer)); 96 .WillRepeatedly(Return(null_pointer));
97 97
98 EXPECT_CALL(*demuxer_, GetTimelineOffset()) 98 EXPECT_CALL(*demuxer_, GetTimelineOffset())
99 .WillRepeatedly(Return(base::Time())); 99 .WillRepeatedly(Return(base::Time()));
100 100
101 EXPECT_CALL(*demuxer_, GetLiveness()) 101 EXPECT_CALL(*demuxer_, GetLiveness())
102 .WillRepeatedly(Return(Demuxer::LIVENESS_UNKNOWN)); 102 .WillRepeatedly(Return(Demuxer::LIVENESS_UNKNOWN));
103 103
104 EXPECT_CALL(*renderer_, GetMediaTime()) 104 EXPECT_CALL(*renderer_, GetMediaTime())
105 .WillRepeatedly(Return(base::TimeDelta())); 105 .WillRepeatedly(Return(base::TimeDelta()));
106
107 EXPECT_CALL(*demuxer_, GetStartTime()).WillRepeatedly(Return(start_time_));
106 } 108 }
107 109
108 virtual ~PipelineTest() { 110 virtual ~PipelineTest() {
109 if (!pipeline_ || !pipeline_->IsRunning()) 111 if (!pipeline_ || !pipeline_->IsRunning())
110 return; 112 return;
111 113
112 ExpectDemuxerStop(); 114 ExpectDemuxerStop();
113 115
114 // The mock demuxer doesn't stop the fake text track stream, 116 // The mock demuxer doesn't stop the fake text track stream,
115 // so just stop it manually. 117 // so just stop it manually.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 198
197 // Sets up expectations on the callback and initializes the pipeline. Called 199 // Sets up expectations on the callback and initializes the pipeline. Called
198 // after tests have set expectations any filters they wish to use. 200 // after tests have set expectations any filters they wish to use.
199 void StartPipelineAndExpect(PipelineStatus start_status) { 201 void StartPipelineAndExpect(PipelineStatus start_status) {
200 EXPECT_CALL(callbacks_, OnStart(start_status)); 202 EXPECT_CALL(callbacks_, OnStart(start_status));
201 203
202 if (start_status == PIPELINE_OK) { 204 if (start_status == PIPELINE_OK) {
203 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_)); 205 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_));
204 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f)); 206 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f));
205 EXPECT_CALL(*renderer_, SetVolume(1.0f)); 207 EXPECT_CALL(*renderer_, SetVolume(1.0f));
206 EXPECT_CALL(*renderer_, StartPlayingFrom(base::TimeDelta())) 208 EXPECT_CALL(*renderer_, StartPlayingFrom(start_time_))
207 .WillOnce(SetBufferingState(&buffering_state_cb_, 209 .WillOnce(SetBufferingState(&buffering_state_cb_,
208 BUFFERING_HAVE_ENOUGH)); 210 BUFFERING_HAVE_ENOUGH));
209 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 211 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
210 } 212 }
211 213
212 StartPipeline(); 214 StartPipeline();
213 message_loop_.RunUntilIdle(); 215 message_loop_.RunUntilIdle();
214 } 216 }
215 217
216 void CreateAudioStream() { 218 void CreateAudioStream() {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 StrictMock<MockRenderer>* renderer_; 308 StrictMock<MockRenderer>* renderer_;
307 StrictMock<CallbackHelper> text_renderer_callbacks_; 309 StrictMock<CallbackHelper> text_renderer_callbacks_;
308 TextRenderer* text_renderer_; 310 TextRenderer* text_renderer_;
309 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; 311 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_;
310 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; 312 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_;
311 scoped_ptr<FakeTextTrackStream> text_stream_; 313 scoped_ptr<FakeTextTrackStream> text_stream_;
312 BufferingStateCB buffering_state_cb_; 314 BufferingStateCB buffering_state_cb_;
313 base::Closure ended_cb_; 315 base::Closure ended_cb_;
314 VideoDecoderConfig video_decoder_config_; 316 VideoDecoderConfig video_decoder_config_;
315 PipelineMetadata metadata_; 317 PipelineMetadata metadata_;
318 base::TimeDelta start_time_;
316 319
317 private: 320 private:
318 DISALLOW_COPY_AND_ASSIGN(PipelineTest); 321 DISALLOW_COPY_AND_ASSIGN(PipelineTest);
319 }; 322 };
320 323
321 // Test that playback controls methods no-op when the pipeline hasn't been 324 // Test that playback controls methods no-op when the pipeline hasn't been
322 // started. 325 // started.
323 TEST_F(PipelineTest, NotStarted) { 326 TEST_F(PipelineTest, NotStarted) {
324 const base::TimeDelta kZero; 327 const base::TimeDelta kZero;
325 328
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Simulate underflow. 738 // Simulate underflow.
736 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); 739 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
737 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); 740 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
738 741
739 // Seek while underflowed. 742 // Seek while underflowed.
740 base::TimeDelta expected = base::TimeDelta::FromSeconds(5); 743 base::TimeDelta expected = base::TimeDelta::FromSeconds(5);
741 ExpectSeek(expected, true); 744 ExpectSeek(expected, true);
742 DoSeek(expected); 745 DoSeek(expected);
743 } 746 }
744 747
748 TEST_F(PipelineTest, PositiveStartTime) {
749 start_time_ = base::TimeDelta::FromSeconds(1);
750 EXPECT_CALL(*demuxer_, GetStartTime()).WillRepeatedly(Return(start_time_));
751 CreateAudioStream();
752 MockDemuxerStreamVector streams;
753 streams.push_back(audio_stream());
754 SetDemuxerExpectations(&streams);
755 SetRendererExpectations();
756 StartPipelineAndExpect(PIPELINE_OK);
757 ExpectDemuxerStop();
758 ExpectPipelineStopAndDestroyPipeline();
759 pipeline_->Stop(
760 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_)));
761 message_loop_.RunUntilIdle();
762 }
763
745 class PipelineTeardownTest : public PipelineTest { 764 class PipelineTeardownTest : public PipelineTest {
746 public: 765 public:
747 enum TeardownState { 766 enum TeardownState {
748 kInitDemuxer, 767 kInitDemuxer,
749 kInitRenderer, 768 kInitRenderer,
750 kFlushing, 769 kFlushing,
751 kSeeking, 770 kSeeking,
752 kPlaying, 771 kPlaying,
753 }; 772 };
754 773
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 993
975 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); 994 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer);
976 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer); 995 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer);
977 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); 996 INSTANTIATE_TEARDOWN_TEST(Error, Flushing);
978 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 997 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
979 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 998 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
980 999
981 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1000 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
982 1001
983 } // namespace media 1002 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/chunk_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698