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

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

Issue 2715513008: Make FakeVideoCaptureDeviceFactory configurable to arbitrary fake device configurations (Closed)
Patch Set: Fix compiler warning. Fix WebRtcDepthCaptureBrowserTest. Created 3 years, 10 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
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 protected: 194 protected:
195 void SetUp() override { 195 void SetUp() override {
196 listener_.reset(new MockMediaStreamProviderListener()); 196 listener_.reset(new MockMediaStreamProviderListener());
197 vcm_ = new VideoCaptureManager( 197 vcm_ = new VideoCaptureManager(
198 std::unique_ptr<media::VideoCaptureDeviceFactory>( 198 std::unique_ptr<media::VideoCaptureDeviceFactory>(
199 new WrappedDeviceFactory()), 199 new WrappedDeviceFactory()),
200 base::ThreadTaskRunnerHandle::Get()); 200 base::ThreadTaskRunnerHandle::Get());
201 video_capture_device_factory_ = static_cast<WrappedDeviceFactory*>( 201 video_capture_device_factory_ = static_cast<WrappedDeviceFactory*>(
202 vcm_->video_capture_device_factory()); 202 vcm_->video_capture_device_factory());
203 const int32_t kNumberOfFakeDevices = 2; 203 const int32_t kNumberOfFakeDevices = 2;
204 video_capture_device_factory_->set_number_of_devices(kNumberOfFakeDevices); 204 video_capture_device_factory_->SetToDefaultDevicesConfig(
205 kNumberOfFakeDevices);
205 vcm_->RegisterListener(listener_.get()); 206 vcm_->RegisterListener(listener_.get());
206 frame_observer_.reset(new MockFrameObserver()); 207 frame_observer_.reset(new MockFrameObserver());
207 208
208 base::RunLoop run_loop; 209 base::RunLoop run_loop;
209 vcm_->EnumerateDevices( 210 vcm_->EnumerateDevices(
210 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, 211 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult,
211 base::Unretained(this), run_loop.QuitClosure())); 212 base::Unretained(this), run_loop.QuitClosure()));
212 run_loop.Run(); 213 run_loop.Run();
213 ASSERT_GE(devices_.size(), 2u); 214 ASSERT_GE(devices_.size(), 2u);
214 } 215 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 base::RunLoop().RunUntilIdle(); 394 base::RunLoop().RunUntilIdle();
394 vcm_->UnregisterListener(); 395 vcm_->UnregisterListener();
395 } 396 }
396 397
397 // Connect and disconnect devices. 398 // Connect and disconnect devices.
398 TEST_F(VideoCaptureManagerTest, ConnectAndDisconnectDevices) { 399 TEST_F(VideoCaptureManagerTest, ConnectAndDisconnectDevices) {
399 int number_of_devices_keep = 400 int number_of_devices_keep =
400 video_capture_device_factory_->number_of_devices(); 401 video_capture_device_factory_->number_of_devices();
401 402
402 // Simulate we remove 1 fake device. 403 // Simulate we remove 1 fake device.
403 video_capture_device_factory_->set_number_of_devices(1); 404 video_capture_device_factory_->SetToDefaultDevicesConfig(1);
404 base::RunLoop run_loop; 405 base::RunLoop run_loop;
405 vcm_->EnumerateDevices( 406 vcm_->EnumerateDevices(
406 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, 407 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult,
407 base::Unretained(this), run_loop.QuitClosure())); 408 base::Unretained(this), run_loop.QuitClosure()));
408 run_loop.Run(); 409 run_loop.Run();
409 ASSERT_EQ(devices_.size(), 1u); 410 ASSERT_EQ(devices_.size(), 1u);
410 411
411 // Simulate we add 2 fake devices. 412 // Simulate we add 2 fake devices.
412 video_capture_device_factory_->set_number_of_devices(3); 413 video_capture_device_factory_->SetToDefaultDevicesConfig(3);
413 base::RunLoop run_loop2; 414 base::RunLoop run_loop2;
414 vcm_->EnumerateDevices( 415 vcm_->EnumerateDevices(
415 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, 416 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult,
416 base::Unretained(this), run_loop2.QuitClosure())); 417 base::Unretained(this), run_loop2.QuitClosure()));
417 run_loop2.Run(); 418 run_loop2.Run();
418 ASSERT_EQ(devices_.size(), 3u); 419 ASSERT_EQ(devices_.size(), 3u);
419 420
420 vcm_->UnregisterListener(); 421 vcm_->UnregisterListener();
421 video_capture_device_factory_->set_number_of_devices(number_of_devices_keep); 422 video_capture_device_factory_->SetToDefaultDevicesConfig(
423 number_of_devices_keep);
422 } 424 }
423 425
424 // Enumerate devices and open the first, then check the list of supported 426 // Enumerate devices and open the first, then check the list of supported
425 // formats. Then start the opened device. The capability list should stay the 427 // formats. Then start the opened device. The capability list should stay the
426 // same. Finally stop the device and check that the capabilities stay unchanged. 428 // same. Finally stop the device and check that the capabilities stay unchanged.
427 TEST_F(VideoCaptureManagerTest, ManipulateDeviceAndCheckCapabilities) { 429 TEST_F(VideoCaptureManagerTest, ManipulateDeviceAndCheckCapabilities) {
428 // Before enumerating the devices, requesting formats should return false. 430 // Before enumerating the devices, requesting formats should return false.
429 int video_session_id = 0; 431 int video_session_id = 0;
430 media::VideoCaptureFormats supported_formats; 432 media::VideoCaptureFormats supported_formats;
431 supported_formats.clear(); 433 supported_formats.clear();
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // Wait to check callbacks before removing the listener. 777 // Wait to check callbacks before removing the listener.
776 base::RunLoop().RunUntilIdle(); 778 base::RunLoop().RunUntilIdle();
777 vcm_->UnregisterListener(); 779 vcm_->UnregisterListener();
778 } 780 }
779 #endif 781 #endif
780 782
781 // TODO(mcasas): Add a test to check consolidation of the supported formats 783 // TODO(mcasas): Add a test to check consolidation of the supported formats
782 // provided by the device when http://crbug.com/323913 is closed. 784 // provided by the device when http://crbug.com/323913 is closed.
783 785
784 } // namespace content 786 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698