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 // Unit test for VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
6 | 6 |
7 #include "content/browser/renderer_host/media/video_capture_manager.h" | 7 #include "content/browser/renderer_host/media/video_capture_manager.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "content/browser/renderer_host/media/in_process_video_capture_provider.
h" |
22 #include "content/browser/renderer_host/media/media_stream_provider.h" | 23 #include "content/browser/renderer_host/media/media_stream_provider.h" |
23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 24 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
24 #include "content/common/media/media_stream_options.h" | 25 #include "content/common/media/media_stream_options.h" |
25 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "media/capture/video/fake_video_capture_device_factory.h" | 27 #include "media/capture/video/fake_video_capture_device_factory.h" |
27 #include "media/capture/video/video_capture_system_impl.h" | 28 #include "media/capture/video/video_capture_system_impl.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 using ::testing::_; | 32 using ::testing::_; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 196 } |
196 | 197 |
197 protected: | 198 protected: |
198 void SetUp() override { | 199 void SetUp() override { |
199 listener_.reset(new MockMediaStreamProviderListener()); | 200 listener_.reset(new MockMediaStreamProviderListener()); |
200 auto video_capture_device_factory = | 201 auto video_capture_device_factory = |
201 base::MakeUnique<WrappedDeviceFactory>(); | 202 base::MakeUnique<WrappedDeviceFactory>(); |
202 video_capture_device_factory_ = video_capture_device_factory.get(); | 203 video_capture_device_factory_ = video_capture_device_factory.get(); |
203 auto video_capture_system = base::MakeUnique<media::VideoCaptureSystemImpl>( | 204 auto video_capture_system = base::MakeUnique<media::VideoCaptureSystemImpl>( |
204 std::move(video_capture_device_factory)); | 205 std::move(video_capture_device_factory)); |
205 vcm_ = new VideoCaptureManager(std::move(video_capture_system), | 206 auto video_capture_provider = |
206 base::ThreadTaskRunnerHandle::Get()); | 207 base::MakeUnique<InProcessVideoCaptureProvider>( |
| 208 std::move(video_capture_system), |
| 209 base::ThreadTaskRunnerHandle::Get()); |
| 210 vcm_ = new VideoCaptureManager(std::move(video_capture_provider)); |
207 const int32_t kNumberOfFakeDevices = 2; | 211 const int32_t kNumberOfFakeDevices = 2; |
208 video_capture_device_factory_->SetToDefaultDevicesConfig( | 212 video_capture_device_factory_->SetToDefaultDevicesConfig( |
209 kNumberOfFakeDevices); | 213 kNumberOfFakeDevices); |
210 vcm_->RegisterListener(listener_.get()); | 214 vcm_->RegisterListener(listener_.get()); |
211 frame_observer_.reset(new MockFrameObserver()); | 215 frame_observer_.reset(new MockFrameObserver()); |
212 | 216 |
213 base::RunLoop run_loop; | 217 base::RunLoop run_loop; |
214 vcm_->EnumerateDevices( | 218 vcm_->EnumerateDevices( |
215 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, | 219 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, |
216 base::Unretained(this), run_loop.QuitClosure())); | 220 base::Unretained(this), run_loop.QuitClosure())); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // Wait to check callbacks before removing the listener. | 791 // Wait to check callbacks before removing the listener. |
788 base::RunLoop().RunUntilIdle(); | 792 base::RunLoop().RunUntilIdle(); |
789 vcm_->UnregisterListener(listener_.get()); | 793 vcm_->UnregisterListener(listener_.get()); |
790 } | 794 } |
791 #endif | 795 #endif |
792 | 796 |
793 // TODO(mcasas): Add a test to check consolidation of the supported formats | 797 // TODO(mcasas): Add a test to check consolidation of the supported formats |
794 // provided by the device when http://crbug.com/323913 is closed. | 798 // provided by the device when http://crbug.com/323913 is closed. |
795 | 799 |
796 } // namespace content | 800 } // namespace content |
OLD | NEW |