| OLD | NEW |
| 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "content/browser/browser_thread_impl.h" | 20 #include "content/browser/browser_thread_impl.h" |
| 21 #include "content/browser/renderer_host/media/media_stream_manager.h" | 21 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 22 #include "content/browser/renderer_host/media/media_stream_requester.h" | 22 #include "content/browser/renderer_host/media/media_stream_requester.h" |
| 23 #include "content/browser/renderer_host/media/video_capture_host.h" | 23 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 24 #include "content/browser/renderer_host/media/video_capture_manager.h" | 24 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 25 #include "content/common/media/media_devices.h" | 25 #include "content/common/media/media_devices.h" |
| 26 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 27 #include "content/public/test/mock_resource_context.h" | |
| 28 #include "content/public/test/test_browser_context.h" | 27 #include "content/public/test/test_browser_context.h" |
| 29 #include "content/public/test/test_browser_thread_bundle.h" | 28 #include "content/public/test/test_browser_thread_bundle.h" |
| 30 #include "content/test/test_content_browser_client.h" | 29 #include "content/test/test_content_browser_client.h" |
| 31 #include "media/audio/audio_system_impl.h" | 30 #include "media/audio/audio_system_impl.h" |
| 32 #include "media/audio/mock_audio_manager.h" | 31 #include "media/audio/mock_audio_manager.h" |
| 33 #include "media/base/media_switches.h" | 32 #include "media/base/media_switches.h" |
| 34 #include "media/capture/video_capture_types.h" | 33 #include "media/capture/video_capture_types.h" |
| 35 #include "mojo/public/cpp/bindings/binding.h" | 34 #include "mojo/public/cpp/bindings/binding.h" |
| 36 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 37 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ASSERT_TRUE(opened_device_label_.empty()); | 157 ASSERT_TRUE(opened_device_label_.empty()); |
| 159 | 158 |
| 160 // Enumerate video devices. | 159 // Enumerate video devices. |
| 161 MediaDeviceInfoArray video_devices; | 160 MediaDeviceInfoArray video_devices; |
| 162 { | 161 { |
| 163 base::RunLoop run_loop; | 162 base::RunLoop run_loop; |
| 164 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; | 163 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; |
| 165 devices_to_enumerate[MEDIA_DEVICE_TYPE_VIDEO_INPUT] = true; | 164 devices_to_enumerate[MEDIA_DEVICE_TYPE_VIDEO_INPUT] = true; |
| 166 media_stream_manager_->media_devices_manager()->EnumerateDevices( | 165 media_stream_manager_->media_devices_manager()->EnumerateDevices( |
| 167 devices_to_enumerate, | 166 devices_to_enumerate, |
| 168 base::Bind( | 167 base::Bind(&VideoInputDevicesEnumerated, run_loop.QuitClosure(), |
| 169 &VideoInputDevicesEnumerated, run_loop.QuitClosure(), | 168 browser_context_.GetMediaDeviceIDSalt(), security_origin, |
| 170 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), | 169 &video_devices)); |
| 171 security_origin, &video_devices)); | |
| 172 run_loop.Run(); | 170 run_loop.Run(); |
| 173 } | 171 } |
| 174 ASSERT_FALSE(video_devices.empty()); | 172 ASSERT_FALSE(video_devices.empty()); |
| 175 | 173 |
| 176 // Open the first device. | 174 // Open the first device. |
| 177 { | 175 { |
| 178 base::RunLoop run_loop; | 176 base::RunLoop run_loop; |
| 179 StreamDeviceInfo opened_device; | 177 StreamDeviceInfo opened_device; |
| 180 media_stream_manager_->OpenDevice( | 178 media_stream_manager_->OpenDevice( |
| 181 &stream_requester_, render_process_id, render_frame_id, | 179 &stream_requester_, render_process_id, render_frame_id, |
| 182 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), | 180 browser_context_.GetMediaDeviceIDSalt(), page_request_id, |
| 183 page_request_id, video_devices[0].device_id, | 181 video_devices[0].device_id, MEDIA_DEVICE_VIDEO_CAPTURE, |
| 184 MEDIA_DEVICE_VIDEO_CAPTURE, security_origin); | 182 security_origin); |
| 185 EXPECT_CALL(stream_requester_, | 183 EXPECT_CALL(stream_requester_, |
| 186 DeviceOpened(render_frame_id, page_request_id, _, _)) | 184 DeviceOpened(render_frame_id, page_request_id, _, _)) |
| 187 .Times(1) | 185 .Times(1) |
| 188 .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()), | 186 .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()), |
| 189 SaveArg<2>(&opened_device_label_), | 187 SaveArg<2>(&opened_device_label_), |
| 190 SaveArg<3>(&opened_device))); | 188 SaveArg<3>(&opened_device))); |
| 191 run_loop.Run(); | 189 run_loop.Run(); |
| 192 Mock::VerifyAndClearExpectations(&stream_requester_); | 190 Mock::VerifyAndClearExpectations(&stream_requester_); |
| 193 ASSERT_NE(StreamDeviceInfo::kNoId, opened_device.session_id); | 191 ASSERT_NE(StreamDeviceInfo::kNoId, opened_device.session_id); |
| 194 opened_session_id_ = opened_device.session_id; | 192 opened_session_id_ = opened_device.session_id; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 StartCapture(); | 364 StartCapture(); |
| 367 | 365 |
| 368 // When the session is closed via the stream without stopping capture, the | 366 // When the session is closed via the stream without stopping capture, the |
| 369 // ENDED event is sent. | 367 // ENDED event is sent. |
| 370 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); | 368 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); |
| 371 CloseSession(); | 369 CloseSession(); |
| 372 base::RunLoop().RunUntilIdle(); | 370 base::RunLoop().RunUntilIdle(); |
| 373 } | 371 } |
| 374 | 372 |
| 375 } // namespace content | 373 } // namespace content |
| OLD | NEW |