Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 media::VideoPixelStorage storage, | 147 media::VideoPixelStorage storage, |
| 148 int frame_feedback_id) override { | 148 int frame_feedback_id) override { |
| 149 return Buffer(); | 149 return Buffer(); |
| 150 } | 150 } |
| 151 double GetBufferPoolUtilization() const override { return 0.0; } | 151 double GetBufferPoolUtilization() const override { return 0.0; } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; | 154 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 class DeviceEnumerationListener | |
| 158 : public base::RefCounted<DeviceEnumerationListener> { | |
| 159 public: | |
| 160 MOCK_METHOD1(OnEnumeratedDevicesCallbackPtr, | |
| 161 void(VideoCaptureDeviceDescriptors* descriptors)); | |
| 162 // GMock doesn't support move-only arguments, so we use this forward method. | |
| 163 void OnEnumeratedDevicesCallback( | |
| 164 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors) { | |
| 165 OnEnumeratedDevicesCallbackPtr(descriptors.release()); | |
| 166 } | |
| 167 | |
| 168 private: | |
| 169 friend class base::RefCounted<DeviceEnumerationListener>; | |
| 170 virtual ~DeviceEnumerationListener() {} | |
| 171 }; | |
| 172 | |
| 173 class ImageCaptureClient : public base::RefCounted<ImageCaptureClient> { | 157 class ImageCaptureClient : public base::RefCounted<ImageCaptureClient> { |
| 174 public: | 158 public: |
| 175 // GMock doesn't support move-only arguments, so we use this forward method. | 159 // GMock doesn't support move-only arguments, so we use this forward method. |
| 176 void DoOnGetPhotoCapabilities(mojom::PhotoCapabilitiesPtr capabilities) { | 160 void DoOnGetPhotoCapabilities(mojom::PhotoCapabilitiesPtr capabilities) { |
| 177 capabilities_ = std::move(capabilities); | 161 capabilities_ = std::move(capabilities); |
| 178 OnCorrectGetPhotoCapabilities(); | 162 OnCorrectGetPhotoCapabilities(); |
| 179 } | 163 } |
| 180 MOCK_METHOD0(OnCorrectGetPhotoCapabilities, void(void)); | 164 MOCK_METHOD0(OnCorrectGetPhotoCapabilities, void(void)); |
| 181 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure, | 165 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure, |
| 182 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&)); | 166 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&)); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 209 | 193 |
| 210 mojom::PhotoCapabilitiesPtr capabilities_; | 194 mojom::PhotoCapabilitiesPtr capabilities_; |
| 211 }; | 195 }; |
| 212 | 196 |
| 213 } // namespace | 197 } // namespace |
| 214 | 198 |
| 215 class FakeVideoCaptureDeviceBase : public ::testing::Test { | 199 class FakeVideoCaptureDeviceBase : public ::testing::Test { |
| 216 protected: | 200 protected: |
| 217 FakeVideoCaptureDeviceBase() | 201 FakeVideoCaptureDeviceBase() |
| 218 : loop_(new base::MessageLoop()), | 202 : loop_(new base::MessageLoop()), |
| 203 descriptors_(new VideoCaptureDeviceDescriptors()), | |
| 219 client_(CreateClient()), | 204 client_(CreateClient()), |
| 220 device_enumeration_listener_(new DeviceEnumerationListener()), | |
| 221 image_capture_client_(new ImageCaptureClient()), | 205 image_capture_client_(new ImageCaptureClient()), |
| 222 video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {} | 206 video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {} |
| 223 | 207 |
| 224 void SetUp() override { EXPECT_CALL(*client_, OnError(_, _)).Times(0); } | 208 void SetUp() override { EXPECT_CALL(*client_, OnError(_, _)).Times(0); } |
| 225 | 209 |
| 226 std::unique_ptr<MockClient> CreateClient() { | 210 std::unique_ptr<MockClient> CreateClient() { |
| 227 return std::unique_ptr<MockClient>(new MockClient(base::Bind( | 211 return std::unique_ptr<MockClient>(new MockClient(base::Bind( |
| 228 &FakeVideoCaptureDeviceBase::OnFrameCaptured, base::Unretained(this)))); | 212 &FakeVideoCaptureDeviceBase::OnFrameCaptured, base::Unretained(this)))); |
| 229 } | 213 } |
| 230 | 214 |
| 231 void OnFrameCaptured(const VideoCaptureFormat& format) { | 215 void OnFrameCaptured(const VideoCaptureFormat& format) { |
| 232 last_format_ = format; | 216 last_format_ = format; |
| 233 run_loop_->QuitClosure().Run(); | 217 run_loop_->QuitClosure().Run(); |
| 234 } | 218 } |
| 235 | 219 |
| 236 void WaitForCapturedFrame() { | 220 void WaitForCapturedFrame() { |
| 237 run_loop_.reset(new base::RunLoop()); | 221 run_loop_.reset(new base::RunLoop()); |
| 238 run_loop_->Run(); | 222 run_loop_->Run(); |
| 239 } | 223 } |
| 240 | 224 |
| 241 std::unique_ptr<VideoCaptureDeviceDescriptors> EnumerateDevices() { | |
| 242 VideoCaptureDeviceDescriptors* descriptors; | |
| 243 EXPECT_CALL(*device_enumeration_listener_.get(), | |
| 244 OnEnumeratedDevicesCallbackPtr(_)) | |
| 245 .WillOnce(SaveArg<0>(&descriptors)); | |
| 246 | |
| 247 video_capture_device_factory_->EnumerateDeviceDescriptors( | |
| 248 base::Bind(&DeviceEnumerationListener::OnEnumeratedDevicesCallback, | |
| 249 device_enumeration_listener_)); | |
| 250 base::RunLoop().RunUntilIdle(); | |
| 251 return std::unique_ptr<VideoCaptureDeviceDescriptors>(descriptors); | |
| 252 } | |
| 253 | |
| 254 const VideoCaptureFormat& last_format() const { return last_format_; } | 225 const VideoCaptureFormat& last_format() const { return last_format_; } |
| 255 | 226 |
| 256 VideoCaptureDeviceDescriptors descriptors_; | |
| 257 const std::unique_ptr<base::MessageLoop> loop_; | 227 const std::unique_ptr<base::MessageLoop> loop_; |
| 228 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_; | |
|
chfremer
2017/04/07 16:34:21
Does this need to be a std::unique_ptr<> or can we
Chandan
2017/04/10 09:18:24
VideoCaptureDeviceDescriptors descriptors_ was unu
| |
| 258 std::unique_ptr<base::RunLoop> run_loop_; | 229 std::unique_ptr<base::RunLoop> run_loop_; |
| 259 std::unique_ptr<MockClient> client_; | 230 std::unique_ptr<MockClient> client_; |
| 260 const scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_; | |
| 261 const scoped_refptr<ImageCaptureClient> image_capture_client_; | 231 const scoped_refptr<ImageCaptureClient> image_capture_client_; |
| 262 VideoCaptureFormat last_format_; | 232 VideoCaptureFormat last_format_; |
| 263 const std::unique_ptr<FakeVideoCaptureDeviceFactory> | 233 const std::unique_ptr<FakeVideoCaptureDeviceFactory> |
| 264 video_capture_device_factory_; | 234 video_capture_device_factory_; |
| 265 }; | 235 }; |
| 266 | 236 |
| 267 class FakeVideoCaptureDeviceTest | 237 class FakeVideoCaptureDeviceTest |
| 268 : public FakeVideoCaptureDeviceBase, | 238 : public FakeVideoCaptureDeviceBase, |
| 269 public ::testing::WithParamInterface< | 239 public ::testing::WithParamInterface< |
| 270 ::testing::tuple<VideoPixelFormat, | 240 ::testing::tuple<VideoPixelFormat, |
| 271 FakeVideoCaptureDevice::DeliveryMode, | 241 FakeVideoCaptureDevice::DeliveryMode, |
| 272 float>> {}; | 242 float>> {}; |
| 273 | 243 |
| 274 // Tests that a frame is delivered with the expected settings. | 244 // Tests that a frame is delivered with the expected settings. |
| 275 // Sweeps through a fixed set of requested/expected resolutions. | 245 // Sweeps through a fixed set of requested/expected resolutions. |
| 276 TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) { | 246 TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) { |
| 277 if (testing::get<1>(GetParam()) == | 247 if (testing::get<1>(GetParam()) == |
| 278 FakeVideoCaptureDevice::DeliveryMode::USE_CLIENT_PROVIDED_BUFFERS && | 248 FakeVideoCaptureDevice::DeliveryMode::USE_CLIENT_PROVIDED_BUFFERS && |
| 279 testing::get<0>(GetParam()) == media::PIXEL_FORMAT_MJPEG) { | 249 testing::get<0>(GetParam()) == media::PIXEL_FORMAT_MJPEG) { |
| 280 // Unsupported case | 250 // Unsupported case |
| 281 return; | 251 return; |
| 282 } | 252 } |
| 283 | 253 |
| 284 const std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 254 descriptors_->clear(); |
|
chfremer
2017/04/07 16:34:21
I believe that the gtest framework will create a n
Chandan
2017/04/10 09:18:24
Done.
| |
| 285 EnumerateDevices()); | 255 video_capture_device_factory_->GetDeviceDescriptors(descriptors_.get()); |
| 286 ASSERT_FALSE(descriptors->empty()); | 256 ASSERT_FALSE(descriptors_->empty()); |
| 287 | 257 |
| 288 std::unique_ptr<VideoCaptureDevice> device = | 258 std::unique_ptr<VideoCaptureDevice> device = |
| 289 FakeVideoCaptureDeviceFactory::CreateDeviceWithDefaultResolutions( | 259 FakeVideoCaptureDeviceFactory::CreateDeviceWithDefaultResolutions( |
| 290 testing::get<0>(GetParam()), testing::get<1>(GetParam()), | 260 testing::get<0>(GetParam()), testing::get<1>(GetParam()), |
| 291 testing::get<2>(GetParam())); | 261 testing::get<2>(GetParam())); |
| 292 ASSERT_TRUE(device); | 262 ASSERT_TRUE(device); |
| 293 | 263 |
| 294 // First: Requested, Second: Expected | 264 // First: Requested, Second: Expected |
| 295 std::vector<std::pair<gfx::Size, gfx::Size>> resolutions_to_test; | 265 std::vector<std::pair<gfx::Size, gfx::Size>> resolutions_to_test; |
| 296 resolutions_to_test.emplace_back(gfx::Size(640, 480), gfx::Size(640, 480)); | 266 resolutions_to_test.emplace_back(gfx::Size(640, 480), gfx::Size(640, 480)); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 323 , | 293 , |
| 324 FakeVideoCaptureDeviceTest, | 294 FakeVideoCaptureDeviceTest, |
| 325 Combine( | 295 Combine( |
| 326 Values(PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_MJPEG), | 296 Values(PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_MJPEG), |
| 327 Values( | 297 Values( |
| 328 FakeVideoCaptureDevice::DeliveryMode::USE_DEVICE_INTERNAL_BUFFERS, | 298 FakeVideoCaptureDevice::DeliveryMode::USE_DEVICE_INTERNAL_BUFFERS, |
| 329 FakeVideoCaptureDevice::DeliveryMode::USE_CLIENT_PROVIDED_BUFFERS), | 299 FakeVideoCaptureDevice::DeliveryMode::USE_CLIENT_PROVIDED_BUFFERS), |
| 330 Values(20, 29.97, 30, 50, 60))); | 300 Values(20, 29.97, 30, 50, 60))); |
| 331 | 301 |
| 332 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { | 302 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { |
| 303 descriptors_->clear(); | |
| 333 video_capture_device_factory_->SetToDefaultDevicesConfig(4); | 304 video_capture_device_factory_->SetToDefaultDevicesConfig(4); |
| 334 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 305 video_capture_device_factory_->GetDeviceDescriptors(descriptors_.get()); |
| 335 EnumerateDevices()); | 306 ASSERT_EQ(4u, descriptors_->size()); |
| 336 ASSERT_EQ(4u, descriptors->size()); | |
| 337 const VideoPixelFormat expected_format_by_device_index[] = { | 307 const VideoPixelFormat expected_format_by_device_index[] = { |
| 338 PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_MJPEG, | 308 PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_MJPEG, |
| 339 PIXEL_FORMAT_I420}; | 309 PIXEL_FORMAT_I420}; |
| 340 | 310 |
| 341 int device_index = 0; | 311 int device_index = 0; |
| 342 for (const auto& descriptors_iterator : *descriptors) { | 312 for (const auto& descriptors_iterator : *descriptors_) { |
| 343 VideoCaptureFormats supported_formats; | 313 VideoCaptureFormats supported_formats; |
| 344 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, | 314 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, |
| 345 &supported_formats); | 315 &supported_formats); |
| 346 ASSERT_EQ(5u, supported_formats.size()); | 316 ASSERT_EQ(5u, supported_formats.size()); |
| 347 VideoPixelFormat expected_format = | 317 VideoPixelFormat expected_format = |
| 348 expected_format_by_device_index[device_index]; | 318 expected_format_by_device_index[device_index]; |
| 349 EXPECT_EQ(96, supported_formats[0].frame_size.width()); | 319 EXPECT_EQ(96, supported_formats[0].frame_size.width()); |
| 350 EXPECT_EQ(96, supported_formats[0].frame_size.height()); | 320 EXPECT_EQ(96, supported_formats[0].frame_size.height()); |
| 351 EXPECT_EQ(expected_format, supported_formats[0].pixel_format); | 321 EXPECT_EQ(expected_format, supported_formats[0].pixel_format); |
| 352 EXPECT_GE(supported_formats[0].frame_rate, 20.0); | 322 EXPECT_GE(supported_formats[0].frame_rate, 20.0); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 364 EXPECT_GE(supported_formats[3].frame_rate, 20.0); | 334 EXPECT_GE(supported_formats[3].frame_rate, 20.0); |
| 365 EXPECT_EQ(1920, supported_formats[4].frame_size.width()); | 335 EXPECT_EQ(1920, supported_formats[4].frame_size.width()); |
| 366 EXPECT_EQ(1080, supported_formats[4].frame_size.height()); | 336 EXPECT_EQ(1080, supported_formats[4].frame_size.height()); |
| 367 EXPECT_EQ(expected_format, supported_formats[4].pixel_format); | 337 EXPECT_EQ(expected_format, supported_formats[4].pixel_format); |
| 368 EXPECT_GE(supported_formats[4].frame_rate, 20.0); | 338 EXPECT_GE(supported_formats[4].frame_rate, 20.0); |
| 369 device_index++; | 339 device_index++; |
| 370 } | 340 } |
| 371 } | 341 } |
| 372 | 342 |
| 373 TEST_F(FakeVideoCaptureDeviceTest, GetCameraCalibration) { | 343 TEST_F(FakeVideoCaptureDeviceTest, GetCameraCalibration) { |
| 344 descriptors_->clear(); | |
| 374 const size_t device_count = 2; | 345 const size_t device_count = 2; |
| 375 video_capture_device_factory_->SetToDefaultDevicesConfig(device_count); | 346 video_capture_device_factory_->SetToDefaultDevicesConfig(device_count); |
| 376 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 347 |
| 377 EnumerateDevices()); | 348 video_capture_device_factory_->GetDeviceDescriptors(descriptors_.get()); |
| 378 ASSERT_EQ(device_count, descriptors->size()); | 349 ASSERT_EQ(device_count, descriptors_->size()); |
| 379 ASSERT_FALSE(descriptors->at(0).camera_calibration); | 350 ASSERT_FALSE(descriptors_->at(0).camera_calibration); |
| 380 const VideoCaptureDeviceDescriptor& depth_device = descriptors->at(1); | 351 const VideoCaptureDeviceDescriptor& depth_device = descriptors_->at(1); |
| 381 EXPECT_EQ("/dev/video1", depth_device.device_id); | 352 EXPECT_EQ("/dev/video1", depth_device.device_id); |
| 382 ASSERT_TRUE(depth_device.camera_calibration); | 353 ASSERT_TRUE(depth_device.camera_calibration); |
| 383 EXPECT_EQ(135.0, depth_device.camera_calibration->focal_length_x); | 354 EXPECT_EQ(135.0, depth_device.camera_calibration->focal_length_x); |
| 384 EXPECT_EQ(135.6, depth_device.camera_calibration->focal_length_y); | 355 EXPECT_EQ(135.6, depth_device.camera_calibration->focal_length_y); |
| 385 EXPECT_EQ(0.0, depth_device.camera_calibration->depth_near); | 356 EXPECT_EQ(0.0, depth_device.camera_calibration->depth_near); |
| 386 EXPECT_EQ(65.535, depth_device.camera_calibration->depth_far); | 357 EXPECT_EQ(65.535, depth_device.camera_calibration->depth_far); |
| 387 } | 358 } |
| 388 | 359 |
| 389 TEST_F(FakeVideoCaptureDeviceTest, ErrorDeviceReportsError) { | 360 TEST_F(FakeVideoCaptureDeviceTest, ErrorDeviceReportsError) { |
| 390 auto device = FakeVideoCaptureDeviceFactory::CreateErrorDevice(); | 361 auto device = FakeVideoCaptureDeviceFactory::CreateErrorDevice(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 float expected_fps; | 518 float expected_fps; |
| 548 size_t expected_device_count; | 519 size_t expected_device_count; |
| 549 std::vector<VideoPixelFormat> expected_pixel_formats; | 520 std::vector<VideoPixelFormat> expected_pixel_formats; |
| 550 }; | 521 }; |
| 551 | 522 |
| 552 class FakeVideoCaptureDeviceFactoryTest | 523 class FakeVideoCaptureDeviceFactoryTest |
| 553 : public FakeVideoCaptureDeviceBase, | 524 : public FakeVideoCaptureDeviceBase, |
| 554 public ::testing::WithParamInterface<CommandLineTestData> {}; | 525 public ::testing::WithParamInterface<CommandLineTestData> {}; |
| 555 | 526 |
| 556 TEST_F(FakeVideoCaptureDeviceFactoryTest, DeviceWithNoSupportedFormats) { | 527 TEST_F(FakeVideoCaptureDeviceFactoryTest, DeviceWithNoSupportedFormats) { |
| 528 descriptors_->clear(); | |
| 557 std::vector<FakeVideoCaptureDeviceSettings> config; | 529 std::vector<FakeVideoCaptureDeviceSettings> config; |
| 558 FakeVideoCaptureDeviceSettings device_setting; | 530 FakeVideoCaptureDeviceSettings device_setting; |
| 559 device_setting.device_id = "Device with no supported formats"; | 531 device_setting.device_id = "Device with no supported formats"; |
| 560 config.emplace_back(device_setting); | 532 config.emplace_back(device_setting); |
| 561 video_capture_device_factory_->SetToCustomDevicesConfig(config); | 533 video_capture_device_factory_->SetToCustomDevicesConfig(config); |
| 562 | 534 |
| 563 const std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 535 video_capture_device_factory_->GetDeviceDescriptors(descriptors_.get()); |
| 564 EnumerateDevices()); | 536 EXPECT_EQ(1u, descriptors_->size()); |
| 565 EXPECT_EQ(1u, descriptors->size()); | |
| 566 media::VideoCaptureFormats supported_formats; | 537 media::VideoCaptureFormats supported_formats; |
| 567 video_capture_device_factory_->GetSupportedFormats(descriptors->at(0), | 538 video_capture_device_factory_->GetSupportedFormats(descriptors_->at(0), |
| 568 &supported_formats); | 539 &supported_formats); |
| 569 EXPECT_EQ(0u, supported_formats.size()); | 540 EXPECT_EQ(0u, supported_formats.size()); |
| 570 auto device = video_capture_device_factory_->CreateDevice(descriptors->at(0)); | 541 auto device = |
| 542 video_capture_device_factory_->CreateDevice(descriptors_->at(0)); | |
| 571 EXPECT_TRUE(device.get()); | 543 EXPECT_TRUE(device.get()); |
| 572 | 544 |
| 573 auto client = CreateClient(); | 545 auto client = CreateClient(); |
| 574 EXPECT_CALL(*client, OnError(_, _)); | 546 EXPECT_CALL(*client, OnError(_, _)); |
| 575 VideoCaptureParams capture_params; | 547 VideoCaptureParams capture_params; |
| 576 capture_params.requested_format.frame_size.SetSize(1280, 720); | 548 capture_params.requested_format.frame_size.SetSize(1280, 720); |
| 577 device->AllocateAndStart(capture_params, std::move(client)); | 549 device->AllocateAndStart(capture_params, std::move(client)); |
| 578 } | 550 } |
| 579 | 551 |
| 580 // Tests that the FakeVideoCaptureDeviceFactory delivers the expected number | 552 // Tests that the FakeVideoCaptureDeviceFactory delivers the expected number |
| 581 // of devices and formats when being configured using command-line switches. | 553 // of devices and formats when being configured using command-line switches. |
| 582 TEST_P(FakeVideoCaptureDeviceFactoryTest, FrameRateAndDeviceCount) { | 554 TEST_P(FakeVideoCaptureDeviceFactoryTest, FrameRateAndDeviceCount) { |
| 555 descriptors_->clear(); | |
| 583 std::vector<FakeVideoCaptureDeviceSettings> config; | 556 std::vector<FakeVideoCaptureDeviceSettings> config; |
| 584 FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString( | 557 FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString( |
| 585 GetParam().switch_value_string, &config); | 558 GetParam().switch_value_string, &config); |
| 586 video_capture_device_factory_->SetToCustomDevicesConfig(config); | 559 video_capture_device_factory_->SetToCustomDevicesConfig(config); |
| 587 | 560 |
| 588 const std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 561 video_capture_device_factory_->GetDeviceDescriptors(descriptors_.get()); |
| 589 EnumerateDevices()); | 562 EXPECT_EQ(GetParam().expected_device_count, descriptors_->size()); |
| 590 EXPECT_EQ(GetParam().expected_device_count, descriptors->size()); | |
| 591 | 563 |
| 592 int device_index = 0; | 564 int device_index = 0; |
| 593 for (const auto& descriptors_iterator : *descriptors) { | 565 for (const auto& descriptors_iterator : *descriptors_) { |
| 594 media::VideoCaptureFormats supported_formats; | 566 media::VideoCaptureFormats supported_formats; |
| 595 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, | 567 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, |
| 596 &supported_formats); | 568 &supported_formats); |
| 597 for (const auto& supported_formats_entry : supported_formats) { | 569 for (const auto& supported_formats_entry : supported_formats) { |
| 598 EXPECT_EQ(GetParam().expected_pixel_formats[device_index], | 570 EXPECT_EQ(GetParam().expected_pixel_formats[device_index], |
| 599 supported_formats_entry.pixel_format); | 571 supported_formats_entry.pixel_format); |
| 600 } | 572 } |
| 601 | 573 |
| 602 std::unique_ptr<VideoCaptureDevice> device = | 574 std::unique_ptr<VideoCaptureDevice> device = |
| 603 video_capture_device_factory_->CreateDevice(descriptors_iterator); | 575 video_capture_device_factory_->CreateDevice(descriptors_iterator); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 4u, | 616 4u, |
| 645 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, | 617 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, |
| 646 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, | 618 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, |
| 647 CommandLineTestData{"device-count=4,ownership=client", | 619 CommandLineTestData{"device-count=4,ownership=client", |
| 648 20, | 620 20, |
| 649 4u, | 621 4u, |
| 650 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, | 622 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, |
| 651 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, | 623 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, |
| 652 CommandLineTestData{"device-count=0", 20, 0u, {PIXEL_FORMAT_I420}})); | 624 CommandLineTestData{"device-count=0", 20, 0u, {PIXEL_FORMAT_I420}})); |
| 653 }; // namespace media | 625 }; // namespace media |
| OLD | NEW |