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

Side by Side Diff: content/renderer/media/rtc_video_decoder_unittest.cc

Issue 8417019: Simplify VideoDecodeEngine interface by making everything synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for CaptureVideoDecoder Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/rtc_video_decoder.cc ('k') | media/base/filters.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/media/rtc_video_decoder.h" 5 #include "content/renderer/media/rtc_video_decoder.h"
6 6
7 #include <deque> 7 #include <deque>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 decoder_->Initialize(NULL, 134 decoder_->Initialize(NULL,
135 NewExpectedClosure(), NewStatisticsCallback()); 135 NewExpectedClosure(), NewStatisticsCallback());
136 message_loop_.RunAllPending(); 136 message_loop_.RunAllPending();
137 } 137 }
138 138
139 StatisticsCallback NewStatisticsCallback() { 139 StatisticsCallback NewStatisticsCallback() {
140 return base::Bind(&MockStatisticsCallback::OnStatistics, 140 return base::Bind(&MockStatisticsCallback::OnStatistics,
141 base::Unretained(&stats_callback_object_)); 141 base::Unretained(&stats_callback_object_));
142 } 142 }
143 143
144 MOCK_METHOD1(FrameReady, void(scoped_refptr<media::VideoFrame>));
145
144 // Fixture members. 146 // Fixture members.
145 scoped_refptr<RTCVideoDecoder> decoder_; 147 scoped_refptr<RTCVideoDecoder> decoder_;
146 scoped_refptr<MockVideoRenderer> renderer_; 148 scoped_refptr<MockVideoRenderer> renderer_;
147 MockStatisticsCallback stats_callback_object_; 149 MockStatisticsCallback stats_callback_object_;
148 StrictMock<MockFilterHost> host_; 150 StrictMock<MockFilterHost> host_;
149 MessageLoop message_loop_; 151 MessageLoop message_loop_;
150 152
151 private: 153 private:
152 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoderTest); 154 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoderTest);
153 }; 155 };
(...skipping 10 matching lines...) Expand all
164 // matches the dimensions specified by RTC. 166 // matches the dimensions specified by RTC.
165 EXPECT_EQ(kWidth, decoder_->natural_size().width()); 167 EXPECT_EQ(kWidth, decoder_->natural_size().width());
166 EXPECT_EQ(kHeight, decoder_->natural_size().height()); 168 EXPECT_EQ(kHeight, decoder_->natural_size().height());
167 } 169 }
168 170
169 TEST_F(RTCVideoDecoderTest, DoSeek) { 171 TEST_F(RTCVideoDecoderTest, DoSeek) {
170 const base::TimeDelta kZero; 172 const base::TimeDelta kZero;
171 173
172 InitializeDecoderSuccessfully(); 174 InitializeDecoderSuccessfully();
173 175
174 decoder_->set_consume_video_frame_callback( 176 // Expect seek and verify the results.
175 base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
176 base::Unretained(renderer_.get())));
177
178 // Expect Seek and verify the results.
179 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
180 .Times(Limits::kMaxVideoFrames);
181 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK)); 177 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK));
182 178
183 message_loop_.RunAllPending(); 179 message_loop_.RunAllPending();
184 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); 180 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_);
185 } 181 }
186 182
187 TEST_F(RTCVideoDecoderTest, DoRenderFrame) { 183 TEST_F(RTCVideoDecoderTest, DoRenderFrame) {
188 const base::TimeDelta kZero; 184 const base::TimeDelta kZero;
189 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta())); 185 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta()));
190 186
191 InitializeDecoderSuccessfully(); 187 InitializeDecoderSuccessfully();
192 188
193 // Pass the frame back to decoder
194 decoder_->set_consume_video_frame_callback(
195 base::Bind(&RTCVideoDecoder::ProduceVideoFrame,
196 base::Unretained(decoder_.get())));
197 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK));
198
199 decoder_->set_consume_video_frame_callback(
200 base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
201 base::Unretained(renderer_.get())));
202 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
203 .Times(Limits::kMaxVideoFrames);
204
205 NullVideoFrame video_frame; 189 NullVideoFrame video_frame;
206 190
207 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { 191 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) {
208 decoder_->RenderFrame(&video_frame); 192 decoder_->RenderFrame(&video_frame);
209 } 193 }
210 194
211 message_loop_.RunAllPending(); 195 message_loop_.RunAllPending();
212 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); 196 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_);
213 } 197 }
214 198
215 TEST_F(RTCVideoDecoderTest, DoSetSize) { 199 TEST_F(RTCVideoDecoderTest, DoSetSize) {
216 InitializeDecoderSuccessfully(); 200 InitializeDecoderSuccessfully();
217 201
218 int new_width = kWidth * 2; 202 int new_width = kWidth * 2;
219 int new_height = kHeight * 2; 203 int new_height = kHeight * 2;
220 gfx::Size new_natural_size(new_width, new_height); 204 gfx::Size new_natural_size(new_width, new_height);
221 int new_reserved = 0; 205 int new_reserved = 0;
222 206
223 EXPECT_CALL(host_, 207 EXPECT_CALL(host_,
224 SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return()); 208 SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return());
225 209
226 decoder_->SetSize(new_width, new_height, new_reserved); 210 decoder_->SetSize(new_width, new_height, new_reserved);
227 211
228 EXPECT_EQ(new_width, decoder_->natural_size().width()); 212 EXPECT_EQ(new_width, decoder_->natural_size().width());
229 EXPECT_EQ(new_height, decoder_->natural_size().height()); 213 EXPECT_EQ(new_height, decoder_->natural_size().height());
230 214
231 message_loop_.RunAllPending(); 215 message_loop_.RunAllPending();
232 } 216 }
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_decoder.cc ('k') | media/base/filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698