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/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream( | 159 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream( |
160 DemuxerStream::Type type) { | 160 DemuxerStream::Type type) { |
161 scoped_ptr<StrictMock<MockDemuxerStream> > stream( | 161 scoped_ptr<StrictMock<MockDemuxerStream> > stream( |
162 new StrictMock<MockDemuxerStream>(type)); | 162 new StrictMock<MockDemuxerStream>(type)); |
163 return stream.Pass(); | 163 return stream.Pass(); |
164 } | 164 } |
165 | 165 |
166 // Sets up expectations to allow the video renderer to initialize. | 166 // Sets up expectations to allow the video renderer to initialize. |
167 void SetRendererExpectations() { | 167 void SetRendererExpectations() { |
168 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _)) | 168 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _)) |
169 .WillOnce(DoAll(SaveArg<2>(&ended_cb_), | 169 .WillOnce(DoAll(SaveArg<3>(&ended_cb_), |
170 SaveArg<4>(&buffering_state_cb_), | 170 SaveArg<5>(&buffering_state_cb_), |
171 RunCallback<0>())); | 171 RunCallback<1>())); |
172 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(audio_stream())); | 172 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(audio_stream())); |
173 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(video_stream())); | 173 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(video_stream())); |
174 } | 174 } |
175 | 175 |
176 void AddTextStream() { | 176 void AddTextStream() { |
177 EXPECT_CALL(*this, OnAddTextTrack(_,_)) | 177 EXPECT_CALL(*this, OnAddTextTrack(_,_)) |
178 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack)); | 178 .WillOnce(Invoke(this, &PipelineTest::DoOnAddTextTrack)); |
179 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(), | 179 static_cast<DemuxerHost*>(pipeline_.get())->AddTextStream(text_stream(), |
180 TextTrackConfig(kTextSubtitles, "", "", "")); | 180 TextTrackConfig(kTextSubtitles, "", "", "")); |
181 message_loop_.RunUntilIdle(); | 181 message_loop_.RunUntilIdle(); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 MockDemuxerStreamVector streams; | 840 MockDemuxerStreamVector streams; |
841 streams.push_back(audio_stream()); | 841 streams.push_back(audio_stream()); |
842 streams.push_back(video_stream()); | 842 streams.push_back(video_stream()); |
843 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); | 843 SetDemuxerExpectations(&streams, base::TimeDelta::FromSeconds(3000)); |
844 | 844 |
845 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(true)); | 845 EXPECT_CALL(*renderer_, HasAudio()).WillRepeatedly(Return(true)); |
846 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(true)); | 846 EXPECT_CALL(*renderer_, HasVideo()).WillRepeatedly(Return(true)); |
847 | 847 |
848 if (state == kInitRenderer) { | 848 if (state == kInitRenderer) { |
849 if (stop_or_error == kStop) { | 849 if (stop_or_error == kStop) { |
850 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _)) | 850 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _)) |
851 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), | 851 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), |
852 RunCallback<0>())); | 852 RunCallback<1>())); |
853 ExpectPipelineStopAndDestroyPipeline(); | 853 ExpectPipelineStopAndDestroyPipeline(); |
854 } else { | 854 } else { |
855 status = PIPELINE_ERROR_INITIALIZATION_FAILED; | 855 status = PIPELINE_ERROR_INITIALIZATION_FAILED; |
856 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _)) | 856 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _)) |
857 .WillOnce(DoAll(RunCallback<3>(status), RunCallback<0>())); | 857 .WillOnce(DoAll(RunCallback<4>(status), RunCallback<1>())); |
858 } | 858 } |
859 | 859 |
860 EXPECT_CALL(*demuxer_, Stop()); | 860 EXPECT_CALL(*demuxer_, Stop()); |
861 return status; | 861 return status; |
862 } | 862 } |
863 | 863 |
864 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _)) | 864 EXPECT_CALL(*renderer_, Initialize(_, _, _, _, _, _)) |
865 .WillOnce(DoAll(SaveArg<4>(&buffering_state_cb_), | 865 .WillOnce(DoAll(SaveArg<5>(&buffering_state_cb_), |
866 RunCallback<0>())); | 866 RunCallback<1>())); |
867 | 867 |
868 EXPECT_CALL(callbacks_, OnMetadata(_)); | 868 EXPECT_CALL(callbacks_, OnMetadata(_)); |
869 | 869 |
870 // If we get here it's a successful initialization. | 870 // If we get here it's a successful initialization. |
871 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f)); | 871 EXPECT_CALL(*renderer_, SetPlaybackRate(0.0f)); |
872 EXPECT_CALL(*renderer_, SetVolume(1.0f)); | 872 EXPECT_CALL(*renderer_, SetVolume(1.0f)); |
873 EXPECT_CALL(*renderer_, StartPlayingFrom(base::TimeDelta())) | 873 EXPECT_CALL(*renderer_, StartPlayingFrom(base::TimeDelta())) |
874 .WillOnce(SetBufferingState(&buffering_state_cb_, | 874 .WillOnce(SetBufferingState(&buffering_state_cb_, |
875 BUFFERING_HAVE_ENOUGH)); | 875 BUFFERING_HAVE_ENOUGH)); |
876 | 876 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 993 |
994 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); | 994 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); |
995 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer); | 995 INSTANTIATE_TEARDOWN_TEST(Error, InitRenderer); |
996 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 996 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
997 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 997 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
998 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 998 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
999 | 999 |
1000 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); | 1000 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); |
1001 | 1001 |
1002 } // namespace media | 1002 } // namespace media |
OLD | NEW |