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

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

Issue 1753043002: Supress pipeline errors during destruction and suspend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment style. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/blink/webmediaplayer_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 "media/base/pipeline_impl.h" 5 #include "media/base/pipeline_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 break; 860 break;
861 861
862 case kFlushing: 862 case kFlushing:
863 case kSeeking: 863 case kSeeking:
864 DoInitialize(state, stop_or_error); 864 DoInitialize(state, stop_or_error);
865 DoSeek(state, stop_or_error); 865 DoSeek(state, stop_or_error);
866 break; 866 break;
867 867
868 case kPlaying: 868 case kPlaying:
869 DoInitialize(state, stop_or_error); 869 DoInitialize(state, stop_or_error);
870 DoStopOrError(stop_or_error); 870 DoStopOrError(stop_or_error, true);
871 break; 871 break;
872 872
873 case kSuspending: 873 case kSuspending:
874 case kSuspended: 874 case kSuspended:
875 case kResuming: 875 case kResuming:
876 DoInitialize(state, stop_or_error); 876 DoInitialize(state, stop_or_error);
877 DoSuspend(state, stop_or_error); 877 DoSuspend(state, stop_or_error);
878 break; 878 break;
879 } 879 }
880 } 880 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 return status; 1023 return status;
1024 } 1024 }
1025 1025
1026 NOTREACHED() << "State not supported: " << state; 1026 NOTREACHED() << "State not supported: " << state;
1027 return status; 1027 return status;
1028 } 1028 }
1029 1029
1030 void DoSuspend(TeardownState state, StopOrError stop_or_error) { 1030 void DoSuspend(TeardownState state, StopOrError stop_or_error) {
1031 PipelineStatus status = SetSuspendExpectations(state, stop_or_error); 1031 PipelineStatus status = SetSuspendExpectations(state, stop_or_error);
1032 1032
1033 if (state != kSuspended) { 1033 if (state == kResuming) {
1034 // DoStopOrError() handles these for kSuspended.
1035 EXPECT_CALL(*demuxer_, Stop()); 1034 EXPECT_CALL(*demuxer_, Stop());
1036 if (status == PIPELINE_OK) { 1035 if (status == PIPELINE_OK)
1037 ExpectPipelineStopAndDestroyPipeline(); 1036 ExpectPipelineStopAndDestroyPipeline();
1038 }
1039 } 1037 }
1040 1038
1041 PipelineImplTest::DoSuspend(); 1039 PipelineImplTest::DoSuspend();
1042 1040
1043 if (state == kSuspended) { 1041 if (state == kResuming) {
1044 DoStopOrError(stop_or_error);
1045 } else if (state == kResuming) {
1046 PipelineImplTest::DoResume(base::TimeDelta()); 1042 PipelineImplTest::DoResume(base::TimeDelta());
1043 return;
1047 } 1044 }
1045
1046 // kSuspended, kSuspending never throw errors, since Resume() is always able
1047 // to restore the pipeline to a pristine state.
1048 DoStopOrError(stop_or_error, false);
1048 } 1049 }
1049 1050
1050 PipelineStatus SetSuspendExpectations(TeardownState state, 1051 PipelineStatus SetSuspendExpectations(TeardownState state,
1051 StopOrError stop_or_error) { 1052 StopOrError stop_or_error) {
1052 PipelineStatus status = PIPELINE_OK; 1053 PipelineStatus status = PIPELINE_OK;
1053 base::Closure stop_cb = 1054 base::Closure stop_cb =
1054 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_)); 1055 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_));
1055 1056
1056 EXPECT_CALL(*renderer_, SetPlaybackRate(0)); 1057 EXPECT_CALL(*renderer_, SetPlaybackRate(0));
1057 if (state == kSuspended || state == kResuming) { 1058 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
1058 EXPECT_CALL(*renderer_, Flush(_)) 1059 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK));
1059 .WillOnce(DoAll( 1060 EXPECT_CALL(*renderer_, Flush(_))
1060 SetBufferingState(&buffering_state_cb_, BUFFERING_HAVE_NOTHING), 1061 .WillOnce(DoAll(
1061 RunClosure<0>())); 1062 SetBufferingState(&buffering_state_cb_, BUFFERING_HAVE_NOTHING),
1062 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); 1063 RunClosure<0>()));
1063 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK)); 1064 if (state == kResuming) {
1064 if (state == kResuming) {
1065 if (stop_or_error == kStop) {
1066 EXPECT_CALL(*demuxer_, Seek(_, _))
1067 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb),
1068 RunCallback<1>(PIPELINE_OK)));
1069 EXPECT_CALL(callbacks_, OnResume(PIPELINE_OK));
1070 } else {
1071 status = PIPELINE_ERROR_READ;
1072 EXPECT_CALL(*demuxer_, Seek(_, _)).WillOnce(RunCallback<1>(status));
1073 EXPECT_CALL(callbacks_, OnResume(status));
1074 }
1075 }
1076 return status;
1077 } else if (state == kSuspending) {
1078 if (stop_or_error == kStop) { 1065 if (stop_or_error == kStop) {
1079 EXPECT_CALL(*renderer_, Flush(_)) 1066 EXPECT_CALL(*demuxer_, Seek(_, _))
1080 .WillOnce(DoAll( 1067 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb),
1081 Stop(pipeline_.get(), stop_cb), 1068 RunCallback<1>(PIPELINE_OK)));
1082 SetBufferingState(&buffering_state_cb_, BUFFERING_HAVE_NOTHING), 1069 EXPECT_CALL(callbacks_, OnResume(PIPELINE_OK));
1083 RunClosure<0>()));
1084 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
1085 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK));
1086 } else { 1070 } else {
1087 status = PIPELINE_ERROR_READ; 1071 status = PIPELINE_ERROR_READ;
1088 EXPECT_CALL(*renderer_, Flush(_)) 1072 EXPECT_CALL(*demuxer_, Seek(_, _)).WillOnce(RunCallback<1>(status));
1089 .WillOnce(SetError(pipeline_.get(), status)); 1073 EXPECT_CALL(callbacks_, OnResume(status));
1090 EXPECT_CALL(callbacks_, OnSuspend(status));
1091 } 1074 }
1092 return status; 1075 } else if (state != kSuspended && state != kSuspending) {
1076 NOTREACHED() << "State not supported: " << state;
1093 } 1077 }
1094 1078
1095 NOTREACHED() << "State not supported: " << state;
1096 return status; 1079 return status;
1097 } 1080 }
1098 1081
1099 void DoStopOrError(StopOrError stop_or_error) { 1082 void DoStopOrError(StopOrError stop_or_error, bool expect_errors) {
1100 InSequence s; 1083 InSequence s;
1101 1084
1102 EXPECT_CALL(*demuxer_, Stop());
1103
1104 switch (stop_or_error) { 1085 switch (stop_or_error) {
1105 case kStop: 1086 case kStop:
1087 EXPECT_CALL(*demuxer_, Stop());
1106 ExpectPipelineStopAndDestroyPipeline(); 1088 ExpectPipelineStopAndDestroyPipeline();
1107 pipeline_->Stop( 1089 pipeline_->Stop(
1108 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); 1090 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_)));
1109 break; 1091 break;
1110 1092
1111 case kError: 1093 case kError:
1112 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); 1094 if (expect_errors) {
1095 EXPECT_CALL(*demuxer_, Stop());
1096 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ));
1097 }
1113 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); 1098 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ);
1114 break; 1099 break;
1115 1100
1116 case kErrorAndStop: 1101 case kErrorAndStop:
1117 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); 1102 EXPECT_CALL(*demuxer_, Stop());
1103 if (expect_errors)
1104 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ));
1118 ExpectPipelineStopAndDestroyPipeline(); 1105 ExpectPipelineStopAndDestroyPipeline();
1119 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); 1106 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ);
1120 message_loop_.RunUntilIdle(); 1107 message_loop_.RunUntilIdle();
1121 pipeline_->Stop( 1108 pipeline_->Stop(
1122 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_))); 1109 base::Bind(&CallbackHelper::OnStop, base::Unretained(&callbacks_)));
1123 break; 1110 break;
1124 } 1111 }
1125 1112
1126 message_loop_.RunUntilIdle(); 1113 message_loop_.RunUntilIdle();
1127 } 1114 }
(...skipping 21 matching lines...) Expand all
1149 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1136 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1150 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1137 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1151 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); 1138 INSTANTIATE_TEARDOWN_TEST(Error, Suspending);
1152 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); 1139 INSTANTIATE_TEARDOWN_TEST(Error, Suspended);
1153 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); 1140 INSTANTIATE_TEARDOWN_TEST(Error, Resuming);
1154 1141
1155 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1142 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1156 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); 1143 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended);
1157 1144
1158 } // namespace media 1145 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698