| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 private: | 35 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); | 36 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class VideoCaptureImplTest : public ::testing::Test { | 39 class VideoCaptureImplTest : public ::testing::Test { |
| 40 public: | 40 public: |
| 41 class MockVideoCaptureImpl : public VideoCaptureImpl { | 41 class MockVideoCaptureImpl : public VideoCaptureImpl { |
| 42 public: | 42 public: |
| 43 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, | 43 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, |
| 44 VideoCaptureMessageFilter* filter) | 44 VideoCaptureMessageFilter* filter) |
| 45 : VideoCaptureImpl(id, filter), received_buffer_count_(0) {} | 45 : VideoCaptureImpl(id, filter, base::ThreadTaskRunnerHandle::Get()), |
| 46 received_buffer_count_(0) {} |
| 46 ~MockVideoCaptureImpl() override {} | 47 ~MockVideoCaptureImpl() override {} |
| 47 | 48 |
| 48 // Override Send() to mimic device to send events. | 49 // Override Send() to mimic device to send events. |
| 49 void Send(IPC::Message* message) override { | 50 void Send(IPC::Message* message) override { |
| 50 CHECK(message); | 51 CHECK(message); |
| 51 | 52 |
| 52 // In this method, messages are sent to the according handlers as if | 53 // In this method, messages are sent to the according handlers as if |
| 53 // we are the device. | 54 // we are the device. |
| 54 bool handled = true; | 55 bool handled = true; |
| 55 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 56 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 109 |
| 109 const media::VideoCaptureParams& capture_params() const { | 110 const media::VideoCaptureParams& capture_params() const { |
| 110 return capture_params_; | 111 return capture_params_; |
| 111 } | 112 } |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 int received_buffer_count_; | 115 int received_buffer_count_; |
| 115 media::VideoCaptureParams capture_params_; | 116 media::VideoCaptureParams capture_params_; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 VideoCaptureImplTest() { | 119 VideoCaptureImplTest() |
| 120 : child_process_(new ChildProcess()), |
| 121 message_filter_(new MockVideoCaptureMessageFilter), |
| 122 session_id_(1), |
| 123 video_capture_impl_( |
| 124 new MockVideoCaptureImpl(session_id_, message_filter_.get())) { |
| 119 params_small_.requested_format = media::VideoCaptureFormat( | 125 params_small_.requested_format = media::VideoCaptureFormat( |
| 120 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); | 126 gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420); |
| 121 | |
| 122 params_large_.requested_format = media::VideoCaptureFormat( | 127 params_large_.requested_format = media::VideoCaptureFormat( |
| 123 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); | 128 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 124 | 129 |
| 125 child_process_.reset(new ChildProcess()); | |
| 126 | |
| 127 message_filter_ = new MockVideoCaptureMessageFilter; | |
| 128 session_id_ = 1; | |
| 129 | |
| 130 video_capture_impl_.reset(new MockVideoCaptureImpl( | |
| 131 session_id_, message_filter_.get())); | |
| 132 | |
| 133 video_capture_impl_->device_id_ = 2; | 130 video_capture_impl_->device_id_ = 2; |
| 134 } | 131 } |
| 135 | 132 |
| 136 virtual ~VideoCaptureImplTest() { | 133 virtual ~VideoCaptureImplTest() {} |
| 137 } | |
| 138 | 134 |
| 139 protected: | 135 protected: |
| 140 MOCK_METHOD2(OnFrameReady, | 136 MOCK_METHOD2(OnFrameReady, |
| 141 void(const scoped_refptr<media::VideoFrame>&, base::TimeTicks)); | 137 void(const scoped_refptr<media::VideoFrame>&, base::TimeTicks)); |
| 142 MOCK_METHOD1(OnStateUpdate, void(VideoCaptureState)); | 138 MOCK_METHOD1(OnStateUpdate, void(VideoCaptureState)); |
| 143 MOCK_METHOD1(OnDeviceFormatsInUse, | 139 MOCK_METHOD1(OnDeviceFormatsInUse, |
| 144 void(const media::VideoCaptureFormats&)); | 140 void(const media::VideoCaptureFormats&)); |
| 145 MOCK_METHOD1(OnDeviceSupportedFormats, | 141 MOCK_METHOD1(OnDeviceSupportedFormats, |
| 146 void(const media::VideoCaptureFormats&)); | 142 void(const media::VideoCaptureFormats&)); |
| 147 | 143 |
| 148 void Init() { | |
| 149 video_capture_impl_->Init(); | |
| 150 } | |
| 151 | |
| 152 void StartCapture(int client_id, const media::VideoCaptureParams& params) { | 144 void StartCapture(int client_id, const media::VideoCaptureParams& params) { |
| 153 video_capture_impl_->StartCapture( | 145 video_capture_impl_->StartCapture( |
| 154 client_id, params, base::Bind(&VideoCaptureImplTest::OnStateUpdate, | 146 client_id, params, base::Bind(&VideoCaptureImplTest::OnStateUpdate, |
| 155 base::Unretained(this)), | 147 base::Unretained(this)), |
| 156 base::Bind(&VideoCaptureImplTest::OnFrameReady, | 148 base::Bind(&VideoCaptureImplTest::OnFrameReady, |
| 157 base::Unretained(this))); | 149 base::Unretained(this))); |
| 158 } | 150 } |
| 159 | 151 |
| 160 void StopCapture(int client_id) { | 152 void StopCapture(int client_id) { |
| 161 video_capture_impl_->StopCapture(client_id); | 153 video_capture_impl_->StopCapture(client_id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 179 | 171 |
| 180 video_capture_impl_->OnBufferReceived( | 172 video_capture_impl_->OnBufferReceived( |
| 181 buffer_id, timestamp, metadata, media::PIXEL_FORMAT_I420, | 173 buffer_id, timestamp, metadata, media::PIXEL_FORMAT_I420, |
| 182 media::VideoFrame::STORAGE_SHMEM, size, gfx::Rect(size)); | 174 media::VideoFrame::STORAGE_SHMEM, size, gfx::Rect(size)); |
| 183 } | 175 } |
| 184 | 176 |
| 185 void BufferDestroyed(int buffer_id) { | 177 void BufferDestroyed(int buffer_id) { |
| 186 video_capture_impl_->OnBufferDestroyed(buffer_id); | 178 video_capture_impl_->OnBufferDestroyed(buffer_id); |
| 187 } | 179 } |
| 188 | 180 |
| 189 void DeInit() { | |
| 190 video_capture_impl_->DeInit(); | |
| 191 } | |
| 192 | |
| 193 void GetDeviceSupportedFormats() { | 181 void GetDeviceSupportedFormats() { |
| 194 const base::Callback<void(const media::VideoCaptureFormats&)> | 182 const base::Callback<void(const media::VideoCaptureFormats&)> |
| 195 callback = base::Bind( | 183 callback = base::Bind( |
| 196 &VideoCaptureImplTest::OnDeviceSupportedFormats, | 184 &VideoCaptureImplTest::OnDeviceSupportedFormats, |
| 197 base::Unretained(this)); | 185 base::Unretained(this)); |
| 198 video_capture_impl_->GetDeviceSupportedFormats(callback); | 186 video_capture_impl_->GetDeviceSupportedFormats(callback); |
| 199 } | 187 } |
| 200 | 188 |
| 201 void GetDeviceFormatsInUse() { | 189 void GetDeviceFormatsInUse() { |
| 202 const base::Callback<void(const media::VideoCaptureFormats&)> | 190 const base::Callback<void(const media::VideoCaptureFormats&)> |
| 203 callback = base::Bind( | 191 callback = base::Bind( |
| 204 &VideoCaptureImplTest::OnDeviceFormatsInUse, | 192 &VideoCaptureImplTest::OnDeviceFormatsInUse, |
| 205 base::Unretained(this)); | 193 base::Unretained(this)); |
| 206 video_capture_impl_->GetDeviceFormatsInUse(callback); | 194 video_capture_impl_->GetDeviceFormatsInUse(callback); |
| 207 } | 195 } |
| 208 | 196 |
| 209 base::MessageLoop message_loop_; | 197 const base::MessageLoop message_loop_; |
| 210 std::unique_ptr<ChildProcess> child_process_; | 198 const std::unique_ptr<ChildProcess> child_process_; |
| 211 scoped_refptr<MockVideoCaptureMessageFilter> message_filter_; | 199 const scoped_refptr<MockVideoCaptureMessageFilter> message_filter_; |
| 212 media::VideoCaptureSessionId session_id_; | 200 const media::VideoCaptureSessionId session_id_; |
| 213 std::unique_ptr<MockVideoCaptureImpl> video_capture_impl_; | 201 std::unique_ptr<MockVideoCaptureImpl> video_capture_impl_; |
| 214 media::VideoCaptureParams params_small_; | 202 media::VideoCaptureParams params_small_; |
| 215 media::VideoCaptureParams params_large_; | 203 media::VideoCaptureParams params_large_; |
| 216 | 204 |
| 217 private: | 205 private: |
| 218 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); | 206 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); |
| 219 }; | 207 }; |
| 220 | 208 |
| 221 TEST_F(VideoCaptureImplTest, Simple) { | 209 TEST_F(VideoCaptureImplTest, Simple) { |
| 222 // Execute SetCapture() and StopCapture() for one client. | 210 // Execute SetCapture() and StopCapture() for one client. |
| 223 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 211 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 224 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); | 212 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 225 | 213 |
| 226 Init(); | |
| 227 StartCapture(0, params_small_); | 214 StartCapture(0, params_small_); |
| 228 StopCapture(0); | 215 StopCapture(0); |
| 229 DeInit(); | |
| 230 } | 216 } |
| 231 | 217 |
| 232 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { | 218 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { |
| 233 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 219 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 234 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 220 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 235 | 221 |
| 236 Init(); | |
| 237 StartCapture(0, params_small_); | 222 StartCapture(0, params_small_); |
| 238 StopCapture(0); | 223 StopCapture(0); |
| 239 StartCapture(1, params_small_); | 224 StartCapture(1, params_small_); |
| 240 StopCapture(1); | 225 StopCapture(1); |
| 241 DeInit(); | |
| 242 } | 226 } |
| 243 | 227 |
| 244 TEST_F(VideoCaptureImplTest, LargeAndSmall) { | 228 TEST_F(VideoCaptureImplTest, LargeAndSmall) { |
| 245 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 229 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 246 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 230 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 247 | 231 |
| 248 Init(); | |
| 249 StartCapture(0, params_large_); | 232 StartCapture(0, params_large_); |
| 250 StopCapture(0); | 233 StopCapture(0); |
| 251 StartCapture(1, params_small_); | 234 StartCapture(1, params_small_); |
| 252 StopCapture(1); | 235 StopCapture(1); |
| 253 DeInit(); | |
| 254 } | 236 } |
| 255 | 237 |
| 256 TEST_F(VideoCaptureImplTest, SmallAndLarge) { | 238 TEST_F(VideoCaptureImplTest, SmallAndLarge) { |
| 257 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 239 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 258 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 240 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 259 | 241 |
| 260 Init(); | |
| 261 StartCapture(0, params_small_); | 242 StartCapture(0, params_small_); |
| 262 StopCapture(0); | 243 StopCapture(0); |
| 263 StartCapture(1, params_large_); | 244 StartCapture(1, params_large_); |
| 264 StopCapture(1); | 245 StopCapture(1); |
| 265 DeInit(); | |
| 266 } | 246 } |
| 267 | 247 |
| 268 // Check that a request to GetDeviceSupportedFormats() ends up eventually in the | 248 // Check that a request to GetDeviceSupportedFormats() ends up eventually in the |
| 269 // provided callback. | 249 // provided callback. |
| 270 TEST_F(VideoCaptureImplTest, GetDeviceFormats) { | 250 TEST_F(VideoCaptureImplTest, GetDeviceFormats) { |
| 271 EXPECT_CALL(*this, OnDeviceSupportedFormats(_)); | 251 EXPECT_CALL(*this, OnDeviceSupportedFormats(_)); |
| 272 | 252 |
| 273 Init(); | |
| 274 GetDeviceSupportedFormats(); | 253 GetDeviceSupportedFormats(); |
| 275 DeInit(); | |
| 276 } | 254 } |
| 277 | 255 |
| 278 // Check that two requests to GetDeviceSupportedFormats() end up eventually | 256 // Check that two requests to GetDeviceSupportedFormats() end up eventually |
| 279 // calling the provided callbacks. | 257 // calling the provided callbacks. |
| 280 TEST_F(VideoCaptureImplTest, TwoClientsGetDeviceFormats) { | 258 TEST_F(VideoCaptureImplTest, TwoClientsGetDeviceFormats) { |
| 281 EXPECT_CALL(*this, OnDeviceSupportedFormats(_)).Times(2); | 259 EXPECT_CALL(*this, OnDeviceSupportedFormats(_)).Times(2); |
| 282 | 260 |
| 283 Init(); | |
| 284 GetDeviceSupportedFormats(); | 261 GetDeviceSupportedFormats(); |
| 285 GetDeviceSupportedFormats(); | 262 GetDeviceSupportedFormats(); |
| 286 DeInit(); | |
| 287 } | 263 } |
| 288 | 264 |
| 289 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the | 265 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the |
| 290 // provided callback. | 266 // provided callback. |
| 291 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) { | 267 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) { |
| 292 EXPECT_CALL(*this, OnDeviceFormatsInUse(_)); | 268 EXPECT_CALL(*this, OnDeviceFormatsInUse(_)); |
| 293 | 269 |
| 294 Init(); | |
| 295 GetDeviceFormatsInUse(); | 270 GetDeviceFormatsInUse(); |
| 296 DeInit(); | |
| 297 } | 271 } |
| 298 | 272 |
| 299 TEST_F(VideoCaptureImplTest, BufferReceived) { | 273 TEST_F(VideoCaptureImplTest, BufferReceived) { |
| 300 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); | 274 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); |
| 301 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); | 275 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); |
| 302 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(1); | 276 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(1); |
| 303 | 277 |
| 304 const gfx::Size size(1280, 720); | 278 const gfx::Size size(1280, 720); |
| 305 | 279 |
| 306 // Create a fake shared memory for buffer. | 280 // Create a fake shared memory for buffer. |
| 307 base::SharedMemory shm; | 281 base::SharedMemory shm; |
| 308 const size_t frame_size = media::VideoFrame::AllocationSize( | 282 const size_t frame_size = media::VideoFrame::AllocationSize( |
| 309 media::PIXEL_FORMAT_I420, size); | 283 media::PIXEL_FORMAT_I420, size); |
| 310 ASSERT_TRUE(shm.CreateAndMapAnonymous(frame_size)); | 284 ASSERT_TRUE(shm.CreateAndMapAnonymous(frame_size)); |
| 311 | 285 |
| 312 media::VideoCaptureParams params; | 286 media::VideoCaptureParams params; |
| 313 params.requested_format = media::VideoCaptureFormat( | 287 params.requested_format = media::VideoCaptureFormat( |
| 314 size, 30, media::PIXEL_FORMAT_I420); | 288 size, 30, media::PIXEL_FORMAT_I420); |
| 315 | 289 |
| 316 Init(); | |
| 317 StartCapture(0, params); | 290 StartCapture(0, params); |
| 318 NewBuffer(0, shm); | 291 NewBuffer(0, shm); |
| 319 BufferReceived(0, size); | 292 BufferReceived(0, size); |
| 320 StopCapture(0); | 293 StopCapture(0); |
| 321 BufferDestroyed(0); | 294 BufferDestroyed(0); |
| 322 DeInit(); | |
| 323 } | 295 } |
| 324 | 296 |
| 325 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { | 297 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { |
| 326 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); | 298 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); |
| 327 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); | 299 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); |
| 328 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0); | 300 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0); |
| 329 | 301 |
| 330 // Create a fake shared memory for buffer. | 302 // Create a fake shared memory for buffer. |
| 331 base::SharedMemory shm; | 303 base::SharedMemory shm; |
| 332 const size_t i420_frame_size = media::VideoFrame::AllocationSize( | 304 const size_t i420_frame_size = media::VideoFrame::AllocationSize( |
| 333 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size); | 305 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size); |
| 334 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size)); | 306 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size)); |
| 335 | 307 |
| 336 Init(); | |
| 337 StartCapture(0, params_large_); | 308 StartCapture(0, params_large_); |
| 338 NewBuffer(0, shm); | 309 NewBuffer(0, shm); |
| 339 StopCapture(0); | 310 StopCapture(0); |
| 340 BufferReceived(0, params_large_.requested_format.frame_size); | 311 BufferReceived(0, params_large_.requested_format.frame_size); |
| 341 BufferDestroyed(0); | 312 BufferDestroyed(0); |
| 342 DeInit(); | |
| 343 | 313 |
| 344 EXPECT_EQ(this->video_capture_impl_->received_buffer_count(), 1); | 314 EXPECT_EQ(this->video_capture_impl_->received_buffer_count(), 1); |
| 345 } | 315 } |
| 346 | 316 |
| 347 TEST_F(VideoCaptureImplTest, AlreadyStarted) { | 317 TEST_F(VideoCaptureImplTest, AlreadyStarted) { |
| 348 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); | 318 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(2); |
| 349 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); | 319 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(2); |
| 350 | 320 |
| 351 Init(); | |
| 352 StartCapture(0, params_small_); | 321 StartCapture(0, params_small_); |
| 353 StartCapture(1, params_large_); | 322 StartCapture(1, params_large_); |
| 354 StopCapture(0); | 323 StopCapture(0); |
| 355 StopCapture(1); | 324 StopCapture(1); |
| 356 DeInit(); | |
| 357 DCHECK(video_capture_impl_->capture_params().requested_format.frame_size == | 325 DCHECK(video_capture_impl_->capture_params().requested_format.frame_size == |
| 358 params_small_.requested_format.frame_size); | 326 params_small_.requested_format.frame_size); |
| 359 } | 327 } |
| 360 | 328 |
| 361 TEST_F(VideoCaptureImplTest, EndedBeforeStop) { | 329 TEST_F(VideoCaptureImplTest, EndedBeforeStop) { |
| 362 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 330 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 363 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); | 331 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)); |
| 364 | 332 |
| 365 Init(); | |
| 366 StartCapture(0, params_small_); | 333 StartCapture(0, params_small_); |
| 367 | 334 |
| 368 // Receive state change message from browser. | 335 // Receive state change message from browser. |
| 369 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ENDED); | 336 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ENDED); |
| 370 | 337 |
| 371 StopCapture(0); | 338 StopCapture(0); |
| 372 DeInit(); | |
| 373 } | 339 } |
| 374 | 340 |
| 375 TEST_F(VideoCaptureImplTest, ErrorBeforeStop) { | 341 TEST_F(VideoCaptureImplTest, ErrorBeforeStop) { |
| 376 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); | 342 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)); |
| 377 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_ERROR)); | 343 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_ERROR)); |
| 378 | 344 |
| 379 Init(); | |
| 380 StartCapture(0, params_small_); | 345 StartCapture(0, params_small_); |
| 381 | 346 |
| 382 // Receive state change message from browser. | 347 // Receive state change message from browser. |
| 383 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR); | 348 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR); |
| 384 | 349 |
| 385 StopCapture(0); | 350 StopCapture(0); |
| 386 DeInit(); | |
| 387 } | 351 } |
| 388 | 352 |
| 389 } // namespace content | 353 } // namespace content |
| OLD | NEW |