Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: media/base/pipeline_unittest.cc

Issue 9325044: Remove AudioDecoder from the Filter heirarchy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 Seek(mocks_->demuxer()->GetStartTime(), _)) 136 Seek(mocks_->demuxer()->GetStartTime(), _))
137 .WillOnce(Invoke(&RunFilterStatusCB)); 137 .WillOnce(Invoke(&RunFilterStatusCB));
138 EXPECT_CALL(*mocks_->video_decoder(), Stop(_)) 138 EXPECT_CALL(*mocks_->video_decoder(), Stop(_))
139 .WillOnce(Invoke(&RunStopFilterCallback)); 139 .WillOnce(Invoke(&RunStopFilterCallback));
140 } 140 }
141 141
142 // Sets up expectations to allow the audio decoder to initialize. 142 // Sets up expectations to allow the audio decoder to initialize.
143 void InitializeAudioDecoder(MockDemuxerStream* stream) { 143 void InitializeAudioDecoder(MockDemuxerStream* stream) {
144 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) 144 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _))
145 .WillOnce(Invoke(&RunPipelineStatusCB3)); 145 .WillOnce(Invoke(&RunPipelineStatusCB3));
146 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f));
147 EXPECT_CALL(*mocks_->audio_decoder(), Seek(base::TimeDelta(), _))
148 .WillOnce(Invoke(&RunFilterStatusCB));
149 EXPECT_CALL(*mocks_->audio_decoder(), Stop(_))
150 .WillOnce(Invoke(&RunStopFilterCallback));
151 } 146 }
152 147
153 // Sets up expectations to allow the video renderer to initialize. 148 // Sets up expectations to allow the video renderer to initialize.
154 void InitializeVideoRenderer() { 149 void InitializeVideoRenderer() {
155 EXPECT_CALL(*mocks_->video_renderer(), 150 EXPECT_CALL(*mocks_->video_renderer(),
156 Initialize(mocks_->video_decoder(), _, _, _)) 151 Initialize(mocks_->video_decoder(), _, _, _))
157 .WillOnce(Invoke(&RunPipelineStatusCB4)); 152 .WillOnce(Invoke(&RunPipelineStatusCB4));
158 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); 153 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f));
159 EXPECT_CALL(*mocks_->video_renderer(), 154 EXPECT_CALL(*mocks_->video_renderer(),
160 Seek(mocks_->demuxer()->GetStartTime(), _)) 155 Seek(mocks_->demuxer()->GetStartTime(), _))
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 MockDemuxerStream* video_stream() { 220 MockDemuxerStream* video_stream() {
226 return video_stream_; 221 return video_stream_;
227 } 222 }
228 223
229 void ExpectSeek(const base::TimeDelta& seek_time) { 224 void ExpectSeek(const base::TimeDelta& seek_time) {
230 // Every filter should receive a call to Seek(). 225 // Every filter should receive a call to Seek().
231 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) 226 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _))
232 .WillOnce(Invoke(&RunFilterStatusCB)); 227 .WillOnce(Invoke(&RunFilterStatusCB));
233 228
234 if (audio_stream_) { 229 if (audio_stream_) {
235 EXPECT_CALL(*mocks_->audio_decoder(), Seek(seek_time, _))
236 .WillOnce(Invoke(&RunFilterStatusCB));
237 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) 230 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _))
238 .WillOnce(Invoke(&RunFilterStatusCB)); 231 .WillOnce(Invoke(&RunFilterStatusCB));
239 } 232 }
240 233
241 if (video_stream_) { 234 if (video_stream_) {
242 EXPECT_CALL(*mocks_->video_decoder(), Seek(seek_time, _)) 235 EXPECT_CALL(*mocks_->video_decoder(), Seek(seek_time, _))
243 .WillOnce(Invoke(&RunFilterStatusCB)); 236 .WillOnce(Invoke(&RunFilterStatusCB));
244 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) 237 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _))
245 .WillOnce(Invoke(&RunFilterStatusCB)); 238 .WillOnce(Invoke(&RunFilterStatusCB));
246 } 239 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 559
567 InitializePipeline(PIPELINE_OK); 560 InitializePipeline(PIPELINE_OK);
568 EXPECT_TRUE(pipeline_->IsInitialized()); 561 EXPECT_TRUE(pipeline_->IsInitialized());
569 EXPECT_TRUE(pipeline_->HasAudio()); 562 EXPECT_TRUE(pipeline_->HasAudio());
570 EXPECT_TRUE(pipeline_->HasVideo()); 563 EXPECT_TRUE(pipeline_->HasVideo());
571 564
572 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f)) 565 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f))
573 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer())); 566 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer()));
574 EXPECT_CALL(*mocks_->demuxer(), 567 EXPECT_CALL(*mocks_->demuxer(),
575 OnAudioRendererDisabled()); 568 OnAudioRendererDisabled());
576 EXPECT_CALL(*mocks_->audio_decoder(),
577 OnAudioRendererDisabled());
578 EXPECT_CALL(*mocks_->audio_renderer(), 569 EXPECT_CALL(*mocks_->audio_renderer(),
579 OnAudioRendererDisabled()); 570 OnAudioRendererDisabled());
580 EXPECT_CALL(*mocks_->video_decoder(), 571 EXPECT_CALL(*mocks_->video_decoder(),
581 OnAudioRendererDisabled()); 572 OnAudioRendererDisabled());
582 EXPECT_CALL(*mocks_->video_renderer(), 573 EXPECT_CALL(*mocks_->video_renderer(),
583 OnAudioRendererDisabled()); 574 OnAudioRendererDisabled());
584 575
585 mocks_->audio_renderer()->SetPlaybackRate(1.0f); 576 mocks_->audio_renderer()->SetPlaybackRate(1.0f);
586 577
587 // Verify that ended event is fired when video ends. 578 // Verify that ended event is fired when video ends.
(...skipping 12 matching lines...) Expand all
600 streams.push_back(video_stream()); 591 streams.push_back(video_stream());
601 592
602 InitializeDemuxer(&streams, base::TimeDelta()); 593 InitializeDemuxer(&streams, base::TimeDelta());
603 InitializeAudioDecoder(audio_stream()); 594 InitializeAudioDecoder(audio_stream());
604 InitializeAudioRenderer(true); 595 InitializeAudioRenderer(true);
605 InitializeVideoDecoder(video_stream()); 596 InitializeVideoDecoder(video_stream());
606 InitializeVideoRenderer(); 597 InitializeVideoRenderer();
607 598
608 EXPECT_CALL(*mocks_->demuxer(), 599 EXPECT_CALL(*mocks_->demuxer(),
609 OnAudioRendererDisabled()); 600 OnAudioRendererDisabled());
610 EXPECT_CALL(*mocks_->audio_decoder(),
611 OnAudioRendererDisabled());
612 EXPECT_CALL(*mocks_->audio_renderer(), 601 EXPECT_CALL(*mocks_->audio_renderer(),
613 OnAudioRendererDisabled()); 602 OnAudioRendererDisabled());
614 EXPECT_CALL(*mocks_->video_decoder(), 603 EXPECT_CALL(*mocks_->video_decoder(),
615 OnAudioRendererDisabled()); 604 OnAudioRendererDisabled());
616 EXPECT_CALL(*mocks_->video_renderer(), 605 EXPECT_CALL(*mocks_->video_renderer(),
617 OnAudioRendererDisabled()); 606 OnAudioRendererDisabled());
618 607
619 InitializePipeline(PIPELINE_OK); 608 InitializePipeline(PIPELINE_OK);
620 EXPECT_TRUE(pipeline_->IsInitialized()); 609 EXPECT_TRUE(pipeline_->IsInitialized());
621 EXPECT_FALSE(pipeline_->HasAudio()); 610 EXPECT_FALSE(pipeline_->HasAudio());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 InitializePipeline(PIPELINE_OK); 682 InitializePipeline(PIPELINE_OK);
694 683
695 // For convenience to simulate filters calling the methods. 684 // For convenience to simulate filters calling the methods.
696 FilterHost* host = pipeline_; 685 FilterHost* host = pipeline_;
697 686
698 EXPECT_EQ(0, host->GetTime().ToInternalValue()); 687 EXPECT_EQ(0, host->GetTime().ToInternalValue());
699 688
700 float playback_rate = 1.0f; 689 float playback_rate = 1.0f;
701 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); 690 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate));
702 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); 691 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate));
703 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate));
704 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); 692 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate));
705 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); 693 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate));
706 pipeline_->SetPlaybackRate(playback_rate); 694 pipeline_->SetPlaybackRate(playback_rate);
707 message_loop_.RunAllPending(); 695 message_loop_.RunAllPending();
708 696
709 InSequence s; 697 InSequence s;
710 698
711 // Verify that the clock doesn't advance since it hasn't been started by 699 // Verify that the clock doesn't advance since it hasn't been started by
712 // a time update from the audio stream. 700 // a time update from the audio stream.
713 int64 start_time = host->GetTime().ToInternalValue(); 701 int64 start_time = host->GetTime().ToInternalValue();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 MockDemuxerStreamVector streams; 735 MockDemuxerStreamVector streams;
748 streams.push_back(audio_stream()); 736 streams.push_back(audio_stream());
749 737
750 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(10)); 738 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(10));
751 InitializeAudioDecoder(audio_stream()); 739 InitializeAudioDecoder(audio_stream());
752 InitializeAudioRenderer(); 740 InitializeAudioRenderer();
753 InitializePipeline(PIPELINE_OK); 741 InitializePipeline(PIPELINE_OK);
754 742
755 float playback_rate = 1.0f; 743 float playback_rate = 1.0f;
756 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); 744 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate));
757 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate));
758 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); 745 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate));
759 pipeline_->SetPlaybackRate(playback_rate); 746 pipeline_->SetPlaybackRate(playback_rate);
760 message_loop_.RunAllPending(); 747 message_loop_.RunAllPending();
761 748
762 InSequence s; 749 InSequence s;
763 750
764 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 751 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
765 752
766 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) 753 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _))
767 .WillOnce(Invoke(&SendReadErrorToCB)); 754 .WillOnce(Invoke(&SendReadErrorToCB));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); 898 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0));
912 } 899 }
913 900
914 // Test that different-thread, some-delay callback (the expected common case) 901 // Test that different-thread, some-delay callback (the expected common case)
915 // works correctly. 902 // works correctly.
916 TEST(PipelineStatusNotificationTest, DelayedCallback) { 903 TEST(PipelineStatusNotificationTest, DelayedCallback) {
917 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); 904 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20));
918 } 905 }
919 906
920 } // namespace media 907 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698