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 <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" |
11 #include "media/base/clock.h" | 11 #include "media/base/clock.h" |
12 #include "media/base/filter_host.h" | 12 #include "media/base/filter_host.h" |
13 #include "media/base/filters.h" | 13 #include "media/base/filters.h" |
14 #include "media/base/media_log.h" | 14 #include "media/base/media_log.h" |
15 #include "media/base/pipeline.h" | 15 #include "media/base/pipeline.h" |
16 #include "media/base/mock_callback.h" | 16 #include "media/base/mock_callback.h" |
17 #include "media/base/mock_filters.h" | 17 #include "media/base/mock_filters.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
20 | 20 |
21 using ::testing::_; | 21 using ::testing::_; |
22 using ::testing::DeleteArg; | 22 using ::testing::DeleteArg; |
| 23 using ::testing::DoAll; |
23 using ::testing::InSequence; | 24 using ::testing::InSequence; |
24 using ::testing::Invoke; | 25 using ::testing::Invoke; |
25 using ::testing::InvokeArgument; | |
26 using ::testing::Mock; | 26 using ::testing::Mock; |
27 using ::testing::NotNull; | 27 using ::testing::NotNull; |
28 using ::testing::Return; | 28 using ::testing::Return; |
29 using ::testing::ReturnRef; | 29 using ::testing::ReturnRef; |
30 using ::testing::StrictMock; | 30 using ::testing::StrictMock; |
31 using ::testing::WithArg; | 31 using ::testing::WithArg; |
32 | 32 |
33 namespace media { | 33 namespace media { |
34 | 34 |
35 // Total bytes of the data source. | 35 // Demuxer properties. |
36 static const int kTotalBytes = 1024; | 36 static const int kTotalBytes = 1024; |
| 37 static const int kBufferedBytes = 1024; |
| 38 static const int kBitrate = 1234; |
| 39 static const bool kLocalSource = false; |
| 40 static const bool kSeekable = true; |
37 | 41 |
38 // Buffered bytes of the data source. | 42 ACTION_P(InitializeDemuxerWithError, error) { |
39 static const int kBufferedBytes = 1024; | 43 arg1.Run(error); |
| 44 } |
| 45 |
| 46 ACTION_P(SetDemuxerProperties, duration) { |
| 47 arg0->SetTotalBytes(kTotalBytes); |
| 48 arg0->SetBufferedBytes(kBufferedBytes); |
| 49 arg0->SetDuration(duration); |
| 50 } |
40 | 51 |
41 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 52 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
42 // also lets us test for missing callbacks. | 53 // also lets us test for missing callbacks. |
43 class CallbackHelper { | 54 class CallbackHelper { |
44 public: | 55 public: |
45 CallbackHelper() {} | 56 CallbackHelper() {} |
46 virtual ~CallbackHelper() {} | 57 virtual ~CallbackHelper() {} |
47 | 58 |
48 MOCK_METHOD1(OnStart, void(PipelineStatus)); | 59 MOCK_METHOD1(OnStart, void(PipelineStatus)); |
49 MOCK_METHOD1(OnSeek, void(PipelineStatus)); | 60 MOCK_METHOD1(OnSeek, void(PipelineStatus)); |
(...skipping 10 matching lines...) Expand all Loading... |
60 // is executed on |message_loop_| and the mock filters instantly call | 71 // is executed on |message_loop_| and the mock filters instantly call |
61 // InitializationComplete(), which keeps the pipeline humming along. If | 72 // InitializationComplete(), which keeps the pipeline humming along. If |
62 // either filters don't call InitializationComplete() immediately or filter | 73 // either filters don't call InitializationComplete() immediately or filter |
63 // initialization is moved to a separate thread this test will become flaky. | 74 // initialization is moved to a separate thread this test will become flaky. |
64 class PipelineTest : public ::testing::Test { | 75 class PipelineTest : public ::testing::Test { |
65 public: | 76 public: |
66 PipelineTest() | 77 PipelineTest() |
67 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) { | 78 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) { |
68 mocks_.reset(new MockFilterCollection()); | 79 mocks_.reset(new MockFilterCollection()); |
69 | 80 |
70 // InitializeDemuxer adds overriding expectations for expected non-NULL | 81 // InitializeDemuxer() adds overriding expectations for expected non-NULL |
71 // streams. | 82 // streams. |
72 DemuxerStream* null_pointer = NULL; | 83 DemuxerStream* null_pointer = NULL; |
73 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) | 84 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) |
74 .WillRepeatedly(Return(null_pointer)); | 85 .WillRepeatedly(Return(null_pointer)); |
75 | 86 |
76 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) | 87 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) |
77 .WillRepeatedly(Return(base::TimeDelta())); | 88 .WillRepeatedly(Return(base::TimeDelta())); |
78 } | 89 } |
79 | 90 |
80 virtual ~PipelineTest() { | 91 virtual ~PipelineTest() { |
81 if (!pipeline_->IsRunning()) { | 92 if (!pipeline_->IsRunning()) { |
82 return; | 93 return; |
83 } | 94 } |
84 | 95 |
85 // Expect a stop callback if we were started. | 96 // Expect a stop callback if we were started. |
86 EXPECT_CALL(callbacks_, OnStop()); | 97 EXPECT_CALL(callbacks_, OnStop()); |
87 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 98 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
88 base::Unretained(&callbacks_))); | 99 base::Unretained(&callbacks_))); |
89 message_loop_.RunAllPending(); | 100 message_loop_.RunAllPending(); |
90 | 101 |
91 pipeline_ = NULL; | 102 pipeline_ = NULL; |
92 mocks_.reset(); | 103 mocks_.reset(); |
93 } | 104 } |
94 | 105 |
95 protected: | 106 protected: |
96 // Sets up expectations to allow the demuxer to initialize. | 107 // Sets up expectations to allow the demuxer to initialize. |
97 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 108 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
98 void InitializeDemuxer(MockDemuxerStreamVector* streams, | 109 void InitializeDemuxer(MockDemuxerStreamVector* streams, |
99 const base::TimeDelta& duration) { | 110 const base::TimeDelta& duration) { |
100 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) | 111 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
101 .WillOnce(Invoke(&RunPipelineStatusCB)); | 112 .WillOnce(DoAll(SetDemuxerProperties(duration), |
102 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( | 113 Invoke(&RunPipelineStatusCB2))); |
103 kTotalBytes, kBufferedBytes, duration); | |
104 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 114 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
105 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) | 115 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) |
106 .WillOnce(Invoke(&RunPipelineStatusCB2)); | 116 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
107 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 117 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
108 .WillOnce(Invoke(&RunStopFilterCallback)); | 118 .WillOnce(Invoke(&RunStopFilterCallback)); |
109 | 119 |
| 120 // Demuxer properties. |
| 121 EXPECT_CALL(*mocks_->demuxer(), GetBitrate()) |
| 122 .WillRepeatedly(Return(kBitrate)); |
| 123 EXPECT_CALL(*mocks_->demuxer(), IsLocalSource()) |
| 124 .WillRepeatedly(Return(kLocalSource)); |
| 125 EXPECT_CALL(*mocks_->demuxer(), IsSeekable()) |
| 126 .WillRepeatedly(Return(kSeekable)); |
| 127 |
110 // Configure the demuxer to return the streams. | 128 // Configure the demuxer to return the streams. |
111 for (size_t i = 0; i < streams->size(); ++i) { | 129 for (size_t i = 0; i < streams->size(); ++i) { |
112 scoped_refptr<DemuxerStream> stream((*streams)[i]); | 130 scoped_refptr<DemuxerStream> stream((*streams)[i]); |
113 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) | 131 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) |
114 .WillRepeatedly(Return(stream)); | 132 .WillRepeatedly(Return(stream)); |
115 } | 133 } |
116 } | 134 } |
117 | 135 |
| 136 void InitializeDemuxer(MockDemuxerStreamVector* streams) { |
| 137 // Initialize with a default non-zero duration. |
| 138 InitializeDemuxer(streams, base::TimeDelta::FromSeconds(10)); |
| 139 } |
| 140 |
118 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { | 141 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { |
119 StrictMock<MockDemuxerStream>* stream = | 142 StrictMock<MockDemuxerStream>* stream = |
120 new StrictMock<MockDemuxerStream>(); | 143 new StrictMock<MockDemuxerStream>(); |
121 EXPECT_CALL(*stream, type()) | 144 EXPECT_CALL(*stream, type()) |
122 .WillRepeatedly(Return(type)); | 145 .WillRepeatedly(Return(type)); |
123 return stream; | 146 return stream; |
124 } | 147 } |
125 | 148 |
126 // Sets up expectations to allow the video decoder to initialize. | 149 // Sets up expectations to allow the video decoder to initialize. |
127 void InitializeVideoDecoder(MockDemuxerStream* stream) { | 150 void InitializeVideoDecoder(MockDemuxerStream* stream) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 297 |
275 // Should always get set to zero. | 298 // Should always get set to zero. |
276 gfx::Size size(1, 1); | 299 gfx::Size size(1, 1); |
277 pipeline_->GetNaturalVideoSize(&size); | 300 pipeline_->GetNaturalVideoSize(&size); |
278 EXPECT_EQ(0, size.width()); | 301 EXPECT_EQ(0, size.width()); |
279 EXPECT_EQ(0, size.height()); | 302 EXPECT_EQ(0, size.height()); |
280 } | 303 } |
281 | 304 |
282 TEST_F(PipelineTest, NeverInitializes) { | 305 TEST_F(PipelineTest, NeverInitializes) { |
283 // Don't execute the callback passed into Initialize(). | 306 // Don't execute the callback passed into Initialize(). |
284 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)); | 307 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)); |
285 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 308 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
286 .WillOnce(Invoke(&RunStopFilterCallback)); | 309 .WillOnce(Invoke(&RunStopFilterCallback)); |
287 | 310 |
288 // This test hangs during initialization by never calling | 311 // This test hangs during initialization by never calling |
289 // InitializationComplete(). StrictMock<> will ensure that the callback is | 312 // InitializationComplete(). StrictMock<> will ensure that the callback is |
290 // never executed. | 313 // never executed. |
291 pipeline_->Start( | 314 pipeline_->Start( |
292 mocks_->Create().Pass(), | 315 mocks_->Create().Pass(), |
293 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 316 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
294 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 317 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
(...skipping 20 matching lines...) Expand all Loading... |
315 collection.Pass(), | 338 collection.Pass(), |
316 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 339 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
317 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 340 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
318 NetworkEventCB(), | 341 NetworkEventCB(), |
319 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 342 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
320 message_loop_.RunAllPending(); | 343 message_loop_.RunAllPending(); |
321 EXPECT_FALSE(pipeline_->IsInitialized()); | 344 EXPECT_FALSE(pipeline_->IsInitialized()); |
322 } | 345 } |
323 | 346 |
324 TEST_F(PipelineTest, URLNotFound) { | 347 TEST_F(PipelineTest, URLNotFound) { |
325 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) | 348 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
326 .WillOnce(RunPipelineStatusCBWithError( | 349 .WillOnce(InitializeDemuxerWithError(PIPELINE_ERROR_URL_NOT_FOUND)); |
327 PIPELINE_ERROR_URL_NOT_FOUND)); | |
328 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 350 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
329 .WillOnce(Invoke(&RunStopFilterCallback)); | 351 .WillOnce(Invoke(&RunStopFilterCallback)); |
330 | 352 |
331 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); | 353 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); |
332 EXPECT_FALSE(pipeline_->IsInitialized()); | 354 EXPECT_FALSE(pipeline_->IsInitialized()); |
333 } | 355 } |
334 | 356 |
335 TEST_F(PipelineTest, NoStreams) { | 357 TEST_F(PipelineTest, NoStreams) { |
336 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) | 358 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) |
337 .WillOnce(Invoke(&RunPipelineStatusCB)); | 359 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
338 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 360 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
339 .WillOnce(Invoke(&RunStopFilterCallback)); | 361 .WillOnce(Invoke(&RunStopFilterCallback)); |
340 | 362 |
341 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); | 363 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); |
342 EXPECT_FALSE(pipeline_->IsInitialized()); | 364 EXPECT_FALSE(pipeline_->IsInitialized()); |
343 } | 365 } |
344 | 366 |
345 TEST_F(PipelineTest, AudioStream) { | 367 TEST_F(PipelineTest, AudioStream) { |
346 CreateAudioStream(); | 368 CreateAudioStream(); |
347 MockDemuxerStreamVector streams; | 369 MockDemuxerStreamVector streams; |
348 streams.push_back(audio_stream()); | 370 streams.push_back(audio_stream()); |
349 | 371 |
350 InitializeDemuxer(&streams, base::TimeDelta()); | 372 InitializeDemuxer(&streams); |
351 InitializeAudioDecoder(audio_stream()); | 373 InitializeAudioDecoder(audio_stream()); |
352 InitializeAudioRenderer(); | 374 InitializeAudioRenderer(); |
353 | 375 |
354 InitializePipeline(PIPELINE_OK); | 376 InitializePipeline(PIPELINE_OK); |
355 EXPECT_TRUE(pipeline_->IsInitialized()); | 377 EXPECT_TRUE(pipeline_->IsInitialized()); |
356 EXPECT_TRUE(pipeline_->HasAudio()); | 378 EXPECT_TRUE(pipeline_->HasAudio()); |
357 EXPECT_FALSE(pipeline_->HasVideo()); | 379 EXPECT_FALSE(pipeline_->HasVideo()); |
358 } | 380 } |
359 | 381 |
360 TEST_F(PipelineTest, VideoStream) { | 382 TEST_F(PipelineTest, VideoStream) { |
361 CreateVideoStream(); | 383 CreateVideoStream(); |
362 MockDemuxerStreamVector streams; | 384 MockDemuxerStreamVector streams; |
363 streams.push_back(video_stream()); | 385 streams.push_back(video_stream()); |
364 | 386 |
365 InitializeDemuxer(&streams, base::TimeDelta()); | 387 InitializeDemuxer(&streams); |
366 InitializeVideoDecoder(video_stream()); | 388 InitializeVideoDecoder(video_stream()); |
367 InitializeVideoRenderer(); | 389 InitializeVideoRenderer(); |
368 | 390 |
369 InitializePipeline(PIPELINE_OK); | 391 InitializePipeline(PIPELINE_OK); |
370 EXPECT_TRUE(pipeline_->IsInitialized()); | 392 EXPECT_TRUE(pipeline_->IsInitialized()); |
371 EXPECT_FALSE(pipeline_->HasAudio()); | 393 EXPECT_FALSE(pipeline_->HasAudio()); |
372 EXPECT_TRUE(pipeline_->HasVideo()); | 394 EXPECT_TRUE(pipeline_->HasVideo()); |
373 } | 395 } |
374 | 396 |
375 TEST_F(PipelineTest, AudioVideoStream) { | 397 TEST_F(PipelineTest, AudioVideoStream) { |
376 CreateAudioStream(); | 398 CreateAudioStream(); |
377 CreateVideoStream(); | 399 CreateVideoStream(); |
378 MockDemuxerStreamVector streams; | 400 MockDemuxerStreamVector streams; |
379 streams.push_back(audio_stream()); | 401 streams.push_back(audio_stream()); |
380 streams.push_back(video_stream()); | 402 streams.push_back(video_stream()); |
381 | 403 |
382 InitializeDemuxer(&streams, base::TimeDelta()); | 404 InitializeDemuxer(&streams); |
383 InitializeAudioDecoder(audio_stream()); | 405 InitializeAudioDecoder(audio_stream()); |
384 InitializeAudioRenderer(); | 406 InitializeAudioRenderer(); |
385 InitializeVideoDecoder(video_stream()); | 407 InitializeVideoDecoder(video_stream()); |
386 InitializeVideoRenderer(); | 408 InitializeVideoRenderer(); |
387 | 409 |
388 InitializePipeline(PIPELINE_OK); | 410 InitializePipeline(PIPELINE_OK); |
389 EXPECT_TRUE(pipeline_->IsInitialized()); | 411 EXPECT_TRUE(pipeline_->IsInitialized()); |
390 EXPECT_TRUE(pipeline_->HasAudio()); | 412 EXPECT_TRUE(pipeline_->HasAudio()); |
391 EXPECT_TRUE(pipeline_->HasVideo()); | 413 EXPECT_TRUE(pipeline_->HasVideo()); |
392 } | 414 } |
(...skipping 18 matching lines...) Expand all Loading... |
411 // Initialize then seek! | 433 // Initialize then seek! |
412 InitializePipeline(PIPELINE_OK); | 434 InitializePipeline(PIPELINE_OK); |
413 DoSeek(expected); | 435 DoSeek(expected); |
414 } | 436 } |
415 | 437 |
416 TEST_F(PipelineTest, SetVolume) { | 438 TEST_F(PipelineTest, SetVolume) { |
417 CreateAudioStream(); | 439 CreateAudioStream(); |
418 MockDemuxerStreamVector streams; | 440 MockDemuxerStreamVector streams; |
419 streams.push_back(audio_stream()); | 441 streams.push_back(audio_stream()); |
420 | 442 |
421 InitializeDemuxer(&streams, base::TimeDelta()); | 443 InitializeDemuxer(&streams); |
422 InitializeAudioDecoder(audio_stream()); | 444 InitializeAudioDecoder(audio_stream()); |
423 InitializeAudioRenderer(); | 445 InitializeAudioRenderer(); |
424 | 446 |
425 // The audio renderer should receive a call to SetVolume(). | 447 // The audio renderer should receive a call to SetVolume(). |
426 float expected = 0.5f; | 448 float expected = 0.5f; |
427 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); | 449 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); |
428 | 450 |
429 // Initialize then set volume! | 451 // Initialize then set volume! |
430 InitializePipeline(PIPELINE_OK); | 452 InitializePipeline(PIPELINE_OK); |
431 pipeline_->SetVolume(expected); | 453 pipeline_->SetVolume(expected); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 pipeline_->GetBufferedTime().ToInternalValue()); | 537 pipeline_->GetBufferedTime().ToInternalValue()); |
516 } | 538 } |
517 | 539 |
518 TEST_F(PipelineTest, DisableAudioRenderer) { | 540 TEST_F(PipelineTest, DisableAudioRenderer) { |
519 CreateAudioStream(); | 541 CreateAudioStream(); |
520 CreateVideoStream(); | 542 CreateVideoStream(); |
521 MockDemuxerStreamVector streams; | 543 MockDemuxerStreamVector streams; |
522 streams.push_back(audio_stream()); | 544 streams.push_back(audio_stream()); |
523 streams.push_back(video_stream()); | 545 streams.push_back(video_stream()); |
524 | 546 |
525 InitializeDemuxer(&streams, base::TimeDelta()); | 547 InitializeDemuxer(&streams); |
526 InitializeAudioDecoder(audio_stream()); | 548 InitializeAudioDecoder(audio_stream()); |
527 InitializeAudioRenderer(); | 549 InitializeAudioRenderer(); |
528 InitializeVideoDecoder(video_stream()); | 550 InitializeVideoDecoder(video_stream()); |
529 InitializeVideoRenderer(); | 551 InitializeVideoRenderer(); |
530 | 552 |
531 InitializePipeline(PIPELINE_OK); | 553 InitializePipeline(PIPELINE_OK); |
532 EXPECT_TRUE(pipeline_->IsInitialized()); | 554 EXPECT_TRUE(pipeline_->IsInitialized()); |
533 EXPECT_TRUE(pipeline_->HasAudio()); | 555 EXPECT_TRUE(pipeline_->HasAudio()); |
534 EXPECT_TRUE(pipeline_->HasVideo()); | 556 EXPECT_TRUE(pipeline_->HasVideo()); |
535 | 557 |
(...skipping 16 matching lines...) Expand all Loading... |
552 host->NotifyEnded(); | 574 host->NotifyEnded(); |
553 } | 575 } |
554 | 576 |
555 TEST_F(PipelineTest, DisableAudioRendererDuringInit) { | 577 TEST_F(PipelineTest, DisableAudioRendererDuringInit) { |
556 CreateAudioStream(); | 578 CreateAudioStream(); |
557 CreateVideoStream(); | 579 CreateVideoStream(); |
558 MockDemuxerStreamVector streams; | 580 MockDemuxerStreamVector streams; |
559 streams.push_back(audio_stream()); | 581 streams.push_back(audio_stream()); |
560 streams.push_back(video_stream()); | 582 streams.push_back(video_stream()); |
561 | 583 |
562 InitializeDemuxer(&streams, base::TimeDelta()); | 584 InitializeDemuxer(&streams); |
563 InitializeAudioDecoder(audio_stream()); | 585 InitializeAudioDecoder(audio_stream()); |
564 InitializeAudioRenderer(true); | 586 InitializeAudioRenderer(true); |
565 InitializeVideoDecoder(video_stream()); | 587 InitializeVideoDecoder(video_stream()); |
566 InitializeVideoRenderer(); | 588 InitializeVideoRenderer(); |
567 | 589 |
568 EXPECT_CALL(*mocks_->demuxer(), | 590 EXPECT_CALL(*mocks_->demuxer(), |
569 OnAudioRendererDisabled()); | 591 OnAudioRendererDisabled()); |
570 EXPECT_CALL(*mocks_->audio_renderer(), | 592 EXPECT_CALL(*mocks_->audio_renderer(), |
571 OnAudioRendererDisabled()); | 593 OnAudioRendererDisabled()); |
572 EXPECT_CALL(*mocks_->video_renderer(), | 594 EXPECT_CALL(*mocks_->video_renderer(), |
(...skipping 12 matching lines...) Expand all Loading... |
585 host->NotifyEnded(); | 607 host->NotifyEnded(); |
586 } | 608 } |
587 | 609 |
588 TEST_F(PipelineTest, EndedCallback) { | 610 TEST_F(PipelineTest, EndedCallback) { |
589 CreateAudioStream(); | 611 CreateAudioStream(); |
590 CreateVideoStream(); | 612 CreateVideoStream(); |
591 MockDemuxerStreamVector streams; | 613 MockDemuxerStreamVector streams; |
592 streams.push_back(audio_stream()); | 614 streams.push_back(audio_stream()); |
593 streams.push_back(video_stream()); | 615 streams.push_back(video_stream()); |
594 | 616 |
595 InitializeDemuxer(&streams, base::TimeDelta()); | 617 InitializeDemuxer(&streams); |
596 InitializeAudioDecoder(audio_stream()); | 618 InitializeAudioDecoder(audio_stream()); |
597 InitializeAudioRenderer(); | 619 InitializeAudioRenderer(); |
598 InitializeVideoDecoder(video_stream()); | 620 InitializeVideoDecoder(video_stream()); |
599 InitializeVideoRenderer(); | 621 InitializeVideoRenderer(); |
600 InitializePipeline(PIPELINE_OK); | 622 InitializePipeline(PIPELINE_OK); |
601 | 623 |
602 // For convenience to simulate filters calling the methods. | 624 // For convenience to simulate filters calling the methods. |
603 FilterHost* host = pipeline_; | 625 FilterHost* host = pipeline_; |
604 | 626 |
605 // Due to short circuit evaluation we only need to test a subset of cases. | 627 // Due to short circuit evaluation we only need to test a subset of cases. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 InitializeVideoRenderer(); | 829 InitializeVideoRenderer(); |
808 | 830 |
809 InitializePipeline(PIPELINE_OK); | 831 InitializePipeline(PIPELINE_OK); |
810 EXPECT_TRUE(pipeline_->IsInitialized()); | 832 EXPECT_TRUE(pipeline_->IsInitialized()); |
811 EXPECT_FALSE(pipeline_->HasAudio()); | 833 EXPECT_FALSE(pipeline_->HasAudio()); |
812 EXPECT_TRUE(pipeline_->HasVideo()); | 834 EXPECT_TRUE(pipeline_->HasVideo()); |
813 | 835 |
814 EXPECT_EQ(kStartTime, pipeline_->GetCurrentTime()); | 836 EXPECT_EQ(kStartTime, pipeline_->GetCurrentTime()); |
815 } | 837 } |
816 | 838 |
| 839 TEST_F(PipelineTest, DemuxerProperties) { |
| 840 CreateAudioStream(); |
| 841 CreateVideoStream(); |
| 842 MockDemuxerStreamVector streams; |
| 843 streams.push_back(audio_stream()); |
| 844 streams.push_back(video_stream()); |
| 845 |
| 846 InitializeDemuxer(&streams); |
| 847 InitializeAudioDecoder(audio_stream()); |
| 848 InitializeAudioRenderer(); |
| 849 InitializeVideoDecoder(video_stream()); |
| 850 InitializeVideoRenderer(); |
| 851 InitializePipeline(PIPELINE_OK); |
| 852 |
| 853 EXPECT_EQ(kLocalSource, pipeline_->IsLocalSource()); |
| 854 EXPECT_EQ(!kSeekable, pipeline_->IsStreaming()); |
| 855 } |
| 856 |
817 class FlexibleCallbackRunner : public base::DelegateSimpleThread::Delegate { | 857 class FlexibleCallbackRunner : public base::DelegateSimpleThread::Delegate { |
818 public: | 858 public: |
819 FlexibleCallbackRunner(base::TimeDelta delay, PipelineStatus status, | 859 FlexibleCallbackRunner(base::TimeDelta delay, PipelineStatus status, |
820 const PipelineStatusCB& status_cb) | 860 const PipelineStatusCB& status_cb) |
821 : delay_(delay), | 861 : delay_(delay), |
822 status_(status), | 862 status_(status), |
823 status_cb_(status_cb) { | 863 status_cb_(status_cb) { |
824 if (delay_ < base::TimeDelta()) { | 864 if (delay_ < base::TimeDelta()) { |
825 status_cb_.Run(status_); | 865 status_cb_.Run(status_); |
826 return; | 866 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 901 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
862 } | 902 } |
863 | 903 |
864 // Test that different-thread, some-delay callback (the expected common case) | 904 // Test that different-thread, some-delay callback (the expected common case) |
865 // works correctly. | 905 // works correctly. |
866 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 906 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
867 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 907 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
868 } | 908 } |
869 | 909 |
870 } // namespace media | 910 } // namespace media |
OLD | NEW |