Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager_unittest.cc

Issue 2810723002: Refactor VideoCaptureManager::GetDeviceFormatsInUse() (Closed)
Patch Set: Addressed review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698