| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/threading/simple_thread.h" | 9 #include "base/threading/simple_thread.h" |
| 10 #include "media/base/pipeline_impl.h" | 10 #include "media/base/pipeline_impl.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool run_build = true; | 208 bool run_build = true; |
| 209 if (url.compare(kUrlMedia) == 0) | 209 if (url.compare(kUrlMedia) == 0) |
| 210 run_build = false; | 210 run_build = false; |
| 211 | 211 |
| 212 pipeline_->Start(mocks_->filter_collection(true, | 212 pipeline_->Start(mocks_->filter_collection(true, |
| 213 true, | 213 true, |
| 214 run_build, | 214 run_build, |
| 215 build_status), | 215 build_status), |
| 216 url, | 216 url, |
| 217 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 217 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 218 &CallbackHelper::OnStart)); | 218 &CallbackHelper::OnStart), |
| 219 !run_build); |
| 219 | 220 |
| 220 message_loop_.RunAllPending(); | 221 message_loop_.RunAllPending(); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void CreateAudioStream() { | 224 void CreateAudioStream() { |
| 224 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 225 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void CreateVideoStream() { | 228 void CreateVideoStream() { |
| 228 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 229 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 TEST_F(PipelineImplTest, NeverInitializes) { | 333 TEST_F(PipelineImplTest, NeverInitializes) { |
| 333 // This test hangs during initialization by never calling | 334 // This test hangs during initialization by never calling |
| 334 // InitializationComplete(). StrictMock<> will ensure that the callback is | 335 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 335 // never executed. | 336 // never executed. |
| 336 pipeline_->Start(mocks_->filter_collection(false, | 337 pipeline_->Start(mocks_->filter_collection(false, |
| 337 false, | 338 false, |
| 338 true, | 339 true, |
| 339 PIPELINE_OK), | 340 PIPELINE_OK), |
| 340 "", | 341 "", |
| 341 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 342 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 342 &CallbackHelper::OnStart)); | 343 &CallbackHelper::OnStart), |
| 344 false); |
| 343 message_loop_.RunAllPending(); | 345 message_loop_.RunAllPending(); |
| 344 | 346 |
| 345 EXPECT_FALSE(pipeline_->IsInitialized()); | 347 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 346 | 348 |
| 347 // Because our callback will get executed when the test tears down, we'll | 349 // Because our callback will get executed when the test tears down, we'll |
| 348 // verify that nothing has been called, then set our expectation for the call | 350 // verify that nothing has been called, then set our expectation for the call |
| 349 // made during tear down. | 351 // made during tear down. |
| 350 Mock::VerifyAndClear(&callbacks_); | 352 Mock::VerifyAndClear(&callbacks_); |
| 351 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 353 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
| 352 } | 354 } |
| 353 | 355 |
| 354 TEST_F(PipelineImplTest, RequiredFilterMissing) { | 356 TEST_F(PipelineImplTest, RequiredFilterMissing) { |
| 355 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | 357 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
| 356 | 358 |
| 357 // Sets up expectations on the callback and initializes the pipeline. Called | 359 // Sets up expectations on the callback and initializes the pipeline. Called |
| 358 // after tests have set expectations any filters they wish to use. | 360 // after tests have set expectations any filters they wish to use. |
| 359 // Expect an initialization callback. | 361 // Expect an initialization callback. |
| 360 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | 362 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
| 361 | 363 |
| 362 // Create a filter collection with missing filter. | 364 // Create a filter collection with missing filter. |
| 363 FilterCollection* collection = | 365 FilterCollection* collection = |
| 364 mocks_->filter_collection(false, | 366 mocks_->filter_collection(false, |
| 365 true, | 367 true, |
| 366 true, | 368 true, |
| 367 PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 369 PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
| 368 pipeline_->Start(collection, "", | 370 pipeline_->Start(collection, "", |
| 369 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 371 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 370 &CallbackHelper::OnStart)); | 372 &CallbackHelper::OnStart), |
| 373 false); |
| 371 message_loop_.RunAllPending(); | 374 message_loop_.RunAllPending(); |
| 372 | 375 |
| 373 EXPECT_FALSE(pipeline_->IsInitialized()); | 376 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 374 } | 377 } |
| 375 | 378 |
| 376 TEST_F(PipelineImplTest, URLNotFound) { | 379 TEST_F(PipelineImplTest, URLNotFound) { |
| 377 // TODO(acolwell,fischman): Since OnStart() is getting called with an error | 380 // TODO(acolwell,fischman): Since OnStart() is getting called with an error |
| 378 // code already, OnError() doesn't also need to get called. Fix the pipeline | 381 // code already, OnError() doesn't also need to get called. Fix the pipeline |
| 379 // (and it's consumers!) so that OnError doesn't need to be called after | 382 // (and it's consumers!) so that OnError doesn't need to be called after |
| 380 // another callback has already reported the error. Same applies to NoStreams | 383 // another callback has already reported the error. Same applies to NoStreams |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 TestPipelineStatusNotification(0); | 895 TestPipelineStatusNotification(0); |
| 893 } | 896 } |
| 894 | 897 |
| 895 // Test that different-thread, some-delay callback (the expected common case) | 898 // Test that different-thread, some-delay callback (the expected common case) |
| 896 // works correctly. | 899 // works correctly. |
| 897 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 900 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 898 TestPipelineStatusNotification(20); | 901 TestPipelineStatusNotification(20); |
| 899 } | 902 } |
| 900 | 903 |
| 901 } // namespace media | 904 } // namespace media |
| OLD | NEW |