| 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 "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | |
| 7 #include <queue> | 8 #include <queue> |
| 8 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 9 | 11 |
| 10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 13 #include "base/location.h" | 15 #include "base/location.h" |
| 14 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 18 #include "content/browser/browser_thread_impl.h" | 20 #include "content/browser/browser_thread_impl.h" |
| 19 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 21 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 20 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | |
| 21 #include "content/browser/renderer_host/media/media_stream_manager.h" | 22 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 22 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 23 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| 23 #include "content/browser/renderer_host/media/video_capture_manager.h" | 24 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 24 #include "content/common/media/media_stream_messages.h" | 25 #include "content/common/media/media_stream_messages.h" |
| 25 #include "content/common/media/media_stream_options.h" | 26 #include "content/common/media/media_stream_options.h" |
| 26 #include "content/public/browser/media_device_id.h" | 27 #include "content/public/browser/media_device_id.h" |
| 27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/test/mock_resource_context.h" | 29 #include "content/public/test/mock_resource_context.h" |
| 29 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
| 30 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 base::RunLoop().RunUntilIdle(); | 842 base::RunLoop().RunUntilIdle(); |
| 842 } | 843 } |
| 843 | 844 |
| 844 TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) { | 845 TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) { |
| 845 StreamControls controls(false, true); | 846 StreamControls controls(false, true); |
| 846 | 847 |
| 847 base::Closure close_callback; | 848 base::Closure close_callback; |
| 848 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy()); | 849 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy()); |
| 849 EXPECT_CALL(*stream_ui, OnStarted(_, _)) | 850 EXPECT_CALL(*stream_ui, OnStarted(_, _)) |
| 850 .WillOnce(SaveArg<0>(&close_callback)); | 851 .WillOnce(SaveArg<0>(&close_callback)); |
| 851 media_stream_manager_->UseFakeUIForTests(stream_ui.Pass()); | 852 media_stream_manager_->UseFakeUIForTests(std::move(stream_ui)); |
| 852 | 853 |
| 853 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); | 854 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); |
| 854 | 855 |
| 855 EXPECT_EQ(host_->audio_devices_.size(), 0u); | 856 EXPECT_EQ(host_->audio_devices_.size(), 0u); |
| 856 EXPECT_EQ(host_->video_devices_.size(), 1u); | 857 EXPECT_EQ(host_->video_devices_.size(), 1u); |
| 857 | 858 |
| 858 ASSERT_FALSE(close_callback.is_null()); | 859 ASSERT_FALSE(close_callback.is_null()); |
| 859 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)); | 860 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)); |
| 860 close_callback.Run(); | 861 close_callback.Run(); |
| 861 base::RunLoop().RunUntilIdle(); | 862 base::RunLoop().RunUntilIdle(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 906 |
| 906 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { | 907 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { |
| 907 SetupFakeUI(false); | 908 SetupFakeUI(false); |
| 908 stream_ui_->SetCameraAccess(false); | 909 stream_ui_->SetCameraAccess(false); |
| 909 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, | 910 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
| 910 MEDIA_DEVICE_VIDEO_CAPTURE); | 911 MEDIA_DEVICE_VIDEO_CAPTURE); |
| 911 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); | 912 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); |
| 912 } | 913 } |
| 913 | 914 |
| 914 }; // namespace content | 915 }; // namespace content |
| OLD | NEW |