OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <sys/fcntl.h> | 5 #include <sys/fcntl.h> |
6 #include <sys/ioctl.h> | 6 #include <sys/ioctl.h> |
7 | 7 |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/scoped_task_environment.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
11 #include "media/capture/video/linux/v4l2_capture_delegate.h" | 12 #include "media/capture/video/linux/v4l2_capture_delegate.h" |
12 #include "media/capture/video/video_capture_device.h" | 13 #include "media/capture/video/video_capture_device.h" |
13 #include "media/capture/video/video_capture_device_descriptor.h" | 14 #include "media/capture/video/video_capture_device_descriptor.h" |
14 #include "media/capture/video_capture_types.h" | 15 #include "media/capture/video_capture_types.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 using ::testing::_; | 19 using ::testing::_; |
19 | 20 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 class V4L2CaptureDelegateTest : public ::testing::Test { | 213 class V4L2CaptureDelegateTest : public ::testing::Test { |
213 public: | 214 public: |
214 V4L2CaptureDelegateTest() | 215 V4L2CaptureDelegateTest() |
215 : device_descriptor_("Device 0", "/dev/video0"), | 216 : device_descriptor_("Device 0", "/dev/video0"), |
216 delegate_(base::MakeUnique<V4L2CaptureDelegate>( | 217 delegate_(base::MakeUnique<V4L2CaptureDelegate>( |
217 device_descriptor_, | 218 device_descriptor_, |
218 base::ThreadTaskRunnerHandle::Get(), | 219 base::ThreadTaskRunnerHandle::Get(), |
219 50)) {} | 220 50)) {} |
220 ~V4L2CaptureDelegateTest() override = default; | 221 ~V4L2CaptureDelegateTest() override = default; |
221 | 222 |
222 base::MessageLoop loop_; | 223 base::test::ScopedTaskEnvironment scoped_task_environment_; |
223 VideoCaptureDeviceDescriptor device_descriptor_; | 224 VideoCaptureDeviceDescriptor device_descriptor_; |
224 std::unique_ptr<V4L2CaptureDelegate> delegate_; | 225 std::unique_ptr<V4L2CaptureDelegate> delegate_; |
225 }; | 226 }; |
226 | 227 |
227 } // anonymous namespace | 228 } // anonymous namespace |
228 | 229 |
229 TEST_F(V4L2CaptureDelegateTest, CreateAndDestroyAndVerifyControls) { | 230 TEST_F(V4L2CaptureDelegateTest, CreateAndDestroyAndVerifyControls) { |
230 // Check that there is at least a video device, otherwise bail. | 231 // Check that there is at least a video device, otherwise bail. |
231 const base::FilePath path("/dev/"); | 232 const base::FilePath path("/dev/"); |
232 base::FileEnumerator enumerator(path, false, base::FileEnumerator::FILES, | 233 base::FileEnumerator enumerator(path, false, base::FileEnumerator::FILES, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // their |default_value|s. | 273 // their |default_value|s. |
273 { | 274 { |
274 base::ScopedFD device_fd( | 275 base::ScopedFD device_fd( |
275 HANDLE_EINTR(open(device_descriptor_.device_id.c_str(), O_RDWR))); | 276 HANDLE_EINTR(open(device_descriptor_.device_id.c_str(), O_RDWR))); |
276 ASSERT_TRUE(device_fd.is_valid()); | 277 ASSERT_TRUE(device_fd.is_valid()); |
277 VerifyUserControlsAreSetToDefaultValues(device_fd.get()); | 278 VerifyUserControlsAreSetToDefaultValues(device_fd.get()); |
278 } | 279 } |
279 } | 280 } |
280 | 281 |
281 }; // namespace media | 282 }; // namespace media |
OLD | NEW |