Chromium Code Reviews| 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/command_line.h" | |
| 8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 10 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
| 11 #include "base/threading/simple_thread.h" | 12 #include "base/threading/simple_thread.h" |
| 12 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
| 13 #include "media/base/fake_text_track_stream.h" | 14 #include "media/base/fake_text_track_stream.h" |
| 14 #include "media/base/gmock_callback_support.h" | 15 #include "media/base/gmock_callback_support.h" |
| 15 #include "media/base/media_log.h" | 16 #include "media/base/media_log.h" |
| 17 #include "media/base/media_switches.h" | |
| 16 #include "media/base/mock_filters.h" | 18 #include "media/base/mock_filters.h" |
| 17 #include "media/base/pipeline.h" | 19 #include "media/base/pipeline.h" |
| 18 #include "media/base/test_helpers.h" | 20 #include "media/base/test_helpers.h" |
| 19 #include "media/base/text_renderer.h" | 21 #include "media/base/text_renderer.h" |
| 20 #include "media/base/text_track_config.h" | 22 #include "media/base/text_track_config.h" |
| 21 #include "media/base/time_delta_interpolator.h" | 23 #include "media/base/time_delta_interpolator.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
| 24 | 26 |
| 25 using ::testing::_; | 27 using ::testing::_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | 81 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); |
| 80 MOCK_METHOD0(OnDurationChange, void()); | 82 MOCK_METHOD0(OnDurationChange, void()); |
| 81 | 83 |
| 82 private: | 84 private: |
| 83 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); | 85 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 PipelineTest() | 88 PipelineTest() |
| 87 : pipeline_(new Pipeline(message_loop_.message_loop_proxy(), | 89 : pipeline_(new Pipeline(message_loop_.message_loop_proxy(), |
| 88 new MediaLog())), | 90 new MediaLog())), |
| 89 filter_collection_(new FilterCollection()), | 91 demuxer_(new StrictMock<MockDemuxer>()), |
| 90 demuxer_(new StrictMock<MockDemuxer>()) { | 92 scoped_renderer_(new StrictMock<MockRenderer>()), |
| 91 filter_collection_->SetDemuxer(demuxer_.get()); | 93 renderer_(scoped_renderer_.get()) { |
| 92 | |
| 93 renderer_ = new StrictMock<MockRenderer>(); | |
| 94 scoped_ptr<Renderer> renderer(renderer_); | |
| 95 filter_collection_->SetRenderer(renderer.Pass()); | |
| 96 | |
| 97 text_renderer_ = new TextRenderer( | |
| 98 message_loop_.message_loop_proxy(), | |
| 99 base::Bind(&PipelineTest::OnAddTextTrack, | |
| 100 base::Unretained(this))); | |
| 101 scoped_ptr<TextRenderer> text_renderer(text_renderer_); | |
| 102 filter_collection_->SetTextRenderer(text_renderer.Pass()); | |
| 103 | |
| 104 // SetDemuxerExpectations() adds overriding expectations for expected | 94 // SetDemuxerExpectations() adds overriding expectations for expected |
| 105 // non-NULL streams. | 95 // non-NULL streams. |
| 106 DemuxerStream* null_pointer = NULL; | 96 DemuxerStream* null_pointer = NULL; |
| 107 EXPECT_CALL(*demuxer_, GetStream(_)) | 97 EXPECT_CALL(*demuxer_, GetStream(_)) |
| 108 .WillRepeatedly(Return(null_pointer)); | 98 .WillRepeatedly(Return(null_pointer)); |
| 109 | 99 |
| 110 EXPECT_CALL(*demuxer_, GetTimelineOffset()) | 100 EXPECT_CALL(*demuxer_, GetTimelineOffset()) |
| 111 .WillRepeatedly(Return(base::Time())); | 101 .WillRepeatedly(Return(base::Time())); |
| 112 | 102 |
| 113 EXPECT_CALL(*demuxer_, GetLiveness()) | 103 EXPECT_CALL(*demuxer_, GetLiveness()) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 130 message_loop_.RunUntilIdle(); | 120 message_loop_.RunUntilIdle(); |
| 131 } | 121 } |
| 132 | 122 |
| 133 // Expect a stop callback if we were started. | 123 // Expect a stop callback if we were started. |
| 134 ExpectPipelineStopAndDestroyPipeline(); | 124 ExpectPipelineStopAndDestroyPipeline(); |
| 135 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 125 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
| 136 base::Unretained(&callbacks_))); | 126 base::Unretained(&callbacks_))); |
| 137 message_loop_.RunUntilIdle(); | 127 message_loop_.RunUntilIdle(); |
| 138 } | 128 } |
| 139 | 129 |
| 130 // Test implementation. | |
| 131 virtual void SetUp() OVERRIDE { | |
| 132 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
|
scherkus (not reviewing)
2014/08/28 18:48:22
IIRC this executes once per test
typically we've
xhwang
2014/08/28 19:52:05
Done.
But I actually searched run_all_unittests.c
scherkus (not reviewing)
2014/08/28 19:57:18
That's because we've launched features / enabled t
| |
| 133 command_line->AppendSwitch(switches::kEnableInbandTextTracks); | |
| 134 } | |
| 135 | |
| 140 void OnDemuxerError() { | 136 void OnDemuxerError() { |
| 141 // Cast because OnDemuxerError is private in Pipeline. | 137 // Cast because OnDemuxerError is private in Pipeline. |
| 142 static_cast<DemuxerHost*>(pipeline_.get()) | 138 static_cast<DemuxerHost*>(pipeline_.get()) |
| 143 ->OnDemuxerError(PIPELINE_ERROR_ABORT); | 139 ->OnDemuxerError(PIPELINE_ERROR_ABORT); |
| 144 } | 140 } |
| 145 | 141 |
| 146 protected: | 142 protected: |
| 147 // Sets up expectations to allow the demuxer to initialize. | 143 // Sets up expectations to allow the demuxer to initialize. |
| 148 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 144 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 149 void SetDemuxerExpectations(MockDemuxerStreamVector* streams, | 145 void SetDemuxerExpectations(MockDemuxerStreamVector* streams, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 } | 180 } |
| 185 | 181 |
| 186 void AddTextStream() { | 182 void AddTextStream() { |
| 187 EXPECT_CALL(*this, OnAddTextTrack(_,_)) | 183 EXPECT_CALL(*this, OnAddTextTrack(_,_)) |
| 188 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack)); | 184 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack)); |
| 189 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(), | 185 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(), |
| 190 TextTrackConfig(kTextSubtitles, "", "", "")); | 186 TextTrackConfig(kTextSubtitles, "", "", "")); |
| 191 message_loop_.RunUntilIdle(); | 187 message_loop_.RunUntilIdle(); |
| 192 } | 188 } |
| 193 | 189 |
| 190 void StartPipeline() { | |
| 191 pipeline_->Start( | |
| 192 demuxer_.get(), | |
| 193 scoped_renderer_.PassAs<Renderer>(), | |
| 194 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | |
| 195 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | |
| 196 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | |
| 197 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | |
| 198 base::Bind(&CallbackHelper::OnBufferingStateChange, | |
| 199 base::Unretained(&callbacks_)), | |
| 200 base::Bind(&CallbackHelper::OnDurationChange, | |
| 201 base::Unretained(&callbacks_)), | |
| 202 base::Bind(&PipelineTest::OnAddTextTrack, base::Unretained(this))); | |
| 203 } | |
| 204 | |
| 194 // Sets up expectations on the callback and initializes the pipeline. Called | 205 // Sets up expectations on the callback and initializes the pipeline. Called |
| 195 // after tests have set expectations any filters they wish to use. | 206 // after tests have set expectations any filters they wish to use. |
| 196 void StartPipeline(PipelineStatus start_status) { | 207 void StartPipelineAndExpect(PipelineStatus start_status) { |
| 197 EXPECT_CALL(callbacks_, OnStart(start_status)); | 208 EXPECT_CALL(callbacks_, OnStart(start_status)); |
| 198 | 209 |
| 199 if (start_status == PIPELINE_OK) { | 210 if (start_status == PIPELINE_OK) { |
| 200 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_)); | 211 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_)); |
| 201 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f)); | 212 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f)); |
| 202 EXPECT_CALL(*renderer_, SetVolume(1.0f)); | 213 EXPECT_CALL(*renderer_, SetVolume(1.0f)); |
| 203 EXPECT_CALL(*renderer_, StartPlayingFrom(base::TimeDelta())) | 214 EXPECT_CALL(*renderer_, StartPlayingFrom(base::TimeDelta())) |
| 204 .WillOnce(SetBufferingState(&buffering_state_cb_, | 215 .WillOnce(SetBufferingState(&buffering_state_cb_, |
| 205 BUFFERING_HAVE_ENOUGH)); | 216 BUFFERING_HAVE_ENOUGH)); |
| 206 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 217 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 207 } | 218 } |
| 208 | 219 |
| 209 pipeline_->Start( | 220 StartPipeline(); |
| 210 filter_collection_.Pass(), | |
| 211 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | |
| 212 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | |
| 213 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | |
| 214 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | |
| 215 base::Bind(&CallbackHelper::OnBufferingStateChange, | |
| 216 base::Unretained(&callbacks_)), | |
| 217 base::Bind(&CallbackHelper::OnDurationChange, | |
| 218 base::Unretained(&callbacks_))); | |
| 219 message_loop_.RunUntilIdle(); | 221 message_loop_.RunUntilIdle(); |
| 220 } | 222 } |
| 221 | 223 |
| 222 void CreateAudioStream() { | 224 void CreateAudioStream() { |
| 223 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 225 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
| 224 } | 226 } |
| 225 | 227 |
| 226 void CreateVideoStream() { | 228 void CreateVideoStream() { |
| 227 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 229 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
| 228 video_stream_->set_video_decoder_config(video_decoder_config_); | 230 video_stream_->set_video_decoder_config(video_decoder_config_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 scoped_ptr<TextTrack> text_track(new MockTextTrack); | 302 scoped_ptr<TextTrack> text_track(new MockTextTrack); |
| 301 done_cb.Run(text_track.Pass()); | 303 done_cb.Run(text_track.Pass()); |
| 302 } | 304 } |
| 303 | 305 |
| 304 // Fixture members. | 306 // Fixture members. |
| 305 StrictMock<CallbackHelper> callbacks_; | 307 StrictMock<CallbackHelper> callbacks_; |
| 306 base::SimpleTestTickClock test_tick_clock_; | 308 base::SimpleTestTickClock test_tick_clock_; |
| 307 base::MessageLoop message_loop_; | 309 base::MessageLoop message_loop_; |
| 308 scoped_ptr<Pipeline> pipeline_; | 310 scoped_ptr<Pipeline> pipeline_; |
| 309 | 311 |
| 310 scoped_ptr<FilterCollection> filter_collection_; | |
| 311 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; | 312 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; |
| 313 scoped_ptr<StrictMock<MockRenderer> > scoped_renderer_; | |
| 312 StrictMock<MockRenderer>* renderer_; | 314 StrictMock<MockRenderer>* renderer_; |
| 313 StrictMock<CallbackHelper> text_renderer_callbacks_; | 315 StrictMock<CallbackHelper> text_renderer_callbacks_; |
| 314 TextRenderer* text_renderer_; | 316 TextRenderer* text_renderer_; |
| 315 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; | 317 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; |
| 316 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; | 318 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; |
| 317 scoped_ptr<FakeTextTrackStream> text_stream_; | 319 scoped_ptr<FakeTextTrackStream> text_stream_; |
| 318 BufferingStateCB buffering_state_cb_; | 320 BufferingStateCB buffering_state_cb_; |
| 319 base::Closure ended_cb_; | 321 base::Closure ended_cb_; |
| 320 VideoDecoderConfig video_decoder_config_; | 322 VideoDecoderConfig video_decoder_config_; |
| 321 PipelineMetadata metadata_; | 323 PipelineMetadata metadata_; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 350 EXPECT_TRUE(kZero == pipeline_->GetMediaDuration()); | 352 EXPECT_TRUE(kZero == pipeline_->GetMediaDuration()); |
| 351 } | 353 } |
| 352 | 354 |
| 353 TEST_F(PipelineTest, NeverInitializes) { | 355 TEST_F(PipelineTest, NeverInitializes) { |
| 354 // Don't execute the callback passed into Initialize(). | 356 // Don't execute the callback passed into Initialize(). |
| 355 EXPECT_CALL(*demuxer_, Initialize(_, _, _)); | 357 EXPECT_CALL(*demuxer_, Initialize(_, _, _)); |
| 356 | 358 |
| 357 // This test hangs during initialization by never calling | 359 // This test hangs during initialization by never calling |
| 358 // InitializationComplete(). StrictMock<> will ensure that the callback is | 360 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 359 // never executed. | 361 // never executed. |
| 360 pipeline_->Start( | 362 StartPipeline(); |
| 361 filter_collection_.Pass(), | |
| 362 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | |
| 363 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | |
| 364 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | |
| 365 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | |
| 366 base::Bind(&CallbackHelper::OnBufferingStateChange, | |
| 367 base::Unretained(&callbacks_)), | |
| 368 base::Bind(&CallbackHelper::OnDurationChange, | |
| 369 base::Unretained(&callbacks_))); | |
| 370 message_loop_.RunUntilIdle(); | 363 message_loop_.RunUntilIdle(); |
| 371 | 364 |
| 372 // Because our callback will get executed when the test tears down, we'll | 365 // Because our callback will get executed when the test tears down, we'll |
| 373 // verify that nothing has been called, then set our expectation for the call | 366 // verify that nothing has been called, then set our expectation for the call |
| 374 // made during tear down. | 367 // made during tear down. |
| 375 Mock::VerifyAndClear(&callbacks_); | 368 Mock::VerifyAndClear(&callbacks_); |
| 376 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 369 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
| 377 } | 370 } |
| 378 | 371 |
| 379 TEST_F(PipelineTest, StopWithoutStart) { | 372 TEST_F(PipelineTest, StopWithoutStart) { |
| 380 ExpectPipelineStopAndDestroyPipeline(); | 373 ExpectPipelineStopAndDestroyPipeline(); |
| 381 pipeline_->Stop( | 374 pipeline_->Stop( |
| 382 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 375 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
| 383 message_loop_.RunUntilIdle(); | 376 message_loop_.RunUntilIdle(); |
| 384 } | 377 } |
| 385 | 378 |
| 386 TEST_F(PipelineTest, StartThenStopImmediately) { | 379 TEST_F(PipelineTest, StartThenStopImmediately) { |
| 387 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 380 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
| 388 .WillOnce(RunCallback<1>(PIPELINE_OK)); | 381 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 389 EXPECT_CALL(*demuxer_, Stop(_)) | 382 EXPECT_CALL(*demuxer_, Stop(_)) |
| 390 .WillOnce(RunClosure<0>()); | 383 .WillOnce(RunClosure<0>()); |
| 391 | 384 |
| 392 EXPECT_CALL(callbacks_, OnStart(_)); | 385 EXPECT_CALL(callbacks_, OnStart(_)); |
| 393 | 386 StartPipeline(); |
| 394 pipeline_->Start( | |
| 395 filter_collection_.Pass(), | |
| 396 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | |
| 397 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | |
| 398 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | |
| 399 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | |
| 400 base::Bind(&CallbackHelper::OnBufferingStateChange, | |
| 401 base::Unretained(&callbacks_)), | |
| 402 base::Bind(&CallbackHelper::OnDurationChange, | |
| 403 base::Unretained(&callbacks_))); | |
| 404 | 387 |
| 405 // Expect a stop callback if we were started. | 388 // Expect a stop callback if we were started. |
| 406 ExpectPipelineStopAndDestroyPipeline(); | 389 ExpectPipelineStopAndDestroyPipeline(); |
| 407 pipeline_->Stop( | 390 pipeline_->Stop( |
| 408 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 391 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
| 409 message_loop_.RunUntilIdle(); | 392 message_loop_.RunUntilIdle(); |
| 410 } | 393 } |
| 411 | 394 |
| 412 TEST_F(PipelineTest, DemuxerErrorDuringStop) { | 395 TEST_F(PipelineTest, DemuxerErrorDuringStop) { |
| 413 CreateAudioStream(); | 396 CreateAudioStream(); |
| 414 MockDemuxerStreamVector streams; | 397 MockDemuxerStreamVector streams; |
| 415 streams.push_back(audio_stream()); | 398 streams.push_back(audio_stream()); |
| 416 | 399 |
| 417 SetDemuxerExpectations(&streams); | 400 SetDemuxerExpectations(&streams); |
| 418 SetRendererExpectations(); | 401 SetRendererExpectations(); |
| 419 | 402 |
| 420 StartPipeline(PIPELINE_OK); | 403 StartPipelineAndExpect(PIPELINE_OK); |
| 421 | 404 |
| 422 EXPECT_CALL(*demuxer_, Stop(_)) | 405 EXPECT_CALL(*demuxer_, Stop(_)) |
| 423 .WillOnce(DoAll(InvokeWithoutArgs(this, &PipelineTest::OnDemuxerError), | 406 .WillOnce(DoAll(InvokeWithoutArgs(this, &PipelineTest::OnDemuxerError), |
| 424 RunClosure<0>())); | 407 RunClosure<0>())); |
| 425 ExpectPipelineStopAndDestroyPipeline(); | 408 ExpectPipelineStopAndDestroyPipeline(); |
| 426 | 409 |
| 427 pipeline_->Stop( | 410 pipeline_->Stop( |
| 428 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 411 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
| 429 message_loop_.RunUntilIdle(); | 412 message_loop_.RunUntilIdle(); |
| 430 } | 413 } |
| 431 | 414 |
| 432 TEST_F(PipelineTest, URLNotFound) { | 415 TEST_F(PipelineTest, URLNotFound) { |
| 433 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 416 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
| 434 .WillOnce(RunCallback<1>(PIPELINE_ERROR_URL_NOT_FOUND)); | 417 .WillOnce(RunCallback<1>(PIPELINE_ERROR_URL_NOT_FOUND)); |
| 435 EXPECT_CALL(*demuxer_, Stop(_)) | 418 EXPECT_CALL(*demuxer_, Stop(_)) |
| 436 .WillOnce(RunClosure<0>()); | 419 .WillOnce(RunClosure<0>()); |
| 437 | 420 |
| 438 StartPipeline(PIPELINE_ERROR_URL_NOT_FOUND); | 421 StartPipelineAndExpect(PIPELINE_ERROR_URL_NOT_FOUND); |
| 439 } | 422 } |
| 440 | 423 |
| 441 TEST_F(PipelineTest, NoStreams) { | 424 TEST_F(PipelineTest, NoStreams) { |
| 442 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 425 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
| 443 .WillOnce(RunCallback<1>(PIPELINE_OK)); | 426 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 444 EXPECT_CALL(*demuxer_, Stop(_)) | 427 EXPECT_CALL(*demuxer_, Stop(_)) |
| 445 .WillOnce(RunClosure<0>()); | 428 .WillOnce(RunClosure<0>()); |
| 446 | 429 |
| 447 StartPipeline(PIPELINE_ERROR_COULD_NOT_RENDER); | 430 StartPipelineAndExpect(PIPELINE_ERROR_COULD_NOT_RENDER); |
| 448 } | 431 } |
| 449 | 432 |
| 450 TEST_F(PipelineTest, AudioStream) { | 433 TEST_F(PipelineTest, AudioStream) { |
| 451 CreateAudioStream(); | 434 CreateAudioStream(); |
| 452 MockDemuxerStreamVector streams; | 435 MockDemuxerStreamVector streams; |
| 453 streams.push_back(audio_stream()); | 436 streams.push_back(audio_stream()); |
| 454 | 437 |
| 455 SetDemuxerExpectations(&streams); | 438 SetDemuxerExpectations(&streams); |
| 456 SetRendererExpectations(); | 439 SetRendererExpectations(); |
| 457 | 440 |
| 458 StartPipeline(PIPELINE_OK); | 441 StartPipelineAndExpect(PIPELINE_OK); |
| 459 EXPECT_TRUE(metadata_.has_audio); | 442 EXPECT_TRUE(metadata_.has_audio); |
| 460 EXPECT_FALSE(metadata_.has_video); | 443 EXPECT_FALSE(metadata_.has_video); |
| 461 } | 444 } |
| 462 | 445 |
| 463 TEST_F(PipelineTest, VideoStream) { | 446 TEST_F(PipelineTest, VideoStream) { |
| 464 CreateVideoStream(); | 447 CreateVideoStream(); |
| 465 MockDemuxerStreamVector streams; | 448 MockDemuxerStreamVector streams; |
| 466 streams.push_back(video_stream()); | 449 streams.push_back(video_stream()); |
| 467 | 450 |
| 468 SetDemuxerExpectations(&streams); | 451 SetDemuxerExpectations(&streams); |
| 469 SetRendererExpectations(); | 452 SetRendererExpectations(); |
| 470 | 453 |
| 471 StartPipeline(PIPELINE_OK); | 454 StartPipelineAndExpect(PIPELINE_OK); |
| 472 EXPECT_FALSE(metadata_.has_audio); | 455 EXPECT_FALSE(metadata_.has_audio); |
| 473 EXPECT_TRUE(metadata_.has_video); | 456 EXPECT_TRUE(metadata_.has_video); |
| 474 } | 457 } |
| 475 | 458 |
| 476 TEST_F(PipelineTest, AudioVideoStream) { | 459 TEST_F(PipelineTest, AudioVideoStream) { |
| 477 CreateAudioStream(); | 460 CreateAudioStream(); |
| 478 CreateVideoStream(); | 461 CreateVideoStream(); |
| 479 MockDemuxerStreamVector streams; | 462 MockDemuxerStreamVector streams; |
| 480 streams.push_back(audio_stream()); | 463 streams.push_back(audio_stream()); |
| 481 streams.push_back(video_stream()); | 464 streams.push_back(video_stream()); |
| 482 | 465 |
| 483 SetDemuxerExpectations(&streams); | 466 SetDemuxerExpectations(&streams); |
| 484 SetRendererExpectations(); | 467 SetRendererExpectations(); |
| 485 | 468 |
| 486 StartPipeline(PIPELINE_OK); | 469 StartPipelineAndExpect(PIPELINE_OK); |
| 487 EXPECT_TRUE(metadata_.has_audio); | 470 EXPECT_TRUE(metadata_.has_audio); |
| 488 EXPECT_TRUE(metadata_.has_video); | 471 EXPECT_TRUE(metadata_.has_video); |
| 489 } | 472 } |
| 490 | 473 |
| 491 TEST_F(PipelineTest, VideoTextStream) { | 474 TEST_F(PipelineTest, VideoTextStream) { |
| 492 CreateVideoStream(); | 475 CreateVideoStream(); |
| 493 CreateTextStream(); | 476 CreateTextStream(); |
| 494 MockDemuxerStreamVector streams; | 477 MockDemuxerStreamVector streams; |
| 495 streams.push_back(video_stream()); | 478 streams.push_back(video_stream()); |
| 496 | 479 |
| 497 SetDemuxerExpectations(&streams); | 480 SetDemuxerExpectations(&streams); |
| 498 SetRendererExpectations(); | 481 SetRendererExpectations(); |
| 499 | 482 |
| 500 StartPipeline(PIPELINE_OK); | 483 StartPipelineAndExpect(PIPELINE_OK); |
| 501 EXPECT_FALSE(metadata_.has_audio); | 484 EXPECT_FALSE(metadata_.has_audio); |
| 502 EXPECT_TRUE(metadata_.has_video); | 485 EXPECT_TRUE(metadata_.has_video); |
| 503 | 486 |
| 504 AddTextStream(); | 487 AddTextStream(); |
| 505 } | 488 } |
| 506 | 489 |
| 507 TEST_F(PipelineTest, VideoAudioTextStream) { | 490 TEST_F(PipelineTest, VideoAudioTextStream) { |
| 508 CreateVideoStream(); | 491 CreateVideoStream(); |
| 509 CreateAudioStream(); | 492 CreateAudioStream(); |
| 510 CreateTextStream(); | 493 CreateTextStream(); |
| 511 MockDemuxerStreamVector streams; | 494 MockDemuxerStreamVector streams; |
| 512 streams.push_back(video_stream()); | 495 streams.push_back(video_stream()); |
| 513 streams.push_back(audio_stream()); | 496 streams.push_back(audio_stream()); |
| 514 | 497 |
| 515 SetDemuxerExpectations(&streams); | 498 SetDemuxerExpectations(&streams); |
| 516 SetRendererExpectations(); | 499 SetRendererExpectations(); |
| 517 | 500 |
| 518 StartPipeline(PIPELINE_OK); | 501 StartPipelineAndExpect(PIPELINE_OK); |
| 519 EXPECT_TRUE(metadata_.has_audio); | 502 EXPECT_TRUE(metadata_.has_audio); |
| 520 EXPECT_TRUE(metadata_.has_video); | 503 EXPECT_TRUE(metadata_.has_video); |
| 521 | 504 |
| 522 AddTextStream(); | 505 AddTextStream(); |
| 523 } | 506 } |
| 524 | 507 |
| 525 TEST_F(PipelineTest, Seek) { | 508 TEST_F(PipelineTest, Seek) { |
| 526 CreateAudioStream(); | 509 CreateAudioStream(); |
| 527 CreateVideoStream(); | 510 CreateVideoStream(); |
| 528 CreateTextStream(); | 511 CreateTextStream(); |
| 529 MockDemuxerStreamVector streams; | 512 MockDemuxerStreamVector streams; |
| 530 streams.push_back(audio_stream()); | 513 streams.push_back(audio_stream()); |
| 531 streams.push_back(video_stream()); | 514 streams.push_back(video_stream()); |
| 532 | 515 |
| 533 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); | 516 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); |
| 534 SetRendererExpectations(); | 517 SetRendererExpectations(); |
| 535 | 518 |
| 536 // Initialize then seek! | 519 // Initialize then seek! |
| 537 StartPipeline(PIPELINE_OK); | 520 StartPipelineAndExpect(PIPELINE_OK); |
| 538 | 521 |
| 539 // Every filter should receive a call to Seek(). | 522 // Every filter should receive a call to Seek(). |
| 540 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); | 523 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); |
| 541 ExpectSeek(expected, false); | 524 ExpectSeek(expected, false); |
| 542 DoSeek(expected); | 525 DoSeek(expected); |
| 543 } | 526 } |
| 544 | 527 |
| 545 TEST_F(PipelineTest, SeekAfterError) { | 528 TEST_F(PipelineTest, SeekAfterError) { |
| 546 CreateAudioStream(); | 529 CreateAudioStream(); |
| 547 MockDemuxerStreamVector streams; | 530 MockDemuxerStreamVector streams; |
| 548 streams.push_back(audio_stream()); | 531 streams.push_back(audio_stream()); |
| 549 | 532 |
| 550 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); | 533 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); |
| 551 SetRendererExpectations(); | 534 SetRendererExpectations(); |
| 552 | 535 |
| 553 // Initialize then seek! | 536 // Initialize then seek! |
| 554 StartPipeline(PIPELINE_OK); | 537 StartPipelineAndExpect(PIPELINE_OK); |
| 555 | 538 |
| 556 EXPECT_CALL(*demuxer_, Stop(_)) | 539 EXPECT_CALL(*demuxer_, Stop(_)) |
| 557 .WillOnce(RunClosure<0>()); | 540 .WillOnce(RunClosure<0>()); |
| 558 EXPECT_CALL(callbacks_, OnError(_)); | 541 EXPECT_CALL(callbacks_, OnError(_)); |
| 559 | 542 |
| 560 static_cast<DemuxerHost*>(pipeline_.get()) | 543 static_cast<DemuxerHost*>(pipeline_.get()) |
| 561 ->OnDemuxerError(PIPELINE_ERROR_ABORT); | 544 ->OnDemuxerError(PIPELINE_ERROR_ABORT); |
| 562 message_loop_.RunUntilIdle(); | 545 message_loop_.RunUntilIdle(); |
| 563 | 546 |
| 564 pipeline_->Seek( | 547 pipeline_->Seek( |
| 565 base::TimeDelta::FromMilliseconds(100), | 548 base::TimeDelta::FromMilliseconds(100), |
| 566 base::Bind(&CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | 549 base::Bind(&CallbackHelper::OnSeek, base::Unretained(&callbacks_))); |
| 567 message_loop_.RunUntilIdle(); | 550 message_loop_.RunUntilIdle(); |
| 568 } | 551 } |
| 569 | 552 |
| 570 TEST_F(PipelineTest, SetVolume) { | 553 TEST_F(PipelineTest, SetVolume) { |
| 571 CreateAudioStream(); | 554 CreateAudioStream(); |
| 572 MockDemuxerStreamVector streams; | 555 MockDemuxerStreamVector streams; |
| 573 streams.push_back(audio_stream()); | 556 streams.push_back(audio_stream()); |
| 574 | 557 |
| 575 SetDemuxerExpectations(&streams); | 558 SetDemuxerExpectations(&streams); |
| 576 SetRendererExpectations(); | 559 SetRendererExpectations(); |
| 577 | 560 |
| 578 // The audio renderer should receive a call to SetVolume(). | 561 // The audio renderer should receive a call to SetVolume(). |
| 579 float expected = 0.5f; | 562 float expected = 0.5f; |
| 580 EXPECT_CALL(*renderer_, SetVolume(expected)); | 563 EXPECT_CALL(*renderer_, SetVolume(expected)); |
| 581 | 564 |
| 582 // Initialize then set volume! | 565 // Initialize then set volume! |
| 583 StartPipeline(PIPELINE_OK); | 566 StartPipelineAndExpect(PIPELINE_OK); |
| 584 pipeline_->SetVolume(expected); | 567 pipeline_->SetVolume(expected); |
| 585 } | 568 } |
| 586 | 569 |
| 587 TEST_F(PipelineTest, Properties) { | 570 TEST_F(PipelineTest, Properties) { |
| 588 CreateVideoStream(); | 571 CreateVideoStream(); |
| 589 MockDemuxerStreamVector streams; | 572 MockDemuxerStreamVector streams; |
| 590 streams.push_back(video_stream()); | 573 streams.push_back(video_stream()); |
| 591 | 574 |
| 592 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 575 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 593 SetDemuxerExpectations(&streams, kDuration); | 576 SetDemuxerExpectations(&streams, kDuration); |
| 594 SetRendererExpectations(); | 577 SetRendererExpectations(); |
| 595 | 578 |
| 596 StartPipeline(PIPELINE_OK); | 579 StartPipelineAndExpect(PIPELINE_OK); |
| 597 EXPECT_EQ(kDuration.ToInternalValue(), | 580 EXPECT_EQ(kDuration.ToInternalValue(), |
| 598 pipeline_->GetMediaDuration().ToInternalValue()); | 581 pipeline_->GetMediaDuration().ToInternalValue()); |
| 599 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 582 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 600 } | 583 } |
| 601 | 584 |
| 602 TEST_F(PipelineTest, GetBufferedTimeRanges) { | 585 TEST_F(PipelineTest, GetBufferedTimeRanges) { |
| 603 CreateVideoStream(); | 586 CreateVideoStream(); |
| 604 MockDemuxerStreamVector streams; | 587 MockDemuxerStreamVector streams; |
| 605 streams.push_back(video_stream()); | 588 streams.push_back(video_stream()); |
| 606 | 589 |
| 607 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 590 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 608 SetDemuxerExpectations(&streams, kDuration); | 591 SetDemuxerExpectations(&streams, kDuration); |
| 609 SetRendererExpectations(); | 592 SetRendererExpectations(); |
| 610 | 593 |
| 611 StartPipeline(PIPELINE_OK); | 594 StartPipelineAndExpect(PIPELINE_OK); |
| 612 | 595 |
| 613 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); | 596 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); |
| 614 | 597 |
| 615 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 598 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 616 pipeline_->AddBufferedTimeRange(base::TimeDelta(), kDuration / 8); | 599 pipeline_->AddBufferedTimeRange(base::TimeDelta(), kDuration / 8); |
| 617 EXPECT_TRUE(pipeline_->DidLoadingProgress()); | 600 EXPECT_TRUE(pipeline_->DidLoadingProgress()); |
| 618 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 601 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 619 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 602 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 620 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); | 603 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); |
| 621 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); | 604 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); |
| 622 | 605 |
| 623 base::TimeDelta kSeekTime = kDuration / 2; | 606 base::TimeDelta kSeekTime = kDuration / 2; |
| 624 ExpectSeek(kSeekTime, false); | 607 ExpectSeek(kSeekTime, false); |
| 625 DoSeek(kSeekTime); | 608 DoSeek(kSeekTime); |
| 626 | 609 |
| 627 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 610 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 628 } | 611 } |
| 629 | 612 |
| 630 TEST_F(PipelineTest, EndedCallback) { | 613 TEST_F(PipelineTest, EndedCallback) { |
| 631 CreateAudioStream(); | 614 CreateAudioStream(); |
| 632 CreateVideoStream(); | 615 CreateVideoStream(); |
| 633 CreateTextStream(); | 616 CreateTextStream(); |
| 634 MockDemuxerStreamVector streams; | 617 MockDemuxerStreamVector streams; |
| 635 streams.push_back(audio_stream()); | 618 streams.push_back(audio_stream()); |
| 636 streams.push_back(video_stream()); | 619 streams.push_back(video_stream()); |
| 637 | 620 |
| 638 SetDemuxerExpectations(&streams); | 621 SetDemuxerExpectations(&streams); |
| 639 SetRendererExpectations(); | 622 SetRendererExpectations(); |
| 640 StartPipeline(PIPELINE_OK); | 623 StartPipelineAndExpect(PIPELINE_OK); |
| 641 | 624 |
| 642 AddTextStream(); | 625 AddTextStream(); |
| 643 | 626 |
| 644 // The ended callback shouldn't run until all renderers have ended. | 627 // The ended callback shouldn't run until all renderers have ended. |
| 645 ended_cb_.Run(); | 628 ended_cb_.Run(); |
| 646 message_loop_.RunUntilIdle(); | 629 message_loop_.RunUntilIdle(); |
| 647 | 630 |
| 648 EXPECT_CALL(callbacks_, OnEnded()); | 631 EXPECT_CALL(callbacks_, OnEnded()); |
| 649 text_stream()->SendEosNotification(); | 632 text_stream()->SendEosNotification(); |
| 650 message_loop_.RunUntilIdle(); | 633 message_loop_.RunUntilIdle(); |
| 651 } | 634 } |
| 652 | 635 |
| 653 TEST_F(PipelineTest, ErrorDuringSeek) { | 636 TEST_F(PipelineTest, ErrorDuringSeek) { |
| 654 CreateAudioStream(); | 637 CreateAudioStream(); |
| 655 MockDemuxerStreamVector streams; | 638 MockDemuxerStreamVector streams; |
| 656 streams.push_back(audio_stream()); | 639 streams.push_back(audio_stream()); |
| 657 | 640 |
| 658 SetDemuxerExpectations(&streams); | 641 SetDemuxerExpectations(&streams); |
| 659 SetRendererExpectations(); | 642 SetRendererExpectations(); |
| 660 StartPipeline(PIPELINE_OK); | 643 StartPipelineAndExpect(PIPELINE_OK); |
| 661 | 644 |
| 662 float playback_rate = 1.0f; | 645 float playback_rate = 1.0f; |
| 663 EXPECT_CALL(*renderer_, SetPlaybackRate(playback_rate)); | 646 EXPECT_CALL(*renderer_, SetPlaybackRate(playback_rate)); |
| 664 pipeline_->SetPlaybackRate(playback_rate); | 647 pipeline_->SetPlaybackRate(playback_rate); |
| 665 message_loop_.RunUntilIdle(); | 648 message_loop_.RunUntilIdle(); |
| 666 | 649 |
| 667 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 650 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
| 668 | 651 |
| 669 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); | 652 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); |
| 670 EXPECT_CALL(*renderer_, Flush(_)) | 653 EXPECT_CALL(*renderer_, Flush(_)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 EXPECT_TRUE(message_loop->IsIdleForTesting()); | 685 EXPECT_TRUE(message_loop->IsIdleForTesting()); |
| 703 } | 686 } |
| 704 | 687 |
| 705 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) { | 688 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) { |
| 706 CreateAudioStream(); | 689 CreateAudioStream(); |
| 707 MockDemuxerStreamVector streams; | 690 MockDemuxerStreamVector streams; |
| 708 streams.push_back(audio_stream()); | 691 streams.push_back(audio_stream()); |
| 709 | 692 |
| 710 SetDemuxerExpectations(&streams); | 693 SetDemuxerExpectations(&streams); |
| 711 SetRendererExpectations(); | 694 SetRendererExpectations(); |
| 712 StartPipeline(PIPELINE_OK); | 695 StartPipelineAndExpect(PIPELINE_OK); |
| 713 | 696 |
| 714 // Trigger additional requests on the pipeline during tear down from error. | 697 // Trigger additional requests on the pipeline during tear down from error. |
| 715 base::Callback<void(PipelineStatus)> cb = base::Bind( | 698 base::Callback<void(PipelineStatus)> cb = base::Bind( |
| 716 &TestNoCallsAfterError, pipeline_.get(), &message_loop_); | 699 &TestNoCallsAfterError, pipeline_.get(), &message_loop_); |
| 717 ON_CALL(callbacks_, OnError(_)) | 700 ON_CALL(callbacks_, OnError(_)) |
| 718 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); | 701 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); |
| 719 | 702 |
| 720 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 703 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
| 721 | 704 |
| 722 // Seek() isn't called as the demuxer errors out first. | 705 // Seek() isn't called as the demuxer errors out first. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 736 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | 719 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); |
| 737 message_loop_.RunUntilIdle(); | 720 message_loop_.RunUntilIdle(); |
| 738 } | 721 } |
| 739 | 722 |
| 740 TEST_F(PipelineTest, DestroyAfterStop) { | 723 TEST_F(PipelineTest, DestroyAfterStop) { |
| 741 CreateAudioStream(); | 724 CreateAudioStream(); |
| 742 MockDemuxerStreamVector streams; | 725 MockDemuxerStreamVector streams; |
| 743 streams.push_back(audio_stream()); | 726 streams.push_back(audio_stream()); |
| 744 SetDemuxerExpectations(&streams); | 727 SetDemuxerExpectations(&streams); |
| 745 SetRendererExpectations(); | 728 SetRendererExpectations(); |
| 746 StartPipeline(PIPELINE_OK); | 729 StartPipelineAndExpect(PIPELINE_OK); |
| 747 | 730 |
| 748 ExpectDemuxerStop(); | 731 ExpectDemuxerStop(); |
| 749 | 732 |
| 750 ExpectPipelineStopAndDestroyPipeline(); | 733 ExpectPipelineStopAndDestroyPipeline(); |
| 751 pipeline_->Stop( | 734 pipeline_->Stop( |
| 752 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 735 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
| 753 message_loop_.RunUntilIdle(); | 736 message_loop_.RunUntilIdle(); |
| 754 } | 737 } |
| 755 | 738 |
| 756 TEST_F(PipelineTest, Underflow) { | 739 TEST_F(PipelineTest, Underflow) { |
| 757 CreateAudioStream(); | 740 CreateAudioStream(); |
| 758 CreateVideoStream(); | 741 CreateVideoStream(); |
| 759 MockDemuxerStreamVector streams; | 742 MockDemuxerStreamVector streams; |
| 760 streams.push_back(audio_stream()); | 743 streams.push_back(audio_stream()); |
| 761 streams.push_back(video_stream()); | 744 streams.push_back(video_stream()); |
| 762 | 745 |
| 763 SetDemuxerExpectations(&streams); | 746 SetDemuxerExpectations(&streams); |
| 764 SetRendererExpectations(); | 747 SetRendererExpectations(); |
| 765 StartPipeline(PIPELINE_OK); | 748 StartPipelineAndExpect(PIPELINE_OK); |
| 766 | 749 |
| 767 // Simulate underflow. | 750 // Simulate underflow. |
| 768 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); | 751 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); |
| 769 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); | 752 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); |
| 770 | 753 |
| 771 // Seek while underflowed. | 754 // Seek while underflowed. |
| 772 base::TimeDelta expected = base::TimeDelta::FromSeconds(5); | 755 base::TimeDelta expected = base::TimeDelta::FromSeconds(5); |
| 773 ExpectSeek(expected, true); | 756 ExpectSeek(expected, true); |
| 774 DoSeek(expected); | 757 DoSeek(expected); |
| 775 } | 758 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 | 798 |
| 816 private: | 799 private: |
| 817 // TODO(scherkus): We do radically different things whether teardown is | 800 // TODO(scherkus): We do radically different things whether teardown is |
| 818 // invoked via stop vs error. The teardown path should be the same, | 801 // invoked via stop vs error. The teardown path should be the same, |
| 819 // see http://crbug.com/110228 | 802 // see http://crbug.com/110228 |
| 820 void DoInitialize(TeardownState state, StopOrError stop_or_error) { | 803 void DoInitialize(TeardownState state, StopOrError stop_or_error) { |
| 821 PipelineStatus expected_status = | 804 PipelineStatus expected_status = |
| 822 SetInitializeExpectations(state, stop_or_error); | 805 SetInitializeExpectations(state, stop_or_error); |
| 823 | 806 |
| 824 EXPECT_CALL(callbacks_, OnStart(expected_status)); | 807 EXPECT_CALL(callbacks_, OnStart(expected_status)); |
| 825 pipeline_->Start( | 808 StartPipeline(); |
| 826 filter_collection_.Pass(), | |
| 827 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | |
| 828 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | |
| 829 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | |
| 830 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | |
| 831 base::Bind(&CallbackHelper::OnBufferingStateChange, | |
| 832 base::Unretained(&callbacks_)), | |
| 833 base::Bind(&CallbackHelper::OnDurationChange, | |
| 834 base::Unretained(&callbacks_))); | |
| 835 message_loop_.RunUntilIdle(); | 809 message_loop_.RunUntilIdle(); |
| 836 } | 810 } |
| 837 | 811 |
| 838 PipelineStatus SetInitializeExpectations(TeardownState state, | 812 PipelineStatus SetInitializeExpectations(TeardownState state, |
| 839 StopOrError stop_or_error) { | 813 StopOrError stop_or_error) { |
| 840 PipelineStatus status = PIPELINE_OK; | 814 PipelineStatus status = PIPELINE_OK; |
| 841 base::Closure stop_cb = base::Bind( | 815 base::Closure stop_cb = base::Bind( |
| 842 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 816 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
| 843 | 817 |
| 844 if (state == kInitDemuxer) { | 818 if (state == kInitDemuxer) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 | 988 |
| 1015 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); | 989 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); |
| 1016 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer); | 990 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer); |
| 1017 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 991 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
| 1018 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 992 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1019 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 993 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1020 | 994 |
| 1021 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); | 995 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); |
| 1022 | 996 |
| 1023 } // namespace media | 997 } // namespace media |
| OLD | NEW |