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/media_stream_provider.h" | 22 #include "content/browser/renderer_host/media/media_stream_provider.h" |
23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
24 #include "content/common/media/media_stream_options.h" | 24 #include "content/common/media/media_stream_options.h" |
25 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "media/capture/video/fake_video_capture_device_factory.h" | 26 #include "media/capture/video/fake_video_capture_device_factory.h" |
| 27 #include "media/capture/video/video_capture_system.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 | 30 |
30 using ::testing::_; | 31 using ::testing::_; |
31 using ::testing::AnyNumber; | 32 using ::testing::AnyNumber; |
32 using ::testing::DoAll; | 33 using ::testing::DoAll; |
33 using ::testing::InSequence; | 34 using ::testing::InSequence; |
34 using ::testing::InvokeWithoutArgs; | 35 using ::testing::InvokeWithoutArgs; |
35 using ::testing::Return; | 36 using ::testing::Return; |
36 using ::testing::SaveArg; | 37 using ::testing::SaveArg; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 devices.emplace_back(MEDIA_DEVICE_VIDEO_CAPTURE, | 190 devices.emplace_back(MEDIA_DEVICE_VIDEO_CAPTURE, |
190 descriptor.GetNameAndModel(), descriptor.device_id); | 191 descriptor.GetNameAndModel(), descriptor.device_id); |
191 } | 192 } |
192 devices_ = std::move(devices); | 193 devices_ = std::move(devices); |
193 quit_closure.Run(); | 194 quit_closure.Run(); |
194 } | 195 } |
195 | 196 |
196 protected: | 197 protected: |
197 void SetUp() override { | 198 void SetUp() override { |
198 listener_.reset(new MockMediaStreamProviderListener()); | 199 listener_.reset(new MockMediaStreamProviderListener()); |
199 vcm_ = new VideoCaptureManager( | 200 auto video_capture_device_factory = |
200 std::unique_ptr<media::VideoCaptureDeviceFactory>( | 201 base::MakeUnique<WrappedDeviceFactory>(); |
201 new WrappedDeviceFactory()), | 202 video_capture_device_factory_ = video_capture_device_factory.get(); |
202 base::ThreadTaskRunnerHandle::Get()); | 203 auto video_capture_system = base::MakeUnique<media::VideoCaptureSystem>( |
203 video_capture_device_factory_ = static_cast<WrappedDeviceFactory*>( | 204 std::move(video_capture_device_factory)); |
204 vcm_->video_capture_device_factory()); | 205 vcm_ = new VideoCaptureManager(std::move(video_capture_system), |
| 206 base::ThreadTaskRunnerHandle::Get()); |
205 const int32_t kNumberOfFakeDevices = 2; | 207 const int32_t kNumberOfFakeDevices = 2; |
206 video_capture_device_factory_->SetToDefaultDevicesConfig( | 208 video_capture_device_factory_->SetToDefaultDevicesConfig( |
207 kNumberOfFakeDevices); | 209 kNumberOfFakeDevices); |
208 vcm_->RegisterListener(listener_.get()); | 210 vcm_->RegisterListener(listener_.get()); |
209 frame_observer_.reset(new MockFrameObserver()); | 211 frame_observer_.reset(new MockFrameObserver()); |
210 | 212 |
211 base::RunLoop run_loop; | 213 base::RunLoop run_loop; |
212 vcm_->EnumerateDevices( | 214 vcm_->EnumerateDevices( |
213 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, | 215 base::Bind(&VideoCaptureManagerTest::HandleEnumerationResult, |
214 base::Unretained(this), run_loop.QuitClosure())); | 216 base::Unretained(this), run_loop.QuitClosure())); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // Wait to check callbacks before removing the listener. | 787 // Wait to check callbacks before removing the listener. |
786 base::RunLoop().RunUntilIdle(); | 788 base::RunLoop().RunUntilIdle(); |
787 vcm_->UnregisterListener(listener_.get()); | 789 vcm_->UnregisterListener(listener_.get()); |
788 } | 790 } |
789 #endif | 791 #endif |
790 | 792 |
791 // TODO(mcasas): Add a test to check consolidation of the supported formats | 793 // TODO(mcasas): Add a test to check consolidation of the supported formats |
792 // provided by the device when http://crbug.com/323913 is closed. | 794 // provided by the device when http://crbug.com/323913 is closed. |
793 | 795 |
794 } // namespace content | 796 } // namespace content |
OLD | NEW |