| 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/video_capture_messages.h" | 7 #include "content/common/media/video_capture_messages.h" |
| 8 #include "content/renderer/media/video_capture_impl.h" | 8 #include "content/renderer/media/video_capture_impl.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) | 74 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) |
| 75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
| 76 DeviceReceiveEmptyBuffer) | 76 DeviceReceiveEmptyBuffer) |
| 77 IPC_MESSAGE_UNHANDLED(handled = false) | 77 IPC_MESSAGE_UNHANDLED(handled = false) |
| 78 IPC_END_MESSAGE_MAP() | 78 IPC_END_MESSAGE_MAP() |
| 79 EXPECT_TRUE(handled); | 79 EXPECT_TRUE(handled); |
| 80 delete message; | 80 delete message; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DeviceStartCapture(int device_id, | 83 void DeviceStartCapture(int device_id, |
| 84 media::VideoCaptureSessionId session_id, | |
| 85 const media::VideoCaptureParams& params) { | 84 const media::VideoCaptureParams& params) { |
| 86 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); | 85 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void DevicePauseCapture(int device_id) {} | 88 void DevicePauseCapture(int device_id) {} |
| 90 | 89 |
| 91 void DeviceStopCapture(int device_id) { | 90 void DeviceStopCapture(int device_id) { |
| 92 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); | 91 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); |
| 93 } | 92 } |
| 94 | 93 |
| 95 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} | 94 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} |
| 96 }; | 95 }; |
| 97 | 96 |
| 98 VideoCaptureImplTest() { | 97 VideoCaptureImplTest() { |
| 99 params_small_.requested_format = media::VideoCaptureFormat( | 98 params_small_.requested_format = media::VideoCaptureFormat( |
| 100 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); | 99 176, 144, 30, media::ConstantResolutionVideoCaptureDevice); |
| 101 | 100 |
| 102 params_large_.requested_format = media::VideoCaptureFormat( | 101 params_large_.requested_format = media::VideoCaptureFormat( |
| 103 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); | 102 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); |
| 104 | 103 |
| 105 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 104 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
| 106 message_loop_proxy_ = base::MessageLoopProxy::current().get(); | 105 message_loop_proxy_ = base::MessageLoopProxy::current().get(); |
| 107 child_process_.reset(new ChildProcess()); | 106 child_process_.reset(new ChildProcess()); |
| 108 | 107 |
| 109 message_filter_ = new MockVideoCaptureMessageFilter; | 108 message_filter_ = new MockVideoCaptureMessageFilter; |
| 110 session_id_ = 1; | 109 session_id_ = 1; |
| 111 | 110 |
| 112 video_capture_impl_ = new MockVideoCaptureImpl( | 111 video_capture_impl_ = new MockVideoCaptureImpl( |
| 113 session_id_, message_loop_proxy_, message_filter_.get()); | 112 session_id_, message_loop_proxy_, message_filter_.get()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 .WillOnce(Return()); | 265 .WillOnce(Return()); |
| 267 EXPECT_CALL(*client2, OnRemoved(_)) | 266 EXPECT_CALL(*client2, OnRemoved(_)) |
| 268 .WillOnce(Return()); | 267 .WillOnce(Return()); |
| 269 | 268 |
| 270 video_capture_impl_->StopCapture(client1.get()); | 269 video_capture_impl_->StopCapture(client1.get()); |
| 271 video_capture_impl_->StopCapture(client2.get()); | 270 video_capture_impl_->StopCapture(client2.get()); |
| 272 message_loop_->RunUntilIdle(); | 271 message_loop_->RunUntilIdle(); |
| 273 } | 272 } |
| 274 | 273 |
| 275 } // namespace content | 274 } // namespace content |
| OLD | NEW |