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

Side by Side Diff: media/renderers/renderer_impl_unittest.cc

Issue 1935873002: Implement disabling and enabling media tracks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control2
Patch Set: Added tests to verify no rendering happens for disabled tracks Created 4 years, 5 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
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 protected: 80 protected:
81 void Destroy() { 81 void Destroy() {
82 renderer_impl_.reset(); 82 renderer_impl_.reset();
83 base::RunLoop().RunUntilIdle(); 83 base::RunLoop().RunUntilIdle();
84 } 84 }
85 85
86 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( 86 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream(
87 DemuxerStream::Type type) { 87 DemuxerStream::Type type) {
88 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( 88 std::unique_ptr<StrictMock<MockDemuxerStream>> stream(
89 new StrictMock<MockDemuxerStream>(type)); 89 new StrictMock<MockDemuxerStream>(type));
90 EXPECT_CALL(*stream, SetStreamRestartedCB(_)).Times(testing::AnyNumber());
90 return stream; 91 return stream;
91 } 92 }
92 93
93 // Sets up expectations to allow the audio renderer to initialize. 94 // Sets up expectations to allow the audio renderer to initialize.
94 void SetAudioRendererInitializeExpectations(PipelineStatus status) { 95 void SetAudioRendererInitializeExpectations(PipelineStatus status) {
95 EXPECT_CALL(*audio_renderer_, Initialize(audio_stream_.get(), _, _, _)) 96 EXPECT_CALL(*audio_renderer_, Initialize(audio_stream_.get(), _, _, _))
96 .WillOnce( 97 .WillOnce(
97 DoAll(SaveArg<2>(&audio_renderer_client_), RunCallback<3>(status))); 98 DoAll(SaveArg<2>(&audio_renderer_client_), RunCallback<3>(status)));
98 } 99 }
99 100
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 audio_renderer_client_->OnEnded(); 497 audio_renderer_client_->OnEnded();
497 base::RunLoop().RunUntilIdle(); 498 base::RunLoop().RunUntilIdle();
498 } 499 }
499 500
500 TEST_F(RendererImplTest, VideoStreamEnded) { 501 TEST_F(RendererImplTest, VideoStreamEnded) {
501 InitializeWithVideo(); 502 InitializeWithVideo();
502 Play(); 503 Play();
503 504
504 EXPECT_CALL(time_source_, StopTicking()); 505 EXPECT_CALL(time_source_, StopTicking());
505 EXPECT_CALL(callbacks_, OnEnded()); 506 EXPECT_CALL(callbacks_, OnEnded());
507 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false));
506 508
507 video_renderer_client_->OnEnded(); 509 video_renderer_client_->OnEnded();
508 base::RunLoop().RunUntilIdle(); 510 base::RunLoop().RunUntilIdle();
509 } 511 }
510 512
511 TEST_F(RendererImplTest, AudioVideoStreamsEnded) { 513 TEST_F(RendererImplTest, AudioVideoStreamsEnded) {
512 InitializeWithAudioAndVideo(); 514 InitializeWithAudioAndVideo();
513 Play(); 515 Play();
514 516
515 // OnEnded() is called only when all streams have finished. 517 // OnEnded() is called only when all streams have finished.
516 audio_renderer_client_->OnEnded(); 518 audio_renderer_client_->OnEnded();
517 base::RunLoop().RunUntilIdle(); 519 base::RunLoop().RunUntilIdle();
518 520
519 EXPECT_CALL(time_source_, StopTicking()); 521 EXPECT_CALL(time_source_, StopTicking());
520 EXPECT_CALL(callbacks_, OnEnded()); 522 EXPECT_CALL(callbacks_, OnEnded());
523 EXPECT_CALL(*video_renderer_, OnTimeStateChanged(false));
521 524
522 video_renderer_client_->OnEnded(); 525 video_renderer_client_->OnEnded();
523 base::RunLoop().RunUntilIdle(); 526 base::RunLoop().RunUntilIdle();
524 } 527 }
525 528
526 TEST_F(RendererImplTest, ErrorAfterInitialize) { 529 TEST_F(RendererImplTest, ErrorAfterInitialize) {
527 InitializeWithAudio(); 530 InitializeWithAudio();
528 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE)); 531 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_DECODE));
529 audio_renderer_client_->OnError(PIPELINE_ERROR_DECODE); 532 audio_renderer_client_->OnError(PIPELINE_ERROR_DECODE);
530 base::RunLoop().RunUntilIdle(); 533 base::RunLoop().RunUntilIdle();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 .WillOnce( 696 .WillOnce(
694 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); 697 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH));
695 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); 698 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime));
696 renderer_impl_->StartPlayingFrom(kStartTime); 699 renderer_impl_->StartPlayingFrom(kStartTime);
697 700
698 // Nothing else should primed on the message loop. 701 // Nothing else should primed on the message loop.
699 base::RunLoop().RunUntilIdle(); 702 base::RunLoop().RunUntilIdle();
700 } 703 }
701 704
702 } // namespace media 705 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698