| OLD | NEW |
| 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 // Unit test for VideoCaptureController. | 5 // Unit test for VideoCaptureController. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/video_capture_controller.h" | 7 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 : public media::VideoFrameConsumerFeedbackObserver { | 108 : public media::VideoFrameConsumerFeedbackObserver { |
| 109 public: | 109 public: |
| 110 MOCK_METHOD2(OnUtilizationReport, | 110 MOCK_METHOD2(OnUtilizationReport, |
| 111 void(int frame_feedback_id, double utilization)); | 111 void(int frame_feedback_id, double utilization)); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class MockFrameBufferPool : public media::FrameBufferPool { | 114 class MockFrameBufferPool : public media::FrameBufferPool { |
| 115 public: | 115 public: |
| 116 MOCK_METHOD1(SetBufferHold, void(int buffer_id)); | 116 MOCK_METHOD1(SetBufferHold, void(int buffer_id)); |
| 117 MOCK_METHOD1(ReleaseBufferHold, void(int buffer_id)); | 117 MOCK_METHOD1(ReleaseBufferHold, void(int buffer_id)); |
| 118 MOCK_METHOD1(GetHandleForTransit, | |
| 119 mojo::ScopedSharedBufferHandle(int buffer_id)); | |
| 120 }; | 118 }; |
| 121 | 119 |
| 122 // Test class. | 120 // Test class. |
| 123 class VideoCaptureControllerTest | 121 class VideoCaptureControllerTest |
| 124 : public testing::Test, | 122 : public testing::Test, |
| 125 public testing::WithParamInterface<media::VideoPixelFormat> { | 123 public testing::WithParamInterface<media::VideoPixelFormat> { |
| 126 public: | 124 public: |
| 127 VideoCaptureControllerTest() {} | 125 VideoCaptureControllerTest() {} |
| 128 ~VideoCaptureControllerTest() override {} | 126 ~VideoCaptureControllerTest() override {} |
| 129 | 127 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 client_a_.get(), | 306 client_a_.get(), |
| 309 200, | 307 200, |
| 310 session_200); | 308 session_200); |
| 311 ASSERT_EQ(3, controller_->GetClientCount()); | 309 ASSERT_EQ(3, controller_->GetClientCount()); |
| 312 | 310 |
| 313 // Now, simulate an incoming captured buffer from the capture device. As a | 311 // Now, simulate an incoming captured buffer from the capture device. As a |
| 314 // side effect this will cause the first buffer to be shared with clients. | 312 // side effect this will cause the first buffer to be shared with clients. |
| 315 uint8_t buffer_no = 1; | 313 uint8_t buffer_no = 1; |
| 316 const int arbitrary_frame_feedback_id = 101; | 314 const int arbitrary_frame_feedback_id = 101; |
| 317 ASSERT_EQ(0.0, device_client_->GetBufferPoolUtilization()); | 315 ASSERT_EQ(0.0, device_client_->GetBufferPoolUtilization()); |
| 318 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 316 media::VideoCaptureDevice::Client::Buffer buffer = |
| 319 device_client_->ReserveOutputBuffer(device_format.frame_size, | 317 device_client_->ReserveOutputBuffer( |
| 320 device_format.pixel_format, | 318 device_format.frame_size, device_format.pixel_format, |
| 321 device_format.pixel_storage, | 319 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 322 arbitrary_frame_feedback_id)); | 320 ASSERT_TRUE(buffer.is_valid()); |
| 323 ASSERT_TRUE(buffer.get()); | 321 auto buffer_access = buffer.handle_provider->GetHandleForInProcessAccess(); |
| 324 ASSERT_EQ(1.0 / kPoolSize, device_client_->GetBufferPoolUtilization()); | 322 ASSERT_EQ(1.0 / kPoolSize, device_client_->GetBufferPoolUtilization()); |
| 325 memset(buffer->data(), buffer_no++, buffer->mapped_size()); | 323 memset(buffer_access->data(), buffer_no++, buffer_access->mapped_size()); |
| 326 { | 324 { |
| 327 InSequence s; | 325 InSequence s; |
| 328 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); | 326 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); |
| 329 EXPECT_CALL(*client_a_, | 327 EXPECT_CALL(*client_a_, |
| 330 DoBufferReady(client_a_route_1, device_format.frame_size)) | 328 DoBufferReady(client_a_route_1, device_format.frame_size)) |
| 331 .Times(1); | 329 .Times(1); |
| 332 } | 330 } |
| 333 { | 331 { |
| 334 InSequence s; | 332 InSequence s; |
| 335 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1)).Times(1); | 333 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1)).Times(1); |
| 336 EXPECT_CALL(*client_b_, | 334 EXPECT_CALL(*client_b_, |
| 337 DoBufferReady(client_b_route_1, device_format.frame_size)) | 335 DoBufferReady(client_b_route_1, device_format.frame_size)) |
| 338 .Times(1); | 336 .Times(1); |
| 339 } | 337 } |
| 340 { | 338 { |
| 341 InSequence s; | 339 InSequence s; |
| 342 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2)).Times(1); | 340 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2)).Times(1); |
| 343 EXPECT_CALL(*client_a_, | 341 EXPECT_CALL(*client_a_, |
| 344 DoBufferReady(client_a_route_2, device_format.frame_size)) | 342 DoBufferReady(client_a_route_2, device_format.frame_size)) |
| 345 .Times(1); | 343 .Times(1); |
| 346 } | 344 } |
| 347 client_a_->resource_utilization_ = 0.5; | 345 client_a_->resource_utilization_ = 0.5; |
| 348 client_b_->resource_utilization_ = -1.0; | 346 client_b_->resource_utilization_ = -1.0; |
| 349 { | 347 { |
| 350 InSequence s; | 348 InSequence s; |
| 351 EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer->id())) | 349 EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer.id())) |
| 352 .Times(1); | 350 .Times(1); |
| 353 // Expect VideoCaptureController to call the load observer with a | 351 // Expect VideoCaptureController to call the load observer with a |
| 354 // resource utilization of 0.5 (the largest of all reported values). | 352 // resource utilization of 0.5 (the largest of all reported values). |
| 355 EXPECT_CALL(*mock_consumer_feedback_observer_, | 353 EXPECT_CALL(*mock_consumer_feedback_observer_, |
| 356 OnUtilizationReport(arbitrary_frame_feedback_id, 0.5)) | 354 OnUtilizationReport(arbitrary_frame_feedback_id, 0.5)) |
| 357 .Times(1); | 355 .Times(1); |
| 358 EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer->id())) | 356 EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer.id())) |
| 359 .Times(1); | 357 .Times(1); |
| 360 } | 358 } |
| 361 | 359 |
| 362 device_client_->OnIncomingCapturedBuffer(std::move(buffer), | 360 device_client_->OnIncomingCapturedBuffer(std::move(buffer), |
| 363 device_format, | 361 device_format, |
| 364 arbitrary_reference_time_, | 362 arbitrary_reference_time_, |
| 365 arbitrary_timestamp_); | 363 arbitrary_timestamp_); |
| 366 | 364 |
| 367 base::RunLoop().RunUntilIdle(); | 365 base::RunLoop().RunUntilIdle(); |
| 368 Mock::VerifyAndClearExpectations(client_a_.get()); | 366 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 369 Mock::VerifyAndClearExpectations(client_b_.get()); | 367 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 370 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_); | 368 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_); |
| 371 Mock::VerifyAndClearExpectations(mock_frame_receiver_observer_); | 369 Mock::VerifyAndClearExpectations(mock_frame_receiver_observer_); |
| 372 | 370 |
| 373 // Second buffer which ought to use the same shared memory buffer. In this | 371 // Second buffer which ought to use the same shared memory buffer. In this |
| 374 // case pretend that the Buffer pointer is held by the device for a long | 372 // case pretend that the Buffer pointer is held by the device for a long |
| 375 // delay. This shouldn't affect anything. | 373 // delay. This shouldn't affect anything. |
| 376 const int arbitrary_frame_feedback_id_2 = 102; | 374 const int arbitrary_frame_feedback_id_2 = 102; |
| 377 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer2 = | 375 media::VideoCaptureDevice::Client::Buffer buffer2 = |
| 378 device_client_->ReserveOutputBuffer(device_format.frame_size, | 376 device_client_->ReserveOutputBuffer( |
| 379 device_format.pixel_format, | 377 device_format.frame_size, device_format.pixel_format, |
| 380 device_format.pixel_storage, | 378 device_format.pixel_storage, arbitrary_frame_feedback_id_2); |
| 381 arbitrary_frame_feedback_id_2); | 379 ASSERT_TRUE(buffer2.is_valid()); |
| 382 ASSERT_TRUE(buffer2.get()); | 380 auto buffer2_access = buffer2.handle_provider->GetHandleForInProcessAccess(); |
| 383 memset(buffer2->data(), buffer_no++, buffer2->mapped_size()); | 381 memset(buffer2_access->data(), buffer_no++, buffer2_access->mapped_size()); |
| 384 client_a_->resource_utilization_ = 0.5; | 382 client_a_->resource_utilization_ = 0.5; |
| 385 client_b_->resource_utilization_ = 3.14; | 383 client_b_->resource_utilization_ = 3.14; |
| 386 // Expect VideoCaptureController to call the load observer with a | 384 // Expect VideoCaptureController to call the load observer with a |
| 387 // resource utilization of 3.14 (the largest of all reported values). | 385 // resource utilization of 3.14 (the largest of all reported values). |
| 388 { | 386 { |
| 389 InSequence s; | 387 InSequence s; |
| 390 EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer2->id())) | 388 EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer2.id())) |
| 391 .Times(1); | 389 .Times(1); |
| 392 // Expect VideoCaptureController to call the load observer with a | 390 // Expect VideoCaptureController to call the load observer with a |
| 393 // resource utilization of 3.14 (the largest of all reported values). | 391 // resource utilization of 3.14 (the largest of all reported values). |
| 394 EXPECT_CALL(*mock_consumer_feedback_observer_, | 392 EXPECT_CALL(*mock_consumer_feedback_observer_, |
| 395 OnUtilizationReport(arbitrary_frame_feedback_id_2, 3.14)) | 393 OnUtilizationReport(arbitrary_frame_feedback_id_2, 3.14)) |
| 396 .Times(1); | 394 .Times(1); |
| 397 EXPECT_CALL(*mock_frame_receiver_observer_, | 395 EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer2.id())) |
| 398 ReleaseBufferHold(buffer2->id())) | |
| 399 .Times(1); | 396 .Times(1); |
| 400 } | 397 } |
| 401 | 398 |
| 402 device_client_->OnIncomingCapturedBuffer(std::move(buffer2), | 399 device_client_->OnIncomingCapturedBuffer(std::move(buffer2), |
| 403 device_format, | 400 device_format, |
| 404 arbitrary_reference_time_, | 401 arbitrary_reference_time_, |
| 405 arbitrary_timestamp_); | 402 arbitrary_timestamp_); |
| 406 | 403 |
| 407 // The buffer should be delivered to the clients in any order. | 404 // The buffer should be delivered to the clients in any order. |
| 408 { | 405 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 435 // Add a fourth client now that some buffers have come through. | 432 // Add a fourth client now that some buffers have come through. |
| 436 controller_->AddClient(client_b_route_2, | 433 controller_->AddClient(client_b_route_2, |
| 437 client_b_.get(), | 434 client_b_.get(), |
| 438 1, | 435 1, |
| 439 session_1); | 436 session_1); |
| 440 Mock::VerifyAndClearExpectations(client_b_.get()); | 437 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 441 | 438 |
| 442 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. | 439 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. |
| 443 for (int i = 0; i < kPoolSize; i++) { | 440 for (int i = 0; i < kPoolSize; i++) { |
| 444 const int arbitrary_frame_feedback_id = 200 + i; | 441 const int arbitrary_frame_feedback_id = 200 + i; |
| 445 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 442 media::VideoCaptureDevice::Client::Buffer buffer = |
| 446 device_client_->ReserveOutputBuffer(device_format.frame_size, | 443 device_client_->ReserveOutputBuffer( |
| 447 device_format.pixel_format, | 444 device_format.frame_size, device_format.pixel_format, |
| 448 device_format.pixel_storage, | 445 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 449 arbitrary_frame_feedback_id); | 446 ASSERT_TRUE(buffer.is_valid()); |
| 450 ASSERT_TRUE(buffer.get()); | 447 auto buffer_access = buffer.handle_provider->GetHandleForInProcessAccess(); |
| 451 memset(buffer->data(), buffer_no++, buffer->mapped_size()); | 448 memset(buffer_access->data(), buffer_no++, buffer_access->mapped_size()); |
| 452 device_client_->OnIncomingCapturedBuffer(std::move(buffer), | 449 device_client_->OnIncomingCapturedBuffer(std::move(buffer), |
| 453 device_format, | 450 device_format, |
| 454 arbitrary_reference_time_, | 451 arbitrary_reference_time_, |
| 455 arbitrary_timestamp_); | 452 arbitrary_timestamp_); |
| 456 } | 453 } |
| 457 // ReserveOutputBuffer ought to fail now, because the pool is depleted. | 454 // ReserveOutputBuffer ought to fail now, because the pool is depleted. |
| 458 ASSERT_FALSE(device_client_ | 455 ASSERT_FALSE(device_client_ |
| 459 ->ReserveOutputBuffer(device_format.frame_size, | 456 ->ReserveOutputBuffer( |
| 460 device_format.pixel_format, | 457 device_format.frame_size, device_format.pixel_format, |
| 461 device_format.pixel_storage, | 458 device_format.pixel_storage, arbitrary_frame_feedback_id) |
| 462 arbitrary_frame_feedback_id) | 459 .is_valid()); |
| 463 .get()); | |
| 464 | 460 |
| 465 // The new client needs to be notified of the creation of |kPoolSize| buffers; | 461 // The new client needs to be notified of the creation of |kPoolSize| buffers; |
| 466 // the old clients only |kPoolSize - 2|. | 462 // the old clients only |kPoolSize - 2|. |
| 467 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); | 463 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); |
| 468 EXPECT_CALL(*client_b_, | 464 EXPECT_CALL(*client_b_, |
| 469 DoBufferReady(client_b_route_2, device_format.frame_size)) | 465 DoBufferReady(client_b_route_2, device_format.frame_size)) |
| 470 .Times(kPoolSize); | 466 .Times(kPoolSize); |
| 471 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)) | 467 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)) |
| 472 .Times(kPoolSize - 2); | 468 .Times(kPoolSize - 2); |
| 473 EXPECT_CALL(*client_a_, | 469 EXPECT_CALL(*client_a_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 487 Mock::VerifyAndClearExpectations(client_a_.get()); | 483 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 488 Mock::VerifyAndClearExpectations(client_b_.get()); | 484 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 489 | 485 |
| 490 // Now test the interaction of client shutdown and buffer delivery. | 486 // Now test the interaction of client shutdown and buffer delivery. |
| 491 // Kill A1 via renderer disconnect (synchronous). | 487 // Kill A1 via renderer disconnect (synchronous). |
| 492 controller_->RemoveClient(client_a_route_1, client_a_.get()); | 488 controller_->RemoveClient(client_a_route_1, client_a_.get()); |
| 493 // Kill B1 via session close (posts a task to disconnect). | 489 // Kill B1 via session close (posts a task to disconnect). |
| 494 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); | 490 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); |
| 495 controller_->StopSession(300); | 491 controller_->StopSession(300); |
| 496 // Queue up another buffer. | 492 // Queue up another buffer. |
| 497 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer3 = | 493 media::VideoCaptureDevice::Client::Buffer buffer3 = |
| 498 device_client_->ReserveOutputBuffer(device_format.frame_size, | 494 device_client_->ReserveOutputBuffer( |
| 499 device_format.pixel_format, | 495 device_format.frame_size, device_format.pixel_format, |
| 500 device_format.pixel_storage, | 496 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 501 arbitrary_frame_feedback_id); | 497 ASSERT_TRUE(buffer3.is_valid()); |
| 502 ASSERT_TRUE(buffer3.get()); | 498 auto buffer3_access = buffer3.handle_provider->GetHandleForInProcessAccess(); |
| 503 memset(buffer3->data(), buffer_no++, buffer3->mapped_size()); | 499 memset(buffer3_access->data(), buffer_no++, buffer3_access->mapped_size()); |
| 504 device_client_->OnIncomingCapturedBuffer(std::move(buffer3), | 500 device_client_->OnIncomingCapturedBuffer(std::move(buffer3), |
| 505 device_format, | 501 device_format, |
| 506 arbitrary_reference_time_, | 502 arbitrary_reference_time_, |
| 507 arbitrary_timestamp_); | 503 arbitrary_timestamp_); |
| 508 | 504 |
| 509 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer4 = | 505 media::VideoCaptureDevice::Client::Buffer buffer4 = |
| 510 device_client_->ReserveOutputBuffer(device_format.frame_size, | 506 device_client_->ReserveOutputBuffer( |
| 511 device_format.pixel_format, | 507 device_format.frame_size, device_format.pixel_format, |
| 512 device_format.pixel_storage, | 508 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 513 arbitrary_frame_feedback_id); | |
| 514 { | 509 { |
| 515 // Kill A2 via session close (posts a task to disconnect, but A2 must not | 510 // Kill A2 via session close (posts a task to disconnect, but A2 must not |
| 516 // be sent either of these two buffers). | 511 // be sent either of these two buffers). |
| 517 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); | 512 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); |
| 518 controller_->StopSession(200); | 513 controller_->StopSession(200); |
| 519 } | 514 } |
| 520 ASSERT_TRUE(buffer4.get()); | 515 ASSERT_TRUE(buffer4.is_valid()); |
| 521 memset(buffer4->data(), buffer_no++, buffer4->mapped_size()); | 516 auto buffer4_access = buffer4.handle_provider->GetHandleForInProcessAccess(); |
| 517 memset(buffer4_access->data(), buffer_no++, buffer4_access->mapped_size()); |
| 522 device_client_->OnIncomingCapturedBuffer(std::move(buffer4), | 518 device_client_->OnIncomingCapturedBuffer(std::move(buffer4), |
| 523 device_format, | 519 device_format, |
| 524 arbitrary_reference_time_, | 520 arbitrary_reference_time_, |
| 525 arbitrary_timestamp_); | 521 arbitrary_timestamp_); |
| 526 // B2 is the only client left, and is the only one that should | 522 // B2 is the only client left, and is the only one that should |
| 527 // get the buffer. | 523 // get the buffer. |
| 528 EXPECT_CALL(*client_b_, | 524 EXPECT_CALL(*client_b_, |
| 529 DoBufferReady(client_b_route_2, device_format.frame_size)) | 525 DoBufferReady(client_b_route_2, device_format.frame_size)) |
| 530 .Times(2); | 526 .Times(2); |
| 531 base::RunLoop().RunUntilIdle(); | 527 base::RunLoop().RunUntilIdle(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 561 // Second client connects after the error state. It also should get told of | 557 // Second client connects after the error state. It also should get told of |
| 562 // the error. | 558 // the error. |
| 563 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 559 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 564 controller_->AddClient(route_id, client_b_.get(), 200, session_200); | 560 controller_->AddClient(route_id, client_b_.get(), 200, session_200); |
| 565 base::RunLoop().RunUntilIdle(); | 561 base::RunLoop().RunUntilIdle(); |
| 566 Mock::VerifyAndClearExpectations(client_b_.get()); | 562 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 567 | 563 |
| 568 media::VideoCaptureFormat device_format( | 564 media::VideoCaptureFormat device_format( |
| 569 capture_resolution, arbitrary_frame_rate_, media::PIXEL_FORMAT_I420, | 565 capture_resolution, arbitrary_frame_rate_, media::PIXEL_FORMAT_I420, |
| 570 media::PIXEL_STORAGE_CPU); | 566 media::PIXEL_STORAGE_CPU); |
| 571 const int arbitrary_frame_feedback_id = 101; | 567 const int arbitrary_frame_feedback_id = 101; |
| 572 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 568 media::VideoCaptureDevice::Client::Buffer buffer = |
| 573 device_client_->ReserveOutputBuffer(device_format.frame_size, | 569 device_client_->ReserveOutputBuffer( |
| 574 device_format.pixel_format, | 570 device_format.frame_size, device_format.pixel_format, |
| 575 device_format.pixel_storage, | 571 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 576 arbitrary_frame_feedback_id)); | |
| 577 device_client_->OnIncomingCapturedBuffer(std::move(buffer), | 572 device_client_->OnIncomingCapturedBuffer(std::move(buffer), |
| 578 device_format, | 573 device_format, |
| 579 arbitrary_reference_time_, | 574 arbitrary_reference_time_, |
| 580 arbitrary_timestamp_); | 575 arbitrary_timestamp_); |
| 581 | 576 |
| 582 base::RunLoop().RunUntilIdle(); | 577 base::RunLoop().RunUntilIdle(); |
| 583 } | 578 } |
| 584 | 579 |
| 585 // Exercises the OnError() codepath of VideoCaptureController, and tests the | 580 // Exercises the OnError() codepath of VideoCaptureController, and tests the |
| 586 // behavior of various operations after the error state has been signalled. | 581 // behavior of various operations after the error state has been signalled. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 598 | 593 |
| 599 // Start the device. Then, before the first buffer, signal an error and | 594 // Start the device. Then, before the first buffer, signal an error and |
| 600 // deliver the buffer. The error should be propagated to clients; the buffer | 595 // deliver the buffer. The error should be propagated to clients; the buffer |
| 601 // should not be. | 596 // should not be. |
| 602 base::RunLoop().RunUntilIdle(); | 597 base::RunLoop().RunUntilIdle(); |
| 603 Mock::VerifyAndClearExpectations(client_a_.get()); | 598 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 604 | 599 |
| 605 media::VideoCaptureFormat device_format( | 600 media::VideoCaptureFormat device_format( |
| 606 gfx::Size(10, 10), arbitrary_frame_rate_, media::PIXEL_FORMAT_I420); | 601 gfx::Size(10, 10), arbitrary_frame_rate_, media::PIXEL_FORMAT_I420); |
| 607 const int arbitrary_frame_feedback_id = 101; | 602 const int arbitrary_frame_feedback_id = 101; |
| 608 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 603 media::VideoCaptureDevice::Client::Buffer buffer = |
| 609 device_client_->ReserveOutputBuffer(device_format.frame_size, | 604 device_client_->ReserveOutputBuffer( |
| 610 device_format.pixel_format, | 605 device_format.frame_size, device_format.pixel_format, |
| 611 device_format.pixel_storage, | 606 device_format.pixel_storage, arbitrary_frame_feedback_id); |
| 612 arbitrary_frame_feedback_id)); | 607 ASSERT_TRUE(buffer.is_valid()); |
| 613 ASSERT_TRUE(buffer.get()); | |
| 614 | 608 |
| 615 device_client_->OnError(FROM_HERE, "Test Error"); | 609 device_client_->OnError(FROM_HERE, "Test Error"); |
| 616 device_client_->OnIncomingCapturedBuffer(std::move(buffer), | 610 device_client_->OnIncomingCapturedBuffer(std::move(buffer), |
| 617 device_format, | 611 device_format, |
| 618 arbitrary_reference_time_, | 612 arbitrary_reference_time_, |
| 619 arbitrary_timestamp_); | 613 arbitrary_timestamp_); |
| 620 | 614 |
| 621 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); | 615 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); |
| 622 base::RunLoop().RunUntilIdle(); | 616 base::RunLoop().RunUntilIdle(); |
| 623 Mock::VerifyAndClearExpectations(client_a_.get()); | 617 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 624 | 618 |
| 625 // Second client connects after the error state. It also should get told of | 619 // Second client connects after the error state. It also should get told of |
| 626 // the error. | 620 // the error. |
| 627 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 621 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 628 controller_->AddClient(route_id, client_b_.get(), 200, session_200); | 622 controller_->AddClient(route_id, client_b_.get(), 200, session_200); |
| 629 Mock::VerifyAndClearExpectations(client_b_.get()); | 623 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 630 } | 624 } |
| 631 | 625 |
| 632 } // namespace content | 626 } // namespace content |
| OLD | NEW |