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

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

Issue 407583002: Fold AudioRenderer::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ClocklessAudioSink Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/audio_renderer_impl.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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // We expect the time to be updated only after the seek has completed. 305 // We expect the time to be updated only after the seek has completed.
306 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); 306 EXPECT_NE(seek_time, pipeline_->GetMediaTime());
307 message_loop_.RunUntilIdle(); 307 message_loop_.RunUntilIdle();
308 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); 308 EXPECT_EQ(seek_time, pipeline_->GetMediaTime());
309 } 309 }
310 310
311 void ExpectStop() { 311 void ExpectStop() {
312 if (demuxer_) 312 if (demuxer_)
313 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 313 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
314 314
315 if (audio_stream_)
316 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>());
317
318 if (video_stream_) 315 if (video_stream_)
319 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); 316 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>());
320 } 317 }
321 318
322 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&, 319 MOCK_METHOD2(OnAddTextTrack, void(const TextTrackConfig&,
323 const AddTextTrackDoneCB&)); 320 const AddTextTrackDoneCB&));
324 321
325 void DoOnAddTextTrack(const TextTrackConfig& config, 322 void DoOnAddTextTrack(const TextTrackConfig& config,
326 const AddTextTrackDoneCB& done_cb) { 323 const AddTextTrackDoneCB& done_cb) {
327 scoped_ptr<TextTrack> text_track(new MockTextTrack); 324 scoped_ptr<TextTrack> text_track(new MockTextTrack);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 message_loop_.RunUntilIdle(); 677 message_loop_.RunUntilIdle();
681 678
682 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 679 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
683 680
684 // Preroll() isn't called as the demuxer errors out first. 681 // Preroll() isn't called as the demuxer errors out first.
685 EXPECT_CALL(time_source_, StopTicking()); 682 EXPECT_CALL(time_source_, StopTicking());
686 EXPECT_CALL(*audio_renderer_, Flush(_)) 683 EXPECT_CALL(*audio_renderer_, Flush(_))
687 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 684 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
688 BUFFERING_HAVE_NOTHING), 685 BUFFERING_HAVE_NOTHING),
689 RunClosure<0>())); 686 RunClosure<0>()));
690 EXPECT_CALL(*audio_renderer_, Stop(_))
691 .WillOnce(RunClosure<0>());
692 687
693 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 688 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
694 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); 689 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ));
695 EXPECT_CALL(*demuxer_, Stop(_)) 690 EXPECT_CALL(*demuxer_, Stop(_))
696 .WillOnce(RunClosure<0>()); 691 .WillOnce(RunClosure<0>());
697 692
698 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, 693 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek,
699 base::Unretained(&callbacks_))); 694 base::Unretained(&callbacks_)));
700 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); 695 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ));
701 message_loop_.RunUntilIdle(); 696 message_loop_.RunUntilIdle();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); 731 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run));
737 732
738 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 733 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
739 734
740 // Seek() isn't called as the demuxer errors out first. 735 // Seek() isn't called as the demuxer errors out first.
741 EXPECT_CALL(time_source_, StopTicking()); 736 EXPECT_CALL(time_source_, StopTicking());
742 EXPECT_CALL(*audio_renderer_, Flush(_)) 737 EXPECT_CALL(*audio_renderer_, Flush(_))
743 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 738 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
744 BUFFERING_HAVE_NOTHING), 739 BUFFERING_HAVE_NOTHING),
745 RunClosure<0>())); 740 RunClosure<0>()));
746 EXPECT_CALL(*audio_renderer_, Stop(_))
747 .WillOnce(RunClosure<0>());
748 741
749 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 742 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
750 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); 743 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ));
751 EXPECT_CALL(*demuxer_, Stop(_)) 744 EXPECT_CALL(*demuxer_, Stop(_))
752 .WillOnce(RunClosure<0>()); 745 .WillOnce(RunClosure<0>());
753 746
754 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, 747 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek,
755 base::Unretained(&callbacks_))); 748 base::Unretained(&callbacks_)));
756 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); 749 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ));
757 message_loop_.RunUntilIdle(); 750 message_loop_.RunUntilIdle();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), 952 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb),
960 RunCallback<1>(PIPELINE_OK))); 953 RunCallback<1>(PIPELINE_OK)));
961 EXPECT_CALL(callbacks_, OnStop()); 954 EXPECT_CALL(callbacks_, OnStop());
962 } else { 955 } else {
963 status = PIPELINE_ERROR_INITIALIZATION_FAILED; 956 status = PIPELINE_ERROR_INITIALIZATION_FAILED;
964 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) 957 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _))
965 .WillOnce(RunCallback<1>(status)); 958 .WillOnce(RunCallback<1>(status));
966 } 959 }
967 960
968 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 961 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
969 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>());
970 return status; 962 return status;
971 } 963 }
972 964
973 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _)) 965 EXPECT_CALL(*audio_renderer_, Initialize(_, _, _, _, _, _, _))
974 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), 966 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_),
975 RunCallback<1>(PIPELINE_OK))); 967 RunCallback<1>(PIPELINE_OK)));
976 968
977 if (state == kInitVideoRenderer) { 969 if (state == kInitVideoRenderer) {
978 if (stop_or_error == kStop) { 970 if (stop_or_error == kStop) {
979 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) 971 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _))
980 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), 972 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb),
981 RunCallback<2>(PIPELINE_OK))); 973 RunCallback<2>(PIPELINE_OK)));
982 EXPECT_CALL(callbacks_, OnStop()); 974 EXPECT_CALL(callbacks_, OnStop());
983 } else { 975 } else {
984 status = PIPELINE_ERROR_INITIALIZATION_FAILED; 976 status = PIPELINE_ERROR_INITIALIZATION_FAILED;
985 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) 977 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _))
986 .WillOnce(RunCallback<2>(status)); 978 .WillOnce(RunCallback<2>(status));
987 } 979 }
988 980
989 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 981 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
990 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>());
991 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); 982 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>());
992 return status; 983 return status;
993 } 984 }
994 985
995 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) 986 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _))
996 .WillOnce(DoAll(SaveArg<5>(&video_buffering_state_cb_), 987 .WillOnce(DoAll(SaveArg<5>(&video_buffering_state_cb_),
997 RunCallback<2>(PIPELINE_OK))); 988 RunCallback<2>(PIPELINE_OK)));
998 989
999 EXPECT_CALL(callbacks_, OnMetadata(_)); 990 EXPECT_CALL(callbacks_, OnMetadata(_));
1000 991
(...skipping 15 matching lines...) Expand all
1016 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 1007 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
1017 1008
1018 return status; 1009 return status;
1019 } 1010 }
1020 1011
1021 void DoSeek(TeardownState state, StopOrError stop_or_error) { 1012 void DoSeek(TeardownState state, StopOrError stop_or_error) {
1022 InSequence s; 1013 InSequence s;
1023 PipelineStatus status = SetSeekExpectations(state, stop_or_error); 1014 PipelineStatus status = SetSeekExpectations(state, stop_or_error);
1024 1015
1025 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 1016 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
1026 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>());
1027 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); 1017 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>());
1028 EXPECT_CALL(callbacks_, OnSeek(status)); 1018 EXPECT_CALL(callbacks_, OnSeek(status));
1029 1019
1030 if (status == PIPELINE_OK) { 1020 if (status == PIPELINE_OK) {
1031 EXPECT_CALL(callbacks_, OnStop()); 1021 EXPECT_CALL(callbacks_, OnStop());
1032 } 1022 }
1033 1023
1034 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( 1024 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind(
1035 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); 1025 &CallbackHelper::OnSeek, base::Unretained(&callbacks_)));
1036 message_loop_.RunUntilIdle(); 1026 message_loop_.RunUntilIdle();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } 1077 }
1088 1078
1089 NOTREACHED() << "State not supported: " << state; 1079 NOTREACHED() << "State not supported: " << state;
1090 return status; 1080 return status;
1091 } 1081 }
1092 1082
1093 void DoStopOrError(StopOrError stop_or_error) { 1083 void DoStopOrError(StopOrError stop_or_error) {
1094 InSequence s; 1084 InSequence s;
1095 1085
1096 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 1086 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
1097 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>());
1098 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); 1087 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>());
1099 1088
1100 switch (stop_or_error) { 1089 switch (stop_or_error) {
1101 case kStop: 1090 case kStop:
1102 EXPECT_CALL(callbacks_, OnStop()); 1091 EXPECT_CALL(callbacks_, OnStop());
1103 pipeline_->Stop(base::Bind( 1092 pipeline_->Stop(base::Bind(
1104 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); 1093 &CallbackHelper::OnStop, base::Unretained(&callbacks_)));
1105 break; 1094 break;
1106 1095
1107 case kError: 1096 case kError:
(...skipping 30 matching lines...) Expand all
1138 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); 1127 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer);
1139 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); 1128 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer);
1140 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); 1129 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer);
1141 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); 1130 INSTANTIATE_TEARDOWN_TEST(Error, Flushing);
1142 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1131 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1143 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1132 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1144 1133
1145 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1134 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1146 1135
1147 } // namespace media 1136 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/audio_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698