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

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

Issue 9860027: Remove DemuxerFactory and URL parameter from Pipeline. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: again Created 8 years, 8 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
« no previous file with comments | « media/base/pipeline.cc ('k') | media/base/preload.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 MOCK_METHOD1(OnStart, void(PipelineStatus)); 48 MOCK_METHOD1(OnStart, void(PipelineStatus));
49 MOCK_METHOD1(OnSeek, void(PipelineStatus)); 49 MOCK_METHOD1(OnSeek, void(PipelineStatus));
50 MOCK_METHOD0(OnStop, void()); 50 MOCK_METHOD0(OnStop, void());
51 MOCK_METHOD1(OnEnded, void(PipelineStatus)); 51 MOCK_METHOD1(OnEnded, void(PipelineStatus));
52 MOCK_METHOD1(OnError, void(PipelineStatus)); 52 MOCK_METHOD1(OnError, void(PipelineStatus));
53 53
54 private: 54 private:
55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); 55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper);
56 }; 56 };
57 57
58 // Run |cb| w/ OK status.
59 static void RunPipelineStatusOKCB(const PipelineStatusCB& cb) {
60 cb.Run(PIPELINE_OK);
61 }
62
63 // TODO(scherkus): even though some filters are initialized on separate 58 // TODO(scherkus): even though some filters are initialized on separate
64 // threads these test aren't flaky... why? It's because filters' Initialize() 59 // threads these test aren't flaky... why? It's because filters' Initialize()
65 // is executed on |message_loop_| and the mock filters instantly call 60 // is executed on |message_loop_| and the mock filters instantly call
66 // InitializationComplete(), which keeps the pipeline humming along. If 61 // InitializationComplete(), which keeps the pipeline humming along. If
67 // either filters don't call InitializationComplete() immediately or filter 62 // either filters don't call InitializationComplete() immediately or filter
68 // initialization is moved to a separate thread this test will become flaky. 63 // initialization is moved to a separate thread this test will become flaky.
69 class PipelineTest : public ::testing::Test { 64 class PipelineTest : public ::testing::Test {
70 public: 65 public:
71 PipelineTest() 66 PipelineTest()
72 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) { 67 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) {
(...skipping 13 matching lines...) Expand all
86 if (!pipeline_->IsRunning()) { 81 if (!pipeline_->IsRunning()) {
87 return; 82 return;
88 } 83 }
89 84
90 // Expect a stop callback if we were started. 85 // Expect a stop callback if we were started.
91 EXPECT_CALL(callbacks_, OnStop()); 86 EXPECT_CALL(callbacks_, OnStop());
92 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, 87 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop,
93 base::Unretained(&callbacks_))); 88 base::Unretained(&callbacks_)));
94 message_loop_.RunAllPending(); 89 message_loop_.RunAllPending();
95 90
91 pipeline_ = NULL;
96 mocks_.reset(); 92 mocks_.reset();
97 } 93 }
98 94
99 protected: 95 protected:
100 // Sets up expectations to allow the demuxer to initialize. 96 // Sets up expectations to allow the demuxer to initialize.
101 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; 97 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector;
102 void InitializeDemuxer(MockDemuxerStreamVector* streams, 98 void InitializeDemuxer(MockDemuxerStreamVector* streams,
103 const base::TimeDelta& duration) { 99 const base::TimeDelta& duration) {
100 EXPECT_CALL(*mocks_->demuxer(), Initialize(_))
101 .WillOnce(Invoke(&RunPipelineStatusCB));
104 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( 102 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration(
105 kTotalBytes, kBufferedBytes, duration); 103 kTotalBytes, kBufferedBytes, duration);
106 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); 104 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f));
107 EXPECT_CALL(*mocks_->demuxer(), SetPreload(AUTO));
108 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) 105 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _))
109 .WillOnce(Invoke(&RunPipelineStatusCB)); 106 .WillOnce(Invoke(&RunPipelineStatusCB2));
110 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) 107 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
111 .WillOnce(Invoke(&RunStopFilterCallback)); 108 .WillOnce(Invoke(&RunStopFilterCallback));
112 109
113 // Configure the demuxer to return the streams. 110 // Configure the demuxer to return the streams.
114 for (size_t i = 0; i < streams->size(); ++i) { 111 for (size_t i = 0; i < streams->size(); ++i) {
115 scoped_refptr<DemuxerStream> stream((*streams)[i]); 112 scoped_refptr<DemuxerStream> stream((*streams)[i]);
116 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) 113 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type()))
117 .WillRepeatedly(Return(stream)); 114 .WillRepeatedly(Return(stream));
118 } 115 }
119 } 116 }
120 117
121 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { 118 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) {
122 StrictMock<MockDemuxerStream>* stream = 119 StrictMock<MockDemuxerStream>* stream =
123 new StrictMock<MockDemuxerStream>(); 120 new StrictMock<MockDemuxerStream>();
124 EXPECT_CALL(*stream, type()) 121 EXPECT_CALL(*stream, type())
125 .WillRepeatedly(Return(type)); 122 .WillRepeatedly(Return(type));
126 return stream; 123 return stream;
127 } 124 }
128 125
129 // Sets up expectations to allow the video decoder to initialize. 126 // Sets up expectations to allow the video decoder to initialize.
130 void InitializeVideoDecoder(MockDemuxerStream* stream) { 127 void InitializeVideoDecoder(MockDemuxerStream* stream) {
131 EXPECT_CALL(*mocks_->video_decoder(), 128 EXPECT_CALL(*mocks_->video_decoder(),
132 Initialize(stream, _, _)) 129 Initialize(stream, _, _))
133 .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); 130 .WillOnce(Invoke(&RunPipelineStatusCB3));
134 } 131 }
135 132
136 // Sets up expectations to allow the audio decoder to initialize. 133 // Sets up expectations to allow the audio decoder to initialize.
137 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) { 134 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) {
138 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) 135 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _))
139 .WillOnce(Invoke(&RunPipelineStatusCB3)); 136 .WillOnce(Invoke(&RunPipelineStatusCB3));
140 } 137 }
141 138
142 // Sets up expectations to allow the video renderer to initialize. 139 // Sets up expectations to allow the video renderer to initialize.
143 void InitializeVideoRenderer() { 140 void InitializeVideoRenderer() {
144 EXPECT_CALL(*mocks_->video_renderer(), Initialize( 141 EXPECT_CALL(*mocks_->video_renderer(), Initialize(
145 scoped_refptr<VideoDecoder>(mocks_->video_decoder()), _, _, _)) 142 scoped_refptr<VideoDecoder>(mocks_->video_decoder()), _, _, _))
146 .WillOnce(Invoke(&RunPipelineStatusCB4)); 143 .WillOnce(Invoke(&RunPipelineStatusCB4));
147 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); 144 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f));
148 EXPECT_CALL(*mocks_->video_renderer(), 145 EXPECT_CALL(*mocks_->video_renderer(),
149 Seek(mocks_->demuxer()->GetStartTime(), _)) 146 Seek(mocks_->demuxer()->GetStartTime(), _))
150 .WillOnce(Invoke(&RunPipelineStatusCB)); 147 .WillOnce(Invoke(&RunPipelineStatusCB2));
151 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) 148 EXPECT_CALL(*mocks_->video_renderer(), Stop(_))
152 .WillOnce(Invoke(&RunStopFilterCallback)); 149 .WillOnce(Invoke(&RunStopFilterCallback));
153 } 150 }
154 151
155 // Sets up expectations to allow the audio renderer to initialize. 152 // Sets up expectations to allow the audio renderer to initialize.
156 void InitializeAudioRenderer(bool disable_after_init_cb = false) { 153 void InitializeAudioRenderer(bool disable_after_init_cb = false) {
157 if (disable_after_init_cb) { 154 if (disable_after_init_cb) {
158 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( 155 EXPECT_CALL(*mocks_->audio_renderer(), Initialize(
159 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) 156 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _))
160 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB4), 157 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB4),
161 DisableAudioRenderer(mocks_->audio_renderer()))); 158 DisableAudioRenderer(mocks_->audio_renderer())));
162 } else { 159 } else {
163 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( 160 EXPECT_CALL(*mocks_->audio_renderer(), Initialize(
164 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) 161 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _))
165 .WillOnce(Invoke(&RunPipelineStatusCB4)); 162 .WillOnce(Invoke(&RunPipelineStatusCB4));
166 } 163 }
167 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); 164 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f));
168 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); 165 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f));
169 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) 166 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _))
170 .WillOnce(Invoke(&RunPipelineStatusCB)); 167 .WillOnce(Invoke(&RunPipelineStatusCB2));
171 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) 168 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_))
172 .WillOnce(Invoke(&RunStopFilterCallback)); 169 .WillOnce(Invoke(&RunStopFilterCallback));
173 } 170 }
174 171
175 // Sets up expectations on the callback and initializes the pipeline. Called 172 // Sets up expectations on the callback and initializes the pipeline. Called
176 // after tests have set expectations any filters they wish to use. 173 // after tests have set expectations any filters they wish to use.
177 void InitializePipeline() {
178 InitializePipeline(PIPELINE_OK);
179 }
180 // Most tests can expect the |filter_collection|'s |build_status| to get
181 // reflected in |Start()|'s argument.
182 void InitializePipeline(PipelineStatus start_status) { 174 void InitializePipeline(PipelineStatus start_status) {
183 InitializePipeline(start_status, start_status);
184 }
185 // But some tests require different statuses in build & Start.
186 void InitializePipeline(PipelineStatus build_status,
187 PipelineStatus start_status) {
188 // Expect an initialization callback.
189 EXPECT_CALL(callbacks_, OnStart(start_status)); 175 EXPECT_CALL(callbacks_, OnStart(start_status));
190 176
191 pipeline_->Start( 177 pipeline_->Start(
192 mocks_->filter_collection(true, true, true, build_status).Pass(), 178 mocks_->Create().Pass(),
193 "",
194 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 179 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
195 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 180 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
196 NetworkEventCB(), 181 NetworkEventCB(),
197 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); 182 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
198
199 message_loop_.RunAllPending(); 183 message_loop_.RunAllPending();
200 } 184 }
201 185
202 void CreateAudioStream() { 186 void CreateAudioStream() {
203 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 187 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
204 } 188 }
205 189
206 void CreateVideoStream() { 190 void CreateVideoStream() {
207 video_stream_ = CreateStream(DemuxerStream::VIDEO); 191 video_stream_ = CreateStream(DemuxerStream::VIDEO);
208 } 192 }
209 193
210 MockDemuxerStream* audio_stream() { 194 MockDemuxerStream* audio_stream() {
211 return audio_stream_; 195 return audio_stream_;
212 } 196 }
213 197
214 MockDemuxerStream* video_stream() { 198 MockDemuxerStream* video_stream() {
215 return video_stream_; 199 return video_stream_;
216 } 200 }
217 201
218 void ExpectSeek(const base::TimeDelta& seek_time) { 202 void ExpectSeek(const base::TimeDelta& seek_time) {
219 // Every filter should receive a call to Seek(). 203 // Every filter should receive a call to Seek().
220 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) 204 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _))
221 .WillOnce(Invoke(&RunPipelineStatusCB)); 205 .WillOnce(Invoke(&RunPipelineStatusCB2));
222 206
223 if (audio_stream_) { 207 if (audio_stream_) {
224 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) 208 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _))
225 .WillOnce(Invoke(&RunPipelineStatusCB)); 209 .WillOnce(Invoke(&RunPipelineStatusCB2));
226 } 210 }
227 211
228 if (video_stream_) { 212 if (video_stream_) {
229 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) 213 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _))
230 .WillOnce(Invoke(&RunPipelineStatusCB)); 214 .WillOnce(Invoke(&RunPipelineStatusCB2));
231 } 215 }
232 216
233 // We expect a successful seek callback. 217 // We expect a successful seek callback.
234 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); 218 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK));
235 } 219 }
236 220
237 void DoSeek(const base::TimeDelta& seek_time) { 221 void DoSeek(const base::TimeDelta& seek_time) {
238 pipeline_->Seek(seek_time, 222 pipeline_->Seek(seek_time,
239 base::Bind(&CallbackHelper::OnSeek, 223 base::Bind(&CallbackHelper::OnSeek,
240 base::Unretained(&callbacks_))); 224 base::Unretained(&callbacks_)));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 EXPECT_EQ(0, pipeline_->GetTotalBytes()); 273 EXPECT_EQ(0, pipeline_->GetTotalBytes());
290 274
291 // Should always get set to zero. 275 // Should always get set to zero.
292 gfx::Size size(1, 1); 276 gfx::Size size(1, 1);
293 pipeline_->GetNaturalVideoSize(&size); 277 pipeline_->GetNaturalVideoSize(&size);
294 EXPECT_EQ(0, size.width()); 278 EXPECT_EQ(0, size.width());
295 EXPECT_EQ(0, size.height()); 279 EXPECT_EQ(0, size.height());
296 } 280 }
297 281
298 TEST_F(PipelineTest, NeverInitializes) { 282 TEST_F(PipelineTest, NeverInitializes) {
283 // Don't execute the callback passed into Initialize().
284 EXPECT_CALL(*mocks_->demuxer(), Initialize(_));
285 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
286 .WillOnce(Invoke(&RunStopFilterCallback));
287
299 // This test hangs during initialization by never calling 288 // This test hangs during initialization by never calling
300 // InitializationComplete(). StrictMock<> will ensure that the callback is 289 // InitializationComplete(). StrictMock<> will ensure that the callback is
301 // never executed. 290 // never executed.
302 pipeline_->Start( 291 pipeline_->Start(
303 mocks_->filter_collection(false, false, true, PIPELINE_OK).Pass(), 292 mocks_->Create().Pass(),
304 "",
305 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 293 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
306 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 294 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
307 NetworkEventCB(), 295 NetworkEventCB(),
308 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); 296 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
309 message_loop_.RunAllPending(); 297 message_loop_.RunAllPending();
310 298
311 EXPECT_FALSE(pipeline_->IsInitialized()); 299 EXPECT_FALSE(pipeline_->IsInitialized());
312 300
313 // Because our callback will get executed when the test tears down, we'll 301 // Because our callback will get executed when the test tears down, we'll
314 // verify that nothing has been called, then set our expectation for the call 302 // verify that nothing has been called, then set our expectation for the call
315 // made during tear down. 303 // made during tear down.
316 Mock::VerifyAndClear(&callbacks_); 304 Mock::VerifyAndClear(&callbacks_);
317 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); 305 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK));
318 } 306 }
319 307
320 TEST_F(PipelineTest, RequiredFilterMissing) { 308 TEST_F(PipelineTest, RequiredFilterMissing) {
321 // Sets up expectations on the callback and initializes the pipeline. Called 309 // Create a filter collection with missing filter.
322 // after tests have set expectations any filters they wish to use. 310 scoped_ptr<FilterCollection> collection(mocks_->Create());
323 // Expect an initialization callback. 311 collection->SetDemuxer(NULL);
312
324 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); 313 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
325
326 // Create a filter collection with missing filter.
327 scoped_ptr<FilterCollection> collection(mocks_->filter_collection(
328 false, true, true, PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
329 pipeline_->Start( 314 pipeline_->Start(
330 collection.Pass(), 315 collection.Pass(),
331 "", 316 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
332 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 317 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
333 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 318 NetworkEventCB(),
334 NetworkEventCB(), 319 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
335 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
336 message_loop_.RunAllPending(); 320 message_loop_.RunAllPending();
337
338 EXPECT_FALSE(pipeline_->IsInitialized()); 321 EXPECT_FALSE(pipeline_->IsInitialized());
339 } 322 }
340 323
341 TEST_F(PipelineTest, URLNotFound) { 324 TEST_F(PipelineTest, URLNotFound) {
325 EXPECT_CALL(*mocks_->demuxer(), Initialize(_))
326 .WillOnce(RunPipelineStatusCBWithError(
327 PIPELINE_ERROR_URL_NOT_FOUND));
328 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
329 .WillOnce(Invoke(&RunStopFilterCallback));
330
342 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); 331 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND);
343 EXPECT_FALSE(pipeline_->IsInitialized()); 332 EXPECT_FALSE(pipeline_->IsInitialized());
344 } 333 }
345 334
346 TEST_F(PipelineTest, NoStreams) { 335 TEST_F(PipelineTest, NoStreams) {
347 // Manually set these expectations because SetPlaybackRate() is not called if 336 EXPECT_CALL(*mocks_->demuxer(), Initialize(_))
348 // we cannot fully initialize the pipeline. 337 .WillOnce(Invoke(&RunPipelineStatusCB));
349 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) 338 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
350 .WillOnce(Invoke(&RunStopFilterCallback)); 339 .WillOnce(Invoke(&RunStopFilterCallback));
351 InitializePipeline(PIPELINE_OK, PIPELINE_ERROR_COULD_NOT_RENDER); 340
341 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER);
352 EXPECT_FALSE(pipeline_->IsInitialized()); 342 EXPECT_FALSE(pipeline_->IsInitialized());
353 } 343 }
354 344
355 TEST_F(PipelineTest, AudioStream) { 345 TEST_F(PipelineTest, AudioStream) {
356 CreateAudioStream(); 346 CreateAudioStream();
357 MockDemuxerStreamVector streams; 347 MockDemuxerStreamVector streams;
358 streams.push_back(audio_stream()); 348 streams.push_back(audio_stream());
359 349
360 InitializeDemuxer(&streams, base::TimeDelta()); 350 InitializeDemuxer(&streams, base::TimeDelta());
361 InitializeAudioDecoder(audio_stream()); 351 InitializeAudioDecoder(audio_stream());
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 PipelineStatus /* status */) { 732 PipelineStatus /* status */) {
743 CHECK(pipeline); 733 CHECK(pipeline);
744 CHECK(message_loop); 734 CHECK(message_loop);
745 735
746 // When we get to this stage, the message loop should be empty. 736 // When we get to this stage, the message loop should be empty.
747 message_loop->AssertIdle(); 737 message_loop->AssertIdle();
748 738
749 // Make calls on pipeline after error has occurred. 739 // Make calls on pipeline after error has occurred.
750 pipeline->SetPlaybackRate(0.5f); 740 pipeline->SetPlaybackRate(0.5f);
751 pipeline->SetVolume(0.5f); 741 pipeline->SetVolume(0.5f);
752 pipeline->SetPreload(AUTO);
753 742
754 // No additional tasks should be queued as a result of these calls. 743 // No additional tasks should be queued as a result of these calls.
755 message_loop->AssertIdle(); 744 message_loop->AssertIdle();
756 } 745 }
757 746
758 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) { 747 TEST_F(PipelineTest, NoMessageDuringTearDownFromError) {
759 CreateAudioStream(); 748 CreateAudioStream();
760 MockDemuxerStreamVector streams; 749 MockDemuxerStreamVector streams;
761 streams.push_back(audio_stream()); 750 streams.push_back(audio_stream());
762 751
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); 861 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0));
873 } 862 }
874 863
875 // Test that different-thread, some-delay callback (the expected common case) 864 // Test that different-thread, some-delay callback (the expected common case)
876 // works correctly. 865 // works correctly.
877 TEST(PipelineStatusNotificationTest, DelayedCallback) { 866 TEST(PipelineStatusNotificationTest, DelayedCallback) {
878 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); 867 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20));
879 } 868 }
880 869
881 } // namespace media 870 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/base/preload.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698