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

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 cc_unittests 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
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 } 112 }
114 113
115 renderer_impl_->Initialize( 114 renderer_impl_->Initialize(
116 demuxer_.get(), 115 demuxer_.get(),
117 base::Bind(&CallbackHelper::OnInitialize, 116 base::Bind(&CallbackHelper::OnInitialize,
118 base::Unretained(&callbacks_)), 117 base::Unretained(&callbacks_)),
119 base::Bind(&CallbackHelper::OnUpdateStatistics, 118 base::Bind(&CallbackHelper::OnUpdateStatistics,
120 base::Unretained(&callbacks_)), 119 base::Unretained(&callbacks_)),
121 base::Bind(&CallbackHelper::OnBufferingStateChange, 120 base::Bind(&CallbackHelper::OnBufferingStateChange,
122 base::Unretained(&callbacks_)), 121 base::Unretained(&callbacks_)),
123 base::Bind(&CallbackHelper::OnVideoFramePaint,
124 base::Unretained(&callbacks_)),
125 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 122 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
126 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 123 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
127 base::Bind(&CallbackHelper::OnWaitingForDecryptionKey, 124 base::Bind(&CallbackHelper::OnWaitingForDecryptionKey,
128 base::Unretained(&callbacks_))); 125 base::Unretained(&callbacks_)));
129 base::RunLoop().RunUntilIdle(); 126 base::RunLoop().RunUntilIdle();
130 } 127 }
131 128
132 void CreateAudioStream() { 129 void CreateAudioStream() {
133 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 130 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
134 streams_.push_back(audio_stream_.get()); 131 streams_.push_back(audio_stream_.get());
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); 427 audio_error_cb_.Run(PIPELINE_ERROR_DECODE);
431 base::RunLoop().RunUntilIdle(); 428 base::RunLoop().RunUntilIdle();
432 } 429 }
433 430
434 TEST_F(RendererImplTest, ErrorDuringInitialize) { 431 TEST_F(RendererImplTest, ErrorDuringInitialize) {
435 CreateAudioAndVideoStream(); 432 CreateAudioAndVideoStream();
436 SetAudioRendererInitializeExpectations(PIPELINE_OK); 433 SetAudioRendererInitializeExpectations(PIPELINE_OK);
437 434
438 // Force an audio error to occur during video renderer initialization. 435 // Force an audio error to occur during video renderer initialization.
439 EXPECT_CALL(*video_renderer_, 436 EXPECT_CALL(*video_renderer_,
440 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _)) 437 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _))
441 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), 438 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE),
442 SaveArg<4>(&video_buffering_state_cb_), 439 SaveArg<4>(&video_buffering_state_cb_),
443 SaveArg<6>(&video_ended_cb_), 440 SaveArg<5>(&video_ended_cb_),
444 RunCallback<1>(PIPELINE_OK))); 441 RunCallback<1>(PIPELINE_OK)));
445 442
446 InitializeAndExpect(PIPELINE_ERROR_DECODE); 443 InitializeAndExpect(PIPELINE_ERROR_DECODE);
447 } 444 }
448 445
449 } // namespace media 446 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698