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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "component/arc/video_facing.h" |
18 #include "content/browser/browser_thread_impl.h" | 19 #include "content/browser/browser_thread_impl.h" |
19 #include "content/browser/renderer_host/media/media_stream_manager.h" | 20 #include "content/browser/renderer_host/media/media_stream_manager.h" |
20 #include "content/browser/renderer_host/media/media_stream_requester.h" | 21 #include "content/browser/renderer_host/media/media_stream_requester.h" |
21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 22 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
22 #include "content/common/media/media_stream_options.h" | 23 #include "content/common/media/media_stream_options.h" |
23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
24 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
25 #include "media/audio/audio_device_description.h" | 26 #include "media/audio/audio_device_description.h" |
26 #include "media/audio/fake_audio_log_factory.h" | 27 #include "media/audio/fake_audio_log_factory.h" |
27 #include "media/base/media_switches.h" | 28 #include "media/base/media_switches.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 MOCK_METHOD4(DeviceOpened, | 153 MOCK_METHOD4(DeviceOpened, |
153 void(int render_frame_id, | 154 void(int render_frame_id, |
154 int page_request_id, | 155 int page_request_id, |
155 const std::string& label, | 156 const std::string& label, |
156 const StreamDeviceInfo& device_info)); | 157 const StreamDeviceInfo& device_info)); |
157 | 158 |
158 private: | 159 private: |
159 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester); | 160 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester); |
160 }; | 161 }; |
161 | 162 |
| 163 class MockVideoCaptureObserver : public component::VideoCaptureObserver { |
| 164 public: |
| 165 MOCK_METHOD1(OnVideoCaptureStarted, void(component::VideoFacingMode)); |
| 166 MOCK_METHOD1(OnVideoCaptureStopped, void(component::VideoFacingMode)); |
| 167 }; |
| 168 |
162 } // namespace | 169 } // namespace |
163 | 170 |
164 class MediaStreamManagerTest : public ::testing::Test { | 171 class MediaStreamManagerTest : public ::testing::Test { |
165 public: | 172 public: |
166 MediaStreamManagerTest() | 173 MediaStreamManagerTest() |
167 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { | 174 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
168 audio_manager_.reset(new MockAudioManager()); | 175 audio_manager_.reset(new MockAudioManager()); |
169 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 176 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get(), new
MockVideoCaptureObserver())); |
170 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
171 } | 178 } |
172 | 179 |
173 ~MediaStreamManagerTest() override {} | 180 ~MediaStreamManagerTest() override {} |
174 | 181 |
175 MOCK_METHOD1(Response, void(int index)); | 182 MOCK_METHOD1(Response, void(int index)); |
176 void ResponseCallback(int index, | 183 void ResponseCallback(int index, |
177 const MediaStreamDevices& devices, | 184 const MediaStreamDevices& devices, |
178 std::unique_ptr<MediaStreamUIProxy> ui_proxy) { | 185 std::unique_ptr<MediaStreamUIProxy> ui_proxy) { |
179 Response(index); | 186 Response(index); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 unique_other_id); | 293 unique_other_id); |
287 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( | 294 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( |
288 kMockSalt, security_origin, hashed_other_id, unique_other_id)); | 295 kMockSalt, security_origin, hashed_other_id, unique_other_id)); |
289 EXPECT_NE(unique_other_id, hashed_other_id); | 296 EXPECT_NE(unique_other_id, hashed_other_id); |
290 EXPECT_EQ(hashed_other_id.size(), 64U); | 297 EXPECT_EQ(hashed_other_id.size(), 64U); |
291 for (const char& c : hashed_other_id) | 298 for (const char& c : hashed_other_id) |
292 EXPECT_TRUE(base::IsAsciiDigit(c) || (c >= 'a' && c <= 'f')); | 299 EXPECT_TRUE(base::IsAsciiDigit(c) || (c >= 'a' && c <= 'f')); |
293 } | 300 } |
294 | 301 |
295 } // namespace content | 302 } // namespace content |
OLD | NEW |