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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 base::RunLoop().RunUntilIdle(); | 244 base::RunLoop().RunUntilIdle(); |
245 host_->UnsubscribeDeviceChangeNotifications(type, subscription_id); | 245 host_->UnsubscribeDeviceChangeNotifications(type, subscription_id); |
246 | 246 |
247 if (has_permission) | 247 if (has_permission) |
248 EXPECT_TRUE(DoesContainLabels(changed_devices)); | 248 EXPECT_TRUE(DoesContainLabels(changed_devices)); |
249 else | 249 else |
250 EXPECT_TRUE(DoesNotContainLabels(changed_devices)); | 250 EXPECT_TRUE(DoesNotContainLabels(changed_devices)); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 std::unique_ptr<MediaDevicesDispatcherHost> host_; | 254 // The order of these members is important on teardown: |
| 255 // MediaDevicesDispatcherHost expects to be destroyed on the IO thread while |
| 256 // MediaStreamManager expects to be destroyed after the IO thread has been |
| 257 // uninitialized. |
255 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 258 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
256 content::TestBrowserThreadBundle thread_bundle_; | 259 content::TestBrowserThreadBundle thread_bundle_; |
| 260 std::unique_ptr<MediaDevicesDispatcherHost> host_; |
| 261 |
257 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> | 262 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> |
258 audio_manager_; | 263 audio_manager_; |
259 content::TestBrowserContext browser_context_; | 264 content::TestBrowserContext browser_context_; |
260 MediaDeviceEnumeration physical_devices_; | 265 MediaDeviceEnumeration physical_devices_; |
261 url::Origin origin_; | 266 url::Origin origin_; |
262 | 267 |
263 std::vector<MediaDeviceInfoArray> enumerated_devices_; | 268 std::vector<MediaDeviceInfoArray> enumerated_devices_; |
264 }; | 269 }; |
265 | 270 |
266 TEST_F(MediaDevicesDispatcherHostTest, EnumerateAudioInputDevices) { | 271 TEST_F(MediaDevicesDispatcherHostTest, EnumerateAudioInputDevices) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 base::Unretained(this))); | 324 base::Unretained(this))); |
320 base::RunLoop().RunUntilIdle(); | 325 base::RunLoop().RunUntilIdle(); |
321 | 326 |
322 // Verify that the callback for a valid origin does get called. | 327 // Verify that the callback for a valid origin does get called. |
323 EXPECT_CALL(*this, ValidOriginCallback(testing::_)); | 328 EXPECT_CALL(*this, ValidOriginCallback(testing::_)); |
324 host_->EnumerateDevices( | 329 host_->EnumerateDevices( |
325 true, true, true, url::Origin(GURL("http://localhost")), | 330 true, true, true, url::Origin(GURL("http://localhost")), |
326 base::Bind(&MediaDevicesDispatcherHostTest::ValidOriginCallback, | 331 base::Bind(&MediaDevicesDispatcherHostTest::ValidOriginCallback, |
327 base::Unretained(this))); | 332 base::Unretained(this))); |
328 base::RunLoop().RunUntilIdle(); | 333 base::RunLoop().RunUntilIdle(); |
| 334 #if defined(OS_WIN) |
| 335 // On Windows, the underlying MediaStreamManager uses a separate thread for |
| 336 // video capture which must be flushed to guarantee that the callback bound to |
| 337 // EnumerateDevices above is invoked before the end of this test's body. |
| 338 media_stream_manager_->FlushVideoCaptureThreadForTesting(); |
| 339 base::RunLoop().RunUntilIdle(); |
| 340 #endif |
329 } | 341 } |
330 | 342 |
331 }; // namespace content | 343 }; // namespace content |
OLD | NEW |