| 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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "content/child/child_process.h" | 6 #include "content/child/child_process.h" |
| 7 #include "content/common/media/encoded_video_capture_messages.h" |
| 7 #include "content/common/media/video_capture_messages.h" | 8 #include "content/common/media/video_capture_messages.h" |
| 8 #include "content/renderer/media/video_capture_impl.h" | 9 #include "content/renderer/media/video_capture_impl.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 using ::testing::_; | 13 using ::testing::_; |
| 13 using ::testing::AtLeast; | 14 using ::testing::AtLeast; |
| 14 using ::testing::Return; | 15 using ::testing::Return; |
| 15 | 16 |
| 16 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \ | 17 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 73 |
| 73 // In this method, messages are sent to the according handlers as if | 74 // In this method, messages are sent to the according handlers as if |
| 74 // we are the device. | 75 // we are the device. |
| 75 bool handled = true; | 76 bool handled = true; |
| 76 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 77 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
| 77 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) | 78 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) |
| 78 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) | 79 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) |
| 79 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) | 80 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) |
| 80 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 81 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
| 81 DeviceReceiveEmptyBuffer) | 82 DeviceReceiveEmptyBuffer) |
| 83 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_GetCapabilities, |
| 84 DeviceGetEncodingCapabilities) |
| 85 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_OpenBitstream, |
| 86 DeviceOpenEncodedBitstream) |
| 87 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_CloseBitstream, |
| 88 DeviceCloseEncodedBitstream) |
| 89 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_TryConfigureBitstream, |
| 90 DeviceSetEncodingConfig) |
| 91 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_BitstreamBufferConsumed, |
| 92 DeviceReturnEncodedBuffer) |
| 82 IPC_MESSAGE_UNHANDLED(handled = false) | 93 IPC_MESSAGE_UNHANDLED(handled = false) |
| 83 IPC_END_MESSAGE_MAP() | 94 IPC_END_MESSAGE_MAP() |
| 84 EXPECT_TRUE(handled); | 95 EXPECT_TRUE(handled); |
| 85 delete message; | 96 delete message; |
| 86 } | 97 } |
| 87 | 98 |
| 88 void DeviceStartCapture(int device_id, | 99 void DeviceStartCapture(int device_id, |
| 89 const media::VideoCaptureParams& params) { | 100 const media::VideoCaptureParams& params) { |
| 90 media::VideoCaptureParams device_info = params; | 101 media::VideoCaptureParams device_info = params; |
| 91 OnDeviceInfoReceived(device_info); | 102 OnDeviceInfoReceived(device_info); |
| 92 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); | 103 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); |
| 93 } | 104 } |
| 94 | 105 |
| 95 void DevicePauseCapture(int device_id) {} | 106 void DevicePauseCapture(int device_id) {} |
| 96 | 107 |
| 97 void DeviceStopCapture(int device_id) { | 108 void DeviceStopCapture(int device_id) { |
| 98 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); | 109 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); |
| 99 } | 110 } |
| 100 | 111 |
| 101 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} | 112 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} |
| 113 |
| 114 void DeviceGetEncodingCapabilities( |
| 115 int device_id, media::VideoCaptureSessionId session_id) {} |
| 116 |
| 117 void DeviceOpenEncodedBitstream(int device_id, |
| 118 media::VideoCaptureSessionId session_id, |
| 119 media::VideoEncodingParameters params) {} |
| 120 |
| 121 void DeviceCloseEncodedBitstream(int device_id) {} |
| 122 |
| 123 void DeviceSetEncodingConfig( |
| 124 int device_id, media::RuntimeVideoEncodingParameters params) {} |
| 125 |
| 126 void DeviceReturnEncodedBuffer(int device_id, int buffer_id) {} |
| 102 }; | 127 }; |
| 103 | 128 |
| 104 VideoCaptureImplTest() { | 129 VideoCaptureImplTest() { |
| 105 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 130 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
| 106 message_loop_proxy_ = | 131 message_loop_proxy_ = |
| 107 base::MessageLoopProxy::current().get(); | 132 base::MessageLoopProxy::current().get(); |
| 108 child_process_.reset(new ChildProcess()); | 133 child_process_.reset(new ChildProcess()); |
| 109 | 134 |
| 110 message_filter_ = new MockVideoCaptureMessageFilter; | 135 message_filter_ = new MockVideoCaptureMessageFilter; |
| 111 session_id_ = 1; | 136 session_id_ = 1; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 .WillOnce(Return()); | 316 .WillOnce(Return()); |
| 292 EXPECT_CALL(*client2, OnRemoved(_)) | 317 EXPECT_CALL(*client2, OnRemoved(_)) |
| 293 .WillOnce(Return()); | 318 .WillOnce(Return()); |
| 294 | 319 |
| 295 video_capture_impl_->StopCapture(client1.get()); | 320 video_capture_impl_->StopCapture(client1.get()); |
| 296 video_capture_impl_->StopCapture(client2.get()); | 321 video_capture_impl_->StopCapture(client2.get()); |
| 297 message_loop_->RunUntilIdle(); | 322 message_loop_->RunUntilIdle(); |
| 298 } | 323 } |
| 299 | 324 |
| 300 } // namespace content | 325 } // namespace content |
| OLD | NEW |