Index: content/renderer/media/video_capture_impl_unittest.cc |
diff --git a/content/renderer/media/video_capture_impl_unittest.cc b/content/renderer/media/video_capture_impl_unittest.cc |
index 6858c4e1fb4b4114ec8afd8f85e15209e48ada45..bef959edadb7f9c7cdbc2412b063519a68e9e511 100644 |
--- a/content/renderer/media/video_capture_impl_unittest.cc |
+++ b/content/renderer/media/video_capture_impl_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "content/child/child_process.h" |
#include "content/common/video_capture.mojom.h" |
#include "content/renderer/media/video_capture_impl.h" |
+#include "mojo/public/cpp/system/platform_handle.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -76,7 +77,7 @@ class MockMojoVideoCaptureHost : public mojom::VideoCaptureHost { |
// This class encapsulates a VideoCaptureImpl under test and the necessary |
// accessory classes, namely: |
// - a VideoCaptureMessageFilter; |
-// - a MockVideoCaptureHost, mimicking the RendererHost; |
+// - a MockMojoVideoCaptureHost, mimicking the RendererHost; |
// - a few callbacks that are bound when calling operations of VideoCaptureImpl |
// and on which we set expectations. |
class VideoCaptureImplTest : public ::testing::Test { |
@@ -120,13 +121,14 @@ class VideoCaptureImplTest : public ::testing::Test { |
video_capture_impl_->StopCapture(client_id); |
} |
- void NewBuffer(int buffer_id, const base::SharedMemory& shm) { |
+ void SimulateOnBufferCreated(int buffer_id, const base::SharedMemory& shm) { |
+ auto handle = base::SharedMemory::DuplicateHandle(shm.handle()); |
video_capture_impl_->OnBufferCreated( |
- base::SharedMemory::DuplicateHandle(shm.handle()), |
- shm.mapped_size(), buffer_id); |
+ buffer_id, mojo::WrapSharedMemoryHandle(handle, shm.mapped_size(), |
+ true /* read_only */)); |
} |
- void BufferReceived(int buffer_id, const gfx::Size& size) { |
+ void SimulateBufferReceived(int buffer_id, const gfx::Size& size) { |
mojom::VideoFrameInfoPtr info = mojom::VideoFrameInfo::New(); |
const base::TimeTicks now = base::TimeTicks::Now(); |
@@ -143,7 +145,7 @@ class VideoCaptureImplTest : public ::testing::Test { |
video_capture_impl_->OnBufferReady(buffer_id, std::move(info)); |
} |
- void BufferDestroyed(int buffer_id) { |
+ void SimulateBufferDestroyed(int buffer_id) { |
video_capture_impl_->OnBufferDestroyed(buffer_id); |
} |
@@ -274,10 +276,10 @@ TEST_F(VideoCaptureImplTest, BufferReceived) { |
.Times(0); |
StartCapture(0, params_small_); |
- NewBuffer(kBufferId, shm); |
- BufferReceived(kBufferId, params_small_.requested_format.frame_size); |
+ SimulateOnBufferCreated(kBufferId, shm); |
+ SimulateBufferReceived(kBufferId, params_small_.requested_format.frame_size); |
StopCapture(0); |
- BufferDestroyed(kBufferId); |
+ SimulateBufferDestroyed(kBufferId); |
EXPECT_EQ(mock_video_capture_host_.released_buffer_count(), 0); |
} |
@@ -298,11 +300,11 @@ TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { |
EXPECT_CALL(mock_video_capture_host_, ReleaseBuffer(_, kBufferId, _, _)); |
StartCapture(0, params_large_); |
- NewBuffer(kBufferId, shm); |
+ SimulateOnBufferCreated(kBufferId, shm); |
StopCapture(0); |
// A buffer received after StopCapture() triggers an instant ReleaseBuffer(). |
- BufferReceived(kBufferId, params_large_.requested_format.frame_size); |
- BufferDestroyed(kBufferId); |
+ SimulateBufferReceived(kBufferId, params_large_.requested_format.frame_size); |
+ SimulateBufferDestroyed(kBufferId); |
EXPECT_EQ(mock_video_capture_host_.released_buffer_count(), 1); |
} |