OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/video/fake_video_capture_device.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
7 | 10 |
8 #include "base/bind.h" | 11 #include "base/bind.h" |
9 #include "base/command_line.h" | 12 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
12 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
13 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
14 #include "build/build_config.h" | 17 #include "build/build_config.h" |
15 #include "media/base/media_switches.h" | 18 #include "media/base/media_switches.h" |
16 #include "media/base/video_capture_types.h" | 19 #include "media/base/video_capture_types.h" |
17 #include "media/capture/video/fake_video_capture_device.h" | |
18 #include "media/capture/video/fake_video_capture_device_factory.h" | 20 #include "media/capture/video/fake_video_capture_device_factory.h" |
19 #include "media/capture/video/video_capture_device.h" | 21 #include "media/capture/video/video_capture_device.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 using ::testing::_; | 25 using ::testing::_; |
24 using ::testing::Bool; | 26 using ::testing::Bool; |
25 using ::testing::Combine; | 27 using ::testing::Combine; |
26 using ::testing::SaveArg; | 28 using ::testing::SaveArg; |
27 using ::testing::Values; | 29 using ::testing::Values; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ASSERT_FALSE(names->empty()); | 207 ASSERT_FALSE(names->empty()); |
206 | 208 |
207 scoped_ptr<VideoCaptureDevice> device(new FakeVideoCaptureDevice( | 209 scoped_ptr<VideoCaptureDevice> device(new FakeVideoCaptureDevice( |
208 testing::get<0>(GetParam()), testing::get<1>(GetParam()), | 210 testing::get<0>(GetParam()), testing::get<1>(GetParam()), |
209 testing::get<2>(GetParam()))); | 211 testing::get<2>(GetParam()))); |
210 ASSERT_TRUE(device); | 212 ASSERT_TRUE(device); |
211 | 213 |
212 VideoCaptureParams capture_params; | 214 VideoCaptureParams capture_params; |
213 capture_params.requested_format.frame_size.SetSize(640, 480); | 215 capture_params.requested_format.frame_size.SetSize(640, 480); |
214 capture_params.requested_format.frame_rate = testing::get<2>(GetParam()); | 216 capture_params.requested_format.frame_rate = testing::get<2>(GetParam()); |
215 device->AllocateAndStart(capture_params, client_.Pass()); | 217 device->AllocateAndStart(capture_params, std::move(client_)); |
216 | 218 |
217 WaitForCapturedFrame(); | 219 WaitForCapturedFrame(); |
218 EXPECT_EQ(last_format().frame_size.width(), 640); | 220 EXPECT_EQ(last_format().frame_size.width(), 640); |
219 EXPECT_EQ(last_format().frame_size.height(), 480); | 221 EXPECT_EQ(last_format().frame_size.height(), 480); |
220 EXPECT_EQ(last_format().frame_rate, testing::get<2>(GetParam())); | 222 EXPECT_EQ(last_format().frame_rate, testing::get<2>(GetParam())); |
221 device->StopAndDeAllocate(); | 223 device->StopAndDeAllocate(); |
222 } | 224 } |
223 | 225 |
224 INSTANTIATE_TEST_CASE_P( | 226 INSTANTIATE_TEST_CASE_P( |
225 , | 227 , |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 ASSERT_FALSE(names->empty()); | 267 ASSERT_FALSE(names->empty()); |
266 | 268 |
267 for (const auto& names_iterator : *names) { | 269 for (const auto& names_iterator : *names) { |
268 scoped_ptr<VideoCaptureDevice> device = | 270 scoped_ptr<VideoCaptureDevice> device = |
269 video_capture_device_factory_->Create(names_iterator); | 271 video_capture_device_factory_->Create(names_iterator); |
270 ASSERT_TRUE(device); | 272 ASSERT_TRUE(device); |
271 | 273 |
272 VideoCaptureParams capture_params; | 274 VideoCaptureParams capture_params; |
273 capture_params.requested_format.frame_size.SetSize(1280, 720); | 275 capture_params.requested_format.frame_size.SetSize(1280, 720); |
274 capture_params.requested_format.frame_rate = GetParam().fps; | 276 capture_params.requested_format.frame_rate = GetParam().fps; |
275 device->AllocateAndStart(capture_params, client_.Pass()); | 277 device->AllocateAndStart(capture_params, std::move(client_)); |
276 | 278 |
277 WaitForCapturedFrame(); | 279 WaitForCapturedFrame(); |
278 EXPECT_EQ(last_format().frame_size.width(), 1280); | 280 EXPECT_EQ(last_format().frame_size.width(), 1280); |
279 EXPECT_EQ(last_format().frame_size.height(), 720); | 281 EXPECT_EQ(last_format().frame_size.height(), 720); |
280 EXPECT_EQ(last_format().frame_rate, GetParam().fps); | 282 EXPECT_EQ(last_format().frame_rate, GetParam().fps); |
281 device->StopAndDeAllocate(); | 283 device->StopAndDeAllocate(); |
282 } | 284 } |
283 } | 285 } |
284 | 286 |
285 INSTANTIATE_TEST_CASE_P(, | 287 INSTANTIATE_TEST_CASE_P(, |
286 FakeVideoCaptureDeviceCommandLineTest, | 288 FakeVideoCaptureDeviceCommandLineTest, |
287 Values(CommandLineTestData{"fps=-1", 5}, | 289 Values(CommandLineTestData{"fps=-1", 5}, |
288 CommandLineTestData{"fps=29.97", 29.97f}, | 290 CommandLineTestData{"fps=29.97", 29.97f}, |
289 CommandLineTestData{"fps=60", 60}, | 291 CommandLineTestData{"fps=60", 60}, |
290 CommandLineTestData{"fps=1000", 60})); | 292 CommandLineTestData{"fps=1000", 60})); |
291 }; // namespace media | 293 }; // namespace media |
OLD | NEW |