| 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, |
| 84 const media::VideoCaptureParams& params) { | 85 const media::VideoCaptureParams& params) { |
| 85 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); | 86 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DevicePauseCapture(int device_id) {} | 89 void DevicePauseCapture(int device_id) {} |
| 89 | 90 |
| 90 void DeviceStopCapture(int device_id) { | 91 void DeviceStopCapture(int device_id) { |
| 91 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); | 92 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} | 95 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 VideoCaptureImplTest() { | 98 VideoCaptureImplTest() { |
| 98 params_small_.requested_format = media::VideoCaptureFormat( | 99 params_small_.requested_format = media::VideoCaptureFormat( |
| 99 176, 144, 30, media::ConstantResolutionVideoCaptureDevice); | 100 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); |
| 100 | 101 |
| 101 params_large_.requested_format = media::VideoCaptureFormat( | 102 params_large_.requested_format = media::VideoCaptureFormat( |
| 102 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 103 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 103 | 104 |
| 104 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 105 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
| 105 message_loop_proxy_ = base::MessageLoopProxy::current().get(); | 106 message_loop_proxy_ = base::MessageLoopProxy::current().get(); |
| 106 child_process_.reset(new ChildProcess()); | 107 child_process_.reset(new ChildProcess()); |
| 107 | 108 |
| 108 message_filter_ = new MockVideoCaptureMessageFilter; | 109 message_filter_ = new MockVideoCaptureMessageFilter; |
| 109 session_id_ = 1; | 110 session_id_ = 1; |
| 110 | 111 |
| 111 video_capture_impl_ = new MockVideoCaptureImpl( | 112 video_capture_impl_ = new MockVideoCaptureImpl( |
| 112 session_id_, message_loop_proxy_, message_filter_.get()); | 113 session_id_, message_loop_proxy_, message_filter_.get()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 .WillOnce(Return()); | 266 .WillOnce(Return()); |
| 266 EXPECT_CALL(*client2, OnRemoved(_)) | 267 EXPECT_CALL(*client2, OnRemoved(_)) |
| 267 .WillOnce(Return()); | 268 .WillOnce(Return()); |
| 268 | 269 |
| 269 video_capture_impl_->StopCapture(client1.get()); | 270 video_capture_impl_->StopCapture(client1.get()); |
| 270 video_capture_impl_->StopCapture(client2.get()); | 271 video_capture_impl_->StopCapture(client2.get()); |
| 271 message_loop_->RunUntilIdle(); | 272 message_loop_->RunUntilIdle(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 } // namespace content | 275 } // namespace content |
| OLD | NEW |