| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/media/media_devices_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 mojo::Binding<::mojom::MediaDevicesListener> binding_; | 67 mojo::Binding<::mojom::MediaDevicesListener> binding_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 class MediaDevicesDispatcherHostTest : public testing::Test { | 72 class MediaDevicesDispatcherHostTest : public testing::Test { |
| 73 public: | 73 public: |
| 74 MediaDevicesDispatcherHostTest() | 74 MediaDevicesDispatcherHostTest() |
| 75 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 75 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 76 origin_(GURL("https://test.com")) { | 76 origin_(GURL("https://test.com")) { |
| 77 // Make sure we use fake devices to avoid long delays. | 77 // Make sure we use fake devices to avoid long delays. Also, have the fake |
| 78 // devices not report any formats in order to force fallback formats to be |
| 79 // used. |
| 78 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 80 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 79 switches::kUseFakeDeviceForMediaStream, | 81 switches::kUseFakeDeviceForMediaStream, |
| 80 base::StringPrintf("device-count=%zu, video-input-default-id=%s", | 82 base::StringPrintf( |
| 81 kNumFakeVideoDevices, kDefaultVideoDeviceID)); | 83 "device-count=%zu, video-input-default-id=%s, format-count=0", |
| 84 kNumFakeVideoDevices, kDefaultVideoDeviceID)); |
| 82 audio_manager_.reset( | 85 audio_manager_.reset( |
| 83 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); | 86 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); |
| 84 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 87 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
| 85 | 88 |
| 86 MockResourceContext* mock_resource_context = | 89 MockResourceContext* mock_resource_context = |
| 87 static_cast<MockResourceContext*>( | 90 static_cast<MockResourceContext*>( |
| 88 browser_context_.GetResourceContext()); | 91 browser_context_.GetResourceContext()); |
| 89 | 92 |
| 90 host_ = base::MakeUnique<MediaDevicesDispatcherHost>( | 93 host_ = base::MakeUnique<MediaDevicesDispatcherHost>( |
| 91 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(), | 94 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 117 | 120 |
| 118 void VideoInputCapabilitiesCallback( | 121 void VideoInputCapabilitiesCallback( |
| 119 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> capabilities) { | 122 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> capabilities) { |
| 120 MockVideoInputCapabilitiesCallback(); | 123 MockVideoInputCapabilitiesCallback(); |
| 121 std::string expected_first_device_id = GetHMACForMediaDeviceID( | 124 std::string expected_first_device_id = GetHMACForMediaDeviceID( |
| 122 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), origin_, | 125 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), origin_, |
| 123 kDefaultVideoDeviceID); | 126 kDefaultVideoDeviceID); |
| 124 EXPECT_EQ(kNumFakeVideoDevices, capabilities.size()); | 127 EXPECT_EQ(kNumFakeVideoDevices, capabilities.size()); |
| 125 EXPECT_EQ(expected_first_device_id, capabilities[0]->device_id); | 128 EXPECT_EQ(expected_first_device_id, capabilities[0]->device_id); |
| 126 for (const auto& capability : capabilities) { | 129 for (const auto& capability : capabilities) { |
| 130 // Expect at least one format, even if the device is unable to report its |
| 131 // supported formats. |
| 127 EXPECT_GT(capability->formats.size(), 1u); | 132 EXPECT_GT(capability->formats.size(), 1u); |
| 128 EXPECT_GT(capability->formats[0].frame_size.width(), 1); | 133 EXPECT_GT(capability->formats[0].frame_size.width(), 1); |
| 129 EXPECT_GT(capability->formats[0].frame_size.height(), 1); | 134 EXPECT_GT(capability->formats[0].frame_size.height(), 1); |
| 130 EXPECT_GT(capability->formats[0].frame_rate, 1); | 135 EXPECT_GT(capability->formats[0].frame_rate, 1); |
| 131 EXPECT_GT(capability->formats[1].frame_size.width(), 1); | 136 EXPECT_GT(capability->formats[1].frame_size.width(), 1); |
| 132 EXPECT_GT(capability->formats[1].frame_size.height(), 1); | 137 EXPECT_GT(capability->formats[1].frame_size.height(), 1); |
| 133 EXPECT_GT(capability->formats[1].frame_rate, 1); | 138 EXPECT_GT(capability->formats[1].frame_rate, 1); |
| 134 } | 139 } |
| 135 } | 140 } |
| 136 | 141 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // On Windows, the underlying MediaStreamManager uses a separate thread for | 383 // On Windows, the underlying MediaStreamManager uses a separate thread for |
| 379 // video capture which must be flushed to guarantee that the callback bound to | 384 // video capture which must be flushed to guarantee that the callback bound to |
| 380 // GetVIdeoInputCapabilities above is invoked before the end of this test's | 385 // GetVIdeoInputCapabilities above is invoked before the end of this test's |
| 381 // body. | 386 // body. |
| 382 media_stream_manager_->FlushVideoCaptureThreadForTesting(); | 387 media_stream_manager_->FlushVideoCaptureThreadForTesting(); |
| 383 base::RunLoop().RunUntilIdle(); | 388 base::RunLoop().RunUntilIdle(); |
| 384 #endif | 389 #endif |
| 385 } | 390 } |
| 386 | 391 |
| 387 }; // namespace content | 392 }; // namespace content |
| OLD | NEW |