Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: content/browser/renderer_host/media/video_capture_unittest.cc

Issue 2487133003: Remove dead code related to media device enumerations and monitoring. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/test/mock_resource_context.h" 27 #include "content/public/test/mock_resource_context.h"
27 #include "content/public/test/test_browser_context.h" 28 #include "content/public/test/test_browser_context.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "content/test/test_content_browser_client.h" 30 #include "content/test/test_content_browser_client.h"
30 #include "media/audio/mock_audio_manager.h" 31 #include "media/audio/mock_audio_manager.h"
31 #include "media/base/media_switches.h" 32 #include "media/base/media_switches.h"
32 #include "media/capture/video_capture_types.h" 33 #include "media/capture/video_capture_types.h"
33 #include "mojo/public/cpp/bindings/binding.h" 34 #include "mojo/public/cpp/bindings/binding.h"
34 #include "net/url_request/url_request_context.h" 35 #include "net/url_request/url_request_context.h"
35 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
36 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
37 38
38 using ::testing::_; 39 using ::testing::_;
39 using ::testing::AnyNumber; 40 using ::testing::AnyNumber;
40 using ::testing::DoAll; 41 using ::testing::DoAll;
41 using ::testing::InSequence; 42 using ::testing::InSequence;
42 using ::testing::Mock; 43 using ::testing::Mock;
43 using ::testing::Return; 44 using ::testing::Return;
44 using ::testing::SaveArg; 45 using ::testing::SaveArg;
45 using ::testing::StrictMock; 46 using ::testing::StrictMock;
46 47
47 namespace content { 48 namespace content {
48 49
50 namespace {
51
52 void VideoInputDevicesEnumerated(base::Closure quit_closure,
53 const std::string& salt,
54 const url::Origin& security_origin,
55 MediaDeviceInfoArray* out,
56 const MediaDeviceEnumeration& enumeration) {
57 for (const auto& info : enumeration[MEDIA_DEVICE_TYPE_VIDEO_INPUT]) {
58 std::string device_id = MediaStreamManager::GetHMACForMediaDeviceID(
59 salt, security_origin, info.device_id);
60 out->push_back(MediaDeviceInfo(device_id, info.label, std::string()));
61 }
62 quit_closure.Run();
63 }
64
65 } // namespace
66
49 // Id used to identify the capture session between renderer and 67 // Id used to identify the capture session between renderer and
50 // video_capture_host. This is an arbitrary value. 68 // video_capture_host. This is an arbitrary value.
51 static const int kDeviceId = 555; 69 static const int kDeviceId = 555;
52 70
53 class MockMediaStreamRequester : public MediaStreamRequester { 71 class MockMediaStreamRequester : public MediaStreamRequester {
54 public: 72 public:
55 MockMediaStreamRequester() {} 73 MockMediaStreamRequester() {}
56 virtual ~MockMediaStreamRequester() {} 74 virtual ~MockMediaStreamRequester() {}
57 75
58 // MediaStreamRequester implementation. 76 // MediaStreamRequester implementation.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 147
130 void OpenSession() { 148 void OpenSession() {
131 const int render_process_id = 1; 149 const int render_process_id = 1;
132 const int render_frame_id = 1; 150 const int render_frame_id = 1;
133 const int page_request_id = 1; 151 const int page_request_id = 1;
134 const url::Origin security_origin(GURL("http://test.com")); 152 const url::Origin security_origin(GURL("http://test.com"));
135 153
136 ASSERT_TRUE(opened_device_label_.empty()); 154 ASSERT_TRUE(opened_device_label_.empty());
137 155
138 // Enumerate video devices. 156 // Enumerate video devices.
139 StreamDeviceInfoArray devices; 157 MediaDeviceInfoArray video_devices;
140 { 158 {
141 base::RunLoop run_loop; 159 base::RunLoop run_loop;
142 std::string label = media_stream_manager_->EnumerateDevices( 160 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate;
143 &stream_requester_, 161 devices_to_enumerate[MEDIA_DEVICE_TYPE_VIDEO_INPUT] = true;
144 render_process_id, 162 media_stream_manager_->media_devices_manager()->EnumerateDevices(
145 render_frame_id, 163 devices_to_enumerate,
146 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), 164 base::Bind(
147 page_request_id, 165 &VideoInputDevicesEnumerated, run_loop.QuitClosure(),
148 MEDIA_DEVICE_VIDEO_CAPTURE, 166 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(),
149 security_origin); 167 security_origin, &video_devices));
150 EXPECT_CALL(stream_requester_,
151 DevicesEnumerated(render_frame_id, page_request_id, label, _))
152 .Times(1)
153 .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()),
154 SaveArg<3>(&devices)));
155 run_loop.Run(); 168 run_loop.Run();
156 Mock::VerifyAndClearExpectations(&stream_requester_);
157 media_stream_manager_->CancelRequest(label);
158 } 169 }
159 ASSERT_FALSE(devices.empty()); 170 ASSERT_FALSE(video_devices.empty());
160 ASSERT_EQ(StreamDeviceInfo::kNoId, devices[0].session_id);
161 171
162 // Open the first device. 172 // Open the first device.
163 { 173 {
164 base::RunLoop run_loop; 174 base::RunLoop run_loop;
165 StreamDeviceInfo opened_device; 175 StreamDeviceInfo opened_device;
166 media_stream_manager_->OpenDevice( 176 media_stream_manager_->OpenDevice(
167 &stream_requester_, 177 &stream_requester_, render_process_id, render_frame_id,
168 render_process_id,
169 render_frame_id,
170 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), 178 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(),
171 page_request_id, 179 page_request_id, video_devices[0].device_id,
172 devices[0].device.id, 180 MEDIA_DEVICE_VIDEO_CAPTURE, security_origin);
173 MEDIA_DEVICE_VIDEO_CAPTURE,
174 security_origin);
175 EXPECT_CALL(stream_requester_, 181 EXPECT_CALL(stream_requester_,
176 DeviceOpened(render_frame_id, page_request_id, _, _)) 182 DeviceOpened(render_frame_id, page_request_id, _, _))
177 .Times(1) 183 .Times(1)
178 .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()), 184 .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()),
179 SaveArg<2>(&opened_device_label_), 185 SaveArg<2>(&opened_device_label_),
180 SaveArg<3>(&opened_device))); 186 SaveArg<3>(&opened_device)));
181 run_loop.Run(); 187 run_loop.Run();
182 Mock::VerifyAndClearExpectations(&stream_requester_); 188 Mock::VerifyAndClearExpectations(&stream_requester_);
183 ASSERT_NE(StreamDeviceInfo::kNoId, opened_device.session_id); 189 ASSERT_NE(StreamDeviceInfo::kNoId, opened_device.session_id);
184 opened_session_id_ = opened_device.session_id; 190 opened_session_id_ = opened_device.session_id;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 StartCapture(); 358 StartCapture();
353 359
354 // When the session is closed via the stream without stopping capture, the 360 // When the session is closed via the stream without stopping capture, the
355 // ENDED event is sent. 361 // ENDED event is sent.
356 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); 362 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED));
357 CloseSession(); 363 CloseSession();
358 base::RunLoop().RunUntilIdle(); 364 base::RunLoop().RunUntilIdle();
359 } 365 }
360 366
361 } // namespace content 367 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/media_stream_requester.h ('k') | content/common/media/media_stream_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698