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/message_loop.h" | 5 #include "base/message_loop/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" | |
8 #include "content/common/media/video_capture_messages.h" | 7 #include "content/common/media/video_capture_messages.h" |
9 #include "content/renderer/media/video_capture_impl.h" | 8 #include "content/renderer/media/video_capture_impl.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 | 11 |
13 using ::testing::_; | 12 using ::testing::_; |
14 using ::testing::AtLeast; | 13 using ::testing::AtLeast; |
15 using ::testing::Return; | 14 using ::testing::Return; |
16 | 15 |
17 namespace content { | 16 namespace content { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 67 |
69 // In this method, messages are sent to the according handlers as if | 68 // In this method, messages are sent to the according handlers as if |
70 // we are the device. | 69 // we are the device. |
71 bool handled = true; | 70 bool handled = true; |
72 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 71 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
73 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) | 72 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) |
74 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) | 73 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) |
75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) | 74 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) |
76 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
77 DeviceReceiveEmptyBuffer) | 76 DeviceReceiveEmptyBuffer) |
78 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_GetCapabilities, | |
79 DeviceGetEncodingCapabilities) | |
80 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_OpenBitstream, | |
81 DeviceOpenEncodedBitstream) | |
82 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_CloseBitstream, | |
83 DeviceCloseEncodedBitstream) | |
84 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_TryConfigureBitstream, | |
85 DeviceSetEncodingConfig) | |
86 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_RequestKeyFrame, | |
87 DeviceRequestKeyFrame) | |
88 IPC_MESSAGE_HANDLER(EncodedVideoCaptureHostMsg_BitstreamBufferConsumed, | |
89 DeviceReturnEncodedBuffer) | |
90 IPC_MESSAGE_UNHANDLED(handled = false) | 77 IPC_MESSAGE_UNHANDLED(handled = false) |
91 IPC_END_MESSAGE_MAP() | 78 IPC_END_MESSAGE_MAP() |
92 EXPECT_TRUE(handled); | 79 EXPECT_TRUE(handled); |
93 delete message; | 80 delete message; |
94 } | 81 } |
95 | 82 |
96 void DeviceStartCapture(int device_id, | 83 void DeviceStartCapture(int device_id, |
97 const media::VideoCaptureParams& params) { | 84 const media::VideoCaptureParams& params) { |
98 media::VideoCaptureParams device_info = params; | 85 media::VideoCaptureParams device_info = params; |
99 OnDeviceInfoReceived(device_info); | 86 OnDeviceInfoReceived(device_info); |
100 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); | 87 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); |
101 } | 88 } |
102 | 89 |
103 void DevicePauseCapture(int device_id) {} | 90 void DevicePauseCapture(int device_id) {} |
104 | 91 |
105 void DeviceStopCapture(int device_id) { | 92 void DeviceStopCapture(int device_id) { |
106 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); | 93 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); |
107 } | 94 } |
108 | 95 |
109 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} | 96 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} |
110 | |
111 void DeviceGetEncodingCapabilities( | |
112 int device_id, media::VideoCaptureSessionId session_id) {} | |
113 | |
114 void DeviceOpenEncodedBitstream(int device_id, | |
115 media::VideoCaptureSessionId session_id, | |
116 media::VideoEncodingParameters params) {} | |
117 | |
118 void DeviceCloseEncodedBitstream(int device_id) {} | |
119 | |
120 void DeviceSetEncodingConfig( | |
121 int device_id, media::RuntimeVideoEncodingParameters params) {} | |
122 | |
123 void DeviceRequestKeyFrame(int device_id) {} | |
124 | |
125 void DeviceReturnEncodedBuffer(int device_id, int buffer_id) {} | |
126 }; | 97 }; |
127 | 98 |
128 VideoCaptureImplTest() | 99 VideoCaptureImplTest() |
129 : capability_small_(176, | 100 : capability_small_(176, |
130 144, | 101 144, |
131 30, | 102 30, |
132 media::VideoCaptureCapability::kI420, | 103 media::VideoCaptureCapability::kI420, |
133 0, | 104 0, |
134 false, | 105 false, |
135 media::ConstantResolutionVideoCaptureDevice), | 106 media::ConstantResolutionVideoCaptureDevice), |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 .WillOnce(Return()); | 294 .WillOnce(Return()); |
324 EXPECT_CALL(*client2, OnRemoved(_)) | 295 EXPECT_CALL(*client2, OnRemoved(_)) |
325 .WillOnce(Return()); | 296 .WillOnce(Return()); |
326 | 297 |
327 video_capture_impl_->StopCapture(client1.get()); | 298 video_capture_impl_->StopCapture(client1.get()); |
328 video_capture_impl_->StopCapture(client2.get()); | 299 video_capture_impl_->StopCapture(client2.get()); |
329 message_loop_->RunUntilIdle(); | 300 message_loop_->RunUntilIdle(); |
330 } | 301 } |
331 | 302 |
332 } // namespace content | 303 } // namespace content |
OLD | NEW |