| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 base::kNullProcessHandle, | 309 base::kNullProcessHandle, |
| 310 200, | 310 200, |
| 311 session_200); | 311 session_200); |
| 312 ASSERT_EQ(3, controller_->GetClientCount()); | 312 ASSERT_EQ(3, controller_->GetClientCount()); |
| 313 | 313 |
| 314 // Now, simulate an incoming captured buffer from the capture device. As a | 314 // Now, simulate an incoming captured buffer from the capture device. As a |
| 315 // side effect this will cause the first buffer to be shared with clients. | 315 // side effect this will cause the first buffer to be shared with clients. |
| 316 uint8 buffer_no = 1; | 316 uint8 buffer_no = 1; |
| 317 ASSERT_EQ(0.0, device_->GetBufferPoolUtilization()); | 317 ASSERT_EQ(0.0, device_->GetBufferPoolUtilization()); |
| 318 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 318 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( |
| 319 device_->ReserveOutputBuffer(capture_resolution, media::PIXEL_FORMAT_I420, | 319 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 320 media::PIXEL_STORAGE_CPU)); | 320 capture_resolution)); |
| 321 ASSERT_TRUE(buffer.get()); | 321 ASSERT_TRUE(buffer.get()); |
| 322 ASSERT_EQ(1.0 / kPoolSize, device_->GetBufferPoolUtilization()); | 322 ASSERT_EQ(1.0 / kPoolSize, device_->GetBufferPoolUtilization()); |
| 323 memset(buffer->data(), buffer_no++, buffer->size()); | 323 memset(buffer->data(), buffer_no++, buffer->size()); |
| 324 { | 324 { |
| 325 InSequence s; | 325 InSequence s; |
| 326 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); | 326 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1); |
| 327 EXPECT_CALL(*client_a_, | 327 EXPECT_CALL(*client_a_, |
| 328 DoI420BufferReady(client_a_route_1, capture_resolution)) | 328 DoI420BufferReady(client_a_route_1, capture_resolution)) |
| 329 .Times(1); | 329 .Times(1); |
| 330 } | 330 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 359 double resource_utilization_in_metadata = -1.0; | 359 double resource_utilization_in_metadata = -1.0; |
| 360 ASSERT_TRUE(video_frame->metadata()->GetDouble( | 360 ASSERT_TRUE(video_frame->metadata()->GetDouble( |
| 361 media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 361 media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 362 &resource_utilization_in_metadata)); | 362 &resource_utilization_in_metadata)); |
| 363 ASSERT_EQ(0.5, resource_utilization_in_metadata); | 363 ASSERT_EQ(0.5, resource_utilization_in_metadata); |
| 364 | 364 |
| 365 // Second buffer which ought to use the same shared memory buffer. In this | 365 // Second buffer which ought to use the same shared memory buffer. In this |
| 366 // case pretend that the Buffer pointer is held by the device for a long | 366 // case pretend that the Buffer pointer is held by the device for a long |
| 367 // delay. This shouldn't affect anything. | 367 // delay. This shouldn't affect anything. |
| 368 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer2 = | 368 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer2 = |
| 369 device_->ReserveOutputBuffer(capture_resolution, media::PIXEL_FORMAT_I420, | 369 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 370 media::PIXEL_STORAGE_CPU); | 370 capture_resolution); |
| 371 ASSERT_TRUE(buffer2.get()); | 371 ASSERT_TRUE(buffer2.get()); |
| 372 memset(buffer2->data(), buffer_no++, buffer2->size()); | 372 memset(buffer2->data(), buffer_no++, buffer2->size()); |
| 373 video_frame = | 373 video_frame = |
| 374 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer2->data())); | 374 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer2->data())); |
| 375 ASSERT_FALSE(video_frame->metadata()->HasKey( | 375 ASSERT_FALSE(video_frame->metadata()->HasKey( |
| 376 media::VideoFrameMetadata::RESOURCE_UTILIZATION)); | 376 media::VideoFrameMetadata::RESOURCE_UTILIZATION)); |
| 377 client_a_->resource_utilization_ = 0.5; | 377 client_a_->resource_utilization_ = 0.5; |
| 378 client_b_->resource_utilization_ = 3.14; | 378 client_b_->resource_utilization_ = 3.14; |
| 379 device_->OnIncomingCapturedVideoFrame(buffer2.Pass(), video_frame, | 379 device_->OnIncomingCapturedVideoFrame(buffer2.Pass(), video_frame, |
| 380 base::TimeTicks()); | 380 base::TimeTicks()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 404 controller_->AddClient(client_b_route_2, | 404 controller_->AddClient(client_b_route_2, |
| 405 client_b_.get(), | 405 client_b_.get(), |
| 406 base::kNullProcessHandle, | 406 base::kNullProcessHandle, |
| 407 1, | 407 1, |
| 408 session_1); | 408 session_1); |
| 409 Mock::VerifyAndClearExpectations(client_b_.get()); | 409 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 410 | 410 |
| 411 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. | 411 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. |
| 412 for (int i = 0; i < kPoolSize; i++) { | 412 for (int i = 0; i < kPoolSize; i++) { |
| 413 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 413 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 414 device_->ReserveOutputBuffer(capture_resolution, | 414 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 415 media::PIXEL_FORMAT_I420, | 415 capture_resolution); |
| 416 media::PIXEL_STORAGE_CPU); | |
| 417 ASSERT_TRUE(buffer.get()); | 416 ASSERT_TRUE(buffer.get()); |
| 418 memset(buffer->data(), buffer_no++, buffer->size()); | 417 memset(buffer->data(), buffer_no++, buffer->size()); |
| 419 video_frame = | 418 video_frame = |
| 420 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); | 419 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); |
| 421 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, | 420 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, |
| 422 base::TimeTicks()); | 421 base::TimeTicks()); |
| 423 } | 422 } |
| 424 // ReserveOutputBuffer ought to fail now, because the pool is depleted. | 423 // ReserveOutputBuffer ought to fail now, because the pool is depleted. |
| 425 ASSERT_FALSE(device_->ReserveOutputBuffer(capture_resolution, | 424 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 426 media::PIXEL_FORMAT_I420, | 425 capture_resolution).get()); |
| 427 media::PIXEL_STORAGE_CPU).get()); | |
| 428 | 426 |
| 429 // The new client needs to be told of 3 buffers; the old clients only 2. | 427 // The new client needs to be told of 3 buffers; the old clients only 2. |
| 430 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); | 428 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize); |
| 431 EXPECT_CALL(*client_b_, | 429 EXPECT_CALL(*client_b_, |
| 432 DoI420BufferReady(client_b_route_2, capture_resolution)) | 430 DoI420BufferReady(client_b_route_2, capture_resolution)) |
| 433 .Times(kPoolSize); | 431 .Times(kPoolSize); |
| 434 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)) | 432 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)) |
| 435 .Times(kPoolSize - 1); | 433 .Times(kPoolSize - 1); |
| 436 EXPECT_CALL(*client_a_, | 434 EXPECT_CALL(*client_a_, |
| 437 DoI420BufferReady(client_a_route_1, capture_resolution)) | 435 DoI420BufferReady(client_a_route_1, capture_resolution)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 451 Mock::VerifyAndClearExpectations(client_b_.get()); | 449 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 452 | 450 |
| 453 // Now test the interaction of client shutdown and buffer delivery. | 451 // Now test the interaction of client shutdown and buffer delivery. |
| 454 // Kill A1 via renderer disconnect (synchronous). | 452 // Kill A1 via renderer disconnect (synchronous). |
| 455 controller_->RemoveClient(client_a_route_1, client_a_.get()); | 453 controller_->RemoveClient(client_a_route_1, client_a_.get()); |
| 456 // Kill B1 via session close (posts a task to disconnect). | 454 // Kill B1 via session close (posts a task to disconnect). |
| 457 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); | 455 EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1); |
| 458 controller_->StopSession(300); | 456 controller_->StopSession(300); |
| 459 // Queue up another buffer. | 457 // Queue up another buffer. |
| 460 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer3 = | 458 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer3 = |
| 461 device_->ReserveOutputBuffer(capture_resolution, media::PIXEL_FORMAT_I420, | 459 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 462 media::PIXEL_STORAGE_CPU); | 460 capture_resolution); |
| 463 ASSERT_TRUE(buffer3.get()); | 461 ASSERT_TRUE(buffer3.get()); |
| 464 memset(buffer3->data(), buffer_no++, buffer3->size()); | 462 memset(buffer3->data(), buffer_no++, buffer3->size()); |
| 465 video_frame = | 463 video_frame = |
| 466 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer3->data())); | 464 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer3->data())); |
| 467 device_->OnIncomingCapturedVideoFrame(buffer3.Pass(), video_frame, | 465 device_->OnIncomingCapturedVideoFrame(buffer3.Pass(), video_frame, |
| 468 base::TimeTicks()); | 466 base::TimeTicks()); |
| 469 | 467 |
| 470 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer4 = | 468 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer4 = |
| 471 device_->ReserveOutputBuffer(capture_resolution, media::PIXEL_FORMAT_I420, | 469 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 472 media::PIXEL_STORAGE_CPU); | 470 capture_resolution); |
| 473 { | 471 { |
| 474 // Kill A2 via session close (posts a task to disconnect, but A2 must not | 472 // Kill A2 via session close (posts a task to disconnect, but A2 must not |
| 475 // be sent either of these two buffers). | 473 // be sent either of these two buffers). |
| 476 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); | 474 EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1); |
| 477 controller_->StopSession(200); | 475 controller_->StopSession(200); |
| 478 } | 476 } |
| 479 ASSERT_TRUE(buffer4.get()); | 477 ASSERT_TRUE(buffer4.get()); |
| 480 memset(buffer4->data(), buffer_no++, buffer4->size()); | 478 memset(buffer4->data(), buffer_no++, buffer4->size()); |
| 481 video_frame = | 479 video_frame = |
| 482 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer4->data())); | 480 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer4->data())); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 499 int mailbox_buffers = kPoolSize / 2; | 497 int mailbox_buffers = kPoolSize / 2; |
| 500 #endif | 498 #endif |
| 501 int shm_buffers = kPoolSize - mailbox_buffers; | 499 int shm_buffers = kPoolSize - mailbox_buffers; |
| 502 if (shm_buffers == mailbox_buffers) { | 500 if (shm_buffers == mailbox_buffers) { |
| 503 shm_buffers--; | 501 shm_buffers--; |
| 504 mailbox_buffers++; | 502 mailbox_buffers++; |
| 505 } | 503 } |
| 506 | 504 |
| 507 for (int i = 0; i < shm_buffers; ++i) { | 505 for (int i = 0; i < shm_buffers; ++i) { |
| 508 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 506 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 509 device_->ReserveOutputBuffer(capture_resolution, | 507 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 510 media::PIXEL_FORMAT_I420, | 508 capture_resolution); |
| 511 media::PIXEL_STORAGE_CPU); | |
| 512 ASSERT_TRUE(buffer.get()); | 509 ASSERT_TRUE(buffer.get()); |
| 513 video_frame = | 510 video_frame = |
| 514 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); | 511 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); |
| 515 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, | 512 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, |
| 516 base::TimeTicks()); | 513 base::TimeTicks()); |
| 517 } | 514 } |
| 518 std::vector<uint32> mailbox_syncpoints(mailbox_buffers); | 515 std::vector<uint32> mailbox_syncpoints(mailbox_buffers); |
| 519 std::vector<uint32> release_syncpoints(mailbox_buffers); | 516 std::vector<uint32> release_syncpoints(mailbox_buffers); |
| 520 for (int i = 0; i < mailbox_buffers; ++i) { | 517 for (int i = 0; i < mailbox_buffers; ++i) { |
| 521 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 518 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 522 device_->ReserveOutputBuffer(capture_resolution, | 519 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, |
| 523 media::PIXEL_FORMAT_ARGB, | 520 capture_resolution); |
| 524 media::PIXEL_STORAGE_TEXTURE); | |
| 525 ASSERT_TRUE(buffer.get()); | 521 ASSERT_TRUE(buffer.get()); |
| 526 #if !defined(OS_ANDROID) | 522 #if !defined(OS_ANDROID) |
| 527 mailbox_syncpoints[i] = | 523 mailbox_syncpoints[i] = |
| 528 ImageTransportFactory::GetInstance()->GetGLHelper()->InsertSyncPoint(); | 524 ImageTransportFactory::GetInstance()->GetGLHelper()->InsertSyncPoint(); |
| 529 #endif | 525 #endif |
| 530 device_->OnIncomingCapturedVideoFrame( | 526 device_->OnIncomingCapturedVideoFrame( |
| 531 buffer.Pass(), | 527 buffer.Pass(), |
| 532 WrapMailboxBuffer(gpu::MailboxHolder(gpu::Mailbox::Generate(), 0, | 528 WrapMailboxBuffer(gpu::MailboxHolder(gpu::Mailbox::Generate(), 0, |
| 533 mailbox_syncpoints[i]), | 529 mailbox_syncpoints[i]), |
| 534 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), | 530 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), |
| 535 capture_resolution), | 531 capture_resolution), |
| 536 base::TimeTicks()); | 532 base::TimeTicks()); |
| 537 } | 533 } |
| 538 // ReserveOutputBuffers ought to fail now regardless of buffer format, because | 534 // ReserveOutputBuffers ought to fail now regardless of buffer format, because |
| 539 // the pool is depleted. | 535 // the pool is depleted. |
| 540 ASSERT_FALSE(device_->ReserveOutputBuffer(capture_resolution, | 536 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 541 media::PIXEL_FORMAT_I420, | 537 capture_resolution).get()); |
| 542 media::PIXEL_STORAGE_CPU).get()); | 538 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, |
| 543 ASSERT_FALSE(device_->ReserveOutputBuffer(capture_resolution, | 539 capture_resolution).get()); |
| 544 media::PIXEL_FORMAT_ARGB, | |
| 545 media::PIXEL_STORAGE_TEXTURE) | |
| 546 .get()); | |
| 547 EXPECT_CALL(*client_b_, | 540 EXPECT_CALL(*client_b_, |
| 548 DoI420BufferReady(client_b_route_2, capture_resolution)) | 541 DoI420BufferReady(client_b_route_2, capture_resolution)) |
| 549 .Times(shm_buffers); | 542 .Times(shm_buffers); |
| 550 EXPECT_CALL(*client_b_, | 543 EXPECT_CALL(*client_b_, |
| 551 DoTextureBufferReady(client_b_route_2, capture_resolution)) | 544 DoTextureBufferReady(client_b_route_2, capture_resolution)) |
| 552 .Times(mailbox_buffers); | 545 .Times(mailbox_buffers); |
| 553 #if !defined(OS_ANDROID) | 546 #if !defined(OS_ANDROID) |
| 554 EXPECT_CALL(*client_b_, DoBufferDestroyed(client_b_route_2)); | 547 EXPECT_CALL(*client_b_, DoBufferDestroyed(client_b_route_2)); |
| 555 #endif | 548 #endif |
| 556 base::RunLoop().RunUntilIdle(); | 549 base::RunLoop().RunUntilIdle(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 584 |
| 592 // Second client connects after the error state. It also should get told of | 585 // Second client connects after the error state. It also should get told of |
| 593 // the error. | 586 // the error. |
| 594 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 587 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 595 controller_->AddClient( | 588 controller_->AddClient( |
| 596 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); | 589 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 597 base::RunLoop().RunUntilIdle(); | 590 base::RunLoop().RunUntilIdle(); |
| 598 Mock::VerifyAndClearExpectations(client_b_.get()); | 591 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 599 | 592 |
| 600 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 593 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( |
| 601 device_->ReserveOutputBuffer(capture_resolution, media::PIXEL_FORMAT_I420, | 594 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 602 media::PIXEL_STORAGE_CPU)); | 595 capture_resolution)); |
| 603 ASSERT_TRUE(buffer.get()); | 596 ASSERT_TRUE(buffer.get()); |
| 604 scoped_refptr<media::VideoFrame> video_frame = | 597 scoped_refptr<media::VideoFrame> video_frame = |
| 605 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); | 598 WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data())); |
| 606 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, | 599 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, |
| 607 base::TimeTicks()); | 600 base::TimeTicks()); |
| 608 | 601 |
| 609 base::RunLoop().RunUntilIdle(); | 602 base::RunLoop().RunUntilIdle(); |
| 610 } | 603 } |
| 611 | 604 |
| 612 // Exercises the OnError() codepath of VideoCaptureController, and tests the | 605 // Exercises the OnError() codepath of VideoCaptureController, and tests the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 627 gfx::Size(10, 10), 25, media::PIXEL_FORMAT_ARGB); | 620 gfx::Size(10, 10), 25, media::PIXEL_FORMAT_ARGB); |
| 628 | 621 |
| 629 // Start the device. Then, before the first buffer, signal an error and | 622 // Start the device. Then, before the first buffer, signal an error and |
| 630 // deliver the buffer. The error should be propagated to clients; the buffer | 623 // deliver the buffer. The error should be propagated to clients; the buffer |
| 631 // should not be. | 624 // should not be. |
| 632 base::RunLoop().RunUntilIdle(); | 625 base::RunLoop().RunUntilIdle(); |
| 633 Mock::VerifyAndClearExpectations(client_a_.get()); | 626 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 634 | 627 |
| 635 const gfx::Size dims(320, 240); | 628 const gfx::Size dims(320, 240); |
| 636 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( | 629 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer( |
| 637 device_->ReserveOutputBuffer(dims, media::PIXEL_FORMAT_I420, | 630 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dims)); |
| 638 media::PIXEL_STORAGE_CPU)); | |
| 639 ASSERT_TRUE(buffer.get()); | 631 ASSERT_TRUE(buffer.get()); |
| 640 | 632 |
| 641 scoped_refptr<media::VideoFrame> video_frame = | 633 scoped_refptr<media::VideoFrame> video_frame = |
| 642 WrapI420Buffer(dims, static_cast<uint8*>(buffer->data())); | 634 WrapI420Buffer(dims, static_cast<uint8*>(buffer->data())); |
| 643 device_->OnError("Test Error"); | 635 device_->OnError("Test Error"); |
| 644 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, | 636 device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, |
| 645 base::TimeTicks()); | 637 base::TimeTicks()); |
| 646 | 638 |
| 647 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); | 639 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); |
| 648 base::RunLoop().RunUntilIdle(); | 640 base::RunLoop().RunUntilIdle(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 664 // buffer. | 656 // buffer. |
| 665 const size_t kScratchpadSizeInBytes = 400; | 657 const size_t kScratchpadSizeInBytes = 400; |
| 666 unsigned char data[kScratchpadSizeInBytes]; | 658 unsigned char data[kScratchpadSizeInBytes]; |
| 667 // Initialize memory to satisfy DrMemory tests. | 659 // Initialize memory to satisfy DrMemory tests. |
| 668 memset(data, 0, kScratchpadSizeInBytes); | 660 memset(data, 0, kScratchpadSizeInBytes); |
| 669 const gfx::Size capture_resolution(10, 10); | 661 const gfx::Size capture_resolution(10, 10); |
| 670 ASSERT_GE(kScratchpadSizeInBytes, capture_resolution.GetArea() * 4u) | 662 ASSERT_GE(kScratchpadSizeInBytes, capture_resolution.GetArea() * 4u) |
| 671 << "Scratchpad is too small to hold the largest pixel format (ARGB)."; | 663 << "Scratchpad is too small to hold the largest pixel format (ARGB)."; |
| 672 | 664 |
| 673 const int kSessionId = 100; | 665 const int kSessionId = 100; |
| 674 for (int format = 0; format < media::PIXEL_FORMAT_MAX; ++format) { | 666 // This Test skips PIXEL_FORMAT_TEXTURE and PIXEL_FORMAT_UNKNOWN. |
| 675 if (format == media::PIXEL_FORMAT_UNKNOWN) | 667 for (int format = 0; format < media::PIXEL_FORMAT_TEXTURE; ++format) { |
| 676 continue; | |
| 677 media::VideoCaptureParams params; | 668 media::VideoCaptureParams params; |
| 678 params.requested_format = media::VideoCaptureFormat( | 669 params.requested_format = media::VideoCaptureFormat( |
| 679 capture_resolution, 30, media::VideoPixelFormat(format)); | 670 capture_resolution, 30, media::VideoPixelFormat(format)); |
| 680 | 671 |
| 681 // Start with one client. | 672 // Start with one client. |
| 682 const VideoCaptureControllerID route_id(0x99); | 673 const VideoCaptureControllerID route_id(0x99); |
| 683 controller_->AddClient(route_id, | 674 controller_->AddClient(route_id, |
| 684 client_a_.get(), | 675 client_a_.get(), |
| 685 base::kNullProcessHandle, | 676 base::kNullProcessHandle, |
| 686 kSessionId, | 677 kSessionId, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); | 744 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); |
| 754 EXPECT_EQ(coded_size.height(), | 745 EXPECT_EQ(coded_size.height(), |
| 755 size_and_rotation.output_resolution.height()); | 746 size_and_rotation.output_resolution.height()); |
| 756 | 747 |
| 757 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); | 748 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); |
| 758 Mock::VerifyAndClearExpectations(client_a_.get()); | 749 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 759 } | 750 } |
| 760 } | 751 } |
| 761 | 752 |
| 762 } // namespace content | 753 } // namespace content |
| OLD | NEW |