| OLD | NEW |
| 1 | 1 |
| 2 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "media/base/clock_impl.h" | 10 #include "media/base/clock_impl.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 Initialize(mocks_->video_decoder(), NotNull())) | 173 Initialize(mocks_->video_decoder(), NotNull())) |
| 174 .WillOnce(Invoke(&RunFilterCallback)); | 174 .WillOnce(Invoke(&RunFilterCallback)); |
| 175 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 175 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 176 EXPECT_CALL(*mocks_->video_renderer(), Seek(base::TimeDelta(), NotNull())) | 176 EXPECT_CALL(*mocks_->video_renderer(), Seek(base::TimeDelta(), NotNull())) |
| 177 .WillOnce(Invoke(&RunFilterCallback)); | 177 .WillOnce(Invoke(&RunFilterCallback)); |
| 178 EXPECT_CALL(*mocks_->video_renderer(), Stop(NotNull())) | 178 EXPECT_CALL(*mocks_->video_renderer(), Stop(NotNull())) |
| 179 .WillOnce(Invoke(&RunStopFilterCallback)); | 179 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Sets up expectations to allow the audio renderer to initialize. | 182 // Sets up expectations to allow the audio renderer to initialize. |
| 183 void InitializeAudioRenderer() { | 183 void InitializeAudioRenderer(bool disable_after_init_callback = false) { |
| 184 EXPECT_CALL(*mocks_->audio_renderer(), | 184 if (disable_after_init_callback) { |
| 185 Initialize(mocks_->audio_decoder(), NotNull())) | 185 EXPECT_CALL(*mocks_->audio_renderer(), |
| 186 .WillOnce(Invoke(&RunFilterCallback)); | 186 Initialize(mocks_->audio_decoder(), NotNull())) |
| 187 .WillOnce(DoAll(Invoke(&RunFilterCallback), |
| 188 DisableAudioRenderer(mocks_->audio_renderer()))); |
| 189 } else { |
| 190 EXPECT_CALL(*mocks_->audio_renderer(), |
| 191 Initialize(mocks_->audio_decoder(), NotNull())) |
| 192 .WillOnce(Invoke(&RunFilterCallback)); |
| 193 } |
| 187 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 194 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 188 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 195 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 189 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), NotNull())) | 196 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), NotNull())) |
| 190 .WillOnce(Invoke(&RunFilterCallback)); | 197 .WillOnce(Invoke(&RunFilterCallback)); |
| 191 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) | 198 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) |
| 192 .WillOnce(Invoke(&RunStopFilterCallback)); | 199 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 193 } | 200 } |
| 194 | 201 |
| 195 // Sets up expectations on the callback and initializes the pipeline. Called | 202 // Sets up expectations on the callback and initializes the pipeline. Called |
| 196 // after tests have set expectations any filters they wish to use. | 203 // after tests have set expectations any filters they wish to use. |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 mocks_->audio_renderer()->SetPlaybackRate(1.0f); | 641 mocks_->audio_renderer()->SetPlaybackRate(1.0f); |
| 635 | 642 |
| 636 // Verify that ended event is fired when video ends. | 643 // Verify that ended event is fired when video ends. |
| 637 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 644 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 638 .WillOnce(Return(true)); | 645 .WillOnce(Return(true)); |
| 639 EXPECT_CALL(callbacks_, OnEnded()); | 646 EXPECT_CALL(callbacks_, OnEnded()); |
| 640 FilterHost* host = pipeline_; | 647 FilterHost* host = pipeline_; |
| 641 host->NotifyEnded(); | 648 host->NotifyEnded(); |
| 642 } | 649 } |
| 643 | 650 |
| 651 TEST_F(PipelineImplTest, DisableAudioRendererDuringInit) { |
| 652 CreateAudioStream(); |
| 653 CreateVideoStream(); |
| 654 MockDemuxerStreamVector streams; |
| 655 streams.push_back(audio_stream()); |
| 656 streams.push_back(video_stream()); |
| 657 |
| 658 InitializeDataSource(); |
| 659 InitializeDemuxer(&streams, base::TimeDelta()); |
| 660 InitializeAudioDecoder(audio_stream()); |
| 661 InitializeAudioRenderer(true); |
| 662 InitializeVideoDecoder(video_stream()); |
| 663 InitializeVideoRenderer(); |
| 664 |
| 665 EXPECT_CALL(*mocks_->data_source(), |
| 666 OnAudioRendererDisabled()); |
| 667 EXPECT_CALL(*mocks_->demuxer(), |
| 668 OnAudioRendererDisabled()); |
| 669 EXPECT_CALL(*mocks_->audio_decoder(), |
| 670 OnAudioRendererDisabled()); |
| 671 EXPECT_CALL(*mocks_->audio_renderer(), |
| 672 OnAudioRendererDisabled()); |
| 673 EXPECT_CALL(*mocks_->video_decoder(), |
| 674 OnAudioRendererDisabled()); |
| 675 EXPECT_CALL(*mocks_->video_renderer(), |
| 676 OnAudioRendererDisabled()); |
| 677 |
| 678 InitializePipeline(); |
| 679 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 680 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 681 EXPECT_FALSE(pipeline_->IsRendered(mime_type::kMajorTypeAudio)); |
| 682 EXPECT_TRUE(pipeline_->IsRendered(mime_type::kMajorTypeVideo)); |
| 683 |
| 684 // Verify that ended event is fired when video ends. |
| 685 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 686 .WillOnce(Return(true)); |
| 687 EXPECT_CALL(callbacks_, OnEnded()); |
| 688 FilterHost* host = pipeline_; |
| 689 host->NotifyEnded(); |
| 690 } |
| 691 |
| 644 TEST_F(PipelineImplTest, EndedCallback) { | 692 TEST_F(PipelineImplTest, EndedCallback) { |
| 645 CreateAudioStream(); | 693 CreateAudioStream(); |
| 646 CreateVideoStream(); | 694 CreateVideoStream(); |
| 647 MockDemuxerStreamVector streams; | 695 MockDemuxerStreamVector streams; |
| 648 streams.push_back(audio_stream()); | 696 streams.push_back(audio_stream()); |
| 649 streams.push_back(video_stream()); | 697 streams.push_back(video_stream()); |
| 650 | 698 |
| 651 InitializeDataSource(); | 699 InitializeDataSource(); |
| 652 InitializeDemuxer(&streams, base::TimeDelta()); | 700 InitializeDemuxer(&streams, base::TimeDelta()); |
| 653 InitializeAudioDecoder(audio_stream()); | 701 InitializeAudioDecoder(audio_stream()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 // Signal end of video stream and make sure OnEnded() callback occurs. | 795 // Signal end of video stream and make sure OnEnded() callback occurs. |
| 748 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 796 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
| 749 .WillOnce(Return(true)); | 797 .WillOnce(Return(true)); |
| 750 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 798 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 751 .WillOnce(Return(true)); | 799 .WillOnce(Return(true)); |
| 752 EXPECT_CALL(callbacks_, OnEnded()); | 800 EXPECT_CALL(callbacks_, OnEnded()); |
| 753 host->NotifyEnded(); | 801 host->NotifyEnded(); |
| 754 } | 802 } |
| 755 | 803 |
| 756 } // namespace media | 804 } // namespace media |
| OLD | NEW |