OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 420 } |
421 | 421 |
422 TEST_F(RendererImplTest, StartPlayingFromWithPlaybackRate) { | 422 TEST_F(RendererImplTest, StartPlayingFromWithPlaybackRate) { |
423 InitializeWithAudioAndVideo(); | 423 InitializeWithAudioAndVideo(); |
424 | 424 |
425 // Play with a zero playback rate shouldn't start time. | 425 // Play with a zero playback rate shouldn't start time. |
426 Play(); | 426 Play(); |
427 Mock::VerifyAndClearExpectations(video_renderer_); | 427 Mock::VerifyAndClearExpectations(video_renderer_); |
428 | 428 |
429 // Positive playback rate when ticking should start time. | 429 // Positive playback rate when ticking should start time. |
430 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(true)); | 430 EXPECT_CALL(*video_renderer_, OnTimeProgressing()); |
431 SetPlaybackRate(1.0); | 431 SetPlaybackRate(1.0); |
432 Mock::VerifyAndClearExpectations(video_renderer_); | 432 Mock::VerifyAndClearExpectations(video_renderer_); |
433 | 433 |
434 // Double notifications shouldn't be sent. | 434 // Double notifications shouldn't be sent. |
435 SetPlaybackRate(1.0); | 435 SetPlaybackRate(1.0); |
436 Mock::VerifyAndClearExpectations(video_renderer_); | 436 Mock::VerifyAndClearExpectations(video_renderer_); |
437 | 437 |
438 // Zero playback rate should stop time. | 438 // Zero playback rate should stop time. |
439 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false)); | 439 EXPECT_CALL(*video_renderer_, OnTimeStopped()); |
440 SetPlaybackRate(0.0); | 440 SetPlaybackRate(0.0); |
441 Mock::VerifyAndClearExpectations(video_renderer_); | 441 Mock::VerifyAndClearExpectations(video_renderer_); |
442 | 442 |
443 // Double notifications shouldn't be sent. | 443 // Double notifications shouldn't be sent. |
444 SetPlaybackRate(0.0); | 444 SetPlaybackRate(0.0); |
445 Mock::VerifyAndClearExpectations(video_renderer_); | 445 Mock::VerifyAndClearExpectations(video_renderer_); |
446 | 446 |
447 // Starting playback and flushing should cause time to stop. | 447 // Starting playback and flushing should cause time to stop. |
448 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(true)); | 448 EXPECT_CALL(*video_renderer_, OnTimeProgressing()); |
449 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false)); | 449 EXPECT_CALL(*video_renderer_, OnTimeStopped()); |
450 SetPlaybackRate(1.0); | 450 SetPlaybackRate(1.0); |
451 Flush(false); | 451 Flush(false); |
452 | 452 |
453 // A positive playback rate when playback isn't started should do nothing. | 453 // A positive playback rate when playback isn't started should do nothing. |
454 SetPlaybackRate(1.0); | 454 SetPlaybackRate(1.0); |
455 } | 455 } |
456 | 456 |
457 TEST_F(RendererImplTest, FlushAfterInitialization) { | 457 TEST_F(RendererImplTest, FlushAfterInitialization) { |
458 InitializeWithAudioAndVideo(); | 458 InitializeWithAudioAndVideo(); |
459 Flush(true); | 459 Flush(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 audio_renderer_client_->OnEnded(); | 500 audio_renderer_client_->OnEnded(); |
501 base::RunLoop().RunUntilIdle(); | 501 base::RunLoop().RunUntilIdle(); |
502 } | 502 } |
503 | 503 |
504 TEST_F(RendererImplTest, VideoStreamEnded) { | 504 TEST_F(RendererImplTest, VideoStreamEnded) { |
505 InitializeWithVideo(); | 505 InitializeWithVideo(); |
506 Play(); | 506 Play(); |
507 | 507 |
508 EXPECT_CALL(time_source_, StopTicking()); | 508 EXPECT_CALL(time_source_, StopTicking()); |
509 EXPECT_CALL(callbacks_, OnEnded()); | 509 EXPECT_CALL(callbacks_, OnEnded()); |
510 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false)); | 510 EXPECT_CALL(*video_renderer_, OnTimeStopped()); |
511 | 511 |
512 video_renderer_client_->OnEnded(); | 512 video_renderer_client_->OnEnded(); |
513 base::RunLoop().RunUntilIdle(); | 513 base::RunLoop().RunUntilIdle(); |
514 } | 514 } |
515 | 515 |
516 TEST_F(RendererImplTest, AudioVideoStreamsEnded) { | 516 TEST_F(RendererImplTest, AudioVideoStreamsEnded) { |
517 InitializeWithAudioAndVideo(); | 517 InitializeWithAudioAndVideo(); |
518 Play(); | 518 Play(); |
519 | 519 |
520 // OnEnded() is called only when all streams have finished. | 520 // OnEnded() is called only when all streams have finished. |
521 audio_renderer_client_->OnEnded(); | 521 audio_renderer_client_->OnEnded(); |
522 base::RunLoop().RunUntilIdle(); | 522 base::RunLoop().RunUntilIdle(); |
523 | 523 |
524 EXPECT_CALL(time_source_, StopTicking()); | 524 EXPECT_CALL(time_source_, StopTicking()); |
525 EXPECT_CALL(callbacks_, OnEnded()); | 525 EXPECT_CALL(callbacks_, OnEnded()); |
526 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false)); | 526 EXPECT_CALL(*video_renderer_, OnTimeStopped()); |
527 | 527 |
528 video_renderer_client_->OnEnded(); | 528 video_renderer_client_->OnEnded(); |
529 base::RunLoop().RunUntilIdle(); | 529 base::RunLoop().RunUntilIdle(); |
530 } | 530 } |
531 | 531 |
532 TEST_F(RendererImplTest, ErrorAfterInitialize) { | 532 TEST_F(RendererImplTest, ErrorAfterInitialize) { |
533 InitializeWithAudio(); | 533 InitializeWithAudio(); |
534 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); | 534 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); |
535 audio_renderer_client_->OnError(PIPELINE_ERROR_DECODE); | 535 audio_renderer_client_->OnError(PIPELINE_ERROR_DECODE); |
536 base::RunLoop().RunUntilIdle(); | 536 base::RunLoop().RunUntilIdle(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>()); | 736 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>()); |
737 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(1); | 737 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(1); |
738 audio_stream_status_change_cb.Run(false, time0); | 738 audio_stream_status_change_cb.Run(false, time0); |
739 | 739 |
740 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); | 740 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); |
741 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)).Times(1); | 741 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)).Times(1); |
742 video_stream_status_change_cb.Run(false, time0); | 742 video_stream_status_change_cb.Run(false, time0); |
743 } | 743 } |
744 | 744 |
745 } // namespace media | 745 } // namespace media |
OLD | NEW |