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 |
scherkus (not reviewing)
2011/01/05 01:28:38
nit: remove blank line
acolwell GONE FROM CHROMIUM
2011/01/05 16:27:46
Done.
| |
185 Initialize(mocks_->audio_decoder(), NotNull())) | 185 if (disable_after_init_callback) { |
186 .WillOnce(Invoke(&RunFilterCallback)); | 186 EXPECT_CALL(*mocks_->audio_renderer(), |
187 Initialize(mocks_->audio_decoder(), NotNull())) | |
188 .WillOnce(DoAll(Invoke(&RunFilterCallback), | |
189 DisableAudioRenderer(mocks_->audio_renderer()))); | |
190 } else { | |
191 EXPECT_CALL(*mocks_->audio_renderer(), | |
192 Initialize(mocks_->audio_decoder(), NotNull())) | |
193 .WillOnce(Invoke(&RunFilterCallback)); | |
194 } | |
187 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 195 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
188 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 196 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
189 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), NotNull())) | 197 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), NotNull())) |
190 .WillOnce(Invoke(&RunFilterCallback)); | 198 .WillOnce(Invoke(&RunFilterCallback)); |
191 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) | 199 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) |
192 .WillOnce(Invoke(&RunStopFilterCallback)); | 200 .WillOnce(Invoke(&RunStopFilterCallback)); |
193 } | 201 } |
194 | 202 |
195 // Sets up expectations on the callback and initializes the pipeline. Called | 203 // Sets up expectations on the callback and initializes the pipeline. Called |
196 // after tests have set expectations any filters they wish to use. | 204 // 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); | 642 mocks_->audio_renderer()->SetPlaybackRate(1.0f); |
635 | 643 |
636 // Verify that ended event is fired when video ends. | 644 // Verify that ended event is fired when video ends. |
637 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 645 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
638 .WillOnce(Return(true)); | 646 .WillOnce(Return(true)); |
639 EXPECT_CALL(callbacks_, OnEnded()); | 647 EXPECT_CALL(callbacks_, OnEnded()); |
640 FilterHost* host = pipeline_; | 648 FilterHost* host = pipeline_; |
641 host->NotifyEnded(); | 649 host->NotifyEnded(); |
642 } | 650 } |
643 | 651 |
652 TEST_F(PipelineImplTest, DisableAudioRendererDuringInit) { | |
653 CreateAudioStream(); | |
654 CreateVideoStream(); | |
655 MockDemuxerStreamVector streams; | |
656 streams.push_back(audio_stream()); | |
657 streams.push_back(video_stream()); | |
658 | |
659 InitializeDataSource(); | |
660 InitializeDemuxer(&streams, base::TimeDelta()); | |
661 InitializeAudioDecoder(audio_stream()); | |
662 InitializeAudioRenderer(true); | |
663 InitializeVideoDecoder(video_stream()); | |
664 InitializeVideoRenderer(); | |
665 | |
666 EXPECT_CALL(*mocks_->data_source(), | |
667 OnAudioRendererDisabled()); | |
668 EXPECT_CALL(*mocks_->demuxer(), | |
669 OnAudioRendererDisabled()); | |
670 EXPECT_CALL(*mocks_->audio_decoder(), | |
671 OnAudioRendererDisabled()); | |
672 EXPECT_CALL(*mocks_->audio_renderer(), | |
673 OnAudioRendererDisabled()); | |
674 EXPECT_CALL(*mocks_->video_decoder(), | |
675 OnAudioRendererDisabled()); | |
676 EXPECT_CALL(*mocks_->video_renderer(), | |
677 OnAudioRendererDisabled()); | |
678 | |
679 InitializePipeline(); | |
680 EXPECT_TRUE(pipeline_->IsInitialized()); | |
681 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
682 EXPECT_FALSE(pipeline_->IsRendered(mime_type::kMajorTypeAudio)); | |
683 EXPECT_TRUE(pipeline_->IsRendered(mime_type::kMajorTypeVideo)); | |
684 | |
685 // Verify that ended event is fired when video ends. | |
686 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | |
687 .WillOnce(Return(true)); | |
688 EXPECT_CALL(callbacks_, OnEnded()); | |
689 FilterHost* host = pipeline_; | |
690 host->NotifyEnded(); | |
691 } | |
692 | |
644 TEST_F(PipelineImplTest, EndedCallback) { | 693 TEST_F(PipelineImplTest, EndedCallback) { |
645 CreateAudioStream(); | 694 CreateAudioStream(); |
646 CreateVideoStream(); | 695 CreateVideoStream(); |
647 MockDemuxerStreamVector streams; | 696 MockDemuxerStreamVector streams; |
648 streams.push_back(audio_stream()); | 697 streams.push_back(audio_stream()); |
649 streams.push_back(video_stream()); | 698 streams.push_back(video_stream()); |
650 | 699 |
651 InitializeDataSource(); | 700 InitializeDataSource(); |
652 InitializeDemuxer(&streams, base::TimeDelta()); | 701 InitializeDemuxer(&streams, base::TimeDelta()); |
653 InitializeAudioDecoder(audio_stream()); | 702 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. | 796 // Signal end of video stream and make sure OnEnded() callback occurs. |
748 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 797 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
749 .WillOnce(Return(true)); | 798 .WillOnce(Return(true)); |
750 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 799 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
751 .WillOnce(Return(true)); | 800 .WillOnce(Return(true)); |
752 EXPECT_CALL(callbacks_, OnEnded()); | 801 EXPECT_CALL(callbacks_, OnEnded()); |
753 host->NotifyEnded(); | 802 host->NotifyEnded(); |
754 } | 803 } |
755 | 804 |
756 } // namespace media | 805 } // namespace media |
OLD | NEW |