| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 base::MessageLoopProxy::current(), | 125 base::MessageLoopProxy::current(), |
| 126 controller_->GetVideoCaptureFormat()); | 126 controller_->GetVideoCaptureFormat()); |
| 127 client_a_.reset(new MockVideoCaptureControllerEventHandler( | 127 client_a_.reset(new MockVideoCaptureControllerEventHandler( |
| 128 controller_.get())); | 128 controller_.get())); |
| 129 client_b_.reset(new MockVideoCaptureControllerEventHandler( | 129 client_b_.reset(new MockVideoCaptureControllerEventHandler( |
| 130 controller_.get())); | 130 controller_.get())); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void TearDown() override { base::RunLoop().RunUntilIdle(); } | 133 void TearDown() override { base::RunLoop().RunUntilIdle(); } |
| 134 | 134 |
| 135 scoped_refptr<media::VideoFrame> WrapI420Buffer( | 135 scoped_refptr<media::VideoFrame> WrapI420Buffer(gfx::Size dimensions, |
| 136 const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer, | 136 uint8* data) { |
| 137 gfx::Size dimensions) { | |
| 138 return media::VideoFrame::WrapExternalPackedMemory( | 137 return media::VideoFrame::WrapExternalPackedMemory( |
| 139 media::VideoFrame::I420, | 138 media::VideoFrame::I420, |
| 140 dimensions, | 139 dimensions, |
| 141 gfx::Rect(dimensions), | 140 gfx::Rect(dimensions), |
| 142 dimensions, | 141 dimensions, |
| 143 reinterpret_cast<uint8*>(buffer->data()), | 142 data, |
| 144 media::VideoFrame::AllocationSize(media::VideoFrame::I420, dimensions), | 143 media::VideoFrame::AllocationSize(media::VideoFrame::I420, dimensions), |
| 145 base::SharedMemory::NULLHandle(), | 144 base::SharedMemory::NULLHandle(), |
| 146 0, | 145 0, |
| 147 base::TimeDelta(), | 146 base::TimeDelta(), |
| 148 base::Closure()); | 147 base::Closure()); |
| 149 } | 148 } |
| 150 | 149 |
| 151 scoped_refptr<media::VideoFrame> WrapMailboxBuffer( | 150 scoped_refptr<media::VideoFrame> WrapMailboxBuffer( |
| 152 scoped_ptr<gpu::MailboxHolder> holder, | 151 scoped_ptr<gpu::MailboxHolder> holder, |
| 153 const media::VideoFrame::ReleaseMailboxCB& release_cb, | 152 const media::VideoFrame::ReleaseMailboxCB& release_cb, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 session_200); | 321 session_200); |
| 323 ASSERT_EQ(3, controller_->GetClientCount()); | 322 ASSERT_EQ(3, controller_->GetClientCount()); |
| 324 | 323 |
| 325 // Now, simulate an incoming captured buffer from the capture device. As a | 324 // Now, simulate an incoming captured buffer from the capture device. As a |
| 326 // side effect this will cause the first buffer to be shared with clients. | 325 // side effect this will cause the first buffer to be shared with clients. |
| 327 uint8 buffer_no = 1; | 326 uint8 buffer_no = 1; |
| 328 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; | 327 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; |
| 329 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 328 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 330 capture_resolution); | 329 capture_resolution); |
| 331 ASSERT_TRUE(buffer.get()); | 330 ASSERT_TRUE(buffer.get()); |
| 332 memset(buffer->data(), buffer_no++, buffer->size()); | 331 scoped_ptr<media::DataHandle> scoped_data_handle(buffer->GetDataHandle()); |
| 332 memset(scoped_data_handle->data(), buffer_no++, buffer->size()); |
| 333 { | 333 { |
| 334 InSequence s; | 334 InSequence s; |
| 335 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); | 335 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); |
| 336 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1,_)).Times(1); | 336 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1,_)).Times(1); |
| 337 } | 337 } |
| 338 { | 338 { |
| 339 InSequence s; | 339 InSequence s; |
| 340 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1)).Times(1); | 340 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1)).Times(1); |
| 341 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1,_)).Times(1); | 341 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1,_)).Times(1); |
| 342 } | 342 } |
| 343 { | 343 { |
| 344 InSequence s; | 344 InSequence s; |
| 345 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2)).Times(1); | 345 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2)).Times(1); |
| 346 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2,_)).Times(1); | 346 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2,_)).Times(1); |
| 347 } | 347 } |
| 348 device_->OnIncomingCapturedVideoFrame( | 348 device_->OnIncomingCapturedVideoFrame( |
| 349 buffer, | 349 buffer, WrapI420Buffer(capture_resolution, |
| 350 WrapI420Buffer(buffer, capture_resolution), | 350 static_cast<uint8*>(scoped_data_handle->data())), |
| 351 base::TimeTicks()); | 351 base::TimeTicks()); |
| 352 buffer = NULL; | 352 buffer = NULL; |
| 353 | 353 |
| 354 base::RunLoop().RunUntilIdle(); | 354 base::RunLoop().RunUntilIdle(); |
| 355 Mock::VerifyAndClearExpectations(client_a_.get()); | 355 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 356 Mock::VerifyAndClearExpectations(client_b_.get()); | 356 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 357 | 357 |
| 358 // Second buffer which ought to use the same shared memory buffer. In this | 358 // Second buffer which ought to use the same shared memory buffer. In this |
| 359 // case pretend that the Buffer pointer is held by the device for a long | 359 // case pretend that the Buffer pointer is held by the device for a long |
| 360 // delay. This shouldn't affect anything. | 360 // delay. This shouldn't affect anything. |
| 361 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 361 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 362 capture_resolution); | 362 capture_resolution); |
| 363 scoped_data_handle = buffer->GetDataHandle().Pass(); |
| 363 ASSERT_TRUE(buffer.get()); | 364 ASSERT_TRUE(buffer.get()); |
| 364 memset(buffer->data(), buffer_no++, buffer->size()); | 365 memset(scoped_data_handle->data(), buffer_no++, buffer->size()); |
| 365 device_->OnIncomingCapturedVideoFrame( | 366 device_->OnIncomingCapturedVideoFrame( |
| 366 buffer, | 367 buffer, WrapI420Buffer(capture_resolution, |
| 367 WrapI420Buffer(buffer, capture_resolution), | 368 static_cast<uint8*>(scoped_data_handle->data())), |
| 368 base::TimeTicks()); | 369 base::TimeTicks()); |
| 369 buffer = NULL; | 370 buffer = NULL; |
| 370 | 371 |
| 371 // The buffer should be delivered to the clients in any order. | 372 // The buffer should be delivered to the clients in any order. |
| 372 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1,_)).Times(1); | 373 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1,_)).Times(1); |
| 373 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1,_)).Times(1); | 374 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1,_)).Times(1); |
| 374 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2,_)).Times(1); | 375 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2,_)).Times(1); |
| 375 base::RunLoop().RunUntilIdle(); | 376 base::RunLoop().RunUntilIdle(); |
| 376 Mock::VerifyAndClearExpectations(client_a_.get()); | 377 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 377 Mock::VerifyAndClearExpectations(client_b_.get()); | 378 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 378 | 379 |
| 379 // Add a fourth client now that some buffers have come through. | 380 // Add a fourth client now that some buffers have come through. |
| 380 controller_->AddClient(client_b_route_2, | 381 controller_->AddClient(client_b_route_2, |
| 381 client_b_.get(), | 382 client_b_.get(), |
| 382 base::kNullProcessHandle, | 383 base::kNullProcessHandle, |
| 383 1, | 384 1, |
| 384 session_1); | 385 session_1); |
| 385 Mock::VerifyAndClearExpectations(client_b_.get()); | 386 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 386 | 387 |
| 387 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. | 388 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. |
| 388 for (int i = 0; i < kPoolSize; i++) { | 389 for (int i = 0; i < kPoolSize; i++) { |
| 389 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 390 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 390 capture_resolution); | 391 capture_resolution); |
| 391 ASSERT_TRUE(buffer.get()); | 392 ASSERT_TRUE(buffer.get()); |
| 392 memset(buffer->data(), buffer_no++, buffer->size()); | 393 scoped_data_handle = buffer->GetDataHandle().Pass(); |
| 394 memset(scoped_data_handle->data(), buffer_no++, buffer->size()); |
| 393 device_->OnIncomingCapturedVideoFrame( | 395 device_->OnIncomingCapturedVideoFrame( |
| 394 buffer, | 396 buffer, WrapI420Buffer(capture_resolution, |
| 395 WrapI420Buffer(buffer, capture_resolution), | 397 static_cast<uint8*>(scoped_data_handle->data())), |
| 396 base::TimeTicks()); | 398 base::TimeTicks()); |
| 397 buffer = NULL; | 399 buffer = NULL; |
| 398 } | 400 } |
| 399 // ReserveOutputBuffer ought to fail now, because the pool is depleted. | 401 // ReserveOutputBuffer ought to fail now, because the pool is depleted. |
| 400 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 402 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 401 capture_resolution).get()); | 403 capture_resolution).get()); |
| 402 | 404 |
| 403 // The new client needs to be told of 3 buffers; the old clients only 2. | 405 // The new client needs to be told of 3 buffers; the old clients only 2. |
| 404 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); | 406 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); |
| 405 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(kPoolSize); | 407 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(kPoolSize); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 419 // Now test the interaction of client shutdown and buffer delivery. | 421 // Now test the interaction of client shutdown and buffer delivery. |
| 420 // Kill A1 via renderer disconnect (synchronous). | 422 // Kill A1 via renderer disconnect (synchronous). |
| 421 controller_->RemoveClient(client_a_route_1, client_a_.get()); | 423 controller_->RemoveClient(client_a_route_1, client_a_.get()); |
| 422 // Kill B1 via session close (posts a task to disconnect). | 424 // Kill B1 via session close (posts a task to disconnect). |
| 423 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); | 425 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); |
| 424 controller_->StopSession(300); | 426 controller_->StopSession(300); |
| 425 // Queue up another buffer. | 427 // Queue up another buffer. |
| 426 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 428 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 427 capture_resolution); | 429 capture_resolution); |
| 428 ASSERT_TRUE(buffer.get()); | 430 ASSERT_TRUE(buffer.get()); |
| 429 memset(buffer->data(), buffer_no++, buffer->size()); | 431 scoped_data_handle = buffer->GetDataHandle().Pass(); |
| 432 memset(scoped_data_handle->data(), buffer_no++, buffer->size()); |
| 430 device_->OnIncomingCapturedVideoFrame( | 433 device_->OnIncomingCapturedVideoFrame( |
| 431 buffer, | 434 buffer, WrapI420Buffer(capture_resolution, |
| 432 WrapI420Buffer(buffer, capture_resolution), | 435 static_cast<uint8*>(scoped_data_handle->data())), |
| 433 base::TimeTicks()); | 436 base::TimeTicks()); |
| 434 buffer = NULL; | 437 buffer = NULL; |
| 435 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 438 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 436 capture_resolution); | 439 capture_resolution); |
| 437 { | 440 { |
| 438 // Kill A2 via session close (posts a task to disconnect, but A2 must not | 441 // Kill A2 via session close (posts a task to disconnect, but A2 must not |
| 439 // be sent either of these two buffers). | 442 // be sent either of these two buffers). |
| 440 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); | 443 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); |
| 441 controller_->StopSession(200); | 444 controller_->StopSession(200); |
| 442 } | 445 } |
| 443 ASSERT_TRUE(buffer.get()); | 446 ASSERT_TRUE(buffer.get()); |
| 444 memset(buffer->data(), buffer_no++, buffer->size()); | 447 memset(scoped_data_handle->data(), buffer_no++, buffer->size()); |
| 445 device_->OnIncomingCapturedVideoFrame( | 448 device_->OnIncomingCapturedVideoFrame( |
| 446 buffer, | 449 buffer, WrapI420Buffer(capture_resolution, |
| 447 WrapI420Buffer(buffer, capture_resolution), | 450 static_cast<uint8*>(scoped_data_handle->data())), |
| 448 base::TimeTicks()); | 451 base::TimeTicks()); |
| 449 buffer = NULL; | 452 buffer = NULL; |
| 450 // B2 is the only client left, and is the only one that should | 453 // B2 is the only client left, and is the only one that should |
| 451 // get the buffer. | 454 // get the buffer. |
| 452 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(2); | 455 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(2); |
| 453 base::RunLoop().RunUntilIdle(); | 456 base::RunLoop().RunUntilIdle(); |
| 454 Mock::VerifyAndClearExpectations(client_a_.get()); | 457 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 455 Mock::VerifyAndClearExpectations(client_b_.get()); | 458 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 456 | 459 |
| 457 // Allocate all buffers from the buffer pool, half as SHM buffer and half as | 460 // Allocate all buffers from the buffer pool, half as SHM buffer and half as |
| 458 // mailbox buffers. Make sure of different counts though. | 461 // mailbox buffers. Make sure of different counts though. |
| 459 #if defined(OS_ANDROID) | 462 #if defined(OS_ANDROID) |
| 460 int mailbox_buffers = 0; | 463 int mailbox_buffers = 0; |
| 461 #else | 464 #else |
| 462 int mailbox_buffers = kPoolSize / 2; | 465 int mailbox_buffers = kPoolSize / 2; |
| 463 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 466 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
| 464 #endif | 467 #endif |
| 465 int shm_buffers = kPoolSize - mailbox_buffers; | 468 int shm_buffers = kPoolSize - mailbox_buffers; |
| 466 if (shm_buffers == mailbox_buffers) { | 469 if (shm_buffers == mailbox_buffers) { |
| 467 shm_buffers--; | 470 shm_buffers--; |
| 468 mailbox_buffers++; | 471 mailbox_buffers++; |
| 469 } | 472 } |
| 470 | 473 |
| 471 for (int i = 0; i < shm_buffers; ++i) { | 474 for (int i = 0; i < shm_buffers; ++i) { |
| 472 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 475 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 473 capture_resolution); | 476 capture_resolution); |
| 474 ASSERT_TRUE(buffer.get()); | 477 ASSERT_TRUE(buffer.get()); |
| 478 scoped_data_handle = buffer->GetDataHandle().Pass(); |
| 475 device_->OnIncomingCapturedVideoFrame( | 479 device_->OnIncomingCapturedVideoFrame( |
| 476 buffer, | 480 buffer, WrapI420Buffer(capture_resolution, |
| 477 WrapI420Buffer(buffer, capture_resolution), | 481 static_cast<uint8*>(scoped_data_handle->data())), |
| 478 base::TimeTicks()); | 482 base::TimeTicks()); |
| 479 buffer = NULL; | 483 buffer = NULL; |
| 480 } | 484 } |
| 481 std::vector<uint32> mailbox_syncpoints(mailbox_buffers); | 485 std::vector<uint32> mailbox_syncpoints(mailbox_buffers); |
| 482 std::vector<uint32> release_syncpoints(mailbox_buffers); | 486 std::vector<uint32> release_syncpoints(mailbox_buffers); |
| 483 for (int i = 0; i < mailbox_buffers; ++i) { | 487 for (int i = 0; i < mailbox_buffers; ++i) { |
| 484 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, | 488 buffer = device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, |
| 485 capture_resolution); | 489 capture_resolution); |
| 486 ASSERT_TRUE(buffer.get()); | 490 ASSERT_TRUE(buffer.get()); |
| 491 scoped_data_handle = buffer->GetDataHandle().Pass(); |
| 487 #if !defined(OS_ANDROID) | 492 #if !defined(OS_ANDROID) |
| 488 mailbox_syncpoints[i] = gl_helper->InsertSyncPoint(); | 493 mailbox_syncpoints[i] = gl_helper->InsertSyncPoint(); |
| 489 #endif | 494 #endif |
| 490 device_->OnIncomingCapturedVideoFrame( | 495 device_->OnIncomingCapturedVideoFrame( |
| 491 buffer, | 496 buffer, |
| 492 WrapMailboxBuffer(make_scoped_ptr(new gpu::MailboxHolder( | 497 WrapMailboxBuffer(make_scoped_ptr(new gpu::MailboxHolder( |
| 493 gpu::Mailbox(), 0, mailbox_syncpoints[i])), | 498 gpu::Mailbox(), 0, mailbox_syncpoints[i])), |
| 494 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), | 499 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), |
| 495 capture_resolution), | 500 capture_resolution), |
| 496 base::TimeTicks()); | 501 base::TimeTicks()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 551 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 547 controller_->AddClient( | 552 controller_->AddClient( |
| 548 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); | 553 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 549 base::RunLoop().RunUntilIdle(); | 554 base::RunLoop().RunUntilIdle(); |
| 550 Mock::VerifyAndClearExpectations(client_b_.get()); | 555 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 551 | 556 |
| 552 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 557 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 553 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 558 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 554 capture_resolution); | 559 capture_resolution); |
| 555 ASSERT_TRUE(buffer.get()); | 560 ASSERT_TRUE(buffer.get()); |
| 561 scoped_ptr<media::DataHandle> scoped_data_handle(buffer->GetDataHandle()); |
| 556 | 562 |
| 557 device_->OnIncomingCapturedVideoFrame( | 563 device_->OnIncomingCapturedVideoFrame( |
| 558 buffer, | 564 buffer, WrapI420Buffer(capture_resolution, |
| 559 WrapI420Buffer(buffer, capture_resolution), | 565 static_cast<uint8*>(scoped_data_handle->data())), |
| 560 base::TimeTicks()); | 566 base::TimeTicks()); |
| 561 buffer = NULL; | 567 buffer = NULL; |
| 562 | 568 |
| 563 base::RunLoop().RunUntilIdle(); | 569 base::RunLoop().RunUntilIdle(); |
| 564 } | 570 } |
| 565 | 571 |
| 566 // Exercises the OnError() codepath of VideoCaptureController, and tests the | 572 // Exercises the OnError() codepath of VideoCaptureController, and tests the |
| 567 // behavior of various operations after the error state has been signalled. | 573 // behavior of various operations after the error state has been signalled. |
| 568 TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { | 574 TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { |
| 569 media::VideoCaptureParams session_100; | 575 media::VideoCaptureParams session_100; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 583 // Start the device. Then, before the first buffer, signal an error and | 589 // Start the device. Then, before the first buffer, signal an error and |
| 584 // deliver the buffer. The error should be propagated to clients; the buffer | 590 // deliver the buffer. The error should be propagated to clients; the buffer |
| 585 // should not be. | 591 // should not be. |
| 586 base::RunLoop().RunUntilIdle(); | 592 base::RunLoop().RunUntilIdle(); |
| 587 Mock::VerifyAndClearExpectations(client_a_.get()); | 593 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 588 | 594 |
| 589 const gfx::Size dims(320, 240); | 595 const gfx::Size dims(320, 240); |
| 590 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 596 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 591 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dims); | 597 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dims); |
| 592 ASSERT_TRUE(buffer.get()); | 598 ASSERT_TRUE(buffer.get()); |
| 599 scoped_ptr<media::DataHandle> scoped_data_handle(buffer->GetDataHandle()); |
| 593 | 600 |
| 594 device_->OnError("Test error"); | 601 device_->OnError("Test error"); |
| 595 device_->OnIncomingCapturedVideoFrame( | 602 device_->OnIncomingCapturedVideoFrame( |
| 596 buffer, | 603 buffer, |
| 597 WrapI420Buffer(buffer, dims), | 604 WrapI420Buffer(dims, static_cast<uint8*>(scoped_data_handle->data())), |
| 598 base::TimeTicks()); | 605 base::TimeTicks()); |
| 599 buffer = NULL; | 606 buffer = NULL; |
| 600 | 607 |
| 601 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); | 608 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); |
| 602 base::RunLoop().RunUntilIdle(); | 609 base::RunLoop().RunUntilIdle(); |
| 603 Mock::VerifyAndClearExpectations(client_a_.get()); | 610 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 604 | 611 |
| 605 // Second client connects after the error state. It also should get told of | 612 // Second client connects after the error state. It also should get told of |
| 606 // the error. | 613 // the error. |
| 607 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 614 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); | 711 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); |
| 705 EXPECT_EQ(coded_size.height(), | 712 EXPECT_EQ(coded_size.height(), |
| 706 size_and_rotation.output_resolution.height()); | 713 size_and_rotation.output_resolution.height()); |
| 707 | 714 |
| 708 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); | 715 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); |
| 709 Mock::VerifyAndClearExpectations(client_a_.get()); | 716 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 710 } | 717 } |
| 711 } | 718 } |
| 712 | 719 |
| 713 } // namespace content | 720 } // namespace content |
| OLD | NEW |