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

Side by Side Diff: content/browser/media/capture/desktop_capture_device_unittest.cc

Issue 1418263006: Extend VideoCaptureDevice::Client::OnError() to have a tracked_objects::Location param. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const uint8* v_data, 68 const uint8* v_data,
69 size_t y_stride, 69 size_t y_stride,
70 size_t u_stride, 70 size_t u_stride,
71 size_t v_stride, 71 size_t v_stride,
72 const media::VideoCaptureFormat& frame_format, 72 const media::VideoCaptureFormat& frame_format,
73 int clockwise_rotation, 73 int clockwise_rotation,
74 const base::TimeTicks& timestamp)); 74 const base::TimeTicks& timestamp));
75 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 75 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
76 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 76 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
77 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 77 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
78 MOCK_METHOD1(OnError, void(const std::string& reason)); 78 MOCK_METHOD2(OnError,
79 void(const tracked_objects::Location& from_here,
80 const std::string& reason));
79 81
80 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>. 82 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>.
81 scoped_ptr<Buffer> ReserveOutputBuffer( 83 scoped_ptr<Buffer> ReserveOutputBuffer(
82 const gfx::Size& dimensions, 84 const gfx::Size& dimensions,
83 media::VideoPixelFormat format, 85 media::VideoPixelFormat format,
84 media::VideoPixelStorage storage) override { 86 media::VideoPixelStorage storage) override {
85 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && 87 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 &&
86 storage == media::PIXEL_STORAGE_CPU); 88 storage == media::PIXEL_STORAGE_CPU);
87 DoReserveOutputBuffer(); 89 DoReserveOutputBuffer();
88 return scoped_ptr<Buffer>(); 90 return scoped_ptr<Buffer>();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 scoped_ptr<webrtc::DesktopCapturer> capturer( 278 scoped_ptr<webrtc::DesktopCapturer> capturer(
277 webrtc::ScreenCapturer::Create( 279 webrtc::ScreenCapturer::Create(
278 webrtc::DesktopCaptureOptions::CreateDefault())); 280 webrtc::DesktopCaptureOptions::CreateDefault()));
279 CreateScreenCaptureDevice(capturer.Pass()); 281 CreateScreenCaptureDevice(capturer.Pass());
280 282
281 media::VideoCaptureFormat format; 283 media::VideoCaptureFormat format;
282 base::WaitableEvent done_event(false, false); 284 base::WaitableEvent done_event(false, false);
283 int frame_size; 285 int frame_size;
284 286
285 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 287 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
286 EXPECT_CALL(*client, OnError(_)).Times(0); 288 EXPECT_CALL(*client, OnError(_, _)).Times(0);
287 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 289 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
288 DoAll(SaveArg<1>(&frame_size), 290 DoAll(SaveArg<1>(&frame_size),
289 SaveArg<2>(&format), 291 SaveArg<2>(&format),
290 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 292 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
291 293
292 media::VideoCaptureParams capture_params; 294 media::VideoCaptureParams capture_params;
293 capture_params.requested_format.frame_size.SetSize(640, 480); 295 capture_params.requested_format.frame_size.SetSize(640, 480);
294 capture_params.requested_format.frame_rate = kFrameRate; 296 capture_params.requested_format.frame_rate = kFrameRate;
295 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 297 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
296 capture_device_->AllocateAndStart(capture_params, client.Pass()); 298 capture_device_->AllocateAndStart(capture_params, client.Pass());
(...skipping 13 matching lines...) Expand all
310 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeConstantResolution) { 312 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeConstantResolution) {
311 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); 313 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer();
312 314
313 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 315 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
314 316
315 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1), 317 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1),
316 gfx::Size(kTestFrameWidth1, kTestFrameHeight1)); 318 gfx::Size(kTestFrameWidth1, kTestFrameHeight1));
317 base::WaitableEvent done_event(false, false); 319 base::WaitableEvent done_event(false, false);
318 320
319 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 321 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
320 EXPECT_CALL(*client, OnError(_)).Times(0); 322 EXPECT_CALL(*client, OnError(_, _)).Times(0);
321 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 323 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
322 DoAll(WithArg<2>(Invoke(&format_checker, 324 DoAll(WithArg<2>(Invoke(&format_checker,
323 &FormatChecker::ExpectAcceptableSize)), 325 &FormatChecker::ExpectAcceptableSize)),
324 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 326 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
325 327
326 media::VideoCaptureParams capture_params; 328 media::VideoCaptureParams capture_params;
327 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 329 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
328 kTestFrameHeight1); 330 kTestFrameHeight1);
329 capture_params.requested_format.frame_rate = kFrameRate; 331 capture_params.requested_format.frame_rate = kFrameRate;
330 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 332 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 19 matching lines...) Expand all
350 // the same aspect ratio. 352 // the same aspect ratio.
351 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeFixedAspectRatio) { 353 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeFixedAspectRatio) {
352 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); 354 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer();
353 355
354 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 356 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
355 357
356 FormatChecker format_checker(gfx::Size(888, 500), gfx::Size(532, 300)); 358 FormatChecker format_checker(gfx::Size(888, 500), gfx::Size(532, 300));
357 base::WaitableEvent done_event(false, false); 359 base::WaitableEvent done_event(false, false);
358 360
359 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 361 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
360 EXPECT_CALL(*client, OnError(_)).Times(0); 362 EXPECT_CALL(*client, OnError(_,_)).Times(0);
361 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 363 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
362 DoAll(WithArg<2>(Invoke(&format_checker, 364 DoAll(WithArg<2>(Invoke(&format_checker,
363 &FormatChecker::ExpectAcceptableSize)), 365 &FormatChecker::ExpectAcceptableSize)),
364 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 366 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
365 367
366 media::VideoCaptureParams capture_params; 368 media::VideoCaptureParams capture_params;
367 const gfx::Size high_def_16_by_9(1920, 1080); 369 const gfx::Size high_def_16_by_9(1920, 1080);
368 ASSERT_GE(high_def_16_by_9.width(), 370 ASSERT_GE(high_def_16_by_9.width(),
369 std::max(kTestFrameWidth1, kTestFrameWidth2)); 371 std::max(kTestFrameWidth1, kTestFrameWidth2));
370 ASSERT_GE(high_def_16_by_9.height(), 372 ASSERT_GE(high_def_16_by_9.height(),
(...skipping 24 matching lines...) Expand all
395 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeVariableResolution) { 397 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeVariableResolution) {
396 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); 398 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer();
397 399
398 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 400 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
399 401
400 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1), 402 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1),
401 gfx::Size(kTestFrameWidth2, kTestFrameHeight2)); 403 gfx::Size(kTestFrameWidth2, kTestFrameHeight2));
402 base::WaitableEvent done_event(false, false); 404 base::WaitableEvent done_event(false, false);
403 405
404 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 406 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
405 EXPECT_CALL(*client, OnError(_)).Times(0); 407 EXPECT_CALL(*client, OnError(_,_)).Times(0);
406 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 408 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
407 DoAll(WithArg<2>(Invoke(&format_checker, 409 DoAll(WithArg<2>(Invoke(&format_checker,
408 &FormatChecker::ExpectAcceptableSize)), 410 &FormatChecker::ExpectAcceptableSize)),
409 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 411 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
410 412
411 media::VideoCaptureParams capture_params; 413 media::VideoCaptureParams capture_params;
412 const gfx::Size high_def_16_by_9(1920, 1080); 414 const gfx::Size high_def_16_by_9(1920, 1080);
413 ASSERT_GE(high_def_16_by_9.width(), 415 ASSERT_GE(high_def_16_by_9.width(),
414 std::max(kTestFrameWidth1, kTestFrameWidth2)); 416 std::max(kTestFrameWidth1, kTestFrameWidth2));
415 ASSERT_GE(high_def_16_by_9.height(), 417 ASSERT_GE(high_def_16_by_9.height(),
(...skipping 26 matching lines...) Expand all
442 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 444 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
443 445
444 media::VideoCaptureFormat format; 446 media::VideoCaptureFormat format;
445 base::WaitableEvent done_event(false, false); 447 base::WaitableEvent done_event(false, false);
446 448
447 int frame_size = 0; 449 int frame_size = 0;
448 output_frame_.reset(new webrtc::BasicDesktopFrame( 450 output_frame_.reset(new webrtc::BasicDesktopFrame(
449 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1))); 451 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1)));
450 452
451 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 453 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
452 EXPECT_CALL(*client, OnError(_)).Times(0); 454 EXPECT_CALL(*client, OnError(_,_)).Times(0);
453 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 455 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
454 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame), 456 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame),
455 SaveArg<1>(&frame_size), 457 SaveArg<1>(&frame_size),
456 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 458 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
457 459
458 media::VideoCaptureParams capture_params; 460 media::VideoCaptureParams capture_params;
459 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 461 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
460 kTestFrameHeight1); 462 kTestFrameHeight1);
461 capture_params.requested_format.frame_rate = kFrameRate; 463 capture_params.requested_format.frame_rate = kFrameRate;
462 capture_params.requested_format.pixel_format = 464 capture_params.requested_format.pixel_format =
(...skipping 22 matching lines...) Expand all
485 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer)); 487 CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer>(mock_capturer));
486 488
487 media::VideoCaptureFormat format; 489 media::VideoCaptureFormat format;
488 base::WaitableEvent done_event(false, false); 490 base::WaitableEvent done_event(false, false);
489 491
490 int frame_size = 0; 492 int frame_size = 0;
491 output_frame_.reset(new webrtc::BasicDesktopFrame( 493 output_frame_.reset(new webrtc::BasicDesktopFrame(
492 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1))); 494 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1)));
493 495
494 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 496 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
495 EXPECT_CALL(*client, OnError(_)).Times(0); 497 EXPECT_CALL(*client, OnError(_,_)).Times(0);
496 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 498 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly(
497 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame), 499 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame),
498 SaveArg<1>(&frame_size), 500 SaveArg<1>(&frame_size),
499 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 501 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
500 502
501 media::VideoCaptureParams capture_params; 503 media::VideoCaptureParams capture_params;
502 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 504 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
503 kTestFrameHeight1); 505 kTestFrameHeight1);
504 capture_params.requested_format.frame_rate = kFrameRate; 506 capture_params.requested_format.frame_rate = kFrameRate;
505 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 507 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 13 matching lines...) Expand all
519 frame_size); 521 frame_size);
520 for (int i = 0; i < output_frame_->size().height(); ++i) { 522 for (int i = 0; i < output_frame_->size().height(); ++i) {
521 EXPECT_EQ(0, 523 EXPECT_EQ(0,
522 memcmp(inverted_frame->data() + i * inverted_frame->stride(), 524 memcmp(inverted_frame->data() + i * inverted_frame->stride(),
523 output_frame_->data() + i * output_frame_->stride(), 525 output_frame_->data() + i * output_frame_->stride(),
524 output_frame_->stride())); 526 output_frame_->stride()));
525 } 527 }
526 } 528 }
527 529
528 } // namespace content 530 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698