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.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 if (video_stream_) | 105 if (video_stream_) |
106 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 106 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
107 .WillOnce(RunClosure<0>()); | 107 .WillOnce(RunClosure<0>()); |
108 } | 108 } |
109 | 109 |
110 // Expect a stop callback if we were started. | 110 // Expect a stop callback if we were started. |
111 EXPECT_CALL(callbacks_, OnStop()); | 111 EXPECT_CALL(callbacks_, OnStop()); |
112 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 112 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
113 base::Unretained(&callbacks_))); | 113 base::Unretained(&callbacks_))); |
114 message_loop_.RunAllPending(); | 114 message_loop_.RunUntilIdle(); |
115 | 115 |
116 pipeline_ = NULL; | 116 pipeline_ = NULL; |
117 mocks_.reset(); | 117 mocks_.reset(); |
118 } | 118 } |
119 | 119 |
120 protected: | 120 protected: |
121 // Sets up expectations to allow the demuxer to initialize. | 121 // Sets up expectations to allow the demuxer to initialize. |
122 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 122 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
123 void InitializeDemuxer(MockDemuxerStreamVector* streams, | 123 void InitializeDemuxer(MockDemuxerStreamVector* streams, |
124 const base::TimeDelta& duration) { | 124 const base::TimeDelta& duration) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); | 200 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); |
201 } | 201 } |
202 | 202 |
203 pipeline_->Start( | 203 pipeline_->Start( |
204 mocks_->Create().Pass(), | 204 mocks_->Create().Pass(), |
205 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 205 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
206 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 206 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
207 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | 207 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), |
208 base::Bind(&CallbackHelper::OnBufferingState, | 208 base::Bind(&CallbackHelper::OnBufferingState, |
209 base::Unretained(&callbacks_))); | 209 base::Unretained(&callbacks_))); |
210 message_loop_.RunAllPending(); | 210 message_loop_.RunUntilIdle(); |
211 } | 211 } |
212 | 212 |
213 void CreateAudioStream() { | 213 void CreateAudioStream() { |
214 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 214 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
215 } | 215 } |
216 | 216 |
217 void CreateVideoStream() { | 217 void CreateVideoStream() { |
218 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 218 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
219 EXPECT_CALL(*video_stream_, video_decoder_config()) | 219 EXPECT_CALL(*video_stream_, video_decoder_config()) |
220 .WillRepeatedly(ReturnRef(video_decoder_config_)); | 220 .WillRepeatedly(ReturnRef(video_decoder_config_)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | 265 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
266 } | 266 } |
267 | 267 |
268 void DoSeek(const base::TimeDelta& seek_time) { | 268 void DoSeek(const base::TimeDelta& seek_time) { |
269 pipeline_->Seek(seek_time, | 269 pipeline_->Seek(seek_time, |
270 base::Bind(&CallbackHelper::OnSeek, | 270 base::Bind(&CallbackHelper::OnSeek, |
271 base::Unretained(&callbacks_))); | 271 base::Unretained(&callbacks_))); |
272 | 272 |
273 // We expect the time to be updated only after the seek has completed. | 273 // We expect the time to be updated only after the seek has completed. |
274 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); | 274 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); |
275 message_loop_.RunAllPending(); | 275 message_loop_.RunUntilIdle(); |
276 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 276 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
277 } | 277 } |
278 | 278 |
279 // Fixture members. | 279 // Fixture members. |
280 StrictMock<CallbackHelper> callbacks_; | 280 StrictMock<CallbackHelper> callbacks_; |
281 MessageLoop message_loop_; | 281 MessageLoop message_loop_; |
282 scoped_refptr<Pipeline> pipeline_; | 282 scoped_refptr<Pipeline> pipeline_; |
283 scoped_ptr<media::MockFilterCollection> mocks_; | 283 scoped_ptr<media::MockFilterCollection> mocks_; |
284 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream_; | 284 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream_; |
285 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream_; | 285 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // This test hangs during initialization by never calling | 333 // This test hangs during initialization by never calling |
334 // InitializationComplete(). StrictMock<> will ensure that the callback is | 334 // InitializationComplete(). StrictMock<> will ensure that the callback is |
335 // never executed. | 335 // never executed. |
336 pipeline_->Start( | 336 pipeline_->Start( |
337 mocks_->Create().Pass(), | 337 mocks_->Create().Pass(), |
338 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 338 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
339 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 339 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
340 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | 340 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), |
341 base::Bind(&CallbackHelper::OnBufferingState, | 341 base::Bind(&CallbackHelper::OnBufferingState, |
342 base::Unretained(&callbacks_))); | 342 base::Unretained(&callbacks_))); |
343 message_loop_.RunAllPending(); | 343 message_loop_.RunUntilIdle(); |
344 | 344 |
345 | 345 |
346 // Because our callback will get executed when the test tears down, we'll | 346 // Because our callback will get executed when the test tears down, we'll |
347 // verify that nothing has been called, then set our expectation for the call | 347 // verify that nothing has been called, then set our expectation for the call |
348 // made during tear down. | 348 // made during tear down. |
349 Mock::VerifyAndClear(&callbacks_); | 349 Mock::VerifyAndClear(&callbacks_); |
350 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 350 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
351 } | 351 } |
352 | 352 |
353 TEST_F(PipelineTest, URLNotFound) { | 353 TEST_F(PipelineTest, URLNotFound) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 streams.push_back(audio_stream()); | 567 streams.push_back(audio_stream()); |
568 streams.push_back(video_stream()); | 568 streams.push_back(video_stream()); |
569 | 569 |
570 InitializeDemuxer(&streams); | 570 InitializeDemuxer(&streams); |
571 InitializeAudioRenderer(audio_stream(), false); | 571 InitializeAudioRenderer(audio_stream(), false); |
572 InitializeVideoRenderer(video_stream()); | 572 InitializeVideoRenderer(video_stream()); |
573 InitializePipeline(PIPELINE_OK); | 573 InitializePipeline(PIPELINE_OK); |
574 | 574 |
575 // The ended callback shouldn't run until both renderers have ended. | 575 // The ended callback shouldn't run until both renderers have ended. |
576 pipeline_->OnAudioRendererEnded(); | 576 pipeline_->OnAudioRendererEnded(); |
577 message_loop_.RunAllPending(); | 577 message_loop_.RunUntilIdle(); |
578 | 578 |
579 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); | 579 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
580 pipeline_->OnVideoRendererEnded(); | 580 pipeline_->OnVideoRendererEnded(); |
581 message_loop_.RunAllPending(); | 581 message_loop_.RunUntilIdle(); |
582 } | 582 } |
583 | 583 |
584 // Static function & time variable used to simulate changes in wallclock time. | 584 // Static function & time variable used to simulate changes in wallclock time. |
585 static int64 g_static_clock_time; | 585 static int64 g_static_clock_time; |
586 static base::Time StaticClockFunction() { | 586 static base::Time StaticClockFunction() { |
587 return base::Time::FromInternalValue(g_static_clock_time); | 587 return base::Time::FromInternalValue(g_static_clock_time); |
588 } | 588 } |
589 | 589 |
590 TEST_F(PipelineTest, AudioStreamShorterThanVideo) { | 590 TEST_F(PipelineTest, AudioStreamShorterThanVideo) { |
591 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); | 591 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); |
(...skipping 13 matching lines...) Expand all Loading... |
605 InitializeVideoRenderer(video_stream()); | 605 InitializeVideoRenderer(video_stream()); |
606 InitializePipeline(PIPELINE_OK); | 606 InitializePipeline(PIPELINE_OK); |
607 | 607 |
608 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue()); | 608 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue()); |
609 | 609 |
610 float playback_rate = 1.0f; | 610 float playback_rate = 1.0f; |
611 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 611 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
612 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); | 612 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); |
613 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 613 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
614 pipeline_->SetPlaybackRate(playback_rate); | 614 pipeline_->SetPlaybackRate(playback_rate); |
615 message_loop_.RunAllPending(); | 615 message_loop_.RunUntilIdle(); |
616 | 616 |
617 InSequence s; | 617 InSequence s; |
618 | 618 |
619 // Verify that the clock doesn't advance since it hasn't been started by | 619 // Verify that the clock doesn't advance since it hasn't been started by |
620 // a time update from the audio stream. | 620 // a time update from the audio stream. |
621 int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); | 621 int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); |
622 g_static_clock_time += | 622 g_static_clock_time += |
623 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); | 623 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); |
624 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); | 624 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); |
625 | 625 |
626 // Signal end of audio stream. | 626 // Signal end of audio stream. |
627 pipeline_->OnAudioRendererEnded(); | 627 pipeline_->OnAudioRendererEnded(); |
628 message_loop_.RunAllPending(); | 628 message_loop_.RunUntilIdle(); |
629 | 629 |
630 // Verify that the clock advances. | 630 // Verify that the clock advances. |
631 start_time = pipeline_->GetMediaTime().ToInternalValue(); | 631 start_time = pipeline_->GetMediaTime().ToInternalValue(); |
632 g_static_clock_time += | 632 g_static_clock_time += |
633 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); | 633 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); |
634 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); | 634 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); |
635 | 635 |
636 // Signal end of video stream and make sure OnEnded() callback occurs. | 636 // Signal end of video stream and make sure OnEnded() callback occurs. |
637 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); | 637 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
638 pipeline_->OnVideoRendererEnded(); | 638 pipeline_->OnVideoRendererEnded(); |
639 } | 639 } |
640 | 640 |
641 TEST_F(PipelineTest, ErrorDuringSeek) { | 641 TEST_F(PipelineTest, ErrorDuringSeek) { |
642 CreateAudioStream(); | 642 CreateAudioStream(); |
643 MockDemuxerStreamVector streams; | 643 MockDemuxerStreamVector streams; |
644 streams.push_back(audio_stream()); | 644 streams.push_back(audio_stream()); |
645 | 645 |
646 InitializeDemuxer(&streams); | 646 InitializeDemuxer(&streams); |
647 InitializeAudioRenderer(audio_stream(), false); | 647 InitializeAudioRenderer(audio_stream(), false); |
648 InitializePipeline(PIPELINE_OK); | 648 InitializePipeline(PIPELINE_OK); |
649 | 649 |
650 float playback_rate = 1.0f; | 650 float playback_rate = 1.0f; |
651 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 651 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
652 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 652 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
653 pipeline_->SetPlaybackRate(playback_rate); | 653 pipeline_->SetPlaybackRate(playback_rate); |
654 message_loop_.RunAllPending(); | 654 message_loop_.RunUntilIdle(); |
655 | 655 |
656 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 656 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
657 | 657 |
658 // Preroll() isn't called as the demuxer errors out first. | 658 // Preroll() isn't called as the demuxer errors out first. |
659 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 659 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
660 .WillOnce(RunClosure<0>()); | 660 .WillOnce(RunClosure<0>()); |
661 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 661 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
662 .WillOnce(RunClosure<0>()); | 662 .WillOnce(RunClosure<0>()); |
663 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 663 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
664 .WillOnce(RunClosure<0>()); | 664 .WillOnce(RunClosure<0>()); |
665 | 665 |
666 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 666 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
667 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); | 667 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); |
668 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 668 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
669 .WillOnce(RunClosure<0>()); | 669 .WillOnce(RunClosure<0>()); |
670 | 670 |
671 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, | 671 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, |
672 base::Unretained(&callbacks_))); | 672 base::Unretained(&callbacks_))); |
673 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | 673 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); |
674 message_loop_.RunAllPending(); | 674 message_loop_.RunUntilIdle(); |
675 } | 675 } |
676 | 676 |
677 // Invoked function OnError. This asserts that the pipeline does not enqueue | 677 // Invoked function OnError. This asserts that the pipeline does not enqueue |
678 // non-teardown related tasks while tearing down. | 678 // non-teardown related tasks while tearing down. |
679 static void TestNoCallsAfterError( | 679 static void TestNoCallsAfterError( |
680 Pipeline* pipeline, MessageLoop* message_loop, | 680 Pipeline* pipeline, MessageLoop* message_loop, |
681 PipelineStatus /* status */) { | 681 PipelineStatus /* status */) { |
682 CHECK(pipeline); | 682 CHECK(pipeline); |
683 CHECK(message_loop); | 683 CHECK(message_loop); |
684 | 684 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 .WillOnce(RunClosure<0>()); | 719 .WillOnce(RunClosure<0>()); |
720 | 720 |
721 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 721 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
722 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); | 722 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); |
723 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 723 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
724 .WillOnce(RunClosure<0>()); | 724 .WillOnce(RunClosure<0>()); |
725 | 725 |
726 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, | 726 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, |
727 base::Unretained(&callbacks_))); | 727 base::Unretained(&callbacks_))); |
728 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | 728 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); |
729 message_loop_.RunAllPending(); | 729 message_loop_.RunUntilIdle(); |
730 } | 730 } |
731 | 731 |
732 TEST_F(PipelineTest, StartTimeIsZero) { | 732 TEST_F(PipelineTest, StartTimeIsZero) { |
733 CreateVideoStream(); | 733 CreateVideoStream(); |
734 MockDemuxerStreamVector streams; | 734 MockDemuxerStreamVector streams; |
735 streams.push_back(video_stream()); | 735 streams.push_back(video_stream()); |
736 | 736 |
737 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 737 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
738 InitializeDemuxer(&streams, kDuration); | 738 InitializeDemuxer(&streams, kDuration); |
739 InitializeVideoRenderer(video_stream()); | 739 InitializeVideoRenderer(video_stream()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 streams.push_back(audio_stream()); | 779 streams.push_back(audio_stream()); |
780 | 780 |
781 InitializeDemuxer(&streams); | 781 InitializeDemuxer(&streams); |
782 InitializeAudioRenderer(audio_stream(), false); | 782 InitializeAudioRenderer(audio_stream(), false); |
783 InitializePipeline(PIPELINE_OK); | 783 InitializePipeline(PIPELINE_OK); |
784 | 784 |
785 float playback_rate = 1.0f; | 785 float playback_rate = 1.0f; |
786 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 786 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
787 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 787 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
788 pipeline_->SetPlaybackRate(playback_rate); | 788 pipeline_->SetPlaybackRate(playback_rate); |
789 message_loop_.RunAllPending(); | 789 message_loop_.RunUntilIdle(); |
790 | 790 |
791 // Provide an initial time update so that the pipeline transitions out of the | 791 // Provide an initial time update so that the pipeline transitions out of the |
792 // "waiting for time update" state. | 792 // "waiting for time update" state. |
793 audio_time_cb_.Run(base::TimeDelta::FromMilliseconds(100), | 793 audio_time_cb_.Run(base::TimeDelta::FromMilliseconds(100), |
794 base::TimeDelta::FromMilliseconds(500)); | 794 base::TimeDelta::FromMilliseconds(500)); |
795 | 795 |
796 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 796 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
797 | 797 |
798 // Arrange to trigger a time update while the demuxer is in the middle of | 798 // Arrange to trigger a time update while the demuxer is in the middle of |
799 // seeking. This update should be ignored by the pipeline and the clock should | 799 // seeking. This update should be ignored by the pipeline and the clock should |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 SetInitializeExpectations(state, stop_or_error); | 937 SetInitializeExpectations(state, stop_or_error); |
938 | 938 |
939 EXPECT_CALL(callbacks_, OnStart(expected_status)); | 939 EXPECT_CALL(callbacks_, OnStart(expected_status)); |
940 pipeline_->Start( | 940 pipeline_->Start( |
941 mocks_->Create().Pass(), | 941 mocks_->Create().Pass(), |
942 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 942 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
943 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 943 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
944 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | 944 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), |
945 base::Bind(&CallbackHelper::OnBufferingState, | 945 base::Bind(&CallbackHelper::OnBufferingState, |
946 base::Unretained(&callbacks_))); | 946 base::Unretained(&callbacks_))); |
947 message_loop_.RunAllPending(); | 947 message_loop_.RunUntilIdle(); |
948 } | 948 } |
949 | 949 |
950 PipelineStatus SetInitializeExpectations(TeardownState state, | 950 PipelineStatus SetInitializeExpectations(TeardownState state, |
951 StopOrError stop_or_error) { | 951 StopOrError stop_or_error) { |
952 PipelineStatus status = PIPELINE_OK; | 952 PipelineStatus status = PIPELINE_OK; |
953 base::Closure stop_cb = base::Bind( | 953 base::Closure stop_cb = base::Bind( |
954 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 954 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
955 | 955 |
956 if (state == kInitDemuxer) { | 956 if (state == kInitDemuxer) { |
957 if (stop_or_error == kStop) { | 957 if (stop_or_error == kStop) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); | 1055 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
1056 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure<0>()); | 1056 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
1057 EXPECT_CALL(callbacks_, OnSeek(status)); | 1057 EXPECT_CALL(callbacks_, OnSeek(status)); |
1058 | 1058 |
1059 if (status == PIPELINE_OK) { | 1059 if (status == PIPELINE_OK) { |
1060 EXPECT_CALL(callbacks_, OnStop()); | 1060 EXPECT_CALL(callbacks_, OnStop()); |
1061 } | 1061 } |
1062 | 1062 |
1063 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | 1063 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( |
1064 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | 1064 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); |
1065 message_loop_.RunAllPending(); | 1065 message_loop_.RunUntilIdle(); |
1066 } | 1066 } |
1067 | 1067 |
1068 PipelineStatus SetSeekExpectations(TeardownState state, | 1068 PipelineStatus SetSeekExpectations(TeardownState state, |
1069 StopOrError stop_or_error) { | 1069 StopOrError stop_or_error) { |
1070 PipelineStatus status = PIPELINE_OK; | 1070 PipelineStatus status = PIPELINE_OK; |
1071 base::Closure stop_cb = base::Bind( | 1071 base::Closure stop_cb = base::Bind( |
1072 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 1072 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
1073 | 1073 |
1074 if (state == kPausing) { | 1074 if (state == kPausing) { |
1075 if (stop_or_error == kStop) { | 1075 if (stop_or_error == kStop) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 | 1170 |
1171 if (stop_or_error == kStop) { | 1171 if (stop_or_error == kStop) { |
1172 EXPECT_CALL(callbacks_, OnStop()); | 1172 EXPECT_CALL(callbacks_, OnStop()); |
1173 pipeline_->Stop(base::Bind( | 1173 pipeline_->Stop(base::Bind( |
1174 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 1174 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
1175 } else { | 1175 } else { |
1176 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | 1176 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); |
1177 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); | 1177 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); |
1178 } | 1178 } |
1179 | 1179 |
1180 message_loop_.RunAllPending(); | 1180 message_loop_.RunUntilIdle(); |
1181 } | 1181 } |
1182 | 1182 |
1183 DISALLOW_COPY_AND_ASSIGN(PipelineTeardownTest); | 1183 DISALLOW_COPY_AND_ASSIGN(PipelineTeardownTest); |
1184 }; | 1184 }; |
1185 | 1185 |
1186 #define INSTANTIATE_TEARDOWN_TEST(stop_or_error, state) \ | 1186 #define INSTANTIATE_TEARDOWN_TEST(stop_or_error, state) \ |
1187 TEST_F(PipelineTeardownTest, stop_or_error##_##state) { \ | 1187 TEST_F(PipelineTeardownTest, stop_or_error##_##state) { \ |
1188 RunTest(k##state, k##stop_or_error); \ | 1188 RunTest(k##state, k##stop_or_error); \ |
1189 } | 1189 } |
1190 | 1190 |
(...skipping 11 matching lines...) Expand all Loading... |
1202 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); | 1202 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); |
1203 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); | 1203 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); |
1204 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); | 1204 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); |
1205 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1205 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
1206 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1206 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
1207 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); | 1207 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); |
1208 INSTANTIATE_TEARDOWN_TEST(Error, Starting); | 1208 INSTANTIATE_TEARDOWN_TEST(Error, Starting); |
1209 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1209 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
1210 | 1210 |
1211 } // namespace media | 1211 } // namespace media |
OLD | NEW |