| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 devices_to_enumerate, | 96 devices_to_enumerate, |
| 97 base::Bind(&PhysicalDevicesEnumerated, run_loop.QuitClosure(), | 97 base::Bind(&PhysicalDevicesEnumerated, run_loop.QuitClosure(), |
| 98 &physical_devices_)); | 98 &physical_devices_)); |
| 99 run_loop.Run(); | 99 run_loop.Run(); |
| 100 | 100 |
| 101 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_AUDIO_INPUT].size(), 0u); | 101 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_AUDIO_INPUT].size(), 0u); |
| 102 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_VIDEO_INPUT].size(), 0u); | 102 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_VIDEO_INPUT].size(), 0u); |
| 103 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].size(), 0u); | 103 ASSERT_GT(physical_devices_[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].size(), 0u); |
| 104 } | 104 } |
| 105 | 105 |
| 106 MOCK_METHOD1(UniqueOriginCallback, |
| 107 void(const std::vector<std::vector<MediaDeviceInfo>>&)); |
| 108 MOCK_METHOD1(ValidOriginCallback, |
| 109 void(const std::vector<std::vector<MediaDeviceInfo>>&)); |
| 110 |
| 106 protected: | 111 protected: |
| 107 void DevicesEnumerated( | 112 void DevicesEnumerated( |
| 108 const base::Closure& closure, | 113 const base::Closure& closure, |
| 109 const std::vector<std::vector<MediaDeviceInfo>>& devices) { | 114 const std::vector<std::vector<MediaDeviceInfo>>& devices) { |
| 110 enumerated_devices_ = devices; | 115 enumerated_devices_ = devices; |
| 111 closure.Run(); | 116 closure.Run(); |
| 112 } | 117 } |
| 113 | 118 |
| 114 void EnumerateDevicesAndWaitForResult(bool enumerate_audio_input, | 119 void EnumerateDevicesAndWaitForResult(bool enumerate_audio_input, |
| 115 bool enumerate_video_input, | 120 bool enumerate_video_input, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 305 } |
| 301 | 306 |
| 302 TEST_F(MediaDevicesDispatcherHostTest, SubscribeDeviceChange) { | 307 TEST_F(MediaDevicesDispatcherHostTest, SubscribeDeviceChange) { |
| 303 SubscribeAndWaitForResult(true); | 308 SubscribeAndWaitForResult(true); |
| 304 } | 309 } |
| 305 | 310 |
| 306 TEST_F(MediaDevicesDispatcherHostTest, SubscribeDeviceChangeNoAccess) { | 311 TEST_F(MediaDevicesDispatcherHostTest, SubscribeDeviceChangeNoAccess) { |
| 307 SubscribeAndWaitForResult(false); | 312 SubscribeAndWaitForResult(false); |
| 308 } | 313 } |
| 309 | 314 |
| 315 TEST_F(MediaDevicesDispatcherHostTest, EnumerateAllDevicesUniqueOrigin) { |
| 316 EXPECT_CALL(*this, UniqueOriginCallback(testing::_)).Times(0); |
| 317 host_->EnumerateDevices( |
| 318 true, true, true, url::Origin(), |
| 319 base::Bind(&MediaDevicesDispatcherHostTest::UniqueOriginCallback, |
| 320 base::Unretained(this))); |
| 321 base::RunLoop().RunUntilIdle(); |
| 322 |
| 323 // Verify that the callback for a valid origin does get called. |
| 324 EXPECT_CALL(*this, ValidOriginCallback(testing::_)); |
| 325 host_->EnumerateDevices( |
| 326 true, true, true, url::Origin(GURL("http://localhost")), |
| 327 base::Bind(&MediaDevicesDispatcherHostTest::ValidOriginCallback, |
| 328 base::Unretained(this))); |
| 329 base::RunLoop().RunUntilIdle(); |
| 330 } |
| 331 |
| 310 }; // namespace content | 332 }; // namespace content |
| OLD | NEW |