| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 dimensions, | 140 dimensions, |
| 141 data, | 141 data, |
| 142 media::VideoFrame::AllocationSize(media::VideoFrame::I420, dimensions), | 142 media::VideoFrame::AllocationSize(media::VideoFrame::I420, dimensions), |
| 143 base::SharedMemory::NULLHandle(), | 143 base::SharedMemory::NULLHandle(), |
| 144 0, | 144 0, |
| 145 base::TimeDelta(), | 145 base::TimeDelta(), |
| 146 base::Closure()); | 146 base::Closure()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 scoped_refptr<media::VideoFrame> WrapMailboxBuffer( | 149 scoped_refptr<media::VideoFrame> WrapMailboxBuffer( |
| 150 scoped_ptr<gpu::MailboxHolder> holder, | 150 const gpu::MailboxHolder& holder, |
| 151 const media::VideoFrame::ReleaseMailboxCB& release_cb, | 151 const media::VideoFrame::ReleaseMailboxCB& release_cb, |
| 152 gfx::Size dimensions) { | 152 gfx::Size dimensions) { |
| 153 return media::VideoFrame::WrapNativeTexture( | 153 return media::VideoFrame::WrapNativeTexture( |
| 154 holder.Pass(), release_cb, dimensions, gfx::Rect(dimensions), | 154 holder, release_cb, dimensions, gfx::Rect(dimensions), dimensions, |
| 155 dimensions, base::TimeDelta(), false); | 155 base::TimeDelta(), false); |
| 156 } | 156 } |
| 157 | 157 |
| 158 TestBrowserThreadBundle bundle_; | 158 TestBrowserThreadBundle bundle_; |
| 159 scoped_ptr<MockVideoCaptureControllerEventHandler> client_a_; | 159 scoped_ptr<MockVideoCaptureControllerEventHandler> client_a_; |
| 160 scoped_ptr<MockVideoCaptureControllerEventHandler> client_b_; | 160 scoped_ptr<MockVideoCaptureControllerEventHandler> client_b_; |
| 161 scoped_ptr<VideoCaptureController> controller_; | 161 scoped_ptr<VideoCaptureController> controller_; |
| 162 scoped_ptr<media::VideoCaptureDevice::Client> device_; | 162 scoped_ptr<media::VideoCaptureDevice::Client> device_; |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); | 165 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 for (int i = 0; i < mailbox_buffers; ++i) { | 481 for (int i = 0; i < mailbox_buffers; ++i) { |
| 482 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 482 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 483 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, | 483 device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, |
| 484 capture_resolution); | 484 capture_resolution); |
| 485 ASSERT_TRUE(buffer.get()); | 485 ASSERT_TRUE(buffer.get()); |
| 486 #if !defined(OS_ANDROID) | 486 #if !defined(OS_ANDROID) |
| 487 mailbox_syncpoints[i] = gl_helper->InsertSyncPoint(); | 487 mailbox_syncpoints[i] = gl_helper->InsertSyncPoint(); |
| 488 #endif | 488 #endif |
| 489 device_->OnIncomingCapturedVideoFrame( | 489 device_->OnIncomingCapturedVideoFrame( |
| 490 buffer.Pass(), | 490 buffer.Pass(), |
| 491 WrapMailboxBuffer(make_scoped_ptr(new gpu::MailboxHolder( | 491 WrapMailboxBuffer( |
| 492 gpu::Mailbox(), 0, mailbox_syncpoints[i])), | 492 gpu::MailboxHolder(gpu::Mailbox(), 0, mailbox_syncpoints[i]), |
| 493 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), | 493 base::Bind(&CacheSyncPoint, &release_syncpoints[i]), |
| 494 capture_resolution), | 494 capture_resolution), |
| 495 base::TimeTicks()); | 495 base::TimeTicks()); |
| 496 } | 496 } |
| 497 // ReserveOutputBuffers ought to fail now regardless of buffer format, because | 497 // ReserveOutputBuffers ought to fail now regardless of buffer format, because |
| 498 // the pool is depleted. | 498 // the pool is depleted. |
| 499 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, | 499 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, |
| 500 capture_resolution).get()); | 500 capture_resolution).get()); |
| 501 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, | 501 ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, |
| 502 capture_resolution).get()); | 502 capture_resolution).get()); |
| 503 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(shm_buffers); | 503 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(shm_buffers); |
| 504 EXPECT_CALL(*client_b_, DoMailboxBufferReady(client_b_route_2)) | 504 EXPECT_CALL(*client_b_, DoMailboxBufferReady(client_b_route_2)) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); | 701 EXPECT_EQ(coded_size.width(), size_and_rotation.output_resolution.width()); |
| 702 EXPECT_EQ(coded_size.height(), | 702 EXPECT_EQ(coded_size.height(), |
| 703 size_and_rotation.output_resolution.height()); | 703 size_and_rotation.output_resolution.height()); |
| 704 | 704 |
| 705 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); | 705 EXPECT_EQ(kSessionId, controller_->RemoveClient(route_id, client_a_.get())); |
| 706 Mock::VerifyAndClearExpectations(client_a_.get()); | 706 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 | 709 |
| 710 } // namespace content | 710 } // namespace content |
| OLD | NEW |