OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/threading/simple_thread.h" | |
9 #include "media/base/pipeline_impl.h" | 10 #include "media/base/pipeline_impl.h" |
10 #include "media/base/media_format.h" | 11 #include "media/base/media_format.h" |
11 #include "media/base/filters.h" | 12 #include "media/base/filters.h" |
12 #include "media/base/filter_host.h" | 13 #include "media/base/filter_host.h" |
13 #include "media/base/mock_callback.h" | 14 #include "media/base/mock_callback.h" |
14 #include "media/base/mock_filters.h" | 15 #include "media/base/mock_filters.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using ::testing::_; | 18 using ::testing::_; |
18 using ::testing::DeleteArg; | 19 using ::testing::DeleteArg; |
(...skipping 13 matching lines...) Expand all Loading... | |
32 // Buffered bytes of the data source. | 33 // Buffered bytes of the data source. |
33 static const int kBufferedBytes = 1024; | 34 static const int kBufferedBytes = 1024; |
34 | 35 |
35 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 36 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
36 // also lets us test for missing callbacks. | 37 // also lets us test for missing callbacks. |
37 class CallbackHelper { | 38 class CallbackHelper { |
38 public: | 39 public: |
39 CallbackHelper() {} | 40 CallbackHelper() {} |
40 virtual ~CallbackHelper() {} | 41 virtual ~CallbackHelper() {} |
41 | 42 |
42 MOCK_METHOD0(OnStart, void()); | 43 MOCK_METHOD1(OnStart, void(PipelineStatus)); |
43 MOCK_METHOD0(OnSeek, void()); | 44 MOCK_METHOD1(OnSeek, void(PipelineStatus)); |
44 MOCK_METHOD0(OnStop, void()); | 45 MOCK_METHOD1(OnStop, void(PipelineStatus)); |
45 MOCK_METHOD0(OnEnded, void()); | 46 MOCK_METHOD1(OnEnded, void(PipelineStatus)); |
46 MOCK_METHOD0(OnError, void()); | 47 MOCK_METHOD1(OnError, void(PipelineStatus)); |
47 | 48 |
48 private: | 49 private: |
49 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); | 50 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
50 }; | 51 }; |
51 | 52 |
52 // TODO(scherkus): even though some filters are initialized on separate | 53 // TODO(scherkus): even though some filters are initialized on separate |
53 // threads these test aren't flaky... why? It's because filters' Initialize() | 54 // threads these test aren't flaky... why? It's because filters' Initialize() |
54 // is executed on |message_loop_| and the mock filters instantly call | 55 // is executed on |message_loop_| and the mock filters instantly call |
55 // InitializationComplete(), which keeps the pipeline humming along. If | 56 // InitializationComplete(), which keeps the pipeline humming along. If |
56 // either filters don't call InitializationComplete() immediately or filter | 57 // either filters don't call InitializationComplete() immediately or filter |
57 // initialization is moved to a separate thread this test will become flaky. | 58 // initialization is moved to a separate thread this test will become flaky. |
58 class PipelineImplTest : public ::testing::Test { | 59 class PipelineImplTest : public ::testing::Test { |
59 public: | 60 public: |
60 PipelineImplTest() | 61 PipelineImplTest() |
61 : pipeline_(new PipelineImpl(&message_loop_)) { | 62 : pipeline_(new PipelineImpl(&message_loop_)) { |
62 pipeline_->Init( | 63 pipeline_->Init( |
63 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 64 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
64 &CallbackHelper::OnEnded), | 65 &CallbackHelper::OnEnded), |
65 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 66 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
66 &CallbackHelper::OnError), | 67 &CallbackHelper::OnError), |
67 NULL); | 68 static_cast<PipelineStatusCallback*>(NULL)); |
68 mocks_.reset(new MockFilterCollection()); | 69 mocks_.reset(new MockFilterCollection()); |
69 } | 70 } |
70 | 71 |
71 virtual ~PipelineImplTest() { | 72 virtual ~PipelineImplTest() { |
72 if (!pipeline_->IsRunning()) { | 73 if (!pipeline_->IsRunning()) { |
73 return; | 74 return; |
74 } | 75 } |
75 | 76 |
76 // Expect a stop callback if we were started. | 77 // Expect a stop callback if we were started. |
77 EXPECT_CALL(callbacks_, OnStop()); | 78 EXPECT_CALL(callbacks_, OnStop(PIPELINE_OK)); |
78 pipeline_->Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 79 pipeline_->Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
79 &CallbackHelper::OnStop)); | 80 &CallbackHelper::OnStop)); |
80 message_loop_.RunAllPending(); | 81 message_loop_.RunAllPending(); |
81 | 82 |
82 mocks_.reset(); | 83 mocks_.reset(); |
83 } | 84 } |
84 | 85 |
85 protected: | 86 protected: |
86 // Sets up expectations to allow the demuxer to initialize. | 87 // Sets up expectations to allow the demuxer to initialize. |
87 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 88 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) | 169 EXPECT_CALL(*mocks_->audio_renderer(), Stop(NotNull())) |
169 .WillOnce(Invoke(&RunStopFilterCallback)); | 170 .WillOnce(Invoke(&RunStopFilterCallback)); |
170 } | 171 } |
171 | 172 |
172 // Sets up expectations on the callback and initializes the pipeline. Called | 173 // Sets up expectations on the callback and initializes the pipeline. Called |
173 // after tests have set expectations any filters they wish to use. | 174 // after tests have set expectations any filters they wish to use. |
174 void InitializePipeline() { | 175 void InitializePipeline() { |
175 InitializePipeline(PIPELINE_OK); | 176 InitializePipeline(PIPELINE_OK); |
176 } | 177 } |
177 | 178 |
178 void InitializePipeline(PipelineError factory_error) { | 179 void InitializePipeline(PipelineStatus start_status) { |
179 // Expect an initialization callback. | 180 // Expect an initialization callback. |
180 EXPECT_CALL(callbacks_, OnStart()); | 181 EXPECT_CALL(callbacks_, OnStart(start_status)); |
181 pipeline_->Start(mocks_->filter_collection(true, true, factory_error), | 182 pipeline_->Start(mocks_->filter_collection(), "", |
182 "", | |
183 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 183 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
184 &CallbackHelper::OnStart)); | 184 &CallbackHelper::OnStart)); |
185 message_loop_.RunAllPending(); | 185 message_loop_.RunAllPending(); |
186 } | 186 } |
187 | 187 |
188 void CreateAudioStream() { | 188 void CreateAudioStream() { |
189 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 189 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
190 } | 190 } |
191 | 191 |
192 void CreateVideoStream() { | 192 void CreateVideoStream() { |
(...skipping 21 matching lines...) Expand all Loading... | |
214 } | 214 } |
215 | 215 |
216 if (video_stream_) { | 216 if (video_stream_) { |
217 EXPECT_CALL(*mocks_->video_decoder(), Seek(seek_time, NotNull())) | 217 EXPECT_CALL(*mocks_->video_decoder(), Seek(seek_time, NotNull())) |
218 .WillOnce(Invoke(&RunFilterCallback)); | 218 .WillOnce(Invoke(&RunFilterCallback)); |
219 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, NotNull())) | 219 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, NotNull())) |
220 .WillOnce(Invoke(&RunFilterCallback)); | 220 .WillOnce(Invoke(&RunFilterCallback)); |
221 } | 221 } |
222 | 222 |
223 // We expect a successful seek callback. | 223 // We expect a successful seek callback. |
224 EXPECT_CALL(callbacks_, OnSeek()); | 224 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
225 | 225 |
226 } | 226 } |
227 | 227 |
228 void DoSeek(const base::TimeDelta& seek_time) { | 228 void DoSeek(const base::TimeDelta& seek_time) { |
229 pipeline_->Seek(seek_time, | 229 pipeline_->Seek(seek_time, |
230 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 230 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
231 &CallbackHelper::OnSeek)); | 231 &CallbackHelper::OnSeek)); |
232 | 232 |
233 // We expect the time to be updated only after the seek has completed. | 233 // We expect the time to be updated only after the seek has completed. |
234 EXPECT_NE(seek_time, pipeline_->GetCurrentTime()); | 234 EXPECT_NE(seek_time, pipeline_->GetCurrentTime()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 286 |
287 EXPECT_EQ(0, pipeline_->GetBufferedBytes()); | 287 EXPECT_EQ(0, pipeline_->GetBufferedBytes()); |
288 EXPECT_EQ(0, pipeline_->GetTotalBytes()); | 288 EXPECT_EQ(0, pipeline_->GetTotalBytes()); |
289 | 289 |
290 // Should always get set to zero. | 290 // Should always get set to zero. |
291 size_t width = 1u; | 291 size_t width = 1u; |
292 size_t height = 1u; | 292 size_t height = 1u; |
293 pipeline_->GetVideoSize(&width, &height); | 293 pipeline_->GetVideoSize(&width, &height); |
294 EXPECT_EQ(0u, width); | 294 EXPECT_EQ(0u, width); |
295 EXPECT_EQ(0u, height); | 295 EXPECT_EQ(0u, height); |
296 | |
297 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
298 } | 296 } |
299 | 297 |
300 TEST_F(PipelineImplTest, NeverInitializes) { | 298 TEST_F(PipelineImplTest, NeverInitializes) { |
301 // This test hangs during initialization by never calling | 299 // This test hangs during initialization by never calling |
302 // InitializationComplete(). StrictMock<> will ensure that the callback is | 300 // InitializationComplete(). StrictMock<> will ensure that the callback is |
303 // never executed. | 301 // never executed. |
304 pipeline_->Start(mocks_->filter_collection(false, false, PIPELINE_OK), "", | 302 pipeline_->Start(mocks_->filter_collection(false, false, PIPELINE_OK), "", |
305 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 303 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
306 &CallbackHelper::OnStart)); | 304 &CallbackHelper::OnStart)); |
307 message_loop_.RunAllPending(); | 305 message_loop_.RunAllPending(); |
308 | 306 |
309 EXPECT_FALSE(pipeline_->IsInitialized()); | 307 EXPECT_FALSE(pipeline_->IsInitialized()); |
310 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
311 | 308 |
312 // Because our callback will get executed when the test tears down, we'll | 309 // Because our callback will get executed when the test tears down, we'll |
313 // verify that nothing has been called, then set our expectation for the call | 310 // verify that nothing has been called, then set our expectation for the call |
314 // made during tear down. | 311 // made during tear down. |
315 Mock::VerifyAndClear(&callbacks_); | 312 Mock::VerifyAndClear(&callbacks_); |
316 EXPECT_CALL(callbacks_, OnStart()); | 313 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
317 } | 314 } |
318 | 315 |
319 TEST_F(PipelineImplTest, RequiredFilterMissing) { | 316 TEST_F(PipelineImplTest, RequiredFilterMissing) { |
320 EXPECT_CALL(callbacks_, OnError()); | 317 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
321 | 318 |
322 // Sets up expectations on the callback and initializes the pipeline. Called | 319 // Sets up expectations on the callback and initializes the pipeline. Called |
323 // after tests have set expectations any filters they wish to use. | 320 // after tests have set expectations any filters they wish to use. |
324 // Expect an initialization callback. | 321 // Expect an initialization callback. |
325 EXPECT_CALL(callbacks_, OnStart()); | 322 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
326 | 323 |
327 // Create a filter collection with missing filter. | 324 // Create a filter collection with missing filter. |
328 FilterCollection* collection = | 325 FilterCollection* collection = |
329 mocks_->filter_collection(false, true, | 326 mocks_->filter_collection(false, true, |
330 PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 327 PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
331 pipeline_->Start(collection, "", | 328 pipeline_->Start(collection, "", |
332 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 329 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
333 &CallbackHelper::OnStart)); | 330 &CallbackHelper::OnStart)); |
334 message_loop_.RunAllPending(); | 331 message_loop_.RunAllPending(); |
335 | 332 |
336 EXPECT_FALSE(pipeline_->IsInitialized()); | 333 EXPECT_FALSE(pipeline_->IsInitialized()); |
337 EXPECT_EQ(PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | |
338 pipeline_->GetError()); | |
339 } | |
340 | |
341 TEST_F(PipelineImplTest, URLNotFound) { | |
acolwell GONE FROM CHROMIUM
2011/03/15 03:56:28
Was this test delete by accident?
Ami GONE FROM CHROMIUM
2011/03/15 17:37:18
Apparently so.
| |
342 | |
343 EXPECT_CALL(callbacks_, OnError()); | |
344 | |
345 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); | |
346 EXPECT_FALSE(pipeline_->IsInitialized()); | |
347 EXPECT_EQ(PIPELINE_ERROR_URL_NOT_FOUND, pipeline_->GetError()); | |
348 } | 334 } |
349 | 335 |
350 TEST_F(PipelineImplTest, NoStreams) { | 336 TEST_F(PipelineImplTest, NoStreams) { |
351 // Manually set these expectations because SetPlaybackRate() is not called if | 337 // Manually set these expectations because SetPlaybackRate() is not called if |
352 // we cannot fully initialize the pipeline. | 338 // we cannot fully initialize the pipeline. |
353 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) | 339 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) |
354 .WillRepeatedly(Return(0)); | 340 .WillRepeatedly(Return(0)); |
355 EXPECT_CALL(*mocks_->demuxer(), Stop(NotNull())) | 341 EXPECT_CALL(*mocks_->demuxer(), Stop(NotNull())) |
356 .WillOnce(Invoke(&RunStopFilterCallback)); | 342 .WillOnce(Invoke(&RunStopFilterCallback)); |
357 EXPECT_CALL(callbacks_, OnError()); | 343 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_COULD_NOT_RENDER)); |
358 | 344 |
359 InitializePipeline(); | 345 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); |
360 EXPECT_FALSE(pipeline_->IsInitialized()); | 346 EXPECT_FALSE(pipeline_->IsInitialized()); |
361 EXPECT_EQ(PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_->GetError()); | |
362 } | 347 } |
363 | 348 |
364 TEST_F(PipelineImplTest, AudioStream) { | 349 TEST_F(PipelineImplTest, AudioStream) { |
365 CreateAudioStream(); | 350 CreateAudioStream(); |
366 MockDemuxerStreamVector streams; | 351 MockDemuxerStreamVector streams; |
367 streams.push_back(audio_stream()); | 352 streams.push_back(audio_stream()); |
368 | 353 |
369 InitializeDemuxer(&streams, base::TimeDelta()); | 354 InitializeDemuxer(&streams, base::TimeDelta()); |
370 InitializeAudioDecoder(audio_stream()); | 355 InitializeAudioDecoder(audio_stream()); |
371 InitializeAudioRenderer(); | 356 InitializeAudioRenderer(); |
372 | 357 |
373 InitializePipeline(); | 358 InitializePipeline(PIPELINE_OK); |
374 EXPECT_TRUE(pipeline_->IsInitialized()); | 359 EXPECT_TRUE(pipeline_->IsInitialized()); |
375 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
376 EXPECT_TRUE(pipeline_->HasAudio()); | 360 EXPECT_TRUE(pipeline_->HasAudio()); |
377 EXPECT_FALSE(pipeline_->HasVideo()); | 361 EXPECT_FALSE(pipeline_->HasVideo()); |
378 } | 362 } |
379 | 363 |
380 TEST_F(PipelineImplTest, VideoStream) { | 364 TEST_F(PipelineImplTest, VideoStream) { |
381 CreateVideoStream(); | 365 CreateVideoStream(); |
382 MockDemuxerStreamVector streams; | 366 MockDemuxerStreamVector streams; |
383 streams.push_back(video_stream()); | 367 streams.push_back(video_stream()); |
384 | 368 |
385 InitializeDemuxer(&streams, base::TimeDelta()); | 369 InitializeDemuxer(&streams, base::TimeDelta()); |
386 InitializeVideoDecoder(video_stream()); | 370 InitializeVideoDecoder(video_stream()); |
387 InitializeVideoRenderer(); | 371 InitializeVideoRenderer(); |
388 | 372 |
389 InitializePipeline(); | 373 InitializePipeline(PIPELINE_OK); |
390 EXPECT_TRUE(pipeline_->IsInitialized()); | 374 EXPECT_TRUE(pipeline_->IsInitialized()); |
391 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
392 EXPECT_FALSE(pipeline_->HasAudio()); | 375 EXPECT_FALSE(pipeline_->HasAudio()); |
393 EXPECT_TRUE(pipeline_->HasVideo()); | 376 EXPECT_TRUE(pipeline_->HasVideo()); |
394 } | 377 } |
395 | 378 |
396 TEST_F(PipelineImplTest, AudioVideoStream) { | 379 TEST_F(PipelineImplTest, AudioVideoStream) { |
397 CreateAudioStream(); | 380 CreateAudioStream(); |
398 CreateVideoStream(); | 381 CreateVideoStream(); |
399 MockDemuxerStreamVector streams; | 382 MockDemuxerStreamVector streams; |
400 streams.push_back(audio_stream()); | 383 streams.push_back(audio_stream()); |
401 streams.push_back(video_stream()); | 384 streams.push_back(video_stream()); |
402 | 385 |
403 InitializeDemuxer(&streams, base::TimeDelta()); | 386 InitializeDemuxer(&streams, base::TimeDelta()); |
404 InitializeAudioDecoder(audio_stream()); | 387 InitializeAudioDecoder(audio_stream()); |
405 InitializeAudioRenderer(); | 388 InitializeAudioRenderer(); |
406 InitializeVideoDecoder(video_stream()); | 389 InitializeVideoDecoder(video_stream()); |
407 InitializeVideoRenderer(); | 390 InitializeVideoRenderer(); |
408 | 391 |
409 InitializePipeline(); | 392 InitializePipeline(PIPELINE_OK); |
410 EXPECT_TRUE(pipeline_->IsInitialized()); | 393 EXPECT_TRUE(pipeline_->IsInitialized()); |
411 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
412 EXPECT_TRUE(pipeline_->HasAudio()); | 394 EXPECT_TRUE(pipeline_->HasAudio()); |
413 EXPECT_TRUE(pipeline_->HasVideo()); | 395 EXPECT_TRUE(pipeline_->HasVideo()); |
414 } | 396 } |
415 | 397 |
416 TEST_F(PipelineImplTest, Seek) { | 398 TEST_F(PipelineImplTest, Seek) { |
417 CreateAudioStream(); | 399 CreateAudioStream(); |
418 CreateVideoStream(); | 400 CreateVideoStream(); |
419 MockDemuxerStreamVector streams; | 401 MockDemuxerStreamVector streams; |
420 streams.push_back(audio_stream()); | 402 streams.push_back(audio_stream()); |
421 streams.push_back(video_stream()); | 403 streams.push_back(video_stream()); |
422 | 404 |
423 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); | 405 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(3000)); |
424 InitializeAudioDecoder(audio_stream()); | 406 InitializeAudioDecoder(audio_stream()); |
425 InitializeAudioRenderer(); | 407 InitializeAudioRenderer(); |
426 InitializeVideoDecoder(video_stream()); | 408 InitializeVideoDecoder(video_stream()); |
427 InitializeVideoRenderer(); | 409 InitializeVideoRenderer(); |
428 | 410 |
429 // Every filter should receive a call to Seek(). | 411 // Every filter should receive a call to Seek(). |
430 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); | 412 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); |
431 ExpectSeek(expected); | 413 ExpectSeek(expected); |
432 | 414 |
433 // Initialize then seek! | 415 // Initialize then seek! |
434 InitializePipeline(); | 416 InitializePipeline(PIPELINE_OK); |
435 DoSeek(expected); | 417 DoSeek(expected); |
436 } | 418 } |
437 | 419 |
438 TEST_F(PipelineImplTest, SetVolume) { | 420 TEST_F(PipelineImplTest, SetVolume) { |
439 CreateAudioStream(); | 421 CreateAudioStream(); |
440 MockDemuxerStreamVector streams; | 422 MockDemuxerStreamVector streams; |
441 streams.push_back(audio_stream()); | 423 streams.push_back(audio_stream()); |
442 | 424 |
443 InitializeDemuxer(&streams, base::TimeDelta()); | 425 InitializeDemuxer(&streams, base::TimeDelta()); |
444 InitializeAudioDecoder(audio_stream()); | 426 InitializeAudioDecoder(audio_stream()); |
445 InitializeAudioRenderer(); | 427 InitializeAudioRenderer(); |
446 | 428 |
447 // The audio renderer should receive a call to SetVolume(). | 429 // The audio renderer should receive a call to SetVolume(). |
448 float expected = 0.5f; | 430 float expected = 0.5f; |
449 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); | 431 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); |
450 | 432 |
451 // Initialize then set volume! | 433 // Initialize then set volume! |
452 InitializePipeline(); | 434 InitializePipeline(PIPELINE_OK); |
453 pipeline_->SetVolume(expected); | 435 pipeline_->SetVolume(expected); |
454 } | 436 } |
455 | 437 |
456 TEST_F(PipelineImplTest, Properties) { | 438 TEST_F(PipelineImplTest, Properties) { |
457 CreateVideoStream(); | 439 CreateVideoStream(); |
458 MockDemuxerStreamVector streams; | 440 MockDemuxerStreamVector streams; |
459 streams.push_back(video_stream()); | 441 streams.push_back(video_stream()); |
460 | 442 |
461 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 443 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
462 InitializeDemuxer(&streams, kDuration); | 444 InitializeDemuxer(&streams, kDuration); |
463 InitializeVideoDecoder(video_stream()); | 445 InitializeVideoDecoder(video_stream()); |
464 InitializeVideoRenderer(); | 446 InitializeVideoRenderer(); |
465 | 447 |
466 InitializePipeline(); | 448 InitializePipeline(PIPELINE_OK); |
467 EXPECT_TRUE(pipeline_->IsInitialized()); | 449 EXPECT_TRUE(pipeline_->IsInitialized()); |
468 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
469 EXPECT_EQ(kDuration.ToInternalValue(), | 450 EXPECT_EQ(kDuration.ToInternalValue(), |
470 pipeline_->GetMediaDuration().ToInternalValue()); | 451 pipeline_->GetMediaDuration().ToInternalValue()); |
471 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); | 452 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); |
472 EXPECT_EQ(kBufferedBytes, pipeline_->GetBufferedBytes()); | 453 EXPECT_EQ(kBufferedBytes, pipeline_->GetBufferedBytes()); |
473 | 454 |
474 // Because kTotalBytes and kBufferedBytes are equal to each other, | 455 // Because kTotalBytes and kBufferedBytes are equal to each other, |
475 // the entire video should be buffered. | 456 // the entire video should be buffered. |
476 EXPECT_EQ(kDuration.ToInternalValue(), | 457 EXPECT_EQ(kDuration.ToInternalValue(), |
477 pipeline_->GetBufferedTime().ToInternalValue()); | 458 pipeline_->GetBufferedTime().ToInternalValue()); |
478 } | 459 } |
479 | 460 |
480 TEST_F(PipelineImplTest, GetBufferedTime) { | 461 TEST_F(PipelineImplTest, GetBufferedTime) { |
481 CreateVideoStream(); | 462 CreateVideoStream(); |
482 MockDemuxerStreamVector streams; | 463 MockDemuxerStreamVector streams; |
483 streams.push_back(video_stream()); | 464 streams.push_back(video_stream()); |
484 | 465 |
485 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); | 466 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); |
486 InitializeDemuxer(&streams, kDuration); | 467 InitializeDemuxer(&streams, kDuration); |
487 InitializeVideoDecoder(video_stream()); | 468 InitializeVideoDecoder(video_stream()); |
488 InitializeVideoRenderer(); | 469 InitializeVideoRenderer(); |
489 | 470 |
490 InitializePipeline(); | 471 InitializePipeline(PIPELINE_OK); |
491 EXPECT_TRUE(pipeline_->IsInitialized()); | 472 EXPECT_TRUE(pipeline_->IsInitialized()); |
492 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
493 | 473 |
494 // TODO(vrk): The following mini-test cases are order-dependent, and should | 474 // TODO(vrk): The following mini-test cases are order-dependent, and should |
495 // probably be separated into independent test cases. | 475 // probably be separated into independent test cases. |
496 | 476 |
497 // Buffered time is 0 if no bytes are buffered. | 477 // Buffered time is 0 if no bytes are buffered. |
498 pipeline_->SetBufferedBytes(0); | 478 pipeline_->SetBufferedBytes(0); |
499 EXPECT_EQ(0, pipeline_->GetBufferedTime().ToInternalValue()); | 479 EXPECT_EQ(0, pipeline_->GetBufferedTime().ToInternalValue()); |
500 | 480 |
501 // We should return buffered_time_ if it is set, valid and less than | 481 // We should return buffered_time_ if it is set, valid and less than |
502 // the current time. | 482 // the current time. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 MockDemuxerStreamVector streams; | 530 MockDemuxerStreamVector streams; |
551 streams.push_back(audio_stream()); | 531 streams.push_back(audio_stream()); |
552 streams.push_back(video_stream()); | 532 streams.push_back(video_stream()); |
553 | 533 |
554 InitializeDemuxer(&streams, base::TimeDelta()); | 534 InitializeDemuxer(&streams, base::TimeDelta()); |
555 InitializeAudioDecoder(audio_stream()); | 535 InitializeAudioDecoder(audio_stream()); |
556 InitializeAudioRenderer(); | 536 InitializeAudioRenderer(); |
557 InitializeVideoDecoder(video_stream()); | 537 InitializeVideoDecoder(video_stream()); |
558 InitializeVideoRenderer(); | 538 InitializeVideoRenderer(); |
559 | 539 |
560 InitializePipeline(); | 540 InitializePipeline(PIPELINE_OK); |
561 EXPECT_TRUE(pipeline_->IsInitialized()); | 541 EXPECT_TRUE(pipeline_->IsInitialized()); |
562 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
563 EXPECT_TRUE(pipeline_->HasAudio()); | 542 EXPECT_TRUE(pipeline_->HasAudio()); |
564 EXPECT_TRUE(pipeline_->HasVideo()); | 543 EXPECT_TRUE(pipeline_->HasVideo()); |
565 | 544 |
566 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f)) | 545 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f)) |
567 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer())); | 546 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer())); |
568 EXPECT_CALL(*mocks_->demuxer(), | 547 EXPECT_CALL(*mocks_->demuxer(), |
569 OnAudioRendererDisabled()); | 548 OnAudioRendererDisabled()); |
570 EXPECT_CALL(*mocks_->audio_decoder(), | 549 EXPECT_CALL(*mocks_->audio_decoder(), |
571 OnAudioRendererDisabled()); | 550 OnAudioRendererDisabled()); |
572 EXPECT_CALL(*mocks_->audio_renderer(), | 551 EXPECT_CALL(*mocks_->audio_renderer(), |
573 OnAudioRendererDisabled()); | 552 OnAudioRendererDisabled()); |
574 EXPECT_CALL(*mocks_->video_decoder(), | 553 EXPECT_CALL(*mocks_->video_decoder(), |
575 OnAudioRendererDisabled()); | 554 OnAudioRendererDisabled()); |
576 EXPECT_CALL(*mocks_->video_renderer(), | 555 EXPECT_CALL(*mocks_->video_renderer(), |
577 OnAudioRendererDisabled()); | 556 OnAudioRendererDisabled()); |
578 | 557 |
579 mocks_->audio_renderer()->SetPlaybackRate(1.0f); | 558 mocks_->audio_renderer()->SetPlaybackRate(1.0f); |
580 | 559 |
581 // Verify that ended event is fired when video ends. | 560 // Verify that ended event is fired when video ends. |
582 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 561 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
583 .WillOnce(Return(true)); | 562 .WillOnce(Return(true)); |
584 EXPECT_CALL(callbacks_, OnEnded()); | 563 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
585 FilterHost* host = pipeline_; | 564 FilterHost* host = pipeline_; |
586 host->NotifyEnded(); | 565 host->NotifyEnded(); |
587 } | 566 } |
588 | 567 |
589 TEST_F(PipelineImplTest, DisableAudioRendererDuringInit) { | 568 TEST_F(PipelineImplTest, DisableAudioRendererDuringInit) { |
590 CreateAudioStream(); | 569 CreateAudioStream(); |
591 CreateVideoStream(); | 570 CreateVideoStream(); |
592 MockDemuxerStreamVector streams; | 571 MockDemuxerStreamVector streams; |
593 streams.push_back(audio_stream()); | 572 streams.push_back(audio_stream()); |
594 streams.push_back(video_stream()); | 573 streams.push_back(video_stream()); |
595 | 574 |
596 InitializeDemuxer(&streams, base::TimeDelta()); | 575 InitializeDemuxer(&streams, base::TimeDelta()); |
597 InitializeAudioDecoder(audio_stream()); | 576 InitializeAudioDecoder(audio_stream()); |
598 InitializeAudioRenderer(true); | 577 InitializeAudioRenderer(true); |
599 InitializeVideoDecoder(video_stream()); | 578 InitializeVideoDecoder(video_stream()); |
600 InitializeVideoRenderer(); | 579 InitializeVideoRenderer(); |
601 | 580 |
602 EXPECT_CALL(*mocks_->demuxer(), | 581 EXPECT_CALL(*mocks_->demuxer(), |
603 OnAudioRendererDisabled()); | 582 OnAudioRendererDisabled()); |
604 EXPECT_CALL(*mocks_->audio_decoder(), | 583 EXPECT_CALL(*mocks_->audio_decoder(), |
605 OnAudioRendererDisabled()); | 584 OnAudioRendererDisabled()); |
606 EXPECT_CALL(*mocks_->audio_renderer(), | 585 EXPECT_CALL(*mocks_->audio_renderer(), |
607 OnAudioRendererDisabled()); | 586 OnAudioRendererDisabled()); |
608 EXPECT_CALL(*mocks_->video_decoder(), | 587 EXPECT_CALL(*mocks_->video_decoder(), |
609 OnAudioRendererDisabled()); | 588 OnAudioRendererDisabled()); |
610 EXPECT_CALL(*mocks_->video_renderer(), | 589 EXPECT_CALL(*mocks_->video_renderer(), |
611 OnAudioRendererDisabled()); | 590 OnAudioRendererDisabled()); |
612 | 591 |
613 InitializePipeline(); | 592 InitializePipeline(PIPELINE_OK); |
614 EXPECT_TRUE(pipeline_->IsInitialized()); | 593 EXPECT_TRUE(pipeline_->IsInitialized()); |
615 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); | |
616 EXPECT_FALSE(pipeline_->HasAudio()); | 594 EXPECT_FALSE(pipeline_->HasAudio()); |
617 EXPECT_TRUE(pipeline_->HasVideo()); | 595 EXPECT_TRUE(pipeline_->HasVideo()); |
618 | 596 |
619 // Verify that ended event is fired when video ends. | 597 // Verify that ended event is fired when video ends. |
620 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 598 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
621 .WillOnce(Return(true)); | 599 .WillOnce(Return(true)); |
622 EXPECT_CALL(callbacks_, OnEnded()); | 600 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
623 FilterHost* host = pipeline_; | 601 FilterHost* host = pipeline_; |
624 host->NotifyEnded(); | 602 host->NotifyEnded(); |
625 } | 603 } |
626 | 604 |
627 TEST_F(PipelineImplTest, EndedCallback) { | 605 TEST_F(PipelineImplTest, EndedCallback) { |
628 CreateAudioStream(); | 606 CreateAudioStream(); |
629 CreateVideoStream(); | 607 CreateVideoStream(); |
630 MockDemuxerStreamVector streams; | 608 MockDemuxerStreamVector streams; |
631 streams.push_back(audio_stream()); | 609 streams.push_back(audio_stream()); |
632 streams.push_back(video_stream()); | 610 streams.push_back(video_stream()); |
633 | 611 |
634 InitializeDemuxer(&streams, base::TimeDelta()); | 612 InitializeDemuxer(&streams, base::TimeDelta()); |
635 InitializeAudioDecoder(audio_stream()); | 613 InitializeAudioDecoder(audio_stream()); |
636 InitializeAudioRenderer(); | 614 InitializeAudioRenderer(); |
637 InitializeVideoDecoder(video_stream()); | 615 InitializeVideoDecoder(video_stream()); |
638 InitializeVideoRenderer(); | 616 InitializeVideoRenderer(); |
639 InitializePipeline(); | 617 InitializePipeline(PIPELINE_OK); |
640 | 618 |
641 // For convenience to simulate filters calling the methods. | 619 // For convenience to simulate filters calling the methods. |
642 FilterHost* host = pipeline_; | 620 FilterHost* host = pipeline_; |
643 | 621 |
644 // Due to short circuit evaluation we only need to test a subset of cases. | 622 // Due to short circuit evaluation we only need to test a subset of cases. |
645 InSequence s; | 623 InSequence s; |
646 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 624 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
647 .WillOnce(Return(false)); | 625 .WillOnce(Return(false)); |
648 host->NotifyEnded(); | 626 host->NotifyEnded(); |
649 | 627 |
650 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 628 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
651 .WillOnce(Return(true)); | 629 .WillOnce(Return(true)); |
652 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 630 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
653 .WillOnce(Return(false)); | 631 .WillOnce(Return(false)); |
654 host->NotifyEnded(); | 632 host->NotifyEnded(); |
655 | 633 |
656 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 634 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
657 .WillOnce(Return(true)); | 635 .WillOnce(Return(true)); |
658 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 636 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
659 .WillOnce(Return(true)); | 637 .WillOnce(Return(true)); |
660 EXPECT_CALL(callbacks_, OnEnded()); | 638 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
661 host->NotifyEnded(); | 639 host->NotifyEnded(); |
662 } | 640 } |
663 | 641 |
664 // Static function & time variable used to simulate changes in wallclock time. | 642 // Static function & time variable used to simulate changes in wallclock time. |
665 static int64 g_static_clock_time; | 643 static int64 g_static_clock_time; |
666 static base::Time StaticClockFunction() { | 644 static base::Time StaticClockFunction() { |
667 return base::Time::FromInternalValue(g_static_clock_time); | 645 return base::Time::FromInternalValue(g_static_clock_time); |
668 } | 646 } |
669 | 647 |
670 TEST_F(PipelineImplTest, AudioStreamShorterThanVideo) { | 648 TEST_F(PipelineImplTest, AudioStreamShorterThanVideo) { |
671 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); | 649 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); |
672 | 650 |
673 CreateAudioStream(); | 651 CreateAudioStream(); |
674 CreateVideoStream(); | 652 CreateVideoStream(); |
675 MockDemuxerStreamVector streams; | 653 MockDemuxerStreamVector streams; |
676 streams.push_back(audio_stream()); | 654 streams.push_back(audio_stream()); |
677 streams.push_back(video_stream()); | 655 streams.push_back(video_stream()); |
678 | 656 |
679 InitializeDemuxer(&streams, duration); | 657 InitializeDemuxer(&streams, duration); |
680 InitializeAudioDecoder(audio_stream()); | 658 InitializeAudioDecoder(audio_stream()); |
681 InitializeAudioRenderer(); | 659 InitializeAudioRenderer(); |
682 InitializeVideoDecoder(video_stream()); | 660 InitializeVideoDecoder(video_stream()); |
683 InitializeVideoRenderer(); | 661 InitializeVideoRenderer(); |
684 InitializePipeline(); | 662 InitializePipeline(PIPELINE_OK); |
685 | 663 |
686 // For convenience to simulate filters calling the methods. | 664 // For convenience to simulate filters calling the methods. |
687 FilterHost* host = pipeline_; | 665 FilterHost* host = pipeline_; |
688 | 666 |
689 // Replace the clock so we can simulate wallclock time advancing w/o using | 667 // Replace the clock so we can simulate wallclock time advancing w/o using |
690 // Sleep(). | 668 // Sleep(). |
691 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); | 669 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); |
692 | 670 |
693 EXPECT_EQ(0, host->GetTime().ToInternalValue()); | 671 EXPECT_EQ(0, host->GetTime().ToInternalValue()); |
694 | 672 |
(...skipping 27 matching lines...) Expand all Loading... | |
722 start_time = host->GetTime().ToInternalValue(); | 700 start_time = host->GetTime().ToInternalValue(); |
723 g_static_clock_time += | 701 g_static_clock_time += |
724 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); | 702 base::TimeDelta::FromMilliseconds(100).ToInternalValue(); |
725 EXPECT_GT(host->GetTime().ToInternalValue(), start_time); | 703 EXPECT_GT(host->GetTime().ToInternalValue(), start_time); |
726 | 704 |
727 // Signal end of video stream and make sure OnEnded() callback occurs. | 705 // Signal end of video stream and make sure OnEnded() callback occurs. |
728 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) | 706 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) |
729 .WillOnce(Return(true)); | 707 .WillOnce(Return(true)); |
730 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 708 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
731 .WillOnce(Return(true)); | 709 .WillOnce(Return(true)); |
732 EXPECT_CALL(callbacks_, OnEnded()); | 710 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
733 host->NotifyEnded(); | 711 host->NotifyEnded(); |
734 } | 712 } |
735 | 713 |
736 TEST_F(PipelineImplTest, ErrorDuringSeek) { | 714 TEST_F(PipelineImplTest, ErrorDuringSeek) { |
737 CreateAudioStream(); | 715 CreateAudioStream(); |
738 MockDemuxerStreamVector streams; | 716 MockDemuxerStreamVector streams; |
739 streams.push_back(audio_stream()); | 717 streams.push_back(audio_stream()); |
740 | 718 |
741 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(10)); | 719 InitializeDemuxer(&streams, base::TimeDelta::FromSeconds(10)); |
742 InitializeAudioDecoder(audio_stream()); | 720 InitializeAudioDecoder(audio_stream()); |
743 InitializeAudioRenderer(); | 721 InitializeAudioRenderer(); |
744 InitializePipeline(); | 722 InitializePipeline(PIPELINE_OK); |
745 | 723 |
746 float playback_rate = 1.0f; | 724 float playback_rate = 1.0f; |
747 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 725 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
748 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); | 726 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); |
749 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 727 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
750 pipeline_->SetPlaybackRate(playback_rate); | 728 pipeline_->SetPlaybackRate(playback_rate); |
751 message_loop_.RunAllPending(); | 729 message_loop_.RunAllPending(); |
752 | 730 |
753 InSequence s; | 731 InSequence s; |
754 | 732 |
755 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); | 733 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); |
756 | 734 |
757 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, NotNull())) | 735 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, NotNull())) |
758 .WillOnce(DoAll(SetError(mocks_->demuxer(), | 736 .WillOnce(DoAll(SetError(mocks_->demuxer(), |
759 PIPELINE_ERROR_READ), | 737 PIPELINE_ERROR_READ), |
760 Invoke(&RunFilterCallback))); | 738 Invoke(&RunFilterCallback))); |
761 | 739 |
762 pipeline_->Seek(seek_time, NewExpectedCallback()); | 740 pipeline_->Seek(seek_time, NewCallback( |
763 EXPECT_CALL(callbacks_, OnError()); | 741 reinterpret_cast<CallbackHelper*>(&callbacks_), &CallbackHelper::OnSeek)); |
742 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)); | |
743 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ)); | |
764 message_loop_.RunAllPending(); | 744 message_loop_.RunAllPending(); |
765 } | 745 } |
766 | 746 |
747 class FlexibleCallbackRunner : public base::DelegateSimpleThread::Delegate { | |
748 public: | |
749 FlexibleCallbackRunner(base::TimeDelta delay, PipelineStatus status, | |
acolwell GONE FROM CHROMIUM
2011/03/15 03:56:28
How about just an int called delayInMs? It would r
Ami GONE FROM CHROMIUM
2011/03/15 17:37:18
Nice catch.
| |
750 PipelineStatusCallback* callback) | |
751 : delay_(delay), status_(status), callback_(callback) { | |
752 if (delay_.InMilliseconds() < 0) { | |
753 callback_->Run(status_); | |
754 return; | |
755 } | |
756 } | |
757 virtual void Run() { | |
758 if (delay_.InMilliseconds() < 0) return; | |
759 base::PlatformThread::Sleep(static_cast<int>(delay_.InMilliseconds())); | |
760 callback_->Run(status_); | |
761 } | |
762 | |
763 private: | |
764 base::TimeDelta delay_; | |
765 PipelineStatus status_; | |
766 PipelineStatusCallback* callback_; | |
767 }; | |
768 | |
769 void TestPipelineStatusNotification(base::TimeDelta delay) { | |
770 PipelineStatusNotification note; | |
771 // Arbitrary error value we expect to fish out of the notification after the | |
772 // callback is fired. | |
773 const PipelineStatus expected_error = PIPELINE_ERROR_URL_NOT_FOUND; | |
774 FlexibleCallbackRunner runner(delay, expected_error, note.Callback()); | |
775 base::DelegateSimpleThread thread(&runner, "FlexibleCallbackRunner"); | |
776 thread.Start(); | |
777 note.Wait(); | |
778 EXPECT_EQ(note.status(), expected_error); | |
779 thread.Join(); | |
780 } | |
781 | |
782 // Test that in-line callback (same thread, no yield) works correctly. | |
783 TEST(PipelineStatusNotificationTest, InlineCallback) { | |
784 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(-1)); | |
785 } | |
786 | |
787 // Test that different-thread, no-delay callback works correctly. | |
788 TEST(PipelineStatusNotificationTest, ImmediateCallback) { | |
789 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | |
790 } | |
791 | |
792 // Test that different-thread, some-delay callback (the expected common case) | |
793 // works correctly. | |
794 TEST(PipelineStatusNotificationTest, DelayedCallback) { | |
795 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | |
796 } | |
797 | |
767 } // namespace media | 798 } // namespace media |
OLD | NEW |