| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
| 11 #include "content/common/media/video_capture_messages.h" | 11 #include "content/common/media/video_capture_messages.h" |
| 12 #include "content/common/video_capture.mojom.h" |
| 12 #include "content/renderer/media/video_capture_impl.h" | 13 #include "content/renderer/media/video_capture_impl.h" |
| 13 #include "media/base/bind_to_current_loop.h" | 14 #include "media/base/bind_to_current_loop.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using ::testing::_; | 18 using ::testing::_; |
| 18 using ::testing::AtLeast; | |
| 19 using ::testing::InvokeWithoutArgs; | |
| 20 using ::testing::Return; | |
| 21 using ::testing::SaveArg; | |
| 22 | 19 |
| 23 namespace content { | 20 namespace content { |
| 24 | 21 |
| 22 // Mock implementation of the Mojo service. TODO(mcasas): Replace completely |
| 23 // MockVideoCaptureMessageFilter, https://crbug.com/651897 |
| 24 class MockMojoVideoCaptureHost : public mojom::VideoCaptureHost { |
| 25 public: |
| 26 MockMojoVideoCaptureHost() = default; |
| 27 |
| 28 MOCK_METHOD1(Stop, void(int32_t)); |
| 29 MOCK_METHOD1(Pause, void(int32_t)); |
| 30 MOCK_METHOD1(RequestRefreshFrame, void(int32_t)); |
| 31 |
| 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(MockMojoVideoCaptureHost); |
| 34 }; |
| 35 |
| 25 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { | 36 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { |
| 26 public: | 37 public: |
| 27 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} | 38 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} |
| 28 | 39 |
| 29 // Filter implementation. | 40 // Filter implementation. |
| 30 MOCK_METHOD1(Send, bool(IPC::Message* message)); | 41 MOCK_METHOD1(Send, bool(IPC::Message* message)); |
| 31 | 42 |
| 32 protected: | 43 protected: |
| 33 virtual ~MockVideoCaptureMessageFilter() {} | 44 virtual ~MockVideoCaptureMessageFilter() {} |
| 34 | 45 |
| 35 private: | 46 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); | 47 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); |
| 37 }; | 48 }; |
| 38 | 49 |
| 39 class VideoCaptureImplTest : public ::testing::Test { | 50 class VideoCaptureImplTest : public ::testing::Test { |
| 40 public: | 51 public: |
| 41 class MockVideoCaptureImpl : public VideoCaptureImpl { | 52 class MockVideoCaptureImpl : public VideoCaptureImpl { |
| 42 public: | 53 public: |
| 43 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, | 54 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, |
| 44 VideoCaptureMessageFilter* filter) | 55 VideoCaptureMessageFilter* filter) |
| 45 : VideoCaptureImpl(id, filter, base::ThreadTaskRunnerHandle::Get()), | 56 : VideoCaptureImpl(id, filter, base::ThreadTaskRunnerHandle::Get()), |
| 46 received_buffer_count_(0) {} | 57 received_buffer_count_(0) {} |
| 47 ~MockVideoCaptureImpl() override {} | 58 ~MockVideoCaptureImpl() override {} |
| 48 | 59 |
| 49 // Override Send() to mimic device to send events. | 60 // Override Send() to mimic device to send events. |
| 50 void Send(IPC::Message* message) override { | 61 void Send(IPC::Message* message) override { |
| 51 CHECK(message); | |
| 52 | |
| 53 // In this method, messages are sent to the according handlers as if | 62 // In this method, messages are sent to the according handlers as if |
| 54 // we are the device. | 63 // we are the device. |
| 55 bool handled = true; | 64 bool handled = true; |
| 56 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 65 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
| 57 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) | 66 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) |
| 58 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) | |
| 59 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) | |
| 60 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 67 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
| 61 DeviceReceiveEmptyBuffer) | 68 DeviceReceiveEmptyBuffer) |
| 62 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats, | 69 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats, |
| 63 DeviceGetSupportedFormats) | 70 DeviceGetSupportedFormats) |
| 64 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse, | 71 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse, |
| 65 DeviceGetFormatsInUse) | 72 DeviceGetFormatsInUse) |
| 66 IPC_MESSAGE_UNHANDLED(handled = false) | 73 IPC_MESSAGE_UNHANDLED(handled = false) |
| 67 IPC_END_MESSAGE_MAP() | 74 IPC_END_MESSAGE_MAP() |
| 68 EXPECT_TRUE(handled); | 75 EXPECT_TRUE(handled); |
| 69 delete message; | 76 delete message; |
| 70 } | 77 } |
| 71 | 78 |
| 72 void DeviceStartCapture(int device_id, | 79 void DeviceStartCapture(int device_id, |
| 73 media::VideoCaptureSessionId session_id, | 80 media::VideoCaptureSessionId session_id, |
| 74 const media::VideoCaptureParams& params) { | 81 const media::VideoCaptureParams& params) { |
| 75 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); | 82 OnStateChanged(VIDEO_CAPTURE_STATE_STARTED); |
| 76 capture_params_ = params; | 83 capture_params_ = params; |
| 77 } | 84 } |
| 78 | 85 |
| 79 void DevicePauseCapture(int device_id) {} | |
| 80 | |
| 81 void DeviceStopCapture(int device_id) { | |
| 82 OnStateChanged(VIDEO_CAPTURE_STATE_STOPPED); | |
| 83 } | |
| 84 | |
| 85 void DeviceReceiveEmptyBuffer(int device_id, | 86 void DeviceReceiveEmptyBuffer(int device_id, |
| 86 int buffer_id, | 87 int buffer_id, |
| 87 const gpu::SyncToken& release_sync_token, | 88 const gpu::SyncToken& release_sync_token, |
| 88 double consumer_resource_utilization) { | 89 double consumer_resource_utilization) { |
| 89 received_buffer_count_++; | 90 received_buffer_count_++; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void DeviceGetSupportedFormats(int device_id, | 93 void DeviceGetSupportedFormats(int device_id, |
| 93 media::VideoCaptureSessionId session_id) { | 94 media::VideoCaptureSessionId session_id) { |
| 94 // When the mock message filter receives a request for the device | 95 // When the mock message filter receives a request for the device |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 : child_process_(new ChildProcess()), | 121 : child_process_(new ChildProcess()), |
| 121 message_filter_(new MockVideoCaptureMessageFilter), | 122 message_filter_(new MockVideoCaptureMessageFilter), |
| 122 session_id_(1), | 123 session_id_(1), |
| 123 video_capture_impl_( | 124 video_capture_impl_( |
| 124 new MockVideoCaptureImpl(session_id_, message_filter_.get())) { | 125 new MockVideoCaptureImpl(session_id_, message_filter_.get())) { |
| 125 params_small_.requested_format = media::VideoCaptureFormat( | 126 params_small_.requested_format = media::VideoCaptureFormat( |
| 126 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); | 127 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); |
| 127 params_large_.requested_format = media::VideoCaptureFormat( | 128 params_large_.requested_format = media::VideoCaptureFormat( |
| 128 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); | 129 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 129 | 130 |
| 131 video_capture_impl_->SetVideoCaptureHostForTesting( |
| 132 &mock_video_capture_host_); |
| 130 video_capture_impl_->device_id_ = 2; | 133 video_capture_impl_->device_id_ = 2; |
| 131 } | 134 } |
| 132 | 135 |
| 133 virtual ~VideoCaptureImplTest() {} | |
| 134 | |
| 135 protected: | 136 protected: |
| 136 MOCK_METHOD2(OnFrameReady, | 137 MOCK_METHOD2(OnFrameReady, |
| 137 void(const scoped_refptr<media::VideoFrame>&, base::TimeTicks)); | 138 void(const scoped_refptr<media::VideoFrame>&, base::TimeTicks)); |
| 138 MOCK_METHOD1(OnStateUpdate, void(VideoCaptureState)); | 139 MOCK_METHOD1(OnStateUpdate, void(VideoCaptureState)); |
| 139 MOCK_METHOD1(OnDeviceFormatsInUse, | 140 MOCK_METHOD1(OnDeviceFormatsInUse, |
| 140 void(const media::VideoCaptureFormats&)); | 141 void(const media::VideoCaptureFormats&)); |
| 141 MOCK_METHOD1(OnDeviceSupportedFormats, | 142 MOCK_METHOD1(OnDeviceSupportedFormats, |
| 142 void(const media::VideoCaptureFormats&)); | 143 void(const media::VideoCaptureFormats&)); |
| 143 | 144 |
| 144 void StartCapture(int client_id, const media::VideoCaptureParams& params) { | 145 void StartCapture(int client_id, const media::VideoCaptureParams& params) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 &VideoCaptureImplTest::OnDeviceFormatsInUse, | 193 &VideoCaptureImplTest::OnDeviceFormatsInUse, |
| 193 base::Unretained(this)); | 194 base::Unretained(this)); |
| 194 video_capture_impl_->GetDeviceFormatsInUse(callback); | 195 video_capture_impl_->GetDeviceFormatsInUse(callback); |
| 195 } | 196 } |
| 196 | 197 |
| 197 const base::MessageLoop message_loop_; | 198 const base::MessageLoop message_loop_; |
| 198 const std::unique_ptr<ChildProcess> child_process_; | 199 const std::unique_ptr<ChildProcess> child_process_; |
| 199 const scoped_refptr<MockVideoCaptureMessageFilter> message_filter_; | 200 const scoped_refptr<MockVideoCaptureMessageFilter> message_filter_; |
| 200 const media::VideoCaptureSessionId session_id_; | 201 const media::VideoCaptureSessionId session_id_; |
| 201 std::unique_ptr<MockVideoCaptureImpl> video_capture_impl_; | 202 std::unique_ptr<MockVideoCaptureImpl> video_capture_impl_; |
| 203 MockMojoVideoCaptureHost mock_video_capture_host_; |
| 202 media::VideoCaptureParams params_small_; | 204 media::VideoCaptureParams params_small_; |
| 203 media::VideoCaptureParams params_large_; | 205 media::VideoCaptureParams params_large_; |
| 204 | 206 |
| 205 private: | 207 private: |
| 206 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); | 208 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 TEST_F(VideoCaptureImplTest, Simple) { | 211 TEST_F(VideoCaptureImplTest, Simple) { |
| 210 // Execute SetCapture() and StopCapture() for one client. | 212 // Execute SetCapture() and StopCapture() for one client. |
| 211 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 213 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 212 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); | 214 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 215 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 213 | 216 |
| 214 StartCapture(0, params_small_); | 217 StartCapture(0, params_small_); |
| 215 StopCapture(0); | 218 StopCapture(0); |
| 216 } | 219 } |
| 217 | 220 |
| 218 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { | 221 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { |
| 219 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 222 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 220 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 223 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 224 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 221 | 225 |
| 222 StartCapture(0, params_small_); | 226 StartCapture(0, params_small_); |
| 223 StopCapture(0); | 227 StopCapture(0); |
| 224 StartCapture(1, params_small_); | 228 StartCapture(1, params_small_); |
| 225 StopCapture(1); | 229 StopCapture(1); |
| 226 } | 230 } |
| 227 | 231 |
| 228 TEST_F(VideoCaptureImplTest, LargeAndSmall) { | 232 TEST_F(VideoCaptureImplTest, LargeAndSmall) { |
| 229 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 233 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 230 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 234 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 235 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 231 | 236 |
| 232 StartCapture(0, params_large_); | 237 StartCapture(0, params_large_); |
| 233 StopCapture(0); | 238 StopCapture(0); |
| 234 StartCapture(1, params_small_); | 239 StartCapture(1, params_small_); |
| 235 StopCapture(1); | 240 StopCapture(1); |
| 236 } | 241 } |
| 237 | 242 |
| 238 TEST_F(VideoCaptureImplTest, SmallAndLarge) { | 243 TEST_F(VideoCaptureImplTest, SmallAndLarge) { |
| 239 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 244 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 240 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 245 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 246 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 241 | 247 |
| 242 StartCapture(0, params_small_); | 248 StartCapture(0, params_small_); |
| 243 StopCapture(0); | 249 StopCapture(0); |
| 244 StartCapture(1, params_large_); | 250 StartCapture(1, params_large_); |
| 245 StopCapture(1); | 251 StopCapture(1); |
| 246 } | 252 } |
| 247 | 253 |
| 248 // Check that a request to GetDeviceSupportedFormats() ends up eventually in the | 254 // Check that a request to GetDeviceSupportedFormats() ends up eventually in the |
| 249 // provided callback. | 255 // provided callback. |
| 250 TEST_F(VideoCaptureImplTest, GetDeviceFormats) { | 256 TEST_F(VideoCaptureImplTest, GetDeviceFormats) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 264 | 270 |
| 265 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the | 271 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the |
| 266 // provided callback. | 272 // provided callback. |
| 267 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) { | 273 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) { |
| 268 EXPECT_CALL(*this, OnDeviceFormatsInUse(_)); | 274 EXPECT_CALL(*this, OnDeviceFormatsInUse(_)); |
| 269 | 275 |
| 270 GetDeviceFormatsInUse(); | 276 GetDeviceFormatsInUse(); |
| 271 } | 277 } |
| 272 | 278 |
| 273 TEST_F(VideoCaptureImplTest, BufferReceived) { | 279 TEST_F(VideoCaptureImplTest, BufferReceived) { |
| 274 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); | 280 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 275 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); | 281 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 276 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(1); | 282 EXPECT_CALL(*this, OnFrameReady(_, _)); |
| 283 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 277 | 284 |
| 278 const gfx::Size size(1280, 720); | 285 const gfx::Size size(1280, 720); |
| 279 | 286 |
| 280 // Create a fake shared memory for buffer. | 287 // Create a fake shared memory for buffer. |
| 281 base::SharedMemory shm; | 288 base::SharedMemory shm; |
| 282 const size_t frame_size = media::VideoFrame::AllocationSize( | 289 const size_t frame_size = media::VideoFrame::AllocationSize( |
| 283 media::PIXEL_FORMAT_I420, size); | 290 media::PIXEL_FORMAT_I420, size); |
| 284 ASSERT_TRUE(shm.CreateAndMapAnonymous(frame_size)); | 291 ASSERT_TRUE(shm.CreateAndMapAnonymous(frame_size)); |
| 285 | 292 |
| 286 media::VideoCaptureParams params; | 293 media::VideoCaptureParams params; |
| 287 params.requested_format = media::VideoCaptureFormat( | 294 params.requested_format = media::VideoCaptureFormat( |
| 288 size, 30, media::PIXEL_FORMAT_I420); | 295 size, 30, media::PIXEL_FORMAT_I420); |
| 289 | 296 |
| 290 StartCapture(0, params); | 297 StartCapture(0, params); |
| 291 NewBuffer(0, shm); | 298 NewBuffer(0, shm); |
| 292 BufferReceived(0, size); | 299 BufferReceived(0, size); |
| 293 StopCapture(0); | 300 StopCapture(0); |
| 294 BufferDestroyed(0); | 301 BufferDestroyed(0); |
| 295 } | 302 } |
| 296 | 303 |
| 297 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { | 304 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { |
| 298 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); | 305 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 299 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); | 306 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 300 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0); | 307 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0); |
| 308 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 301 | 309 |
| 302 // Create a fake shared memory for buffer. | 310 // Create a fake shared memory for buffer. |
| 303 base::SharedMemory shm; | 311 base::SharedMemory shm; |
| 304 const size_t i420_frame_size = media::VideoFrame::AllocationSize( | 312 const size_t i420_frame_size = media::VideoFrame::AllocationSize( |
| 305 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size); | 313 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size); |
| 306 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size)); | 314 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size)); |
| 307 | 315 |
| 308 StartCapture(0, params_large_); | 316 StartCapture(0, params_large_); |
| 309 NewBuffer(0, shm); | 317 NewBuffer(0, shm); |
| 310 StopCapture(0); | 318 StopCapture(0); |
| 311 BufferReceived(0, params_large_.requested_format.frame_size); | 319 BufferReceived(0, params_large_.requested_format.frame_size); |
| 312 BufferDestroyed(0); | 320 BufferDestroyed(0); |
| 313 | 321 |
| 314 EXPECT_EQ(this->video_capture_impl_->received_buffer_count(), 1); | 322 EXPECT_EQ(this->video_capture_impl_->received_buffer_count(), 1); |
| 315 } | 323 } |
| 316 | 324 |
| 317 TEST_F(VideoCaptureImplTest, AlreadyStarted) { | 325 TEST_F(VideoCaptureImplTest, AlreadyStarted) { |
| 318 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 326 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 319 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 327 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 328 EXPECT_CALL(mock_video_capture_host_, Stop(_)); |
| 320 | 329 |
| 321 StartCapture(0, params_small_); | 330 StartCapture(0, params_small_); |
| 322 StartCapture(1, params_large_); | 331 StartCapture(1, params_large_); |
| 323 StopCapture(0); | 332 StopCapture(0); |
| 324 StopCapture(1); | 333 StopCapture(1); |
| 325 DCHECK(video_capture_impl_->capture_params().requested_format.frame_size == | 334 DCHECK(video_capture_impl_->capture_params().requested_format.frame_size == |
| 326 params_small_.requested_format.frame_size); | 335 params_small_.requested_format.frame_size); |
| 327 } | 336 } |
| 328 | 337 |
| 329 TEST_F(VideoCaptureImplTest, EndedBeforeStop) { | 338 TEST_F(VideoCaptureImplTest, EndedBeforeStop) { |
| 330 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 339 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 331 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); | 340 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 332 | 341 |
| 333 StartCapture(0, params_small_); | 342 StartCapture(0, params_small_); |
| 334 | 343 |
| 335 // Receive state change message from browser. | 344 // Receive state change message from browser. |
| 336 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ENDED); | 345 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ENDED); |
| 337 | 346 |
| 338 StopCapture(0); | 347 StopCapture(0); |
| 339 } | 348 } |
| 340 | 349 |
| 341 TEST_F(VideoCaptureImplTest, ErrorBeforeStop) { | 350 TEST_F(VideoCaptureImplTest, ErrorBeforeStop) { |
| 342 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 351 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 343 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_ERROR)); | 352 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_ERROR)); |
| 344 | 353 |
| 345 StartCapture(0, params_small_); | 354 StartCapture(0, params_small_); |
| 346 | 355 |
| 347 // Receive state change message from browser. | 356 // Receive state change message from browser. |
| 348 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR); | 357 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR); |
| 349 | 358 |
| 350 StopCapture(0); | 359 StopCapture(0); |
| 351 } | 360 } |
| 352 | 361 |
| 353 } // namespace content | 362 } // namespace content |
| OLD | NEW |