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

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

Issue 2267963002: Add support for cancellation of demuxer reads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch to using aborted status. Created 4 years, 3 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
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 <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 250 }
251 251
252 void DoSeek(const base::TimeDelta& seek_time) { 252 void DoSeek(const base::TimeDelta& seek_time) {
253 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, 253 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek,
254 base::Unretained(&callbacks_))); 254 base::Unretained(&callbacks_)));
255 base::RunLoop().RunUntilIdle(); 255 base::RunLoop().RunUntilIdle();
256 } 256 }
257 257
258 void ExpectSuspend() { 258 void ExpectSuspend() {
259 EXPECT_CALL(*renderer_, SetPlaybackRate(0)); 259 EXPECT_CALL(*renderer_, SetPlaybackRate(0));
260 EXPECT_CALL(*renderer_, Flush(_))
261 .WillOnce(
262 DoAll(SetBufferingState(&renderer_client_, BUFFERING_HAVE_NOTHING),
263 RunClosure<0>()));
264 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
265 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK)); 260 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK));
266 } 261 }
267 262
268 void DoSuspend() { 263 void DoSuspend() {
269 pipeline_->Suspend( 264 pipeline_->Suspend(
270 base::Bind(&CallbackHelper::OnSuspend, base::Unretained(&callbacks_))); 265 base::Bind(&CallbackHelper::OnSuspend, base::Unretained(&callbacks_)));
271 base::RunLoop().RunUntilIdle(); 266 base::RunLoop().RunUntilIdle();
272 267
273 // |renderer_| has been deleted, replace it. 268 // |renderer_| has been deleted, replace it.
274 scoped_renderer_.reset(new StrictMock<MockRenderer>()), 269 scoped_renderer_.reset(new StrictMock<MockRenderer>()),
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 return; 990 return;
996 } 991 }
997 992
998 // kSuspended, kSuspending never throw errors, since Resume() is always able 993 // kSuspended, kSuspending never throw errors, since Resume() is always able
999 // to restore the pipeline to a pristine state. 994 // to restore the pipeline to a pristine state.
1000 DoStopOrError(stop_or_error, false); 995 DoStopOrError(stop_or_error, false);
1001 } 996 }
1002 997
1003 void SetSuspendExpectations(TeardownState state, StopOrError stop_or_error) { 998 void SetSuspendExpectations(TeardownState state, StopOrError stop_or_error) {
1004 EXPECT_CALL(*renderer_, SetPlaybackRate(0)); 999 EXPECT_CALL(*renderer_, SetPlaybackRate(0));
1005 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
1006 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK)); 1000 EXPECT_CALL(callbacks_, OnSuspend(PIPELINE_OK));
1007 EXPECT_CALL(*renderer_, Flush(_))
1008 .WillOnce(
1009 DoAll(SetBufferingState(&renderer_client_, BUFFERING_HAVE_NOTHING),
1010 RunClosure<0>()));
1011 if (state == kResuming) { 1001 if (state == kResuming) {
1012 if (stop_or_error == kStop) { 1002 if (stop_or_error == kStop) {
1013 EXPECT_CALL(*demuxer_, Seek(_, _)) 1003 EXPECT_CALL(*demuxer_, Seek(_, _))
1014 .WillOnce( 1004 .WillOnce(
1015 DoAll(Stop(pipeline_.get()), RunCallback<1>(PIPELINE_OK))); 1005 DoAll(Stop(pipeline_.get()), RunCallback<1>(PIPELINE_OK)));
1016 // Note: OnResume callback is not called after pipeline is stopped. 1006 // Note: OnResume callback is not called after pipeline is stopped.
1017 } else { 1007 } else {
1018 EXPECT_CALL(*demuxer_, Seek(_, _)) 1008 EXPECT_CALL(*demuxer_, Seek(_, _))
1019 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); 1009 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ));
1020 EXPECT_CALL(callbacks_, OnResume(PIPELINE_ERROR_READ)); 1010 EXPECT_CALL(callbacks_, OnResume(PIPELINE_ERROR_READ));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1065 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1076 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1066 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1077 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); 1067 INSTANTIATE_TEARDOWN_TEST(Error, Suspending);
1078 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); 1068 INSTANTIATE_TEARDOWN_TEST(Error, Suspended);
1079 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); 1069 INSTANTIATE_TEARDOWN_TEST(Error, Resuming);
1080 1070
1081 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1071 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1082 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); 1072 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended);
1083 1073
1084 } // namespace media 1074 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698