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

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 68503005: Reorganize media::VideoCapture* types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a7375761 Rebase. Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 void OnBufferFilledDispatch(int device_id, 194 void OnBufferFilledDispatch(int device_id,
195 int buffer_id, 195 int buffer_id,
196 base::Time timestamp, 196 base::Time timestamp,
197 const media::VideoCaptureFormat& frame_format) { 197 const media::VideoCaptureFormat& frame_format) {
198 base::SharedMemory* dib = filled_dib_[buffer_id]; 198 base::SharedMemory* dib = filled_dib_[buffer_id];
199 ASSERT_TRUE(dib != NULL); 199 ASSERT_TRUE(dib != NULL);
200 if (dump_video_) { 200 if (dump_video_) {
201 if (!format_.IsValid()) { 201 if (!format_.IsValid()) {
202 dumper_.StartDump(frame_format.width, frame_format.height); 202 dumper_.StartDump(frame_format.frame_size.width(),
203 frame_format.frame_size.height());
203 format_ = frame_format; 204 format_ = frame_format;
204 } 205 }
205 ASSERT_EQ(format_.width, frame_format.width) 206 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width())
206 << "Dump format does not handle variable resolution."; 207 << "Dump format does not handle variable resolution.";
207 ASSERT_EQ(format_.height, frame_format.height) 208 ASSERT_EQ(format_.frame_size.height(), frame_format.frame_size.height())
208 << "Dump format does not handle variable resolution.";; 209 << "Dump format does not handle variable resolution.";
209 dumper_.NewVideoFrame(dib->memory()); 210 dumper_.NewVideoFrame(dib->memory());
210 } 211 }
211 212
212 OnBufferFilled(device_id, buffer_id, timestamp, frame_format); 213 OnBufferFilled(device_id, buffer_id, timestamp, frame_format);
213 if (return_buffers_) { 214 if (return_buffers_) {
214 VideoCaptureHost::OnReceiveEmptyBuffer(device_id, buffer_id); 215 VideoCaptureHost::OnReceiveEmptyBuffer(device_id, buffer_id);
215 } 216 }
216 } 217 }
217 218
218 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { 219 void OnStateChangedDispatch(int device_id, VideoCaptureState state) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 EXPECT_CALL(*host_, OnNewBufferCreated(kDeviceId, _, _, _)) 341 EXPECT_CALL(*host_, OnNewBufferCreated(kDeviceId, _, _, _))
341 .Times(AnyNumber()).WillRepeatedly(Return()); 342 .Times(AnyNumber()).WillRepeatedly(Return());
342 343
343 base::RunLoop run_loop; 344 base::RunLoop run_loop;
344 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _)) 345 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _))
345 .Times(AnyNumber()).WillOnce(ExitMessageLoop( 346 .Times(AnyNumber()).WillOnce(ExitMessageLoop(
346 message_loop_, run_loop.QuitClosure())); 347 message_loop_, run_loop.QuitClosure()));
347 348
348 media::VideoCaptureParams params; 349 media::VideoCaptureParams params;
349 params.requested_format = media::VideoCaptureFormat( 350 params.requested_format = media::VideoCaptureFormat(
350 352, 288, 30, media::ConstantResolutionVideoCaptureDevice); 351 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
351 params.session_id = opened_session_id_; 352 params.session_id = opened_session_id_;
352 host_->OnStartCapture(kDeviceId, params); 353 host_->OnStartCapture(kDeviceId, params);
353 run_loop.Run(); 354 run_loop.Run();
354 } 355 }
355 356
356 void StartStopCapture() { 357 void StartStopCapture() {
357 // Quickly start and then stop capture, without giving much chance for 358 // Quickly start and then stop capture, without giving much chance for
358 // asynchronous start operations to complete. 359 // asynchronous start operations to complete.
359 InSequence s; 360 InSequence s;
360 base::RunLoop run_loop; 361 base::RunLoop run_loop;
361 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)); 362 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED));
362 media::VideoCaptureParams params; 363 media::VideoCaptureParams params;
363 params.requested_format = media::VideoCaptureFormat( 364 params.requested_format = media::VideoCaptureFormat(
364 352, 288, 30, media::ConstantResolutionVideoCaptureDevice); 365 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
365 params.session_id = opened_session_id_; 366 params.session_id = opened_session_id_;
366 host_->OnStartCapture(kDeviceId, params); 367 host_->OnStartCapture(kDeviceId, params);
367 host_->OnStopCapture(kDeviceId); 368 host_->OnStopCapture(kDeviceId);
368 run_loop.RunUntilIdle(); 369 run_loop.RunUntilIdle();
369 } 370 }
370 371
371 #ifdef DUMP_VIDEO 372 #ifdef DUMP_VIDEO
372 void CaptureAndDumpVideo(int width, int height, int frame_rate) { 373 void CaptureAndDumpVideo(int width, int height, int frame_rate) {
373 InSequence s; 374 InSequence s;
374 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _)) 375 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _))
375 .Times(AnyNumber()).WillRepeatedly(Return()); 376 .Times(AnyNumber()).WillRepeatedly(Return());
376 377
377 base::RunLoop run_loop; 378 base::RunLoop run_loop;
378 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _)) 379 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _))
379 .Times(AnyNumber()) 380 .Times(AnyNumber())
380 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); 381 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure()));
381 382
382 media::VideoCaptureParams params; 383 media::VideoCaptureParams params;
383 params.requested_format = media::VideoCaptureFormat( 384 params.requested_format =
384 width, height, frame_rate, media::ConstantResolutionVideoCaptureDevice); 385 media::VideoCaptureFormat(gfx::Size(width, height), frame_rate);
385 params.session_id = opened_session_id_; 386 params.session_id = opened_session_id_;
386 host_->SetDumpVideo(true); 387 host_->SetDumpVideo(true);
387 host_->OnStartCapture(kDeviceId, params); 388 host_->OnStartCapture(kDeviceId, params);
388 run_loop.Run(); 389 run_loop.Run();
389 } 390 }
390 #endif 391 #endif
391 392
392 void StopCapture() { 393 void StopCapture() {
393 base::RunLoop run_loop; 394 base::RunLoop run_loop;
394 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)) 395 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED))
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 #ifdef DUMP_VIDEO 484 #ifdef DUMP_VIDEO
484 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 485 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
485 CaptureAndDumpVideo(640, 480, 30); 486 CaptureAndDumpVideo(640, 480, 30);
486 } 487 }
487 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 488 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
488 CaptureAndDumpVideo(1280, 720, 30); 489 CaptureAndDumpVideo(1280, 720, 30);
489 } 490 }
490 #endif 491 #endif
491 492
492 } // namespace content 493 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698