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 "component/arc/video_facing.h" |
20 #include "content/browser/browser_thread_impl.h" | 21 #include "content/browser/browser_thread_impl.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_requester.h" | 23 #include "content/browser/renderer_host/media/media_stream_requester.h" |
23 #include "content/browser/renderer_host/media/video_capture_host.h" | 24 #include "content/browser/renderer_host/media/video_capture_host.h" |
24 #include "content/browser/renderer_host/media/video_capture_manager.h" | 25 #include "content/browser/renderer_host/media/video_capture_manager.h" |
25 #include "content/common/media/media_devices.h" | 26 #include "content/common/media/media_devices.h" |
26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
27 #include "content/public/test/mock_resource_context.h" | 28 #include "content/public/test/mock_resource_context.h" |
28 #include "content/public/test/test_browser_context.h" | 29 #include "content/public/test/test_browser_context.h" |
29 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 25 matching lines...) Expand all Loading... |
55 MediaDeviceInfoArray* out, | 56 MediaDeviceInfoArray* out, |
56 const MediaDeviceEnumeration& enumeration) { | 57 const MediaDeviceEnumeration& enumeration) { |
57 for (const auto& info : enumeration[MEDIA_DEVICE_TYPE_VIDEO_INPUT]) { | 58 for (const auto& info : enumeration[MEDIA_DEVICE_TYPE_VIDEO_INPUT]) { |
58 std::string device_id = MediaStreamManager::GetHMACForMediaDeviceID( | 59 std::string device_id = MediaStreamManager::GetHMACForMediaDeviceID( |
59 salt, security_origin, info.device_id); | 60 salt, security_origin, info.device_id); |
60 out->push_back(MediaDeviceInfo(device_id, info.label, std::string())); | 61 out->push_back(MediaDeviceInfo(device_id, info.label, std::string())); |
61 } | 62 } |
62 quit_closure.Run(); | 63 quit_closure.Run(); |
63 } | 64 } |
64 | 65 |
| 66 class MockVideoCaptureObserver : public component::VideoCaptureObserver { |
| 67 public: |
| 68 MOCK_METHOD1(OnVideoCaptureStarted, void(component::VideoFacingMode)); |
| 69 MOCK_METHOD1(OnVideoCaptureStopped, void(component::VideoFacingMode)); |
| 70 }; |
| 71 |
65 } // namespace | 72 } // namespace |
66 | 73 |
67 // Id used to identify the capture session between renderer and | 74 // Id used to identify the capture session between renderer and |
68 // video_capture_host. This is an arbitrary value. | 75 // video_capture_host. This is an arbitrary value. |
69 static const int kDeviceId = 555; | 76 static const int kDeviceId = 555; |
70 | 77 |
71 class MockMediaStreamRequester : public MediaStreamRequester { | 78 class MockMediaStreamRequester : public MediaStreamRequester { |
72 public: | 79 public: |
73 MockMediaStreamRequester() {} | 80 MockMediaStreamRequester() {} |
74 virtual ~MockMediaStreamRequester() {} | 81 virtual ~MockMediaStreamRequester() {} |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 opened_session_id_(kInvalidMediaCaptureSessionId), | 126 opened_session_id_(kInvalidMediaCaptureSessionId), |
120 observer_binding_(this) {} | 127 observer_binding_(this) {} |
121 | 128 |
122 void SetUp() override { | 129 void SetUp() override { |
123 SetBrowserClientForTesting(&browser_client_); | 130 SetBrowserClientForTesting(&browser_client_); |
124 | 131 |
125 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 132 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
126 switches::kUseFakeDeviceForMediaStream); | 133 switches::kUseFakeDeviceForMediaStream); |
127 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 134 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
128 switches::kUseFakeUIForMediaStream); | 135 switches::kUseFakeUIForMediaStream); |
129 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 136 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get(), new
MockVideoCaptureObserver())); |
130 | 137 |
131 // Create a Host and connect it to a simulated IPC channel. | 138 // Create a Host and connect it to a simulated IPC channel. |
132 host_.reset(new VideoCaptureHost(media_stream_manager_.get())); | 139 host_.reset(new VideoCaptureHost(media_stream_manager_.get())); |
133 | 140 |
134 OpenSession(); | 141 OpenSession(); |
135 } | 142 } |
136 | 143 |
137 void TearDown() override { | 144 void TearDown() override { |
138 Mock::VerifyAndClearExpectations(host_.get()); | 145 Mock::VerifyAndClearExpectations(host_.get()); |
139 EXPECT_TRUE(host_->controllers_.empty()); | 146 EXPECT_TRUE(host_->controllers_.empty()); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 StartCapture(); | 365 StartCapture(); |
359 | 366 |
360 // When the session is closed via the stream without stopping capture, the | 367 // When the session is closed via the stream without stopping capture, the |
361 // ENDED event is sent. | 368 // ENDED event is sent. |
362 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); | 369 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); |
363 CloseSession(); | 370 CloseSession(); |
364 base::RunLoop().RunUntilIdle(); | 371 base::RunLoop().RunUntilIdle(); |
365 } | 372 } |
366 | 373 |
367 } // namespace content | 374 } // namespace content |
OLD | NEW |