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" |
| 11 #include "media/base/clock.h" | 11 #include "media/base/clock.h" |
| 12 #include "media/base/media_log.h" | 12 #include "media/base/media_log.h" |
| 13 #include "media/base/pipeline.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 "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
| 18 | 18 |
| 19 using ::testing::_; | 19 using ::testing::_; |
| 20 using ::testing::DeleteArg; | 20 using ::testing::DeleteArg; |
| 21 using ::testing::DoAll; | 21 using ::testing::DoAll; |
| 22 using ::testing::InSequence; | 22 using ::testing::InSequence; |
|
Ami GONE FROM CHROMIUM
2012/08/08 17:21:08
TODO(scherkus): drop InSequence from this file.
| |
| 23 using ::testing::Invoke; | 23 using ::testing::Invoke; |
| 24 using ::testing::InvokeWithoutArgs; | 24 using ::testing::InvokeWithoutArgs; |
| 25 using ::testing::Mock; | 25 using ::testing::Mock; |
| 26 using ::testing::NotNull; | 26 using ::testing::NotNull; |
| 27 using ::testing::Return; | 27 using ::testing::Return; |
| 28 using ::testing::ReturnRef; | 28 using ::testing::ReturnRef; |
| 29 using ::testing::SaveArg; | 29 using ::testing::SaveArg; |
| 30 using ::testing::StrictMock; | 30 using ::testing::StrictMock; |
| 31 using ::testing::WithArg; | 31 using ::testing::WithArg; |
| 32 | 32 |
| 33 namespace media { | 33 namespace media { |
| 34 | 34 |
| 35 // Demuxer properties. | 35 // Demuxer properties. |
| 36 static const int kTotalBytes = 1024; | 36 static const int kTotalBytes = 1024; |
| 37 static const int kBitrate = 1234; | 37 static const int kBitrate = 1234; |
| 38 | 38 |
| 39 ACTION_P(SetDemuxerProperties, duration) { | 39 ACTION_P(SetDemuxerProperties, duration) { |
| 40 arg0->SetTotalBytes(kTotalBytes); | 40 arg0->SetTotalBytes(kTotalBytes); |
| 41 arg0->SetDuration(duration); | 41 arg0->SetDuration(duration); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ACTION_P2(Stop, pipeline, stop_cb) { | |
| 45 pipeline->Stop(stop_cb); | |
| 46 } | |
| 47 | |
| 48 ACTION_P2(SetError, pipeline, status) { | |
| 49 pipeline->SetErrorForTesting(status); | |
| 50 } | |
| 51 | |
| 44 ACTION(RunPipelineStatusCB1) { | 52 ACTION(RunPipelineStatusCB1) { |
|
Ami GONE FROM CHROMIUM
2012/08/08 17:21:08
FWIW, this is a dup of RunPipelineStatusCB in mock
scherkus (not reviewing)
2012/08/08 22:14:29
you're living in the past, man!!! see http://crrev
| |
| 45 arg1.Run(PIPELINE_OK); | 53 arg1.Run(PIPELINE_OK); |
| 46 } | 54 } |
| 47 | 55 |
| 48 ACTION_P(RunPipelineStatusCB1WithStatus, status) { | 56 ACTION_P(RunPipelineStatusCB1WithStatus, status) { |
| 49 arg1.Run(status); | 57 arg1.Run(status); |
| 50 } | 58 } |
| 51 | 59 |
| 52 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 60 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
| 53 // also lets us test for missing callbacks. | 61 // also lets us test for missing callbacks. |
| 54 class CallbackHelper { | 62 class CallbackHelper { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 virtual ~PipelineTest() { | 99 virtual ~PipelineTest() { |
| 92 if (!pipeline_->IsRunning()) { | 100 if (!pipeline_->IsRunning()) { |
| 93 return; | 101 return; |
| 94 } | 102 } |
| 95 | 103 |
| 96 // Shutdown sequence. | 104 // Shutdown sequence. |
| 97 if (pipeline_->IsInitialized()) { | 105 if (pipeline_->IsInitialized()) { |
| 98 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 106 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 99 .WillOnce(RunClosure()); | 107 .WillOnce(RunClosure()); |
| 100 | 108 |
| 109 // TODO(scherkus): Don't pause+flush on shutdown, | |
| 110 // see http://crbug.com/110228 | |
| 101 if (audio_stream_) { | 111 if (audio_stream_) { |
| 102 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 112 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 103 .WillOnce(RunClosure()); | 113 .WillOnce(RunClosure()); |
| 104 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 114 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 105 .WillOnce(RunClosure()); | 115 .WillOnce(RunClosure()); |
| 106 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 116 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 107 .WillOnce(RunClosure()); | 117 .WillOnce(RunClosure()); |
| 108 } | 118 } |
| 109 | 119 |
| 110 if (video_stream_) { | 120 if (video_stream_) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 pipeline_->Seek(seek_time, | 286 pipeline_->Seek(seek_time, |
| 277 base::Bind(&CallbackHelper::OnSeek, | 287 base::Bind(&CallbackHelper::OnSeek, |
| 278 base::Unretained(&callbacks_))); | 288 base::Unretained(&callbacks_))); |
| 279 | 289 |
| 280 // We expect the time to be updated only after the seek has completed. | 290 // We expect the time to be updated only after the seek has completed. |
| 281 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); | 291 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); |
| 282 message_loop_.RunAllPending(); | 292 message_loop_.RunAllPending(); |
| 283 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 293 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
| 284 } | 294 } |
| 285 | 295 |
| 296 void SetupShutdownTest() { | |
|
Ami GONE FROM CHROMIUM
2012/08/08 17:21:08
I can't tell from this impl, nor from the name, wh
scherkus (not reviewing)
2012/08/08 22:14:29
Done.
| |
| 297 CreateAudioStream(); | |
| 298 MockDemuxerStreamVector streams; | |
| 299 streams.push_back(audio_stream()); | |
| 300 | |
| 301 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); | |
| 302 InitializeAudioDecoder(audio_stream()); | |
| 303 InitializeAudioRenderer(); | |
| 304 InitializePipeline(PIPELINE_OK); | |
| 305 } | |
| 306 | |
| 286 // Fixture members. | 307 // Fixture members. |
| 287 StrictMock<CallbackHelper> callbacks_; | 308 StrictMock<CallbackHelper> callbacks_; |
| 288 MessageLoop message_loop_; | 309 MessageLoop message_loop_; |
| 289 scoped_refptr<Pipeline> pipeline_; | 310 scoped_refptr<Pipeline> pipeline_; |
| 290 scoped_ptr<media::MockFilterCollection> mocks_; | 311 scoped_ptr<media::MockFilterCollection> mocks_; |
| 291 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream_; | 312 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream_; |
| 292 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream_; | 313 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream_; |
| 293 AudioRenderer::TimeCB audio_time_cb_; | 314 AudioRenderer::TimeCB audio_time_cb_; |
| 294 | 315 |
| 295 private: | 316 private: |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 | 478 |
| 458 // Initialize then seek! | 479 // Initialize then seek! |
| 459 InitializePipeline(PIPELINE_OK); | 480 InitializePipeline(PIPELINE_OK); |
| 460 | 481 |
| 461 // Every filter should receive a call to Seek(). | 482 // Every filter should receive a call to Seek(). |
| 462 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); | 483 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); |
| 463 ExpectSeek(expected); | 484 ExpectSeek(expected); |
| 464 DoSeek(expected); | 485 DoSeek(expected); |
| 465 } | 486 } |
| 466 | 487 |
| 488 TEST_F(PipelineTest, Stop_DuringStart) { | |
| 489 base::Closure stop_cb = base::Bind( | |
| 490 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | |
| 491 | |
| 492 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | |
| 493 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunPipelineStatusCB1())); | |
| 494 | |
| 495 // Stop sequence. | |
| 496 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
| 497 .WillOnce(RunClosure()); | |
| 498 EXPECT_CALL(callbacks_, OnStop()); | |
| 499 | |
| 500 InitializePipeline(PIPELINE_OK); | |
| 501 } | |
| 502 | |
| 503 TEST_F(PipelineTest, Stop_DuringPause) { | |
|
Ami GONE FROM CHROMIUM
2012/08/08 17:21:08
Stop_During{Pause,Flush,Seek} look like they can b
| |
| 504 SetupShutdownTest(); | |
| 505 base::Closure stop_cb = base::Bind( | |
| 506 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | |
| 507 | |
| 508 InSequence s; | |
| 509 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | |
| 510 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure())); | |
| 511 | |
| 512 // We complete seeks before stopping. | |
| 513 // TODO(scherkus): We should be able to stop in any state. | |
| 514 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 515 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | |
| 516 .WillOnce(RunPipelineStatusCB1()); | |
| 517 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | |
| 518 .WillOnce(RunPipelineStatusCB1()); | |
| 519 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)).WillOnce(RunClosure()); | |
| 520 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | |
| 521 | |
| 522 // Stop sequence. | |
| 523 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
| 524 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 525 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 526 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 527 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 528 EXPECT_CALL(callbacks_, OnStop()); | |
| 529 | |
| 530 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 531 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 532 message_loop_.RunAllPending(); | |
| 533 } | |
| 534 | |
| 535 TEST_F(PipelineTest, Stop_DuringFlush) { | |
| 536 SetupShutdownTest(); | |
| 537 base::Closure stop_cb = base::Bind( | |
| 538 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | |
| 539 | |
| 540 InSequence s; | |
| 541 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 542 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | |
| 543 .WillOnce(DoAll(Stop(pipeline_, stop_cb), RunClosure())); | |
| 544 | |
| 545 // We complete seeks before stopping. | |
| 546 // TODO(scherkus): We should be able to stop in any state. | |
| 547 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | |
| 548 .WillOnce(RunPipelineStatusCB1()); | |
| 549 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | |
| 550 .WillOnce(RunPipelineStatusCB1()); | |
| 551 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)).WillOnce(RunClosure()); | |
| 552 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | |
| 553 | |
| 554 // Stop sequence. | |
| 555 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
| 556 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 557 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 558 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 559 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 560 EXPECT_CALL(callbacks_, OnStop()); | |
| 561 | |
| 562 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 563 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 564 message_loop_.RunAllPending(); | |
| 565 } | |
| 566 | |
| 567 TEST_F(PipelineTest, Stop_DuringSeek) { | |
| 568 SetupShutdownTest(); | |
| 569 base::Closure stop_cb = base::Bind( | |
| 570 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); | |
| 571 | |
| 572 InSequence s; | |
| 573 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 574 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 575 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | |
| 576 .WillOnce(DoAll(Stop(pipeline_, stop_cb), | |
| 577 RunPipelineStatusCB1WithStatus(PIPELINE_OK))); | |
| 578 | |
| 579 // We complete seeks before stopping. | |
| 580 // TODO(scherkus): We should be able to stop in any state. | |
| 581 EXPECT_CALL(*mocks_->audio_renderer(), Preroll(_, _)) | |
| 582 .WillOnce(RunPipelineStatusCB1()); | |
| 583 EXPECT_CALL(*mocks_->audio_renderer(), Play(_)).WillOnce(RunClosure()); | |
| 584 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | |
| 585 | |
| 586 // Stop sequence. | |
| 587 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
| 588 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 589 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 590 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 591 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 592 EXPECT_CALL(callbacks_, OnStop()); | |
| 593 | |
| 594 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 595 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 596 message_loop_.RunAllPending(); | |
| 597 } | |
| 598 | |
| 599 TEST_F(PipelineTest, Stop_DuringPlayback) { | |
| 600 SetupShutdownTest(); | |
| 601 | |
| 602 InSequence s; | |
| 603 | |
| 604 // Stop sequence. | |
| 605 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
|
Ami GONE FROM CHROMIUM
2012/08/08 17:21:08
Can you pull out this stanza into a helper ExpectP
| |
| 606 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 607 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 608 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 609 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 610 EXPECT_CALL(callbacks_, OnStop()); | |
| 611 | |
| 612 pipeline_->Stop(base::Bind( | |
| 613 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | |
| 614 message_loop_.RunAllPending(); | |
| 615 } | |
| 616 | |
| 617 TEST_F(PipelineTest, Error_DuringStart) { | |
| 618 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) | |
| 619 .WillOnce(RunPipelineStatusCB1WithStatus(PIPELINE_ERROR_READ)); | |
| 620 | |
| 621 // Stop sequence. | |
| 622 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
| 623 .WillOnce(RunClosure()); | |
| 624 | |
| 625 // Start callback should fire with error but nothing else. | |
| 626 InitializePipeline(PIPELINE_ERROR_READ); | |
| 627 } | |
| 628 | |
| 629 TEST_F(PipelineTest, Error_DuringPause) { | |
| 630 SetupShutdownTest(); | |
| 631 | |
| 632 InSequence s; | |
| 633 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | |
| 634 .WillOnce(DoAll(SetError(pipeline_, PIPELINE_ERROR_READ), RunClosure())); | |
| 635 | |
| 636 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | |
| 637 | |
| 638 // Stop sequence. | |
| 639 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 640 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 641 | |
| 642 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 643 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 644 message_loop_.RunAllPending(); | |
| 645 } | |
| 646 | |
| 647 TEST_F(PipelineTest, Error_DuringFlush) { | |
| 648 SetupShutdownTest(); | |
| 649 | |
| 650 InSequence s; | |
| 651 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 652 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | |
| 653 .WillOnce(DoAll(SetError(pipeline_, PIPELINE_ERROR_READ), RunClosure())); | |
| 654 | |
| 655 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | |
| 656 | |
| 657 // Stop sequence. | |
| 658 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 659 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 660 | |
| 661 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 662 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 663 message_loop_.RunAllPending(); | |
| 664 } | |
| 665 | |
| 666 TEST_F(PipelineTest, Error_DuringSeek) { | |
| 667 SetupShutdownTest(); | |
| 668 | |
| 669 InSequence s; | |
| 670 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 671 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 672 EXPECT_CALL(*mocks_->demuxer(), Seek(_, _)) | |
| 673 .WillOnce(RunPipelineStatusCB1WithStatus(PIPELINE_ERROR_READ)); | |
| 674 | |
| 675 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | |
| 676 | |
| 677 // Stop sequence. | |
| 678 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 679 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 680 | |
| 681 pipeline_->Seek(base::TimeDelta::FromSeconds(10), base::Bind( | |
| 682 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); | |
| 683 message_loop_.RunAllPending(); | |
| 684 } | |
| 685 | |
| 686 TEST_F(PipelineTest, Error_DuringPlayback) { | |
| 687 SetupShutdownTest(); | |
| 688 | |
| 689 InSequence s; | |
| 690 | |
| 691 // Stop sequence. | |
| 692 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
| 693 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 694 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 695 EXPECT_CALL(*mocks_->demuxer(), Stop(_)).WillOnce(RunClosure()); | |
| 696 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 697 | |
| 698 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | |
| 699 | |
| 700 pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ); | |
| 701 message_loop_.RunAllPending(); | |
| 702 } | |
| 703 | |
| 704 TEST_F(PipelineTest, Error_DuringStop) { | |
| 705 SetupShutdownTest(); | |
| 706 | |
| 707 InSequence s; | |
| 708 | |
| 709 // Stop sequence. | |
| 710 // TODO(scherkus): Don't pause+flush on shutdown, see http://crbug.com/110228 | |
| 711 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)).WillOnce(RunClosure()); | |
| 712 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)).WillOnce(RunClosure()); | |
| 713 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
| 714 .WillOnce(DoAll(SetError(pipeline_, PIPELINE_ERROR_READ), RunClosure())); | |
| 715 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)).WillOnce(RunClosure()); | |
| 716 | |
| 717 // No error callback should fire. | |
| 718 EXPECT_CALL(callbacks_, OnStop()); | |
| 719 | |
| 720 pipeline_->Stop(base::Bind( | |
| 721 &CallbackHelper::OnStop, base::Unretained(&callbacks_))); | |
| 722 message_loop_.RunAllPending(); | |
| 723 } | |
| 724 | |
| 467 TEST_F(PipelineTest, SetVolume) { | 725 TEST_F(PipelineTest, SetVolume) { |
| 468 CreateAudioStream(); | 726 CreateAudioStream(); |
| 469 MockDemuxerStreamVector streams; | 727 MockDemuxerStreamVector streams; |
| 470 streams.push_back(audio_stream()); | 728 streams.push_back(audio_stream()); |
| 471 | 729 |
| 472 InitializeDemuxer(&streams); | 730 InitializeDemuxer(&streams); |
| 473 InitializeAudioDecoder(audio_stream()); | 731 InitializeAudioDecoder(audio_stream()); |
| 474 InitializeAudioRenderer(); | 732 InitializeAudioRenderer(); |
| 475 | 733 |
| 476 // The audio renderer should receive a call to SetVolume(). | 734 // The audio renderer should receive a call to SetVolume(). |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 1209 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 952 } | 1210 } |
| 953 | 1211 |
| 954 // Test that different-thread, some-delay callback (the expected common case) | 1212 // Test that different-thread, some-delay callback (the expected common case) |
| 955 // works correctly. | 1213 // works correctly. |
| 956 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 1214 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 957 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 1215 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 958 } | 1216 } |
| 959 | 1217 |
| 960 } // namespace media | 1218 } // namespace media |
| OLD | NEW |