| 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 // Unit test for VideoCaptureController. | 5 // Unit test for VideoCaptureController. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 MOCK_METHOD1(StopCapture, void(const media::VideoCaptureSessionId&)); | 112 MOCK_METHOD1(StopCapture, void(const media::VideoCaptureSessionId&)); |
| 113 | 113 |
| 114 void Start(const media::VideoCaptureParams& capture_params, | 114 void Start(const media::VideoCaptureParams& capture_params, |
| 115 media::VideoCaptureDevice::EventHandler* vc_receiver) OVERRIDE { | 115 media::VideoCaptureDevice::EventHandler* vc_receiver) OVERRIDE { |
| 116 StartCapture(capture_params.width, capture_params.height, vc_receiver); | 116 StartCapture(capture_params.width, capture_params.height, vc_receiver); |
| 117 // TODO(mcasas): Add testing for variable resolution video capture devices, | 117 // TODO(mcasas): Add testing for variable resolution video capture devices, |
| 118 // supported by FakeVideoCaptureDevice. See crbug.com/261410, second part. | 118 // supported by FakeVideoCaptureDevice. See crbug.com/261410, second part. |
| 119 media::VideoCaptureCapability capture_format( | 119 media::VideoCaptureCapability capture_format( |
| 120 capture_params.width, | 120 capture_params.width, |
| 121 capture_params.height, | 121 capture_params.height, |
| 122 capture_params.frame_per_second, | 122 capture_params.frame_rate, |
| 123 media::VideoCaptureCapability::kI420, | 123 media::kI420, |
| 124 0, | 124 0, |
| 125 false, | 125 false, |
| 126 media::ConstantResolutionVideoCaptureDevice); | 126 media::ConstantResolutionVideoCaptureDevice); |
| 127 video_capture_device_->Allocate(capture_format, vc_receiver); | 127 video_capture_device_->Allocate(capture_format, vc_receiver); |
| 128 video_capture_device_->Start(); | 128 video_capture_device_->Start(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void Stop(const media::VideoCaptureSessionId& capture_session_id, | 131 void Stop(const media::VideoCaptureSessionId& capture_session_id, |
| 132 base::Closure stopped_cb) OVERRIDE { | 132 base::Closure stopped_cb) OVERRIDE { |
| 133 StopCapture(capture_session_id); | 133 StopCapture(capture_session_id); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 private: | 177 private: |
| 178 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); | 178 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 // Try to start and stop capture. | 181 // Try to start and stop capture. |
| 182 TEST_F(VideoCaptureControllerTest, StartAndStop) { | 182 TEST_F(VideoCaptureControllerTest, StartAndStop) { |
| 183 media::VideoCaptureParams capture_params; | 183 media::VideoCaptureParams capture_params; |
| 184 capture_params.session_id = vcm_->video_session_id_; | 184 capture_params.session_id = vcm_->video_session_id_; |
| 185 capture_params.width = 320; | 185 capture_params.width = 320; |
| 186 capture_params.height = 240; | 186 capture_params.height = 240; |
| 187 capture_params.frame_per_second = 30; | 187 capture_params.frame_rate = 30; |
| 188 | 188 |
| 189 InSequence s; | 189 InSequence s; |
| 190 EXPECT_CALL(*vcm_.get(), | 190 EXPECT_CALL(*vcm_.get(), |
| 191 StartCapture(capture_params.width, | 191 StartCapture(capture_params.width, |
| 192 capture_params.height, | 192 capture_params.height, |
| 193 controller_.get())).Times(1); | 193 controller_.get())).Times(1); |
| 194 EXPECT_CALL(*controller_handler_, | 194 EXPECT_CALL(*controller_handler_, |
| 195 DoFrameInfo(controller_handler_->controller_id_)) | 195 DoFrameInfo(controller_handler_->controller_id_)) |
| 196 .Times(AtLeast(1)); | 196 .Times(AtLeast(1)); |
| 197 EXPECT_CALL(*controller_handler_, | 197 EXPECT_CALL(*controller_handler_, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 212 capture_params); | 212 capture_params); |
| 213 message_loop_->Run(); | 213 message_loop_->Run(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Try to stop session before stopping capture. | 216 // Try to stop session before stopping capture. |
| 217 TEST_F(VideoCaptureControllerTest, StopSession) { | 217 TEST_F(VideoCaptureControllerTest, StopSession) { |
| 218 media::VideoCaptureParams capture_params; | 218 media::VideoCaptureParams capture_params; |
| 219 capture_params.session_id = vcm_->video_session_id_; | 219 capture_params.session_id = vcm_->video_session_id_; |
| 220 capture_params.width = 320; | 220 capture_params.width = 320; |
| 221 capture_params.height = 240; | 221 capture_params.height = 240; |
| 222 capture_params.frame_per_second = 30; | 222 capture_params.frame_rate = 30; |
| 223 | 223 |
| 224 InSequence s; | 224 InSequence s; |
| 225 EXPECT_CALL(*vcm_.get(), | 225 EXPECT_CALL(*vcm_.get(), |
| 226 StartCapture(capture_params.width, | 226 StartCapture(capture_params.width, |
| 227 capture_params.height, | 227 capture_params.height, |
| 228 controller_.get())).Times(1); | 228 controller_.get())).Times(1); |
| 229 EXPECT_CALL(*controller_handler_, | 229 EXPECT_CALL(*controller_handler_, |
| 230 DoFrameInfo(controller_handler_->controller_id_)) | 230 DoFrameInfo(controller_handler_->controller_id_)) |
| 231 .Times(AtLeast(1)); | 231 .Times(AtLeast(1)); |
| 232 EXPECT_CALL(*controller_handler_, | 232 EXPECT_CALL(*controller_handler_, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 256 message_loop_->PostDelayedTask(FROM_HERE, | 256 message_loop_->PostDelayedTask(FROM_HERE, |
| 257 base::MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); | 257 base::MessageLoop::QuitClosure(), base::TimeDelta::FromSeconds(1)); |
| 258 message_loop_->Run(); | 258 message_loop_->Run(); |
| 259 | 259 |
| 260 EXPECT_CALL(*vcm_.get(), StopCapture(vcm_->video_session_id_)).Times(1); | 260 EXPECT_CALL(*vcm_.get(), StopCapture(vcm_->video_session_id_)).Times(1); |
| 261 controller_->StopCapture(controller_handler_->controller_id_, | 261 controller_->StopCapture(controller_handler_->controller_id_, |
| 262 controller_handler_.get()); | 262 controller_handler_.get()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 } // namespace content | 265 } // namespace content |
| OLD | NEW |