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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 .WillRepeatedly(Return(base::Time())); | 115 .WillRepeatedly(Return(base::Time())); |
116 | 116 |
117 EXPECT_CALL(*demuxer_, GetLiveness()) | 117 EXPECT_CALL(*demuxer_, GetLiveness()) |
118 .WillRepeatedly(Return(Demuxer::LIVENESS_UNKNOWN)); | 118 .WillRepeatedly(Return(Demuxer::LIVENESS_UNKNOWN)); |
119 } | 119 } |
120 | 120 |
121 virtual ~PipelineTest() { | 121 virtual ~PipelineTest() { |
122 if (!pipeline_ || !pipeline_->IsRunning()) | 122 if (!pipeline_ || !pipeline_->IsRunning()) |
123 return; | 123 return; |
124 | 124 |
125 ExpectStop(); | 125 ExpectDemuxerStop(); |
126 | 126 |
127 // The mock demuxer doesn't stop the fake text track stream, | 127 // The mock demuxer doesn't stop the fake text track stream, |
128 // so just stop it manually. | 128 // so just stop it manually. |
129 if (text_stream_) { | 129 if (text_stream_) { |
130 text_stream_->Stop(); | 130 text_stream_->Stop(); |
131 message_loop_.RunUntilIdle(); | 131 message_loop_.RunUntilIdle(); |
132 } | 132 } |
133 | 133 |
134 // Expect a stop callback if we were started. | 134 // Expect a stop callback if we were started. |
135 EXPECT_CALL(callbacks_, OnStop()); | 135 ExpectPipelineStopAndDestroyPipeline(); |
136 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 136 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
137 base::Unretained(&callbacks_))); | 137 base::Unretained(&callbacks_))); |
138 message_loop_.RunUntilIdle(); | 138 message_loop_.RunUntilIdle(); |
139 } | 139 } |
140 | 140 |
141 void OnDemuxerError() { | 141 void OnDemuxerError() { |
142 // Cast because OnDemuxerError is private in Pipeline. | 142 // Cast because OnDemuxerError is private in Pipeline. |
143 static_cast<DemuxerHost*>(pipeline_.get()) | 143 static_cast<DemuxerHost*>(pipeline_.get()) |
144 ->OnDemuxerError(PIPELINE_ERROR_ABORT); | 144 ->OnDemuxerError(PIPELINE_ERROR_ABORT); |
145 } | 145 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 pipeline_->Seek(seek_time, | 307 pipeline_->Seek(seek_time, |
308 base::Bind(&CallbackHelper::OnSeek, | 308 base::Bind(&CallbackHelper::OnSeek, |
309 base::Unretained(&callbacks_))); | 309 base::Unretained(&callbacks_))); |
310 | 310 |
311 // We expect the time to be updated only after the seek has completed. | 311 // We expect the time to be updated only after the seek has completed. |
312 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); | 312 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); |
313 message_loop_.RunUntilIdle(); | 313 message_loop_.RunUntilIdle(); |
314 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 314 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
315 } | 315 } |
316 | 316 |
317 void ExpectStop() { | 317 void DestroyPipeline() { |
| 318 pipeline_.reset(); |
| 319 } |
| 320 |
| 321 void ExpectDemuxerStop() { |
318 if (demuxer_) | 322 if (demuxer_) |
319 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 323 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
320 } | 324 } |
321 | 325 |
| 326 void ExpectPipelineStopAndDestroyPipeline() { |
| 327 // After the Pipeline is stopped, it could be destroyed any time. Always |
| 328 // destroy the pipeline immediately after OnStop() to test this. |
| 329 EXPECT_CALL(callbacks_, OnStop()) |
| 330 .WillOnce(Invoke(this, &PipelineTest::DestroyPipeline)); |
| 331 } |
| 332 |
322 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&, | 333 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&, |
323 const AddTextTrackDoneCB&)); | 334 const AddTextTrackDoneCB&)); |
324 | 335 |
325 void DoOnAddTextTrack(const TextTrackConfig& config, | 336 void DoOnAddTextTrack(const TextTrackConfig& config, |
326 const AddTextTrackDoneCB& done_cb) { | 337 const AddTextTrackDoneCB& done_cb) { |
327 scoped_ptr<TextTrack> text_track(new MockTextTrack); | 338 scoped_ptr<TextTrack> text_track(new MockTextTrack); |
328 done_cb.Run(text_track.Pass()); | 339 done_cb.Run(text_track.Pass()); |
329 } | 340 } |
330 | 341 |
331 // Fixture members. | 342 // Fixture members. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 message_loop_.RunUntilIdle(); | 413 message_loop_.RunUntilIdle(); |
403 | 414 |
404 // Because our callback will get executed when the test tears down, we'll | 415 // Because our callback will get executed when the test tears down, we'll |
405 // verify that nothing has been called, then set our expectation for the call | 416 // verify that nothing has been called, then set our expectation for the call |
406 // made during tear down. | 417 // made during tear down. |
407 Mock::VerifyAndClear(&callbacks_); | 418 Mock::VerifyAndClear(&callbacks_); |
408 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 419 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
409 } | 420 } |
410 | 421 |
411 TEST_F(PipelineTest, StopWithoutStart) { | 422 TEST_F(PipelineTest, StopWithoutStart) { |
412 EXPECT_CALL(callbacks_, OnStop()); | 423 ExpectPipelineStopAndDestroyPipeline(); |
413 pipeline_->Stop( | 424 pipeline_->Stop( |
414 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 425 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
415 message_loop_.RunUntilIdle(); | 426 message_loop_.RunUntilIdle(); |
416 } | 427 } |
417 | 428 |
418 TEST_F(PipelineTest, StartThenStopImmediately) { | 429 TEST_F(PipelineTest, StartThenStopImmediately) { |
419 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 430 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
420 .WillOnce(RunCallback<1>(PIPELINE_OK)); | 431 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
421 EXPECT_CALL(*demuxer_, Stop(_)) | 432 EXPECT_CALL(*demuxer_, Stop(_)) |
422 .WillOnce(RunClosure<0>()); | 433 .WillOnce(RunClosure<0>()); |
423 | 434 |
424 EXPECT_CALL(callbacks_, OnStart(_)); | 435 EXPECT_CALL(callbacks_, OnStart(_)); |
425 | 436 |
426 pipeline_->Start( | 437 pipeline_->Start( |
427 filter_collection_.Pass(), | 438 filter_collection_.Pass(), |
428 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 439 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
429 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 440 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
430 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | 441 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), |
431 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), | 442 base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)), |
432 base::Bind(&CallbackHelper::OnBufferingStateChange, | 443 base::Bind(&CallbackHelper::OnBufferingStateChange, |
433 base::Unretained(&callbacks_)), | 444 base::Unretained(&callbacks_)), |
434 base::Bind(&CallbackHelper::OnDurationChange, | 445 base::Bind(&CallbackHelper::OnDurationChange, |
435 base::Unretained(&callbacks_))); | 446 base::Unretained(&callbacks_))); |
436 | 447 |
437 // Expect a stop callback if we were started. | 448 // Expect a stop callback if we were started. |
438 EXPECT_CALL(callbacks_, OnStop()); | 449 ExpectPipelineStopAndDestroyPipeline(); |
439 pipeline_->Stop( | 450 pipeline_->Stop( |
440 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 451 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
441 message_loop_.RunUntilIdle(); | 452 message_loop_.RunUntilIdle(); |
442 } | 453 } |
443 | 454 |
444 TEST_F(PipelineTest, DemuxerErrorDuringStop) { | 455 TEST_F(PipelineTest, DemuxerErrorDuringStop) { |
445 CreateAudioStream(); | 456 CreateAudioStream(); |
446 MockDemuxerStreamVector streams; | 457 MockDemuxerStreamVector streams; |
447 streams.push_back(audio_stream()); | 458 streams.push_back(audio_stream()); |
448 | 459 |
449 SetDemuxerExpectations(&streams); | 460 SetDemuxerExpectations(&streams); |
450 SetAudioRendererExpectations(audio_stream()); | 461 SetAudioRendererExpectations(audio_stream()); |
451 | 462 |
452 StartPipeline(PIPELINE_OK); | 463 StartPipeline(PIPELINE_OK); |
453 | 464 |
454 EXPECT_CALL(*demuxer_, Stop(_)) | 465 EXPECT_CALL(*demuxer_, Stop(_)) |
455 .WillOnce(DoAll(InvokeWithoutArgs(this, &PipelineTest::OnDemuxerError), | 466 .WillOnce(DoAll(InvokeWithoutArgs(this, &PipelineTest::OnDemuxerError), |
456 RunClosure<0>())); | 467 RunClosure<0>())); |
457 EXPECT_CALL(callbacks_, OnStop()); | 468 ExpectPipelineStopAndDestroyPipeline(); |
458 | 469 |
459 pipeline_->Stop( | 470 pipeline_->Stop( |
460 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 471 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
461 message_loop_.RunUntilIdle(); | 472 message_loop_.RunUntilIdle(); |
462 } | 473 } |
463 | 474 |
464 TEST_F(PipelineTest, URLNotFound) { | 475 TEST_F(PipelineTest, URLNotFound) { |
465 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 476 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
466 .WillOnce(RunCallback<1>(PIPELINE_ERROR_URL_NOT_FOUND)); | 477 .WillOnce(RunCallback<1>(PIPELINE_ERROR_URL_NOT_FOUND)); |
467 EXPECT_CALL(*demuxer_, Stop(_)) | 478 EXPECT_CALL(*demuxer_, Stop(_)) |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time); | 895 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time); |
885 | 896 |
886 // Now that the seek is complete, verify that time updates advance the current | 897 // Now that the seek is complete, verify that time updates advance the current |
887 // time. | 898 // time. |
888 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100); | 899 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100); |
889 audio_time_cb_.Run(new_time, new_time); | 900 audio_time_cb_.Run(new_time, new_time); |
890 | 901 |
891 EXPECT_EQ(pipeline_->GetMediaTime(), new_time); | 902 EXPECT_EQ(pipeline_->GetMediaTime(), new_time); |
892 } | 903 } |
893 | 904 |
894 static void DeletePipeline(scoped_ptr<Pipeline> pipeline) { | 905 TEST_F(PipelineTest, DestroyAfterStop) { |
895 // |pipeline| will go out of scope. | |
896 } | |
897 | |
898 TEST_F(PipelineTest, DeleteAfterStop) { | |
899 CreateAudioStream(); | 906 CreateAudioStream(); |
900 MockDemuxerStreamVector streams; | 907 MockDemuxerStreamVector streams; |
901 streams.push_back(audio_stream()); | 908 streams.push_back(audio_stream()); |
902 SetDemuxerExpectations(&streams); | 909 SetDemuxerExpectations(&streams); |
903 SetAudioRendererExpectations(audio_stream()); | 910 SetAudioRendererExpectations(audio_stream()); |
904 StartPipeline(PIPELINE_OK); | 911 StartPipeline(PIPELINE_OK); |
905 | 912 |
906 ExpectStop(); | 913 ExpectDemuxerStop(); |
907 | 914 |
908 Pipeline* pipeline = pipeline_.get(); | 915 ExpectPipelineStopAndDestroyPipeline(); |
909 pipeline->Stop(base::Bind(&DeletePipeline, base::Passed(&pipeline_))); | 916 pipeline_->Stop( |
| 917 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
910 message_loop_.RunUntilIdle(); | 918 message_loop_.RunUntilIdle(); |
911 } | 919 } |
912 | 920 |
913 TEST_F(PipelineTest, Underflow) { | 921 TEST_F(PipelineTest, Underflow) { |
914 CreateAudioStream(); | 922 CreateAudioStream(); |
915 CreateVideoStream(); | 923 CreateVideoStream(); |
916 MockDemuxerStreamVector streams; | 924 MockDemuxerStreamVector streams; |
917 streams.push_back(audio_stream()); | 925 streams.push_back(audio_stream()); |
918 streams.push_back(video_stream()); | 926 streams.push_back(video_stream()); |
919 | 927 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 | 960 |
953 // Double post here! This is a hack to simulate the case where TimeCB is | 961 // Double post here! This is a hack to simulate the case where TimeCB is |
954 // posted during ~AudioRenderer(), which is triggered in Pipeline::DoStop. | 962 // posted during ~AudioRenderer(), which is triggered in Pipeline::DoStop. |
955 // Since we can't EXPECT_CALL the dtor and Pipeline::DoStop() is posted | 963 // Since we can't EXPECT_CALL the dtor and Pipeline::DoStop() is posted |
956 // as well, we need to post twice here. | 964 // as well, we need to post twice here. |
957 message_loop_.PostTask( | 965 message_loop_.PostTask( |
958 FROM_HERE, base::Bind(&PostTimeCB, &message_loop_, audio_time_cb_)); | 966 FROM_HERE, base::Bind(&PostTimeCB, &message_loop_, audio_time_cb_)); |
959 | 967 |
960 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 968 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
961 | 969 |
962 Pipeline* pipeline = pipeline_.get(); | 970 ExpectPipelineStopAndDestroyPipeline(); |
963 pipeline->Stop(base::Bind(&DeletePipeline, base::Passed(&pipeline_))); | 971 pipeline_->Stop( |
| 972 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
964 message_loop_.RunUntilIdle(); | 973 message_loop_.RunUntilIdle(); |
965 } | 974 } |
966 | 975 |
967 class PipelineTeardownTest : public PipelineTest { | 976 class PipelineTeardownTest : public PipelineTest { |
968 public: | 977 public: |
969 enum TeardownState { | 978 enum TeardownState { |
970 kInitDemuxer, | 979 kInitDemuxer, |
971 kInitAudioRenderer, | 980 kInitAudioRenderer, |
972 kInitVideoRenderer, | 981 kInitVideoRenderer, |
973 kFlushing, | 982 kFlushing, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 StopOrError stop_or_error) { | 1040 StopOrError stop_or_error) { |
1032 PipelineStatus status = PIPELINE_OK; | 1041 PipelineStatus status = PIPELINE_OK; |
1033 base::Closure stop_cb = base::Bind( | 1042 base::Closure stop_cb = base::Bind( |
1034 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 1043 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
1035 | 1044 |
1036 if (state == kInitDemuxer) { | 1045 if (state == kInitDemuxer) { |
1037 if (stop_or_error == kStop) { | 1046 if (stop_or_error == kStop) { |
1038 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 1047 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
1039 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), | 1048 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), |
1040 RunCallback<1>(PIPELINE_OK))); | 1049 RunCallback<1>(PIPELINE_OK))); |
1041 EXPECT_CALL(callbacks_, OnStop()); | 1050 ExpectPipelineStopAndDestroyPipeline(); |
1042 } else { | 1051 } else { |
1043 status = DEMUXER_ERROR_COULD_NOT_OPEN; | 1052 status = DEMUXER_ERROR_COULD_NOT_OPEN; |
1044 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) | 1053 EXPECT_CALL(*demuxer_, Initialize(_, _, _)) |
1045 .WillOnce(RunCallback<1>(status)); | 1054 .WillOnce(RunCallback<1>(status)); |
1046 } | 1055 } |
1047 | 1056 |
1048 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 1057 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
1049 return status; | 1058 return status; |
1050 } | 1059 } |
1051 | 1060 |
1052 CreateAudioStream(); | 1061 CreateAudioStream(); |
1053 CreateVideoStream(); | 1062 CreateVideoStream(); |
1054 MockDemuxerStreamVector streams; | 1063 MockDemuxerStreamVector streams; |
1055 streams.push_back(audio_stream()); | 1064 streams.push_back(audio_stream()); |
1056 streams.push_back(video_stream()); | 1065 streams.push_back(video_stream()); |
1057 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); | 1066 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); |
1058 | 1067 |
1059 if (state == kInitAudioRenderer) { | 1068 if (state == kInitAudioRenderer) { |
1060 if (stop_or_error == kStop) { | 1069 if (stop_or_error == kStop) { |
1061 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) | 1070 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) |
1062 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), | 1071 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), |
1063 RunCallback<1>(PIPELINE_OK))); | 1072 RunCallback<1>(PIPELINE_OK))); |
1064 EXPECT_CALL(callbacks_, OnStop()); | 1073 ExpectPipelineStopAndDestroyPipeline(); |
1065 } else { | 1074 } else { |
1066 status = PIPELINE_ERROR_INITIALIZATION_FAILED; | 1075 status = PIPELINE_ERROR_INITIALIZATION_FAILED; |
1067 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) | 1076 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) |
1068 .WillOnce(RunCallback<1>(status)); | 1077 .WillOnce(RunCallback<1>(status)); |
1069 } | 1078 } |
1070 | 1079 |
1071 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 1080 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
1072 return status; | 1081 return status; |
1073 } | 1082 } |
1074 | 1083 |
1075 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) | 1084 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) |
1076 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), | 1085 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), |
1077 RunCallback<1>(PIPELINE_OK))); | 1086 RunCallback<1>(PIPELINE_OK))); |
1078 | 1087 |
1079 if (state == kInitVideoRenderer) { | 1088 if (state == kInitVideoRenderer) { |
1080 if (stop_or_error == kStop) { | 1089 if (stop_or_error == kStop) { |
1081 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) | 1090 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) |
1082 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), | 1091 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), |
1083 RunCallback<2>(PIPELINE_OK))); | 1092 RunCallback<2>(PIPELINE_OK))); |
1084 EXPECT_CALL(callbacks_, OnStop()); | 1093 ExpectPipelineStopAndDestroyPipeline(); |
1085 } else { | 1094 } else { |
1086 status = PIPELINE_ERROR_INITIALIZATION_FAILED; | 1095 status = PIPELINE_ERROR_INITIALIZATION_FAILED; |
1087 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) | 1096 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) |
1088 .WillOnce(RunCallback<2>(status)); | 1097 .WillOnce(RunCallback<2>(status)); |
1089 } | 1098 } |
1090 | 1099 |
1091 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 1100 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
1092 return status; | 1101 return status; |
1093 } | 1102 } |
1094 | 1103 |
(...skipping 24 matching lines...) Expand all Loading... |
1119 } | 1128 } |
1120 | 1129 |
1121 void DoSeek(TeardownState state, StopOrError stop_or_error) { | 1130 void DoSeek(TeardownState state, StopOrError stop_or_error) { |
1122 InSequence s; | 1131 InSequence s; |
1123 PipelineStatus status = SetSeekExpectations(state, stop_or_error); | 1132 PipelineStatus status = SetSeekExpectations(state, stop_or_error); |
1124 | 1133 |
1125 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 1134 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
1126 EXPECT_CALL(callbacks_, OnSeek(status)); | 1135 EXPECT_CALL(callbacks_, OnSeek(status)); |
1127 | 1136 |
1128 if (status == PIPELINE_OK) { | 1137 if (status == PIPELINE_OK) { |
1129 EXPECT_CALL(callbacks_, OnStop()); | 1138 ExpectPipelineStopAndDestroyPipeline(); |
1130 } | 1139 } |
1131 | 1140 |
1132 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | 1141 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( |
1133 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | 1142 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); |
1134 message_loop_.RunUntilIdle(); | 1143 message_loop_.RunUntilIdle(); |
1135 } | 1144 } |
1136 | 1145 |
1137 PipelineStatus SetSeekExpectations(TeardownState state, | 1146 PipelineStatus SetSeekExpectations(TeardownState state, |
1138 StopOrError stop_or_error) { | 1147 StopOrError stop_or_error) { |
1139 PipelineStatus status = PIPELINE_OK; | 1148 PipelineStatus status = PIPELINE_OK; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 return status; | 1197 return status; |
1189 } | 1198 } |
1190 | 1199 |
1191 void DoStopOrError(StopOrError stop_or_error) { | 1200 void DoStopOrError(StopOrError stop_or_error) { |
1192 InSequence s; | 1201 InSequence s; |
1193 | 1202 |
1194 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); | 1203 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); |
1195 | 1204 |
1196 switch (stop_or_error) { | 1205 switch (stop_or_error) { |
1197 case kStop: | 1206 case kStop: |
1198 EXPECT_CALL(callbacks_, OnStop()); | 1207 ExpectPipelineStopAndDestroyPipeline(); |
1199 pipeline_->Stop(base::Bind( | 1208 pipeline_->Stop(base::Bind( |
1200 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 1209 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
1201 break; | 1210 break; |
1202 | 1211 |
1203 case kError: | 1212 case kError: |
1204 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | 1213 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); |
1205 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); | 1214 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); |
1206 break; | 1215 break; |
1207 | 1216 |
1208 case kErrorAndStop: | 1217 case kErrorAndStop: |
1209 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | 1218 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); |
1210 EXPECT_CALL(callbacks_, OnStop()); | 1219 ExpectPipelineStopAndDestroyPipeline(); |
1211 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); | 1220 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); |
1212 pipeline_->Stop(base::Bind( | 1221 pipeline_->Stop(base::Bind( |
1213 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 1222 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
1214 break; | 1223 break; |
1215 } | 1224 } |
1216 | 1225 |
1217 message_loop_.RunUntilIdle(); | 1226 message_loop_.RunUntilIdle(); |
1218 } | 1227 } |
1219 | 1228 |
1220 DISALLOW_COPY_AND_ASSIGN(PipelineTeardownTest); | 1229 DISALLOW_COPY_AND_ASSIGN(PipelineTeardownTest); |
(...skipping 14 matching lines...) Expand all Loading... |
1235 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); | 1244 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); |
1236 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); | 1245 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); |
1237 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); | 1246 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); |
1238 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1247 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
1239 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1248 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
1240 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1249 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
1241 | 1250 |
1242 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); | 1251 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); |
1243 | 1252 |
1244 } // namespace media | 1253 } // namespace media |
OLD | NEW |