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

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

Issue 1053113002: Prime the landing pad for the new video rendering pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast. Created 5 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
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | media/renderers/video_renderer_impl.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 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 public: 42 public:
43 CallbackHelper() {} 43 CallbackHelper() {}
44 virtual ~CallbackHelper() {} 44 virtual ~CallbackHelper() {}
45 45
46 MOCK_METHOD1(OnInitialize, void(PipelineStatus)); 46 MOCK_METHOD1(OnInitialize, void(PipelineStatus));
47 MOCK_METHOD0(OnFlushed, void()); 47 MOCK_METHOD0(OnFlushed, void());
48 MOCK_METHOD0(OnEnded, void()); 48 MOCK_METHOD0(OnEnded, void());
49 MOCK_METHOD1(OnError, void(PipelineStatus)); 49 MOCK_METHOD1(OnError, void(PipelineStatus));
50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&)); 50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&));
51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); 51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState));
52 MOCK_METHOD1(OnVideoFramePaint, void(const scoped_refptr<VideoFrame>&));
53 MOCK_METHOD0(OnWaitingForDecryptionKey, void()); 52 MOCK_METHOD0(OnWaitingForDecryptionKey, void());
54 53
55 private: 54 private:
56 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); 55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper);
57 }; 56 };
58 57
59 RendererImplTest() 58 RendererImplTest()
60 : demuxer_(new StrictMock<MockDemuxer>()), 59 : demuxer_(new StrictMock<MockDemuxer>()),
61 video_renderer_(new StrictMock<MockVideoRenderer>()), 60 video_renderer_(new StrictMock<MockVideoRenderer>()),
62 audio_renderer_(new StrictMock<MockAudioRenderer>()), 61 audio_renderer_(new StrictMock<MockAudioRenderer>()),
(...skipping 28 matching lines...) Expand all
91 EXPECT_CALL(*audio_renderer_, 90 EXPECT_CALL(*audio_renderer_,
92 Initialize(audio_stream_.get(), _, _, _, _, _, _, _)) 91 Initialize(audio_stream_.get(), _, _, _, _, _, _, _))
93 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), 92 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_),
94 SaveArg<5>(&audio_ended_cb_), 93 SaveArg<5>(&audio_ended_cb_),
95 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status))); 94 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status)));
96 } 95 }
97 96
98 // Sets up expectations to allow the video renderer to initialize. 97 // Sets up expectations to allow the video renderer to initialize.
99 void SetVideoRendererInitializeExpectations(PipelineStatus status) { 98 void SetVideoRendererInitializeExpectations(PipelineStatus status) {
100 EXPECT_CALL(*video_renderer_, 99 EXPECT_CALL(*video_renderer_,
101 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _)) 100 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _))
102 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), 101 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_),
103 SaveArg<6>(&video_ended_cb_), RunCallback<1>(status))); 102 SaveArg<5>(&video_ended_cb_), RunCallback<1>(status)));
104 } 103 }
105 104
106 void InitializeAndExpect(PipelineStatus start_status) { 105 void InitializeAndExpect(PipelineStatus start_status) {
107 EXPECT_CALL(callbacks_, OnInitialize(start_status)); 106 EXPECT_CALL(callbacks_, OnInitialize(start_status));
108 EXPECT_CALL(callbacks_, OnWaitingForDecryptionKey()).Times(0); 107 EXPECT_CALL(callbacks_, OnWaitingForDecryptionKey()).Times(0);
109 108
110 if (start_status == PIPELINE_OK && audio_stream_) { 109 if (start_status == PIPELINE_OK && audio_stream_) {
111 EXPECT_CALL(*audio_renderer_, GetTimeSource()) 110 EXPECT_CALL(*audio_renderer_, GetTimeSource())
112 .WillOnce(Return(&time_source_)); 111 .WillOnce(Return(&time_source_));
113 } else { 112 } else {
114 renderer_impl_->set_time_source_for_testing(&time_source_); 113 renderer_impl_->set_time_source_for_testing(&time_source_);
115 } 114 }
116 115
117 renderer_impl_->Initialize( 116 renderer_impl_->Initialize(
118 demuxer_.get(), 117 demuxer_.get(),
119 base::Bind(&CallbackHelper::OnInitialize, 118 base::Bind(&CallbackHelper::OnInitialize,
120 base::Unretained(&callbacks_)), 119 base::Unretained(&callbacks_)),
121 base::Bind(&CallbackHelper::OnUpdateStatistics, 120 base::Bind(&CallbackHelper::OnUpdateStatistics,
122 base::Unretained(&callbacks_)), 121 base::Unretained(&callbacks_)),
123 base::Bind(&CallbackHelper::OnBufferingStateChange, 122 base::Bind(&CallbackHelper::OnBufferingStateChange,
124 base::Unretained(&callbacks_)), 123 base::Unretained(&callbacks_)),
125 base::Bind(&CallbackHelper::OnVideoFramePaint,
126 base::Unretained(&callbacks_)),
127 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 124 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
128 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 125 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
129 base::Bind(&CallbackHelper::OnWaitingForDecryptionKey, 126 base::Bind(&CallbackHelper::OnWaitingForDecryptionKey,
130 base::Unretained(&callbacks_))); 127 base::Unretained(&callbacks_)));
131 base::RunLoop().RunUntilIdle(); 128 base::RunLoop().RunUntilIdle();
132 } 129 }
133 130
134 void CreateAudioStream() { 131 void CreateAudioStream() {
135 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 132 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
136 streams_.push_back(audio_stream_.get()); 133 streams_.push_back(audio_stream_.get());
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); 465 audio_error_cb_.Run(PIPELINE_ERROR_DECODE);
469 base::RunLoop().RunUntilIdle(); 466 base::RunLoop().RunUntilIdle();
470 } 467 }
471 468
472 TEST_F(RendererImplTest, ErrorDuringInitialize) { 469 TEST_F(RendererImplTest, ErrorDuringInitialize) {
473 CreateAudioAndVideoStream(); 470 CreateAudioAndVideoStream();
474 SetAudioRendererInitializeExpectations(PIPELINE_OK); 471 SetAudioRendererInitializeExpectations(PIPELINE_OK);
475 472
476 // Force an audio error to occur during video renderer initialization. 473 // Force an audio error to occur during video renderer initialization.
477 EXPECT_CALL(*video_renderer_, 474 EXPECT_CALL(*video_renderer_,
478 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _)) 475 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _))
479 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), 476 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE),
480 SaveArg<4>(&video_buffering_state_cb_), 477 SaveArg<4>(&video_buffering_state_cb_),
481 SaveArg<6>(&video_ended_cb_), 478 SaveArg<5>(&video_ended_cb_),
482 RunCallback<1>(PIPELINE_OK))); 479 RunCallback<1>(PIPELINE_OK)));
483 480
484 InitializeAndExpect(PIPELINE_ERROR_DECODE); 481 InitializeAndExpect(PIPELINE_ERROR_DECODE);
485 } 482 }
486 483
487 TEST_F(RendererImplTest, AudioUnderflow) { 484 TEST_F(RendererImplTest, AudioUnderflow) {
488 InitializeWithAudio(); 485 InitializeWithAudio();
489 Play(); 486 Play();
490 487
491 // Underflow should occur immediately with a single audio track. 488 // Underflow should occur immediately with a single audio track.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 Mock::VerifyAndClearExpectations(&time_source_); 558 Mock::VerifyAndClearExpectations(&time_source_);
562 559
563 EXPECT_CALL(time_source_, StopTicking()); 560 EXPECT_CALL(time_source_, StopTicking());
564 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); 561 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
565 562
566 // Nothing else should primed on the message loop. 563 // Nothing else should primed on the message loop.
567 base::RunLoop().RunUntilIdle(); 564 base::RunLoop().RunUntilIdle();
568 } 565 }
569 566
570 } // namespace media 567 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | media/renderers/video_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698