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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // use is an empty vector. | 601 // use is an empty vector. |
602 TEST_F(VideoCaptureManagerTest, | 602 TEST_F(VideoCaptureManagerTest, |
603 StartDeviceAndGetDeviceFormatInUseWithDeviceId) { | 603 StartDeviceAndGetDeviceFormatInUseWithDeviceId) { |
604 std::string device_id = devices_.front().device.id; | 604 std::string device_id = devices_.front().device.id; |
605 InSequence s; | 605 InSequence s; |
606 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 606 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
607 int video_session_id = vcm_->Open(devices_.front().device); | 607 int video_session_id = vcm_->Open(devices_.front().device); |
608 base::RunLoop().RunUntilIdle(); | 608 base::RunLoop().RunUntilIdle(); |
609 | 609 |
610 // Right after opening the device, we should see no format in use. | 610 // Right after opening the device, we should see no format in use. |
611 media::VideoCaptureFormats formats_in_use; | 611 EXPECT_EQ(base::nullopt, |
612 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, | 612 vcm_->GetDeviceFormatInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id)); |
613 &formats_in_use)); | |
614 EXPECT_TRUE(formats_in_use.empty()); | |
615 | 613 |
616 EXPECT_CALL(*frame_observer_, OnStarted(_)); | 614 EXPECT_CALL(*frame_observer_, OnStarted(_)); |
617 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 615 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
618 base::RunLoop().RunUntilIdle(); | 616 base::RunLoop().RunUntilIdle(); |
619 // After StartClient(), |formats_in_use| should contain one valid format. | 617 // After StartClient(), device's format in use should be valid. |
620 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, | 618 base::Optional<media::VideoCaptureFormat> format_in_use = |
621 &formats_in_use)); | 619 vcm_->GetDeviceFormatInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id); |
622 EXPECT_EQ(formats_in_use.size(), 1u); | 620 EXPECT_TRUE(format_in_use.has_value()); |
623 if (formats_in_use.size()) { | 621 EXPECT_TRUE(format_in_use->IsValid()); |
624 media::VideoCaptureFormat& format_in_use = formats_in_use.front(); | 622 EXPECT_GT(format_in_use->frame_size.width(), 1); |
625 EXPECT_TRUE(format_in_use.IsValid()); | 623 EXPECT_GT(format_in_use->frame_size.height(), 1); |
626 EXPECT_GT(format_in_use.frame_size.width(), 1); | 624 EXPECT_GT(format_in_use->frame_rate, 1); |
627 EXPECT_GT(format_in_use.frame_size.height(), 1); | |
628 EXPECT_GT(format_in_use.frame_rate, 1); | |
629 } | |
630 formats_in_use.clear(); | |
631 | 625 |
632 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 626 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
633 StopClient(client_id); | 627 StopClient(client_id); |
634 base::RunLoop().RunUntilIdle(); | 628 base::RunLoop().RunUntilIdle(); |
635 // After StopClient(), the device's formats in use should be empty again. | 629 // After StopClient(), the device's format in use should be empty again. |
636 EXPECT_TRUE(vcm_->GetDeviceFormatsInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id, | 630 EXPECT_EQ(base::nullopt, |
637 &formats_in_use)); | 631 vcm_->GetDeviceFormatInUse(MEDIA_DEVICE_VIDEO_CAPTURE, device_id)); |
638 EXPECT_TRUE(formats_in_use.empty()); | |
639 | 632 |
640 vcm_->Close(video_session_id); | 633 vcm_->Close(video_session_id); |
641 base::RunLoop().RunUntilIdle(); | 634 base::RunLoop().RunUntilIdle(); |
642 vcm_->UnregisterListener(listener_.get()); | 635 vcm_->UnregisterListener(listener_.get()); |
643 } | 636 } |
644 | 637 |
645 // Open two different devices. | 638 // Open two different devices. |
646 TEST_F(VideoCaptureManagerTest, OpenTwo) { | 639 TEST_F(VideoCaptureManagerTest, OpenTwo) { |
647 InSequence s; | 640 InSequence s; |
648 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2); | 641 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // Wait to check callbacks before removing the listener. | 780 // Wait to check callbacks before removing the listener. |
788 base::RunLoop().RunUntilIdle(); | 781 base::RunLoop().RunUntilIdle(); |
789 vcm_->UnregisterListener(listener_.get()); | 782 vcm_->UnregisterListener(listener_.get()); |
790 } | 783 } |
791 #endif | 784 #endif |
792 | 785 |
793 // TODO(mcasas): Add a test to check consolidation of the supported formats | 786 // TODO(mcasas): Add a test to check consolidation of the supported formats |
794 // provided by the device when http://crbug.com/323913 is closed. | 787 // provided by the device when http://crbug.com/323913 is closed. |
795 | 788 |
796 } // namespace content | 789 } // namespace content |
OLD | NEW |