| 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 VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/video_capture_manager.h" | 7 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 MOCK_METHOD2(Opened, void(MediaStreamType, int)); | 131 MOCK_METHOD2(Opened, void(MediaStreamType, int)); |
| 132 MOCK_METHOD2(Closed, void(MediaStreamType, int)); | 132 MOCK_METHOD2(Closed, void(MediaStreamType, int)); |
| 133 MOCK_METHOD2(Aborted, void(MediaStreamType, int)); | 133 MOCK_METHOD2(Aborted, void(MediaStreamType, int)); |
| 134 }; // class MockMediaStreamProviderListener | 134 }; // class MockMediaStreamProviderListener |
| 135 | 135 |
| 136 // Needed as an input argument to StartCaptureForClient(). | 136 // Needed as an input argument to StartCaptureForClient(). |
| 137 class MockFrameObserver : public VideoCaptureControllerEventHandler { | 137 class MockFrameObserver : public VideoCaptureControllerEventHandler { |
| 138 public: | 138 public: |
| 139 MOCK_METHOD1(OnError, void(VideoCaptureControllerID id)); | 139 MOCK_METHOD1(OnError, void(VideoCaptureControllerID id)); |
| 140 MOCK_METHOD1(OnStarted, void(VideoCaptureControllerID id)); |
| 140 | 141 |
| 141 void OnBufferCreated(VideoCaptureControllerID id, | 142 void OnBufferCreated(VideoCaptureControllerID id, |
| 142 mojo::ScopedSharedBufferHandle handle, | 143 mojo::ScopedSharedBufferHandle handle, |
| 143 int length, int buffer_id) override {} | 144 int length, int buffer_id) override {} |
| 144 void OnBufferDestroyed(VideoCaptureControllerID id, int buffer_id) override {} | 145 void OnBufferDestroyed(VideoCaptureControllerID id, int buffer_id) override {} |
| 145 void OnBufferReady(VideoCaptureControllerID id, | 146 void OnBufferReady(VideoCaptureControllerID id, |
| 146 int buffer_id, | 147 int buffer_id, |
| 147 const scoped_refptr<media::VideoFrame>& frame) override {} | 148 const scoped_refptr<media::VideoFrame>& frame) override {} |
| 148 void OnEnded(VideoCaptureControllerID id) override {} | 149 void OnEnded(VideoCaptureControllerID id) override {} |
| 149 | 150 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 private: | 275 private: |
| 275 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManagerTest); | 276 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManagerTest); |
| 276 }; | 277 }; |
| 277 | 278 |
| 278 // Test cases | 279 // Test cases |
| 279 | 280 |
| 280 // Try to open, start, stop and close a device. | 281 // Try to open, start, stop and close a device. |
| 281 TEST_F(VideoCaptureManagerTest, CreateAndClose) { | 282 TEST_F(VideoCaptureManagerTest, CreateAndClose) { |
| 282 InSequence s; | 283 InSequence s; |
| 283 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 284 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 285 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 284 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 286 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 285 | 287 |
| 286 int video_session_id = vcm_->Open(devices_.front()); | 288 int video_session_id = vcm_->Open(devices_.front()); |
| 287 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 289 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 288 | 290 |
| 289 StopClient(client_id); | 291 StopClient(client_id); |
| 290 vcm_->Close(video_session_id); | 292 vcm_->Close(video_session_id); |
| 291 | 293 |
| 292 // Wait to check callbacks before removing the listener. | 294 // Wait to check callbacks before removing the listener. |
| 293 base::RunLoop().RunUntilIdle(); | 295 base::RunLoop().RunUntilIdle(); |
| 294 vcm_->UnregisterListener(); | 296 vcm_->UnregisterListener(); |
| 295 } | 297 } |
| 296 | 298 |
| 297 TEST_F(VideoCaptureManagerTest, CreateAndCloseMultipleTimes) { | 299 TEST_F(VideoCaptureManagerTest, CreateAndCloseMultipleTimes) { |
| 298 InSequence s; | 300 InSequence s; |
| 299 for (int i = 1 ; i < 3 ; ++i) { | 301 for (int i = 1 ; i < 3 ; ++i) { |
| 300 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, i)); | 302 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, i)); |
| 303 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 301 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, i)); | 304 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, i)); |
| 302 int video_session_id = vcm_->Open(devices_.front()); | 305 int video_session_id = vcm_->Open(devices_.front()); |
| 303 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 306 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 304 | 307 |
| 305 StopClient(client_id); | 308 StopClient(client_id); |
| 306 vcm_->Close(video_session_id); | 309 vcm_->Close(video_session_id); |
| 307 } | 310 } |
| 308 | 311 |
| 309 // Wait to check callbacks before removing the listener. | 312 // Wait to check callbacks before removing the listener. |
| 310 base::RunLoop().RunUntilIdle(); | 313 base::RunLoop().RunUntilIdle(); |
| 311 vcm_->UnregisterListener(); | 314 vcm_->UnregisterListener(); |
| 312 } | 315 } |
| 313 | 316 |
| 314 // Try to open, start, and abort a device. | 317 // Try to open, start, and abort a device. |
| 315 TEST_F(VideoCaptureManagerTest, CreateAndAbort) { | 318 TEST_F(VideoCaptureManagerTest, CreateAndAbort) { |
| 316 InSequence s; | 319 InSequence s; |
| 317 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 320 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 321 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 318 EXPECT_CALL(*listener_, Aborted(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 322 EXPECT_CALL(*listener_, Aborted(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 319 | 323 |
| 320 int video_session_id = vcm_->Open(devices_.front()); | 324 int video_session_id = vcm_->Open(devices_.front()); |
| 321 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 325 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 322 | 326 |
| 323 // Wait for device opened. | 327 // Wait for device opened. |
| 324 base::RunLoop().RunUntilIdle(); | 328 base::RunLoop().RunUntilIdle(); |
| 325 | 329 |
| 326 vcm_->StopCaptureForClient(controllers_[client_id], client_id, | 330 vcm_->StopCaptureForClient(controllers_[client_id], client_id, |
| 327 frame_observer_.get(), true); | 331 frame_observer_.get(), true); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 EXPECT_TRUE( | 404 EXPECT_TRUE( |
| 401 vcm_->GetDeviceSupportedFormats(video_session_id, &supported_formats)); | 405 vcm_->GetDeviceSupportedFormats(video_session_id, &supported_formats)); |
| 402 ASSERT_GT(supported_formats.size(), 1u); | 406 ASSERT_GT(supported_formats.size(), 1u); |
| 403 EXPECT_GT(supported_formats[0].frame_size.width(), 1); | 407 EXPECT_GT(supported_formats[0].frame_size.width(), 1); |
| 404 EXPECT_GT(supported_formats[0].frame_size.height(), 1); | 408 EXPECT_GT(supported_formats[0].frame_size.height(), 1); |
| 405 EXPECT_GT(supported_formats[0].frame_rate, 1); | 409 EXPECT_GT(supported_formats[0].frame_rate, 1); |
| 406 EXPECT_GT(supported_formats[1].frame_size.width(), 1); | 410 EXPECT_GT(supported_formats[1].frame_size.width(), 1); |
| 407 EXPECT_GT(supported_formats[1].frame_size.height(), 1); | 411 EXPECT_GT(supported_formats[1].frame_size.height(), 1); |
| 408 EXPECT_GT(supported_formats[1].frame_rate, 1); | 412 EXPECT_GT(supported_formats[1].frame_rate, 1); |
| 409 | 413 |
| 414 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 410 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 415 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 411 base::RunLoop().RunUntilIdle(); | 416 base::RunLoop().RunUntilIdle(); |
| 412 // After StartClient(), device's supported formats should stay the same. | 417 // After StartClient(), device's supported formats should stay the same. |
| 413 supported_formats.clear(); | 418 supported_formats.clear(); |
| 414 EXPECT_TRUE( | 419 EXPECT_TRUE( |
| 415 vcm_->GetDeviceSupportedFormats(video_session_id, &supported_formats)); | 420 vcm_->GetDeviceSupportedFormats(video_session_id, &supported_formats)); |
| 416 ASSERT_GE(supported_formats.size(), 2u); | 421 ASSERT_GE(supported_formats.size(), 2u); |
| 417 EXPECT_GT(supported_formats[0].frame_size.width(), 1); | 422 EXPECT_GT(supported_formats[0].frame_size.width(), 1); |
| 418 EXPECT_GT(supported_formats[0].frame_size.height(), 1); | 423 EXPECT_GT(supported_formats[0].frame_size.height(), 1); |
| 419 EXPECT_GT(supported_formats[0].frame_rate, 1); | 424 EXPECT_GT(supported_formats[0].frame_rate, 1); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 supported_formats.clear(); | 471 supported_formats.clear(); |
| 467 EXPECT_TRUE(vcm_->GetDeviceSupportedFormats(device_id, &supported_formats)); | 472 EXPECT_TRUE(vcm_->GetDeviceSupportedFormats(device_id, &supported_formats)); |
| 468 ASSERT_GE(supported_formats.size(), 2u); | 473 ASSERT_GE(supported_formats.size(), 2u); |
| 469 EXPECT_GT(supported_formats[0].frame_size.width(), 1); | 474 EXPECT_GT(supported_formats[0].frame_size.width(), 1); |
| 470 EXPECT_GT(supported_formats[0].frame_size.height(), 1); | 475 EXPECT_GT(supported_formats[0].frame_size.height(), 1); |
| 471 EXPECT_GT(supported_formats[0].frame_rate, 1); | 476 EXPECT_GT(supported_formats[0].frame_rate, 1); |
| 472 EXPECT_GT(supported_formats[1].frame_size.width(), 1); | 477 EXPECT_GT(supported_formats[1].frame_size.width(), 1); |
| 473 EXPECT_GT(supported_formats[1].frame_size.height(), 1); | 478 EXPECT_GT(supported_formats[1].frame_size.height(), 1); |
| 474 EXPECT_GT(supported_formats[1].frame_rate, 1); | 479 EXPECT_GT(supported_formats[1].frame_rate, 1); |
| 475 | 480 |
| 481 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 476 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 482 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 477 base::RunLoop().RunUntilIdle(); | 483 base::RunLoop().RunUntilIdle(); |
| 478 // After StartClient(), device's supported formats should stay the same. | 484 // After StartClient(), device's supported formats should stay the same. |
| 479 supported_formats.clear(); | 485 supported_formats.clear(); |
| 480 EXPECT_TRUE(vcm_->GetDeviceSupportedFormats(device_id, &supported_formats)); | 486 EXPECT_TRUE(vcm_->GetDeviceSupportedFormats(device_id, &supported_formats)); |
| 481 ASSERT_GE(supported_formats.size(), 2u); | 487 ASSERT_GE(supported_formats.size(), 2u); |
| 482 EXPECT_GT(supported_formats[0].frame_size.width(), 1); | 488 EXPECT_GT(supported_formats[0].frame_size.width(), 1); |
| 483 EXPECT_GT(supported_formats[0].frame_size.height(), 1); | 489 EXPECT_GT(supported_formats[0].frame_size.height(), 1); |
| 484 EXPECT_GT(supported_formats[0].frame_rate, 1); | 490 EXPECT_GT(supported_formats[0].frame_rate, 1); |
| 485 EXPECT_GT(supported_formats[1].frame_size.width(), 1); | 491 EXPECT_GT(supported_formats[1].frame_size.width(), 1); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 512 InSequence s; | 518 InSequence s; |
| 513 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 519 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 514 int video_session_id = vcm_->Open(devices_.front()); | 520 int video_session_id = vcm_->Open(devices_.front()); |
| 515 base::RunLoop().RunUntilIdle(); | 521 base::RunLoop().RunUntilIdle(); |
| 516 | 522 |
| 517 // Right after opening the device, we should see no format in use. | 523 // Right after opening the device, we should see no format in use. |
| 518 media::VideoCaptureFormats formats_in_use; | 524 media::VideoCaptureFormats formats_in_use; |
| 519 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(video_session_id, &formats_in_use)); | 525 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(video_session_id, &formats_in_use)); |
| 520 EXPECT_TRUE(formats_in_use.empty()); | 526 EXPECT_TRUE(formats_in_use.empty()); |
| 521 | 527 |
| 528 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 522 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 529 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 523 base::RunLoop().RunUntilIdle(); | 530 base::RunLoop().RunUntilIdle(); |
| 524 // After StartClient(), |formats_in_use| should contain one valid format. | 531 // After StartClient(), |formats_in_use| should contain one valid format. |
| 525 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(video_session_id, &formats_in_use)); | 532 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(video_session_id, &formats_in_use)); |
| 526 EXPECT_EQ(formats_in_use.size(), 1u); | 533 EXPECT_EQ(formats_in_use.size(), 1u); |
| 527 if (formats_in_use.size()) { | 534 if (formats_in_use.size()) { |
| 528 media::VideoCaptureFormat& format_in_use = formats_in_use.front(); | 535 media::VideoCaptureFormat& format_in_use = formats_in_use.front(); |
| 529 EXPECT_TRUE(format_in_use.IsValid()); | 536 EXPECT_TRUE(format_in_use.IsValid()); |
| 530 EXPECT_GT(format_in_use.frame_size.width(), 1); | 537 EXPECT_GT(format_in_use.frame_size.width(), 1); |
| 531 EXPECT_GT(format_in_use.frame_size.height(), 1); | 538 EXPECT_GT(format_in_use.frame_size.height(), 1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 557 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 564 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 558 int video_session_id = vcm_->Open(devices_.front()); | 565 int video_session_id = vcm_->Open(devices_.front()); |
| 559 base::RunLoop().RunUntilIdle(); | 566 base::RunLoop().RunUntilIdle(); |
| 560 | 567 |
| 561 // Right after opening the device, we should see no format in use. | 568 // Right after opening the device, we should see no format in use. |
| 562 media::VideoCaptureFormats formats_in_use; | 569 media::VideoCaptureFormats formats_in_use; |
| 563 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, | 570 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, |
| 564 &formats_in_use)); | 571 &formats_in_use)); |
| 565 EXPECT_TRUE(formats_in_use.empty()); | 572 EXPECT_TRUE(formats_in_use.empty()); |
| 566 | 573 |
| 574 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 567 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 575 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 568 base::RunLoop().RunUntilIdle(); | 576 base::RunLoop().RunUntilIdle(); |
| 569 // After StartClient(), |formats_in_use| should contain one valid format. | 577 // After StartClient(), |formats_in_use| should contain one valid format. |
| 570 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, | 578 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, |
| 571 &formats_in_use)); | 579 &formats_in_use)); |
| 572 EXPECT_EQ(formats_in_use.size(), 1u); | 580 EXPECT_EQ(formats_in_use.size(), 1u); |
| 573 if (formats_in_use.size()) { | 581 if (formats_in_use.size()) { |
| 574 media::VideoCaptureFormat& format_in_use = formats_in_use.front(); | 582 media::VideoCaptureFormat& format_in_use = formats_in_use.front(); |
| 575 EXPECT_TRUE(format_in_use.IsValid()); | 583 EXPECT_TRUE(format_in_use.IsValid()); |
| 576 EXPECT_GT(format_in_use.frame_size.width(), 1); | 584 EXPECT_GT(format_in_use.frame_size.width(), 1); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 650 |
| 643 // Wait to check callbacks before removing the listener. | 651 // Wait to check callbacks before removing the listener. |
| 644 base::RunLoop().RunUntilIdle(); | 652 base::RunLoop().RunUntilIdle(); |
| 645 vcm_->UnregisterListener(); | 653 vcm_->UnregisterListener(); |
| 646 } | 654 } |
| 647 | 655 |
| 648 // Open and start a device, close it before calling Stop. | 656 // Open and start a device, close it before calling Stop. |
| 649 TEST_F(VideoCaptureManagerTest, CloseWithoutStop) { | 657 TEST_F(VideoCaptureManagerTest, CloseWithoutStop) { |
| 650 InSequence s; | 658 InSequence s; |
| 651 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 659 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 660 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 652 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 661 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 653 | 662 |
| 654 int video_session_id = vcm_->Open(devices_.front()); | 663 int video_session_id = vcm_->Open(devices_.front()); |
| 655 | 664 |
| 656 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 665 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 657 | 666 |
| 658 // Close will stop the running device, an assert will be triggered in | 667 // Close will stop the running device, an assert will be triggered in |
| 659 // VideoCaptureManager destructor otherwise. | 668 // VideoCaptureManager destructor otherwise. |
| 660 vcm_->Close(video_session_id); | 669 vcm_->Close(video_session_id); |
| 661 StopClient(client_id); | 670 StopClient(client_id); |
| 662 | 671 |
| 663 // Wait to check callbacks before removing the listener | 672 // Wait to check callbacks before removing the listener |
| 664 base::RunLoop().RunUntilIdle(); | 673 base::RunLoop().RunUntilIdle(); |
| 665 vcm_->UnregisterListener(); | 674 vcm_->UnregisterListener(); |
| 666 } | 675 } |
| 667 | 676 |
| 668 // Try to open, start, pause and resume a device. Confirm the device is | 677 // Try to open, start, pause and resume a device. Confirm the device is |
| 669 // paused/resumed at the correct times in both single-client and multiple-client | 678 // paused/resumed at the correct times in both single-client and multiple-client |
| 670 // scenarios. | 679 // scenarios. |
| 671 TEST_F(VideoCaptureManagerTest, PauseAndResumeClient) { | 680 TEST_F(VideoCaptureManagerTest, PauseAndResumeClient) { |
| 672 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 681 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 682 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 673 | 683 |
| 674 const int video_session_id = vcm_->Open(devices_.front()); | 684 const int video_session_id = vcm_->Open(devices_.front()); |
| 675 const VideoCaptureControllerID client_id = | 685 const VideoCaptureControllerID client_id = |
| 676 StartClient(video_session_id, true); | 686 StartClient(video_session_id, true); |
| 677 | 687 |
| 678 // Test pause/resume when only one client is present. | 688 // Test pause/resume when only one client is present. |
| 679 EXPECT_CALL(*video_capture_device_factory_, WillSuspendDevice()).Times(1); | 689 EXPECT_CALL(*video_capture_device_factory_, WillSuspendDevice()).Times(1); |
| 680 PauseClient(client_id); | 690 PauseClient(client_id); |
| 681 EXPECT_CALL(*video_capture_device_factory_, WillResumeDevice()).Times(1); | 691 EXPECT_CALL(*video_capture_device_factory_, WillResumeDevice()).Times(1); |
| 682 ResumeClient(video_session_id, client_id); | 692 ResumeClient(video_session_id, client_id); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 702 // Wait to check callbacks before removing the listener. | 712 // Wait to check callbacks before removing the listener. |
| 703 base::RunLoop().RunUntilIdle(); | 713 base::RunLoop().RunUntilIdle(); |
| 704 vcm_->UnregisterListener(); | 714 vcm_->UnregisterListener(); |
| 705 } | 715 } |
| 706 | 716 |
| 707 #if defined(OS_ANDROID) | 717 #if defined(OS_ANDROID) |
| 708 // Try to open, start, pause and resume a device. | 718 // Try to open, start, pause and resume a device. |
| 709 TEST_F(VideoCaptureManagerTest, PauseAndResumeDevice) { | 719 TEST_F(VideoCaptureManagerTest, PauseAndResumeDevice) { |
| 710 InSequence s; | 720 InSequence s; |
| 711 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 721 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 722 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
| 712 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 723 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 713 | 724 |
| 714 int video_session_id = vcm_->Open(devices_.front()); | 725 int video_session_id = vcm_->Open(devices_.front()); |
| 715 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 726 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 716 | 727 |
| 717 // Release/ResumeDevices according to ApplicationStatus. Should cause no | 728 // Release/ResumeDevices according to ApplicationStatus. Should cause no |
| 718 // problem in any order. Check https://crbug.com/615557 for more details. | 729 // problem in any order. Check https://crbug.com/615557 for more details. |
| 719 ApplicationStateChange( | 730 ApplicationStateChange( |
| 720 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); | 731 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); |
| 721 ApplicationStateChange( | 732 ApplicationStateChange( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 733 // Wait to check callbacks before removing the listener. | 744 // Wait to check callbacks before removing the listener. |
| 734 base::RunLoop().RunUntilIdle(); | 745 base::RunLoop().RunUntilIdle(); |
| 735 vcm_->UnregisterListener(); | 746 vcm_->UnregisterListener(); |
| 736 } | 747 } |
| 737 #endif | 748 #endif |
| 738 | 749 |
| 739 // TODO(mcasas): Add a test to check consolidation of the supported formats | 750 // TODO(mcasas): Add a test to check consolidation of the supported formats |
| 740 // provided by the device when http://crbug.com/323913 is closed. | 751 // provided by the device when http://crbug.com/323913 is closed. |
| 741 | 752 |
| 742 } // namespace content | 753 } // namespace content |
| OLD | NEW |