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