Chromium Code Reviews| 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" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // streams. | 82 // streams. |
| 83 DemuxerStream* null_pointer = NULL; | 83 DemuxerStream* null_pointer = NULL; |
| 84 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) | 84 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) |
| 85 .WillRepeatedly(Return(null_pointer)); | 85 .WillRepeatedly(Return(null_pointer)); |
| 86 | 86 |
| 87 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) | 87 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) |
| 88 .WillRepeatedly(Return(base::TimeDelta())); | 88 .WillRepeatedly(Return(base::TimeDelta())); |
| 89 } | 89 } |
| 90 | 90 |
| 91 virtual ~PipelineTest() { | 91 virtual ~PipelineTest() { |
| 92 if (!pipeline_->IsRunning()) { | |
| 93 return; | |
| 94 } | |
| 95 | |
| 96 // Shutdown sequence. | 92 // Shutdown sequence. |
| 97 if (pipeline_->IsInitialized()) { | 93 if (pipeline_->IsRunning()) { |
| 98 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 94 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 99 .WillOnce(RunClosure()); | 95 .WillOnce(RunClosure()); |
| 100 | 96 |
| 101 if (audio_stream_) { | 97 if (audio_stream_) { |
| 102 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 98 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 103 .WillOnce(RunClosure()); | 99 .WillOnce(RunClosure()); |
| 104 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 100 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 105 .WillOnce(RunClosure()); | 101 .WillOnce(RunClosure()); |
| 106 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 102 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 107 .WillOnce(RunClosure()); | 103 .WillOnce(RunClosure()); |
| 108 } | 104 } |
| 109 | 105 |
| 110 if (video_stream_) { | 106 if (video_stream_) { |
| 111 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)) | 107 EXPECT_CALL(*mocks_->video_renderer(), Pause(_)) |
| 112 .WillOnce(RunClosure()); | 108 .WillOnce(RunClosure()); |
| 113 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)) | 109 EXPECT_CALL(*mocks_->video_renderer(), Flush(_)) |
| 114 .WillOnce(RunClosure()); | 110 .WillOnce(RunClosure()); |
| 115 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 111 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 116 .WillOnce(RunClosure()); | 112 .WillOnce(RunClosure()); |
| 117 } | 113 } |
| 118 } | 114 } |
| 119 | 115 |
| 120 // Expect a stop callback if we were started. | 116 // Stop() callbacks are always executed regardless of run state. |
| 121 EXPECT_CALL(callbacks_, OnStop()); | 117 EXPECT_CALL(callbacks_, OnStop()); |
| 122 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 118 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
| 123 base::Unretained(&callbacks_))); | 119 base::Unretained(&callbacks_))); |
| 124 message_loop_.RunAllPending(); | 120 message_loop_.RunAllPending(); |
| 125 | 121 |
| 126 pipeline_ = NULL; | 122 pipeline_ = NULL; |
| 127 mocks_.reset(); | 123 mocks_.reset(); |
| 128 } | 124 } |
| 129 | 125 |
| 130 protected: | 126 protected: |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 private: | 291 private: |
| 296 DISALLOW_COPY_AND_ASSIGN(PipelineTest); | 292 DISALLOW_COPY_AND_ASSIGN(PipelineTest); |
| 297 }; | 293 }; |
| 298 | 294 |
| 299 // Test that playback controls methods no-op when the pipeline hasn't been | 295 // Test that playback controls methods no-op when the pipeline hasn't been |
| 300 // started. | 296 // started. |
| 301 TEST_F(PipelineTest, NotStarted) { | 297 TEST_F(PipelineTest, NotStarted) { |
| 302 const base::TimeDelta kZero; | 298 const base::TimeDelta kZero; |
| 303 | 299 |
| 304 EXPECT_FALSE(pipeline_->IsRunning()); | 300 EXPECT_FALSE(pipeline_->IsRunning()); |
| 305 EXPECT_FALSE(pipeline_->IsInitialized()); | |
| 306 EXPECT_FALSE(pipeline_->HasAudio()); | 301 EXPECT_FALSE(pipeline_->HasAudio()); |
| 307 EXPECT_FALSE(pipeline_->HasVideo()); | 302 EXPECT_FALSE(pipeline_->HasVideo()); |
| 308 | 303 |
| 309 // Setting should still work. | 304 // Setting should still work. |
| 310 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); | 305 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); |
| 311 pipeline_->SetPlaybackRate(-1.0f); | 306 pipeline_->SetPlaybackRate(-1.0f); |
| 312 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); | 307 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); |
| 313 pipeline_->SetPlaybackRate(1.0f); | 308 pipeline_->SetPlaybackRate(1.0f); |
| 314 EXPECT_EQ(1.0f, pipeline_->GetPlaybackRate()); | 309 EXPECT_EQ(1.0f, pipeline_->GetPlaybackRate()); |
| 315 | 310 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 329 // Should always get set to zero. | 324 // Should always get set to zero. |
| 330 gfx::Size size(1, 1); | 325 gfx::Size size(1, 1); |
| 331 pipeline_->GetNaturalVideoSize(&size); | 326 pipeline_->GetNaturalVideoSize(&size); |
| 332 EXPECT_EQ(0, size.width()); | 327 EXPECT_EQ(0, size.width()); |
| 333 EXPECT_EQ(0, size.height()); | 328 EXPECT_EQ(0, size.height()); |
| 334 } | 329 } |
| 335 | 330 |
| 336 TEST_F(PipelineTest, NeverInitializes) { | 331 TEST_F(PipelineTest, NeverInitializes) { |
| 337 // Don't execute the callback passed into Initialize(). | 332 // Don't execute the callback passed into Initialize(). |
| 338 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)); | 333 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)); |
| 339 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
|
scherkus (not reviewing)
2012/08/08 02:20:56
now covered by ~PipelineTest() IsRunning() path (a
| |
| 340 .WillOnce(RunClosure()); | |
| 341 | 334 |
| 342 // This test hangs during initialization by never calling | 335 // This test hangs during initialization by never calling |
| 343 // InitializationComplete(). StrictMock<> will ensure that the callback is | 336 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 344 // never executed. | 337 // never executed. |
| 345 pipeline_->Start( | 338 pipeline_->Start( |
| 346 mocks_->Create().Pass(), | 339 mocks_->Create().Pass(), |
| 347 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 340 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 348 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 341 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 349 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 342 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 350 message_loop_.RunAllPending(); | 343 message_loop_.RunAllPending(); |
| 351 | 344 |
| 352 EXPECT_FALSE(pipeline_->IsInitialized()); | |
| 353 | |
| 354 // Because our callback will get executed when the test tears down, we'll | 345 // Because our callback will get executed when the test tears down, we'll |
| 355 // verify that nothing has been called, then set our expectation for the call | 346 // verify that nothing has been called, then set our expectation for the call |
| 356 // made during tear down. | 347 // made during tear down. |
| 357 Mock::VerifyAndClear(&callbacks_); | 348 Mock::VerifyAndClear(&callbacks_); |
| 358 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 349 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
| 359 } | 350 } |
| 360 | 351 |
| 361 TEST_F(PipelineTest, RequiredFilterMissing) { | 352 TEST_F(PipelineTest, RequiredFilterMissing) { |
| 362 // Create a filter collection with missing filter. | 353 // Create a filter collection with missing filter. |
| 363 scoped_ptr<FilterCollection> collection(mocks_->Create()); | 354 scoped_ptr<FilterCollection> collection(mocks_->Create()); |
| 364 collection->SetDemuxer(NULL); | 355 collection->SetDemuxer(NULL); |
| 365 | 356 |
| 366 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | 357 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
| 367 pipeline_->Start( | 358 pipeline_->Start( |
| 368 collection.Pass(), | 359 collection.Pass(), |
| 369 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 360 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 370 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 361 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 371 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 362 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 372 message_loop_.RunAllPending(); | 363 message_loop_.RunAllPending(); |
| 373 EXPECT_FALSE(pipeline_->IsInitialized()); | |
| 374 } | 364 } |
| 375 | 365 |
| 376 TEST_F(PipelineTest, URLNotFound) { | 366 TEST_F(PipelineTest, URLNotFound) { |
| 377 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 367 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 378 .WillOnce(RunPipelineStatusCB1WithStatus(PIPELINE_ERROR_URL_NOT_FOUND)); | 368 .WillOnce(RunPipelineStatusCB1WithStatus(PIPELINE_ERROR_URL_NOT_FOUND)); |
| 379 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 369 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 380 .WillOnce(RunClosure()); | 370 .WillOnce(RunClosure()); |
| 381 | 371 |
| 382 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); | 372 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); |
| 383 EXPECT_FALSE(pipeline_->IsInitialized()); | |
| 384 } | 373 } |
| 385 | 374 |
| 386 TEST_F(PipelineTest, NoStreams) { | 375 TEST_F(PipelineTest, NoStreams) { |
| 387 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | 376 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
| 388 .WillOnce(RunPipelineStatusCB1()); | 377 .WillOnce(RunPipelineStatusCB1()); |
| 389 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 378 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 390 .WillOnce(RunClosure()); | 379 .WillOnce(RunClosure()); |
| 391 | 380 |
| 392 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); | 381 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); |
| 393 EXPECT_FALSE(pipeline_->IsInitialized()); | |
| 394 } | 382 } |
| 395 | 383 |
| 396 TEST_F(PipelineTest, AudioStream) { | 384 TEST_F(PipelineTest, AudioStream) { |
| 397 CreateAudioStream(); | 385 CreateAudioStream(); |
| 398 MockDemuxerStreamVector streams; | 386 MockDemuxerStreamVector streams; |
| 399 streams.push_back(audio_stream()); | 387 streams.push_back(audio_stream()); |
| 400 | 388 |
| 401 InitializeDemuxer(&streams); | 389 InitializeDemuxer(&streams); |
| 402 InitializeAudioDecoder(audio_stream()); | 390 InitializeAudioDecoder(audio_stream()); |
| 403 InitializeAudioRenderer(); | 391 InitializeAudioRenderer(); |
| 404 | 392 |
| 405 InitializePipeline(PIPELINE_OK); | 393 InitializePipeline(PIPELINE_OK); |
| 406 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 407 EXPECT_TRUE(pipeline_->HasAudio()); | 394 EXPECT_TRUE(pipeline_->HasAudio()); |
| 408 EXPECT_FALSE(pipeline_->HasVideo()); | 395 EXPECT_FALSE(pipeline_->HasVideo()); |
| 409 } | 396 } |
| 410 | 397 |
| 411 TEST_F(PipelineTest, VideoStream) { | 398 TEST_F(PipelineTest, VideoStream) { |
| 412 CreateVideoStream(); | 399 CreateVideoStream(); |
| 413 MockDemuxerStreamVector streams; | 400 MockDemuxerStreamVector streams; |
| 414 streams.push_back(video_stream()); | 401 streams.push_back(video_stream()); |
| 415 | 402 |
| 416 InitializeDemuxer(&streams); | 403 InitializeDemuxer(&streams); |
| 417 InitializeVideoDecoder(video_stream()); | 404 InitializeVideoDecoder(video_stream()); |
| 418 InitializeVideoRenderer(); | 405 InitializeVideoRenderer(); |
| 419 | 406 |
| 420 InitializePipeline(PIPELINE_OK); | 407 InitializePipeline(PIPELINE_OK); |
| 421 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 422 EXPECT_FALSE(pipeline_->HasAudio()); | 408 EXPECT_FALSE(pipeline_->HasAudio()); |
| 423 EXPECT_TRUE(pipeline_->HasVideo()); | 409 EXPECT_TRUE(pipeline_->HasVideo()); |
| 424 } | 410 } |
| 425 | 411 |
| 426 TEST_F(PipelineTest, AudioVideoStream) { | 412 TEST_F(PipelineTest, AudioVideoStream) { |
| 427 CreateAudioStream(); | 413 CreateAudioStream(); |
| 428 CreateVideoStream(); | 414 CreateVideoStream(); |
| 429 MockDemuxerStreamVector streams; | 415 MockDemuxerStreamVector streams; |
| 430 streams.push_back(audio_stream()); | 416 streams.push_back(audio_stream()); |
| 431 streams.push_back(video_stream()); | 417 streams.push_back(video_stream()); |
| 432 | 418 |
| 433 InitializeDemuxer(&streams); | 419 InitializeDemuxer(&streams); |
| 434 InitializeAudioDecoder(audio_stream()); | 420 InitializeAudioDecoder(audio_stream()); |
| 435 InitializeAudioRenderer(); | 421 InitializeAudioRenderer(); |
| 436 InitializeVideoDecoder(video_stream()); | 422 InitializeVideoDecoder(video_stream()); |
| 437 InitializeVideoRenderer(); | 423 InitializeVideoRenderer(); |
| 438 | 424 |
| 439 InitializePipeline(PIPELINE_OK); | 425 InitializePipeline(PIPELINE_OK); |
| 440 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 441 EXPECT_TRUE(pipeline_->HasAudio()); | 426 EXPECT_TRUE(pipeline_->HasAudio()); |
| 442 EXPECT_TRUE(pipeline_->HasVideo()); | 427 EXPECT_TRUE(pipeline_->HasVideo()); |
| 443 } | 428 } |
| 444 | 429 |
| 445 TEST_F(PipelineTest, Seek) { | 430 TEST_F(PipelineTest, Seek) { |
| 446 CreateAudioStream(); | 431 CreateAudioStream(); |
| 447 CreateVideoStream(); | 432 CreateVideoStream(); |
| 448 MockDemuxerStreamVector streams; | 433 MockDemuxerStreamVector streams; |
| 449 streams.push_back(audio_stream()); | 434 streams.push_back(audio_stream()); |
| 450 streams.push_back(video_stream()); | 435 streams.push_back(video_stream()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 CreateVideoStream(); | 471 CreateVideoStream(); |
| 487 MockDemuxerStreamVector streams; | 472 MockDemuxerStreamVector streams; |
| 488 streams.push_back(video_stream()); | 473 streams.push_back(video_stream()); |
| 489 | 474 |
| 490 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 475 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 491 InitializeDemuxer(&streams, kDuration); | 476 InitializeDemuxer(&streams, kDuration); |
| 492 InitializeVideoDecoder(video_stream()); | 477 InitializeVideoDecoder(video_stream()); |
| 493 InitializeVideoRenderer(); | 478 InitializeVideoRenderer(); |
| 494 | 479 |
| 495 InitializePipeline(PIPELINE_OK); | 480 InitializePipeline(PIPELINE_OK); |
| 496 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 497 EXPECT_EQ(kDuration.ToInternalValue(), | 481 EXPECT_EQ(kDuration.ToInternalValue(), |
| 498 pipeline_->GetMediaDuration().ToInternalValue()); | 482 pipeline_->GetMediaDuration().ToInternalValue()); |
| 499 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); | 483 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); |
| 500 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 484 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 501 } | 485 } |
| 502 | 486 |
| 503 TEST_F(PipelineTest, GetBufferedTimeRanges) { | 487 TEST_F(PipelineTest, GetBufferedTimeRanges) { |
| 504 CreateVideoStream(); | 488 CreateVideoStream(); |
| 505 MockDemuxerStreamVector streams; | 489 MockDemuxerStreamVector streams; |
| 506 streams.push_back(video_stream()); | 490 streams.push_back(video_stream()); |
| 507 | 491 |
| 508 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 492 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 509 InitializeDemuxer(&streams, kDuration); | 493 InitializeDemuxer(&streams, kDuration); |
| 510 InitializeVideoDecoder(video_stream()); | 494 InitializeVideoDecoder(video_stream()); |
| 511 InitializeVideoRenderer(); | 495 InitializeVideoRenderer(); |
| 512 | 496 |
| 513 InitializePipeline(PIPELINE_OK); | 497 InitializePipeline(PIPELINE_OK); |
| 514 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 515 | 498 |
| 516 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); | 499 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); |
| 517 | 500 |
| 518 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 501 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 519 pipeline_->AddBufferedByteRange(0, kTotalBytes / 8); | 502 pipeline_->AddBufferedByteRange(0, kTotalBytes / 8); |
| 520 EXPECT_TRUE(pipeline_->DidLoadingProgress()); | 503 EXPECT_TRUE(pipeline_->DidLoadingProgress()); |
| 521 EXPECT_FALSE(pipeline_->DidLoadingProgress()); | 504 EXPECT_FALSE(pipeline_->DidLoadingProgress()); |
| 522 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 505 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 523 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); | 506 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); |
| 524 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); | 507 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 streams.push_back(audio_stream()); | 543 streams.push_back(audio_stream()); |
| 561 streams.push_back(video_stream()); | 544 streams.push_back(video_stream()); |
| 562 | 545 |
| 563 InitializeDemuxer(&streams); | 546 InitializeDemuxer(&streams); |
| 564 InitializeAudioDecoder(audio_stream()); | 547 InitializeAudioDecoder(audio_stream()); |
| 565 InitializeAudioRenderer(); | 548 InitializeAudioRenderer(); |
| 566 InitializeVideoDecoder(video_stream()); | 549 InitializeVideoDecoder(video_stream()); |
| 567 InitializeVideoRenderer(); | 550 InitializeVideoRenderer(); |
| 568 | 551 |
| 569 InitializePipeline(PIPELINE_OK); | 552 InitializePipeline(PIPELINE_OK); |
| 570 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 571 EXPECT_TRUE(pipeline_->HasAudio()); | 553 EXPECT_TRUE(pipeline_->HasAudio()); |
| 572 EXPECT_TRUE(pipeline_->HasVideo()); | 554 EXPECT_TRUE(pipeline_->HasVideo()); |
| 573 | 555 |
| 574 EXPECT_CALL(*mocks_->demuxer(), OnAudioRendererDisabled()); | 556 EXPECT_CALL(*mocks_->demuxer(), OnAudioRendererDisabled()); |
| 575 pipeline_->OnAudioDisabled(); | 557 pipeline_->OnAudioDisabled(); |
| 576 | 558 |
| 577 // Verify that ended event is fired when video ends. | 559 // Verify that ended event is fired when video ends. |
| 578 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 560 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 579 .WillOnce(Return(true)); | 561 .WillOnce(Return(true)); |
| 580 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); | 562 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 591 InitializeDemuxer(&streams); | 573 InitializeDemuxer(&streams); |
| 592 InitializeAudioDecoder(audio_stream()); | 574 InitializeAudioDecoder(audio_stream()); |
| 593 InitializeAudioRenderer(true); | 575 InitializeAudioRenderer(true); |
| 594 InitializeVideoDecoder(video_stream()); | 576 InitializeVideoDecoder(video_stream()); |
| 595 InitializeVideoRenderer(); | 577 InitializeVideoRenderer(); |
| 596 | 578 |
| 597 EXPECT_CALL(*mocks_->demuxer(), | 579 EXPECT_CALL(*mocks_->demuxer(), |
| 598 OnAudioRendererDisabled()); | 580 OnAudioRendererDisabled()); |
| 599 | 581 |
| 600 InitializePipeline(PIPELINE_OK); | 582 InitializePipeline(PIPELINE_OK); |
| 601 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 602 EXPECT_FALSE(pipeline_->HasAudio()); | 583 EXPECT_FALSE(pipeline_->HasAudio()); |
| 603 EXPECT_TRUE(pipeline_->HasVideo()); | 584 EXPECT_TRUE(pipeline_->HasVideo()); |
| 604 | 585 |
| 605 // Verify that ended event is fired when video ends. | 586 // Verify that ended event is fired when video ends. |
| 606 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 587 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 607 .WillOnce(Return(true)); | 588 .WillOnce(Return(true)); |
| 608 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); | 589 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
| 609 pipeline_->OnRendererEnded(); | 590 pipeline_->OnRendererEnded(); |
| 610 } | 591 } |
| 611 | 592 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 CreateVideoStream(); | 788 CreateVideoStream(); |
| 808 MockDemuxerStreamVector streams; | 789 MockDemuxerStreamVector streams; |
| 809 streams.push_back(video_stream()); | 790 streams.push_back(video_stream()); |
| 810 | 791 |
| 811 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 792 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 812 InitializeDemuxer(&streams, kDuration); | 793 InitializeDemuxer(&streams, kDuration); |
| 813 InitializeVideoDecoder(video_stream()); | 794 InitializeVideoDecoder(video_stream()); |
| 814 InitializeVideoRenderer(); | 795 InitializeVideoRenderer(); |
| 815 | 796 |
| 816 InitializePipeline(PIPELINE_OK); | 797 InitializePipeline(PIPELINE_OK); |
| 817 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 818 EXPECT_FALSE(pipeline_->HasAudio()); | 798 EXPECT_FALSE(pipeline_->HasAudio()); |
| 819 EXPECT_TRUE(pipeline_->HasVideo()); | 799 EXPECT_TRUE(pipeline_->HasVideo()); |
| 820 | 800 |
| 821 EXPECT_EQ(base::TimeDelta(), pipeline_->GetMediaTime()); | 801 EXPECT_EQ(base::TimeDelta(), pipeline_->GetMediaTime()); |
| 822 } | 802 } |
| 823 | 803 |
| 824 TEST_F(PipelineTest, StartTimeIsNonZero) { | 804 TEST_F(PipelineTest, StartTimeIsNonZero) { |
| 825 const base::TimeDelta kStartTime = base::TimeDelta::FromSeconds(4); | 805 const base::TimeDelta kStartTime = base::TimeDelta::FromSeconds(4); |
| 826 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 806 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
| 827 | 807 |
| 828 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) | 808 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) |
| 829 .WillRepeatedly(Return(kStartTime)); | 809 .WillRepeatedly(Return(kStartTime)); |
| 830 | 810 |
| 831 CreateVideoStream(); | 811 CreateVideoStream(); |
| 832 MockDemuxerStreamVector streams; | 812 MockDemuxerStreamVector streams; |
| 833 streams.push_back(video_stream()); | 813 streams.push_back(video_stream()); |
| 834 | 814 |
| 835 InitializeDemuxer(&streams, kDuration); | 815 InitializeDemuxer(&streams, kDuration); |
| 836 InitializeVideoDecoder(video_stream()); | 816 InitializeVideoDecoder(video_stream()); |
| 837 InitializeVideoRenderer(); | 817 InitializeVideoRenderer(); |
| 838 | 818 |
| 839 InitializePipeline(PIPELINE_OK); | 819 InitializePipeline(PIPELINE_OK); |
| 840 EXPECT_TRUE(pipeline_->IsInitialized()); | |
| 841 EXPECT_FALSE(pipeline_->HasAudio()); | 820 EXPECT_FALSE(pipeline_->HasAudio()); |
| 842 EXPECT_TRUE(pipeline_->HasVideo()); | 821 EXPECT_TRUE(pipeline_->HasVideo()); |
| 843 | 822 |
| 844 EXPECT_EQ(kStartTime, pipeline_->GetMediaTime()); | 823 EXPECT_EQ(kStartTime, pipeline_->GetMediaTime()); |
| 845 } | 824 } |
| 846 | 825 |
| 847 static void RunTimeCB(const AudioRenderer::TimeCB& time_cb, | 826 static void RunTimeCB(const AudioRenderer::TimeCB& time_cb, |
| 848 int time_in_ms, | 827 int time_in_ms, |
| 849 int max_time_in_ms) { | 828 int max_time_in_ms) { |
| 850 time_cb.Run(base::TimeDelta::FromMilliseconds(time_in_ms), | 829 time_cb.Run(base::TimeDelta::FromMilliseconds(time_in_ms), |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 930 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 952 } | 931 } |
| 953 | 932 |
| 954 // Test that different-thread, some-delay callback (the expected common case) | 933 // Test that different-thread, some-delay callback (the expected common case) |
| 955 // works correctly. | 934 // works correctly. |
| 956 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 935 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 957 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 936 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 958 } | 937 } |
| 959 | 938 |
| 960 } // namespace media | 939 } // namespace media |
| OLD | NEW |