| 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 "media/test/pipeline_integration_test_base.h" | 5 #include "media/test/pipeline_integration_test_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 PipelineStatus PipelineIntegrationTestBase::StartInternal( | 117 PipelineStatus PipelineIntegrationTestBase::StartInternal( |
| 118 std::unique_ptr<DataSource> data_source, | 118 std::unique_ptr<DataSource> data_source, |
| 119 CdmContext* cdm_context, | 119 CdmContext* cdm_context, |
| 120 uint8_t test_type) { | 120 uint8_t test_type) { |
| 121 hashing_enabled_ = test_type & kHashed; | 121 hashing_enabled_ = test_type & kHashed; |
| 122 clockless_playback_ = test_type & kClockless; | 122 clockless_playback_ = test_type & kClockless; |
| 123 | 123 |
| 124 EXPECT_CALL(*this, OnMetadata(_)) | 124 EXPECT_CALL(*this, OnMetadata(_)) |
| 125 .Times(AtMost(1)) | 125 .Times(AtMost(1)) |
| 126 .WillRepeatedly(SaveArg<0>(&metadata_)); | 126 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 127 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 127 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 128 .Times(AnyNumber()); | 128 .Times(AnyNumber()); |
| 129 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 129 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 130 .Times(AnyNumber()); | 130 .Times(AnyNumber()); |
| 131 CreateDemuxer(std::move(data_source)); | 131 CreateDemuxer(std::move(data_source)); |
| 132 | 132 |
| 133 if (cdm_context) { | 133 if (cdm_context) { |
| 134 EXPECT_CALL(*this, DecryptorAttached(true)); | 134 EXPECT_CALL(*this, DecryptorAttached(true)); |
| 135 pipeline_->SetCdm( | 135 pipeline_->SetCdm( |
| 136 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, | 136 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, |
| 137 base::Unretained(this))); | 137 base::Unretained(this))); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Should never be called as the required decryption keys for the encrypted | 140 // Should never be called as the required decryption keys for the encrypted |
| 141 // media files are provided in advance. | 141 // media files are provided in advance. |
| 142 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 142 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 143 | 143 |
| 144 pipeline_->Start( | 144 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, |
| 145 demuxer_.get(), CreateRenderer(), | 145 base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, |
| 146 base::Bind(&PipelineIntegrationTestBase::OnEnded, base::Unretained(this)), | 146 base::Unretained(this))); |
| 147 base::Bind(&PipelineIntegrationTestBase::OnError, base::Unretained(this)), | |
| 148 base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, | |
| 149 base::Unretained(this)), | |
| 150 base::Bind(&PipelineIntegrationTestBase::OnMetadata, | |
| 151 base::Unretained(this)), | |
| 152 base::Bind(&PipelineIntegrationTestBase::OnBufferingStateChanged, | |
| 153 base::Unretained(this)), | |
| 154 base::Closure(), base::Bind(&PipelineIntegrationTestBase::OnAddTextTrack, | |
| 155 base::Unretained(this)), | |
| 156 base::Bind(&PipelineIntegrationTestBase::OnWaitingForDecryptionKey, | |
| 157 base::Unretained(this))); | |
| 158 message_loop_.Run(); | 147 message_loop_.Run(); |
| 159 return pipeline_status_; | 148 return pipeline_status_; |
| 160 } | 149 } |
| 161 | 150 |
| 162 PipelineStatus PipelineIntegrationTestBase::StartWithFile( | 151 PipelineStatus PipelineIntegrationTestBase::StartWithFile( |
| 163 const std::string& filename, | 152 const std::string& filename, |
| 164 CdmContext* cdm_context, | 153 CdmContext* cdm_context, |
| 165 uint8_t test_type) { | 154 uint8_t test_type) { |
| 166 std::unique_ptr<FileDataSource> file_data_source(new FileDataSource()); | 155 std::unique_ptr<FileDataSource> file_data_source(new FileDataSource()); |
| 167 base::FilePath file_path(GetTestDataFilePath(filename)); | 156 base::FilePath file_path(GetTestDataFilePath(filename)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 195 pipeline_->SetPlaybackRate(1); | 184 pipeline_->SetPlaybackRate(1); |
| 196 } | 185 } |
| 197 | 186 |
| 198 void PipelineIntegrationTestBase::Pause() { | 187 void PipelineIntegrationTestBase::Pause() { |
| 199 pipeline_->SetPlaybackRate(0); | 188 pipeline_->SetPlaybackRate(0); |
| 200 } | 189 } |
| 201 | 190 |
| 202 bool PipelineIntegrationTestBase::Seek(base::TimeDelta seek_time) { | 191 bool PipelineIntegrationTestBase::Seek(base::TimeDelta seek_time) { |
| 203 ended_ = false; | 192 ended_ = false; |
| 204 | 193 |
| 205 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 194 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 206 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); | 195 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); |
| 207 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked, | 196 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked, |
| 208 base::Unretained(this), seek_time)); | 197 base::Unretained(this), seek_time)); |
| 209 message_loop_.Run(); | 198 message_loop_.Run(); |
| 210 return (pipeline_status_ == PIPELINE_OK); | 199 return (pipeline_status_ == PIPELINE_OK); |
| 211 } | 200 } |
| 212 | 201 |
| 213 bool PipelineIntegrationTestBase::Suspend() { | 202 bool PipelineIntegrationTestBase::Suspend() { |
| 214 pipeline_->Suspend(base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, | 203 pipeline_->Suspend(base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, |
| 215 base::Unretained(this))); | 204 base::Unretained(this))); |
| 216 message_loop_.Run(); | 205 message_loop_.Run(); |
| 217 return (pipeline_status_ == PIPELINE_OK); | 206 return (pipeline_status_ == PIPELINE_OK); |
| 218 } | 207 } |
| 219 | 208 |
| 220 bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) { | 209 bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) { |
| 221 ended_ = false; | 210 ended_ = false; |
| 222 | 211 |
| 223 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 212 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 224 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); | 213 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); |
| 225 pipeline_->Resume(CreateRenderer(), seek_time, | 214 pipeline_->Resume(CreateRenderer(), seek_time, |
| 226 base::Bind(&PipelineIntegrationTestBase::OnSeeked, | 215 base::Bind(&PipelineIntegrationTestBase::OnSeeked, |
| 227 base::Unretained(this), seek_time)); | 216 base::Unretained(this), seek_time)); |
| 228 message_loop_.Run(); | 217 message_loop_.Run(); |
| 229 return (pipeline_status_ == PIPELINE_OK); | 218 return (pipeline_status_ == PIPELINE_OK); |
| 230 } | 219 } |
| 231 | 220 |
| 232 void PipelineIntegrationTestBase::Stop() { | 221 void PipelineIntegrationTestBase::Stop() { |
| 233 DCHECK(pipeline_->IsRunning()); | 222 DCHECK(pipeline_->IsRunning()); |
| 234 pipeline_->Stop(base::MessageLoop::QuitWhenIdleClosure()); | 223 pipeline_->Stop(); |
| 235 message_loop_.Run(); | 224 message_loop_.RunUntilIdle(); |
| 236 } | 225 } |
| 237 | 226 |
| 238 void PipelineIntegrationTestBase::FailTest(PipelineStatus status) { | 227 void PipelineIntegrationTestBase::FailTest(PipelineStatus status) { |
| 239 DCHECK_NE(PIPELINE_OK, status); | 228 DCHECK_NE(PIPELINE_OK, status); |
| 240 OnError(status); | 229 OnError(status); |
| 241 } | 230 } |
| 242 | 231 |
| 243 void PipelineIntegrationTestBase::QuitAfterCurrentTimeTask( | 232 void PipelineIntegrationTestBase::QuitAfterCurrentTimeTask( |
| 244 const base::TimeDelta& quit_time) { | 233 const base::TimeDelta& quit_time) { |
| 245 if (pipeline_->GetMediaTime() >= quit_time || | 234 if (pipeline_->GetMediaTime() >= quit_time || |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 DCHECK(clockless_playback_); | 378 DCHECK(clockless_playback_); |
| 390 return clockless_audio_sink_->render_time(); | 379 return clockless_audio_sink_->render_time(); |
| 391 } | 380 } |
| 392 | 381 |
| 393 base::TimeTicks DummyTickClock::NowTicks() { | 382 base::TimeTicks DummyTickClock::NowTicks() { |
| 394 now_ += base::TimeDelta::FromSeconds(60); | 383 now_ += base::TimeDelta::FromSeconds(60); |
| 395 return now_; | 384 return now_; |
| 396 } | 385 } |
| 397 | 386 |
| 398 } // namespace media | 387 } // namespace media |
| OLD | NEW |