| 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" |
| 11 #include "media/base/clock.h" | 11 #include "media/base/clock.h" |
| 12 #include "media/base/gmock_callback_support.h" |
| 12 #include "media/base/media_log.h" | 13 #include "media/base/media_log.h" |
| 13 #include "media/base/pipeline.h" | |
| 14 #include "media/base/mock_callback.h" | 14 #include "media/base/mock_callback.h" |
| 15 #include "media/base/mock_filters.h" | 15 #include "media/base/mock_filters.h" |
| 16 #include "media/base/pipeline.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 18 | 19 |
| 19 using ::testing::_; | 20 using ::testing::_; |
| 20 using ::testing::DeleteArg; | 21 using ::testing::DeleteArg; |
| 21 using ::testing::DoAll; | 22 using ::testing::DoAll; |
| 22 // TODO(scherkus): Remove InSequence after refactoring Pipeline. | 23 // TODO(scherkus): Remove InSequence after refactoring Pipeline. |
| 23 using ::testing::InSequence; | 24 using ::testing::InSequence; |
| 24 using ::testing::Invoke; | 25 using ::testing::Invoke; |
| 25 using ::testing::InvokeWithoutArgs; | 26 using ::testing::InvokeWithoutArgs; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 } | 44 } |
| 44 | 45 |
| 45 ACTION_P2(Stop, pipeline, stop_cb) { | 46 ACTION_P2(Stop, pipeline, stop_cb) { |
| 46 pipeline->Stop(stop_cb); | 47 pipeline->Stop(stop_cb); |
| 47 } | 48 } |
| 48 | 49 |
| 49 ACTION_P2(SetError, pipeline, status) { | 50 ACTION_P2(SetError, pipeline, status) { |
| 50 pipeline->SetErrorForTesting(status); | 51 pipeline->SetErrorForTesting(status); |
| 51 } | 52 } |
| 52 | 53 |
| 53 ACTION(RunPipelineStatusCB) { | |
| 54 arg1.Run(PIPELINE_OK); | |
| 55 } | |
| 56 | |
| 57 ACTION(RunPipelineStatusCB2) { | |
| 58 arg2.Run(PIPELINE_OK); | |
| 59 } | |
| 60 | |
| 61 ACTION_P(RunPipelineStatusCBWithStatus, status) { | |
| 62 arg1.Run(status); | |
| 63 } | |
| 64 | |
| 65 ACTION_P(RunPipelineStatusCB2WithStatus, status) { | |
| 66 arg2.Run(status); | |
| 67 } | |
| 68 | |
| 69 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 54 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
| 70 // also lets us test for missing callbacks. | 55 // also lets us test for missing callbacks. |
| 71 class CallbackHelper { | 56 class CallbackHelper { |
| 72 public: | 57 public: |
| 73 CallbackHelper() {} | 58 CallbackHelper() {} |
| 74 virtual ~CallbackHelper() {} | 59 virtual ~CallbackHelper() {} |
| 75 | 60 |
| 76 MOCK_METHOD1(OnStart, void(PipelineStatus)); | 61 MOCK_METHOD1(OnStart, void(PipelineStatus)); |
| 77 MOCK_METHOD1(OnSeek, void(PipelineStatus)); | 62 MOCK_METHOD1(OnSeek, void(PipelineStatus)); |
| 78 MOCK_METHOD0(OnStop, void()); | 63 MOCK_METHOD0(OnStop, void()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 104 .WillRepeatedly(Return(null_pointer)); | 89 .WillRepeatedly(Return(null_pointer)); |
| 105 | 90 |
| 106 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) | 91 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) |
| 107 .WillRepeatedly(Return(base::TimeDelta())); | 92 .WillRepeatedly(Return(base::TimeDelta())); |
| 108 } | 93 } |
| 109 | 94 |
| 110 virtual ~PipelineTest() { | 95 virtual ~PipelineTest() { |
| 111 // Shutdown sequence. | 96 // Shutdown sequence. |
| 112 if (pipeline_->IsRunning()) { | 97 if (pipeline_->IsRunning()) { |
| 113 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 98 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 114 .WillOnce(RunClosure()); | 99 .WillOnce(RunClosure<0>()); |
| 115 | 100 |
| 116 if (audio_stream_) | 101 if (audio_stream_) |
| 117 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | 102 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 103 .WillOnce(RunClosure<0>()); |
| 118 | 104 |
| 119 if (video_stream_) | 105 if (video_stream_) |
| 120 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure()); | 106 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 107 .WillOnce(RunClosure<0>()); |
| 121 } | 108 } |
| 122 | 109 |
| 123 // Expect a stop callback if we were started. | 110 // Expect a stop callback if we were started. |
| 124 EXPECT_CALL(callbacks_, OnStop()); | 111 EXPECT_CALL(callbacks_, OnStop()); |
| 125 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 112 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
| 126 base::Unretained(&callbacks_))); | 113 base::Unretained(&callbacks_))); |
| 127 message_loop_.RunAllPending(); | 114 message_loop_.RunAllPending(); |
| 128 | 115 |
| 129 pipeline_ = NULL; | 116 pipeline_ = NULL; |
| 130 mocks_.reset(); | 117 mocks_.reset(); |
| 131 } | 118 } |
| 132 | 119 |
| 133 protected: | 120 protected: |
| 134 // Sets up expectations to allow the demuxer to initialize. | 121 // Sets up expectations to allow the demuxer to initialize. |
| 135 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 122 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 136 void InitializeDemuxer(MockDemuxerStreamVector* streams, | 123 void InitializeDemuxer(MockDemuxerStreamVector* streams, |
| 137 const base::TimeDelta& duration) { | 124 const base::TimeDelta& duration) { |
| 138 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 125 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 139 .WillOnce(DoAll(SetDemuxerProperties(duration), | 126 .WillOnce(DoAll(SetDemuxerProperties(duration), |
| 140 RunPipelineStatusCB())); | 127 RunCallback<1>(PIPELINE_OK))); |
| 141 | 128 |
| 142 // Configure the demuxer to return the streams. | 129 // Configure the demuxer to return the streams. |
| 143 for (size_t i = 0; i < streams->size(); ++i) { | 130 for (size_t i = 0; i < streams->size(); ++i) { |
| 144 scoped_refptr<DemuxerStream> stream((*streams)[i]); | 131 scoped_refptr<DemuxerStream> stream((*streams)[i]); |
| 145 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) | 132 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) |
| 146 .WillRepeatedly(Return(stream)); | 133 .WillRepeatedly(Return(stream)); |
| 147 } | 134 } |
| 148 } | 135 } |
| 149 | 136 |
| 150 void InitializeDemuxer(MockDemuxerStreamVector* streams) { | 137 void InitializeDemuxer(MockDemuxerStreamVector* streams) { |
| 151 // Initialize with a default non-zero duration. | 138 // Initialize with a default non-zero duration. |
| 152 InitializeDemuxer(streams, base::TimeDelta::FromSeconds(10)); | 139 InitializeDemuxer(streams, base::TimeDelta::FromSeconds(10)); |
| 153 } | 140 } |
| 154 | 141 |
| 155 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { | 142 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { |
| 156 StrictMock<MockDemuxerStream>* stream = | 143 StrictMock<MockDemuxerStream>* stream = |
| 157 new StrictMock<MockDemuxerStream>(); | 144 new StrictMock<MockDemuxerStream>(); |
| 158 EXPECT_CALL(*stream, type()) | 145 EXPECT_CALL(*stream, type()) |
| 159 .WillRepeatedly(Return(type)); | 146 .WillRepeatedly(Return(type)); |
| 160 return stream; | 147 return stream; |
| 161 } | 148 } |
| 162 | 149 |
| 163 // Sets up expectations to allow the video renderer to initialize. | 150 // Sets up expectations to allow the video renderer to initialize. |
| 164 void InitializeVideoRenderer(const scoped_refptr<DemuxerStream>& stream) { | 151 void InitializeVideoRenderer(const scoped_refptr<DemuxerStream>& stream) { |
| 165 EXPECT_CALL(*mocks_->video_renderer(), | 152 EXPECT_CALL(*mocks_->video_renderer(), |
| 166 Initialize(stream, _, _, _, _, _, _, _, _, _)) | 153 Initialize(stream, _, _, _, _, _, _, _, _, _)) |
| 167 .WillOnce(RunPipelineStatusCB2()); | 154 .WillOnce(RunCallback<2>(PIPELINE_OK)); |
| 168 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 155 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 169 | 156 |
| 170 // Startup sequence. | 157 // Startup sequence. |
| 171 EXPECT_CALL(*mocks_->video_renderer(), | 158 EXPECT_CALL(*mocks_->video_renderer(), |
| 172 Preroll(mocks_->demuxer()->GetStartTime(), _)) | 159 Preroll(mocks_->demuxer()->GetStartTime(), _)) |
| 173 .WillOnce(RunPipelineStatusCB()); | 160 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 174 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) | 161 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) |
| 175 .WillOnce(RunClosure()); | 162 .WillOnce(RunClosure<0>()); |
| 176 } | 163 } |
| 177 | 164 |
| 178 // Sets up expectations to allow the audio renderer to initialize. | 165 // Sets up expectations to allow the audio renderer to initialize. |
| 179 void InitializeAudioRenderer(const scoped_refptr<DemuxerStream>& stream, | 166 void InitializeAudioRenderer(const scoped_refptr<DemuxerStream>& stream, |
| 180 bool disable_after_init_cb) { | 167 bool disable_after_init_cb) { |
| 181 if (disable_after_init_cb) { | 168 if (disable_after_init_cb) { |
| 182 EXPECT_CALL(*mocks_->audio_renderer(), | 169 EXPECT_CALL(*mocks_->audio_renderer(), |
| 183 Initialize(stream, _, _, _, _, _, _, _, _)) | 170 Initialize(stream, _, _, _, _, _, _, _, _)) |
| 184 .WillOnce(DoAll(RunPipelineStatusCB2(), | 171 .WillOnce(DoAll(RunCallback<2>(PIPELINE_OK), |
| 185 WithArg<7>(RunClosure()))); // |disabled_cb|. | 172 WithArg<7>(RunClosure<0>()))); // |disabled_cb|. |
| 186 } else { | 173 } else { |
| 187 EXPECT_CALL(*mocks_->audio_renderer(), | 174 EXPECT_CALL(*mocks_->audio_renderer(), |
| 188 Initialize(stream, _, _, _, _, _, _, _, _)) | 175 Initialize(stream, _, _, _, _, _, _, _, _)) |
| 189 .WillOnce(DoAll(SaveArg<5>(&audio_time_cb_), | 176 .WillOnce(DoAll(SaveArg<5>(&audio_time_cb_), |
| 190 RunPipelineStatusCB2())); | 177 RunCallback<2>(PIPELINE_OK))); |
| 191 } | 178 } |
| 192 } | 179 } |
| 193 | 180 |
| 194 // Sets up expectations on the callback and initializes the pipeline. Called | 181 // Sets up expectations on the callback and initializes the pipeline. Called |
| 195 // after tests have set expectations any filters they wish to use. | 182 // after tests have set expectations any filters they wish to use. |
| 196 void InitializePipeline(PipelineStatus start_status) { | 183 void InitializePipeline(PipelineStatus start_status) { |
| 197 EXPECT_CALL(callbacks_, OnStart(start_status)); | 184 EXPECT_CALL(callbacks_, OnStart(start_status)); |
| 198 | 185 |
| 199 if (start_status == PIPELINE_OK) { | 186 if (start_status == PIPELINE_OK) { |
| 200 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kHaveMetadata)); | 187 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kHaveMetadata)); |
| 201 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 188 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
| 202 | 189 |
| 203 if (audio_stream_) { | 190 if (audio_stream_) { |
| 204 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 191 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 205 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 192 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 206 | 193 |
| 207 // Startup sequence. | 194 // Startup sequence. |
| 208 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(base::TimeDelta(), _)) | 195 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(base::TimeDelta(), _)) |
| 209 .WillOnce(RunPipelineStatusCB()); | 196 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 210 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 197 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 211 .WillOnce(RunClosure()); | 198 .WillOnce(RunClosure<0>()); |
| 212 } | 199 } |
| 213 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); | 200 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); |
| 214 } | 201 } |
| 215 | 202 |
| 216 pipeline_->Start( | 203 pipeline_->Start( |
| 217 mocks_->Create().Pass(), | 204 mocks_->Create().Pass(), |
| 218 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 205 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 219 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 206 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 220 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), | 207 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), |
| 221 base::Bind(&CallbackHelper::OnBufferingState, | 208 base::Bind(&CallbackHelper::OnBufferingState, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 237 return audio_stream_; | 224 return audio_stream_; |
| 238 } | 225 } |
| 239 | 226 |
| 240 MockDemuxerStream* video_stream() { | 227 MockDemuxerStream* video_stream() { |
| 241 return video_stream_; | 228 return video_stream_; |
| 242 } | 229 } |
| 243 | 230 |
| 244 void ExpectSeek(const base::TimeDelta& seek_time) { | 231 void ExpectSeek(const base::TimeDelta& seek_time) { |
| 245 // Every filter should receive a call to Seek(). | 232 // Every filter should receive a call to Seek(). |
| 246 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 233 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 247 .WillOnce(RunPipelineStatusCB()); | 234 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 248 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(_)); | 235 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(_)); |
| 249 | 236 |
| 250 if (audio_stream_) { | 237 if (audio_stream_) { |
| 251 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 238 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 252 .WillOnce(RunClosure()); | 239 .WillOnce(RunClosure<0>()); |
| 253 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 240 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 254 .WillOnce(RunClosure()); | 241 .WillOnce(RunClosure<0>()); |
| 255 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(seek_time, _)) | 242 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(seek_time, _)) |
| 256 .WillOnce(RunPipelineStatusCB()); | 243 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 257 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(_)); | 244 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(_)); |
| 258 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(_)); | 245 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(_)); |
| 259 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 246 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 260 .WillOnce(RunClosure()); | 247 .WillOnce(RunClosure<0>()); |
| 261 } | 248 } |
| 262 | 249 |
| 263 if (video_stream_) { | 250 if (video_stream_) { |
| 264 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)) | 251 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)) |
| 265 .WillOnce(RunClosure()); | 252 .WillOnce(RunClosure<0>()); |
| 266 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)) | 253 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)) |
| 267 .WillOnce(RunClosure()); | 254 .WillOnce(RunClosure<0>()); |
| 268 EXPECT_CALL(*mocks_->video_renderer(), Preroll(seek_time, _)) | 255 EXPECT_CALL(*mocks_->video_renderer(), Preroll(seek_time, _)) |
| 269 .WillOnce(RunPipelineStatusCB()); | 256 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 270 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(_)); | 257 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(_)); |
| 271 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) | 258 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) |
| 272 .WillOnce(RunClosure()); | 259 .WillOnce(RunClosure<0>()); |
| 273 } | 260 } |
| 274 | 261 |
| 275 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); | 262 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); |
| 276 | 263 |
| 277 // We expect a successful seek callback. | 264 // We expect a successful seek callback. |
| 278 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | 265 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
| 279 } | 266 } |
| 280 | 267 |
| 281 void DoSeek(const base::TimeDelta& seek_time) { | 268 void DoSeek(const base::TimeDelta& seek_time) { |
| 282 pipeline_->Seek(seek_time, | 269 pipeline_->Seek(seek_time, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 345 |
| 359 // 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 |
| 360 // 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 |
| 361 // made during tear down. | 348 // made during tear down. |
| 362 Mock::VerifyAndClear(&callbacks_); | 349 Mock::VerifyAndClear(&callbacks_); |
| 363 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 350 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
| 364 } | 351 } |
| 365 | 352 |
| 366 TEST_F(PipelineTest, URLNotFound) { | 353 TEST_F(PipelineTest, URLNotFound) { |
| 367 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 354 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 368 .WillOnce(RunPipelineStatusCBWithStatus(PIPELINE_ERROR_URL_NOT_FOUND)); | 355 .WillOnce(RunCallback<1>(PIPELINE_ERROR_URL_NOT_FOUND)); |
| 369 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 356 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 370 .WillOnce(RunClosure()); | 357 .WillOnce(RunClosure<0>()); |
| 371 | 358 |
| 372 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); | 359 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); |
| 373 } | 360 } |
| 374 | 361 |
| 375 TEST_F(PipelineTest, NoStreams) { | 362 TEST_F(PipelineTest, NoStreams) { |
| 376 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 363 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 377 .WillOnce(RunPipelineStatusCB()); | 364 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 378 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 365 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 379 .WillOnce(RunClosure()); | 366 .WillOnce(RunClosure<0>()); |
| 380 | 367 |
| 381 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); | 368 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); |
| 382 } | 369 } |
| 383 | 370 |
| 384 TEST_F(PipelineTest, AudioStream) { | 371 TEST_F(PipelineTest, AudioStream) { |
| 385 CreateAudioStream(); | 372 CreateAudioStream(); |
| 386 MockDemuxerStreamVector streams; | 373 MockDemuxerStreamVector streams; |
| 387 streams.push_back(audio_stream()); | 374 streams.push_back(audio_stream()); |
| 388 | 375 |
| 389 InitializeDemuxer(&streams); | 376 InitializeDemuxer(&streams); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 float playback_rate = 1.0f; | 650 float playback_rate = 1.0f; |
| 664 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 651 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
| 665 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 652 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
| 666 pipeline_->SetPlaybackRate(playback_rate); | 653 pipeline_->SetPlaybackRate(playback_rate); |
| 667 message_loop_.RunAllPending(); | 654 message_loop_.RunAllPending(); |
| 668 | 655 |
| 669 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 656 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
| 670 | 657 |
| 671 // Preroll() isn't called as the demuxer errors out first. | 658 // Preroll() isn't called as the demuxer errors out first. |
| 672 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 659 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 673 .WillOnce(RunClosure()); | 660 .WillOnce(RunClosure<0>()); |
| 674 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 661 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 675 .WillOnce(RunClosure()); | 662 .WillOnce(RunClosure<0>()); |
| 676 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 663 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 677 .WillOnce(RunClosure()); | 664 .WillOnce(RunClosure<0>()); |
| 678 | 665 |
| 679 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 666 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 680 .WillOnce(RunPipelineStatusCBWithStatus(PIPELINE_ERROR_READ)); | 667 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); |
| 681 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 668 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 682 .WillOnce(RunClosure()); | 669 .WillOnce(RunClosure<0>()); |
| 683 | 670 |
| 684 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, | 671 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, |
| 685 base::Unretained(&callbacks_))); | 672 base::Unretained(&callbacks_))); |
| 686 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | 673 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); |
| 687 message_loop_.RunAllPending(); | 674 message_loop_.RunAllPending(); |
| 688 } | 675 } |
| 689 | 676 |
| 690 // Invoked function OnError. This asserts that the pipeline does not enqueue | 677 // Invoked function OnError. This asserts that the pipeline does not enqueue |
| 691 // non-teardown related tasks while tearing down. | 678 // non-teardown related tasks while tearing down. |
| 692 static void TestNoCallsAfterError( | 679 static void TestNoCallsAfterError( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 718 // Trigger additional requests on the pipeline during tear down from error. | 705 // Trigger additional requests on the pipeline during tear down from error. |
| 719 base::Callback<void(PipelineStatus)> cb = base::Bind( | 706 base::Callback<void(PipelineStatus)> cb = base::Bind( |
| 720 &TestNoCallsAfterError, pipeline_, &message_loop_); | 707 &TestNoCallsAfterError, pipeline_, &message_loop_); |
| 721 ON_CALL(callbacks_, OnError(_)) | 708 ON_CALL(callbacks_, OnError(_)) |
| 722 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); | 709 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); |
| 723 | 710 |
| 724 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 711 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
| 725 | 712 |
| 726 // Seek() isn't called as the demuxer errors out first. | 713 // Seek() isn't called as the demuxer errors out first. |
| 727 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 714 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 728 .WillOnce(RunClosure()); | 715 .WillOnce(RunClosure<0>()); |
| 729 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 716 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 730 .WillOnce(RunClosure()); | 717 .WillOnce(RunClosure<0>()); |
| 731 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 718 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 732 .WillOnce(RunClosure()); | 719 .WillOnce(RunClosure<0>()); |
| 733 | 720 |
| 734 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 721 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 735 .WillOnce(RunPipelineStatusCBWithStatus(PIPELINE_ERROR_READ)); | 722 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); |
| 736 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 723 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 737 .WillOnce(RunClosure()); | 724 .WillOnce(RunClosure<0>()); |
| 738 | 725 |
| 739 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, | 726 pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, |
| 740 base::Unretained(&callbacks_))); | 727 base::Unretained(&callbacks_))); |
| 741 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | 728 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); |
| 742 message_loop_.RunAllPending(); | 729 message_loop_.RunAllPending(); |
| 743 } | 730 } |
| 744 | 731 |
| 745 TEST_F(PipelineTest, StartTimeIsZero) { | 732 TEST_F(PipelineTest, StartTimeIsZero) { |
| 746 CreateVideoStream(); | 733 CreateVideoStream(); |
| 747 MockDemuxerStreamVector streams; | 734 MockDemuxerStreamVector streams; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 base::TimeDelta::FromMilliseconds(500)); | 794 base::TimeDelta::FromMilliseconds(500)); |
| 808 | 795 |
| 809 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 796 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
| 810 | 797 |
| 811 // 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 |
| 812 // 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 |
| 813 // not get updated. | 800 // not get updated. |
| 814 base::Closure closure = base::Bind(&RunTimeCB, audio_time_cb_, 300, 700); | 801 base::Closure closure = base::Bind(&RunTimeCB, audio_time_cb_, 300, 700); |
| 815 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 802 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 816 .WillOnce(DoAll(InvokeWithoutArgs(&closure, &base::Closure::Run), | 803 .WillOnce(DoAll(InvokeWithoutArgs(&closure, &base::Closure::Run), |
| 817 RunPipelineStatusCB())); | 804 RunCallback<1>(PIPELINE_OK))); |
| 818 | 805 |
| 819 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 806 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 820 .WillOnce(RunClosure()); | 807 .WillOnce(RunClosure<0>()); |
| 821 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 808 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 822 .WillOnce(RunClosure()); | 809 .WillOnce(RunClosure<0>()); |
| 823 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(seek_time, _)) | 810 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(seek_time, _)) |
| 824 .WillOnce(RunPipelineStatusCB()); | 811 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 825 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(_)); | 812 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(_)); |
| 826 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(_)); | 813 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(_)); |
| 827 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(_)); | 814 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(_)); |
| 828 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 815 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 829 .WillOnce(RunClosure()); | 816 .WillOnce(RunClosure<0>()); |
| 830 | 817 |
| 831 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); | 818 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); |
| 832 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | 819 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
| 833 DoSeek(seek_time); | 820 DoSeek(seek_time); |
| 834 | 821 |
| 835 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time); | 822 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time); |
| 836 | 823 |
| 837 // Now that the seek is complete, verify that time updates advance the current | 824 // Now that the seek is complete, verify that time updates advance the current |
| 838 // time. | 825 // time. |
| 839 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100); | 826 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 949 |
| 963 PipelineStatus SetInitializeExpectations(TeardownState state, | 950 PipelineStatus SetInitializeExpectations(TeardownState state, |
| 964 StopOrError stop_or_error) { | 951 StopOrError stop_or_error) { |
| 965 PipelineStatus status = PIPELINE_OK; | 952 PipelineStatus status = PIPELINE_OK; |
| 966 base::Closure stop_cb = base::Bind( | 953 base::Closure stop_cb = base::Bind( |
| 967 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 954 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
| 968 | 955 |
| 969 if (state == kInitDemuxer) { | 956 if (state == kInitDemuxer) { |
| 970 if (stop_or_error == kStop) { | 957 if (stop_or_error == kStop) { |
| 971 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 958 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 972 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB())); | 959 .WillOnce(DoAll(Stop(pipeline_, stop_cb), |
| 960 RunCallback<1>(PIPELINE_OK))); |
| 973 EXPECT_CALL(callbacks_, OnStop()); | 961 EXPECT_CALL(callbacks_, OnStop()); |
| 974 } else { | 962 } else { |
| 975 status = DEMUXER_ERROR_COULD_NOT_OPEN; | 963 status = DEMUXER_ERROR_COULD_NOT_OPEN; |
| 976 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 964 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 977 .WillOnce(RunPipelineStatusCBWithStatus(status)); | 965 .WillOnce(RunCallback<1>(status)); |
| 978 } | 966 } |
| 979 | 967 |
| 980 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | 968 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 981 return status; | 969 return status; |
| 982 } | 970 } |
| 983 | 971 |
| 984 CreateAudioStream(); | 972 CreateAudioStream(); |
| 985 CreateVideoStream(); | 973 CreateVideoStream(); |
| 986 MockDemuxerStreamVector streams; | 974 MockDemuxerStreamVector streams; |
| 987 streams.push_back(audio_stream()); | 975 streams.push_back(audio_stream()); |
| 988 streams.push_back(video_stream()); | 976 streams.push_back(video_stream()); |
| 989 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); | 977 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); |
| 990 | 978 |
| 991 if (state == kInitAudioRenderer) { | 979 if (state == kInitAudioRenderer) { |
| 992 if (stop_or_error == kStop) { | 980 if (stop_or_error == kStop) { |
| 993 EXPECT_CALL(*mocks_->audio_renderer(), | 981 EXPECT_CALL(*mocks_->audio_renderer(), |
| 994 Initialize(_, _, _, _, _, _, _, _, _)) | 982 Initialize(_, _, _, _, _, _, _, _, _)) |
| 995 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB2())); | 983 .WillOnce(DoAll(Stop(pipeline_, stop_cb), |
| 984 RunCallback<2>(PIPELINE_OK))); |
| 996 EXPECT_CALL(callbacks_, OnStop()); | 985 EXPECT_CALL(callbacks_, OnStop()); |
| 997 } else { | 986 } else { |
| 998 status = PIPELINE_ERROR_INITIALIZATION_FAILED; | 987 status = PIPELINE_ERROR_INITIALIZATION_FAILED; |
| 999 EXPECT_CALL(*mocks_->audio_renderer(), | 988 EXPECT_CALL(*mocks_->audio_renderer(), |
| 1000 Initialize(_, _, _, _, _, _, _, _, _)) | 989 Initialize(_, _, _, _, _, _, _, _, _)) |
| 1001 .WillOnce(RunPipelineStatusCB2WithStatus(status)); | 990 .WillOnce(RunCallback<2>(status)); |
| 1002 } | 991 } |
| 1003 | 992 |
| 1004 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | 993 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1005 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | 994 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1006 return status; | 995 return status; |
| 1007 } | 996 } |
| 1008 | 997 |
| 1009 EXPECT_CALL(*mocks_->audio_renderer(), | 998 EXPECT_CALL(*mocks_->audio_renderer(), |
| 1010 Initialize(_, _, _, _, _, _, _, _, _)) | 999 Initialize(_, _, _, _, _, _, _, _, _)) |
| 1011 .WillOnce(RunPipelineStatusCB2()); | 1000 .WillOnce(RunCallback<2>(PIPELINE_OK)); |
| 1012 | 1001 |
| 1013 if (state == kInitVideoRenderer) { | 1002 if (state == kInitVideoRenderer) { |
| 1014 if (stop_or_error == kStop) { | 1003 if (stop_or_error == kStop) { |
| 1015 EXPECT_CALL(*mocks_->video_renderer(), | 1004 EXPECT_CALL(*mocks_->video_renderer(), |
| 1016 Initialize(_, _, _, _, _, _, _, _, _, _)) | 1005 Initialize(_, _, _, _, _, _, _, _, _, _)) |
| 1017 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB2())); | 1006 .WillOnce(DoAll(Stop(pipeline_, stop_cb), |
| 1007 RunCallback<2>(PIPELINE_OK))); |
| 1018 EXPECT_CALL(callbacks_, OnStop()); | 1008 EXPECT_CALL(callbacks_, OnStop()); |
| 1019 } else { | 1009 } else { |
| 1020 status = PIPELINE_ERROR_INITIALIZATION_FAILED; | 1010 status = PIPELINE_ERROR_INITIALIZATION_FAILED; |
| 1021 EXPECT_CALL(*mocks_->video_renderer(), | 1011 EXPECT_CALL(*mocks_->video_renderer(), |
| 1022 Initialize(_, _, _, _, _, _, _, _, _, _)) | 1012 Initialize(_, _, _, _, _, _, _, _, _, _)) |
| 1023 .WillOnce(RunPipelineStatusCB2WithStatus(status)); | 1013 .WillOnce(RunCallback<2>(status)); |
| 1024 } | 1014 } |
| 1025 | 1015 |
| 1026 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | 1016 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1027 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | 1017 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1028 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure()); | 1018 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1029 return status; | 1019 return status; |
| 1030 } | 1020 } |
| 1031 | 1021 |
| 1032 EXPECT_CALL(*mocks_->video_renderer(), | 1022 EXPECT_CALL(*mocks_->video_renderer(), |
| 1033 Initialize(_, _, _, _, _, _, _, _, _, _)) | 1023 Initialize(_, _, _, _, _, _, _, _, _, _)) |
| 1034 .WillOnce(RunPipelineStatusCB2()); | 1024 .WillOnce(RunCallback<2>(PIPELINE_OK)); |
| 1035 | 1025 |
| 1036 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kHaveMetadata)); | 1026 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kHaveMetadata)); |
| 1037 | 1027 |
| 1038 // If we get here it's a successful initialization. | 1028 // If we get here it's a successful initialization. |
| 1039 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(base::TimeDelta(), _)) | 1029 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(base::TimeDelta(), _)) |
| 1040 .WillOnce(RunPipelineStatusCB()); | 1030 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 1041 EXPECT_CALL(*mocks_->video_renderer(), Preroll(base::TimeDelta(), _)) | 1031 EXPECT_CALL(*mocks_->video_renderer(), Preroll(base::TimeDelta(), _)) |
| 1042 .WillOnce(RunPipelineStatusCB()); | 1032 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 1043 | 1033 |
| 1044 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 1034 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
| 1045 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 1035 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 1046 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 1036 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 1047 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 1037 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 1048 | 1038 |
| 1049 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 1039 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 1050 .WillOnce(RunClosure()); | 1040 .WillOnce(RunClosure<0>()); |
| 1051 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) | 1041 EXPECT_CALL(*mocks_->video_renderer(), Play(_)) |
| 1052 .WillOnce(RunClosure()); | 1042 .WillOnce(RunClosure<0>()); |
| 1053 | 1043 |
| 1054 if (status == PIPELINE_OK) | 1044 if (status == PIPELINE_OK) |
| 1055 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); | 1045 EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kPrerollCompleted)); |
| 1056 | 1046 |
| 1057 return status; | 1047 return status; |
| 1058 } | 1048 } |
| 1059 | 1049 |
| 1060 void DoSeek(TeardownState state, StopOrError stop_or_error) { | 1050 void DoSeek(TeardownState state, StopOrError stop_or_error) { |
| 1061 InSequence s; | 1051 InSequence s; |
| 1062 PipelineStatus status = SetSeekExpectations(state, stop_or_error); | 1052 PipelineStatus status = SetSeekExpectations(state, stop_or_error); |
| 1063 | 1053 |
| 1064 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | 1054 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1065 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | 1055 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1066 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure()); | 1056 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1067 EXPECT_CALL(callbacks_, OnSeek(status)); | 1057 EXPECT_CALL(callbacks_, OnSeek(status)); |
| 1068 | 1058 |
| 1069 if (status == PIPELINE_OK) { | 1059 if (status == PIPELINE_OK) { |
| 1070 EXPECT_CALL(callbacks_, OnStop()); | 1060 EXPECT_CALL(callbacks_, OnStop()); |
| 1071 } | 1061 } |
| 1072 | 1062 |
| 1073 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | 1063 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( |
| 1074 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | 1064 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); |
| 1075 message_loop_.RunAllPending(); | 1065 message_loop_.RunAllPending(); |
| 1076 } | 1066 } |
| 1077 | 1067 |
| 1078 PipelineStatus SetSeekExpectations(TeardownState state, | 1068 PipelineStatus SetSeekExpectations(TeardownState state, |
| 1079 StopOrError stop_or_error) { | 1069 StopOrError stop_or_error) { |
| 1080 PipelineStatus status = PIPELINE_OK; | 1070 PipelineStatus status = PIPELINE_OK; |
| 1081 base::Closure stop_cb = base::Bind( | 1071 base::Closure stop_cb = base::Bind( |
| 1082 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | 1072 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); |
| 1083 | 1073 |
| 1084 if (state == kPausing) { | 1074 if (state == kPausing) { |
| 1085 if (stop_or_error == kStop) { | 1075 if (stop_or_error == kStop) { |
| 1086 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 1076 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 1087 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure())); | 1077 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure<0>())); |
| 1088 } else { | 1078 } else { |
| 1089 status = PIPELINE_ERROR_READ; | 1079 status = PIPELINE_ERROR_READ; |
| 1090 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 1080 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 1091 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure())); | 1081 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure<0>())); |
| 1092 } | 1082 } |
| 1093 | 1083 |
| 1094 return status; | 1084 return status; |
| 1095 } | 1085 } |
| 1096 | 1086 |
| 1097 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | 1087 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure<0>()); |
| 1098 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)).WillOnce(RunClosure()); | 1088 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)).WillOnce(RunClosure<0>()); |
| 1099 | 1089 |
| 1100 if (state == kFlushing) { | 1090 if (state == kFlushing) { |
| 1101 if (stop_or_error == kStop) { | 1091 if (stop_or_error == kStop) { |
| 1102 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 1092 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 1103 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure())); | 1093 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure<0>())); |
| 1104 } else { | 1094 } else { |
| 1105 status = PIPELINE_ERROR_READ; | 1095 status = PIPELINE_ERROR_READ; |
| 1106 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 1096 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 1107 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure())); | 1097 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure<0>())); |
| 1108 } | 1098 } |
| 1109 | 1099 |
| 1110 return status; | 1100 return status; |
| 1111 } | 1101 } |
| 1112 | 1102 |
| 1113 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | 1103 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure<0>()); |
| 1114 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)).WillOnce(RunClosure()); | 1104 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)).WillOnce(RunClosure<0>()); |
| 1115 | 1105 |
| 1116 if (state == kSeeking) { | 1106 if (state == kSeeking) { |
| 1117 if (stop_or_error == kStop) { | 1107 if (stop_or_error == kStop) { |
| 1118 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | 1108 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) |
| 1119 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB())); | 1109 .WillOnce(DoAll(Stop(pipeline_, stop_cb), |
| 1110 RunCallback<1>(PIPELINE_OK))); |
| 1120 } else { | 1111 } else { |
| 1121 status = PIPELINE_ERROR_READ; | 1112 status = PIPELINE_ERROR_READ; |
| 1122 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | 1113 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) |
| 1123 .WillOnce(RunPipelineStatusCBWithStatus(status)); | 1114 .WillOnce(RunCallback<1>(status)); |
| 1124 } | 1115 } |
| 1125 | 1116 |
| 1126 return status; | 1117 return status; |
| 1127 } | 1118 } |
| 1128 | 1119 |
| 1129 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | 1120 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) |
| 1130 .WillOnce(RunPipelineStatusCB()); | 1121 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 1131 | 1122 |
| 1132 if (state == kPrerolling) { | 1123 if (state == kPrerolling) { |
| 1133 if (stop_or_error == kStop) { | 1124 if (stop_or_error == kStop) { |
| 1134 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | 1125 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) |
| 1135 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB())); | 1126 .WillOnce(DoAll(Stop(pipeline_, stop_cb), |
| 1127 RunCallback<1>(PIPELINE_OK))); |
| 1136 } else { | 1128 } else { |
| 1137 status = PIPELINE_ERROR_READ; | 1129 status = PIPELINE_ERROR_READ; |
| 1138 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | 1130 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) |
| 1139 .WillOnce(RunPipelineStatusCBWithStatus(status)); | 1131 .WillOnce(RunCallback<1>(status)); |
| 1140 } | 1132 } |
| 1141 | 1133 |
| 1142 return status; | 1134 return status; |
| 1143 } | 1135 } |
| 1144 | 1136 |
| 1145 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | 1137 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) |
| 1146 .WillOnce(RunPipelineStatusCB()); | 1138 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 1147 EXPECT_CALL(*mocks_->video_renderer(), Preroll(_, _)) | 1139 EXPECT_CALL(*mocks_->video_renderer(), Preroll(_, _)) |
| 1148 .WillOnce(RunPipelineStatusCB()); | 1140 .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| 1149 | 1141 |
| 1150 // Playback rate and volume are updated prior to starting. | 1142 // Playback rate and volume are updated prior to starting. |
| 1151 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 1143 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
| 1152 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 1144 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 1153 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 1145 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 1154 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 1146 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 1155 | 1147 |
| 1156 if (state == kStarting) { | 1148 if (state == kStarting) { |
| 1157 if (stop_or_error == kStop) { | 1149 if (stop_or_error == kStop) { |
| 1158 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 1150 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 1159 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure())); | 1151 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure<0>())); |
| 1160 } else { | 1152 } else { |
| 1161 status = PIPELINE_ERROR_READ; | 1153 status = PIPELINE_ERROR_READ; |
| 1162 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) | 1154 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)) |
| 1163 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure())); | 1155 .WillOnce(DoAll(SetError(pipeline_, status), RunClosure<0>())); |
| 1164 } | 1156 } |
| 1165 return status; | 1157 return status; |
| 1166 } | 1158 } |
| 1167 | 1159 |
| 1168 NOTREACHED() << "State not supported: " << state; | 1160 NOTREACHED() << "State not supported: " << state; |
| 1169 return status; | 1161 return status; |
| 1170 } | 1162 } |
| 1171 | 1163 |
| 1172 void DoStopOrError(StopOrError stop_or_error) { | 1164 void DoStopOrError(StopOrError stop_or_error) { |
| 1173 InSequence s; | 1165 InSequence s; |
| 1174 | 1166 |
| 1175 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | 1167 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1176 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | 1168 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1177 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure()); | 1169 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)).WillOnce(RunClosure<0>()); |
| 1178 | 1170 |
| 1179 if (stop_or_error == kStop) { | 1171 if (stop_or_error == kStop) { |
| 1180 EXPECT_CALL(callbacks_, OnStop()); | 1172 EXPECT_CALL(callbacks_, OnStop()); |
| 1181 pipeline_->Stop(base::Bind( | 1173 pipeline_->Stop(base::Bind( |
| 1182 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | 1174 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); |
| 1183 } else { | 1175 } else { |
| 1184 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | 1176 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); |
| 1185 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); | 1177 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); |
| 1186 } | 1178 } |
| 1187 | 1179 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1210 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); | 1202 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); |
| 1211 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); | 1203 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); |
| 1212 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); | 1204 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); |
| 1213 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1205 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
| 1214 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1206 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1215 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); | 1207 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); |
| 1216 INSTANTIATE_TEARDOWN_TEST(Error, Starting); | 1208 INSTANTIATE_TEARDOWN_TEST(Error, Starting); |
| 1217 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1209 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1218 | 1210 |
| 1219 } // namespace media | 1211 } // namespace media |
| OLD | NEW |