| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "media/video/capture/fake_video_capture_device.h" | 10 #include "media/video/capture/fake_video_capture_device.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 TEST_F(FakeVideoCaptureDeviceTest, Capture) { | 90 TEST_F(FakeVideoCaptureDeviceTest, Capture) { |
| 91 VideoCaptureDevice::Names names; | 91 VideoCaptureDevice::Names names; |
| 92 | 92 |
| 93 video_capture_device_factory_->GetDeviceNames(&names); | 93 video_capture_device_factory_->GetDeviceNames(&names); |
| 94 | 94 |
| 95 ASSERT_GT(static_cast<int>(names.size()), 0); | 95 ASSERT_GT(static_cast<int>(names.size()), 0); |
| 96 | 96 |
| 97 scoped_ptr<VideoCaptureDevice> device( | 97 scoped_ptr<VideoCaptureDevice> device( |
| 98 video_capture_device_factory_->Create(names.front())); | 98 video_capture_device_factory_->Create( |
| 99 base::MessageLoopProxy::current(), names.front())); |
| 99 ASSERT_TRUE(device); | 100 ASSERT_TRUE(device); |
| 100 | 101 |
| 101 EXPECT_CALL(*client_, OnErr()).Times(0); | 102 EXPECT_CALL(*client_, OnErr()).Times(0); |
| 102 | 103 |
| 103 VideoCaptureParams capture_params; | 104 VideoCaptureParams capture_params; |
| 104 capture_params.requested_format.frame_size.SetSize(640, 480); | 105 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 105 capture_params.requested_format.frame_rate = 30; | 106 capture_params.requested_format.frame_rate = 30; |
| 106 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 107 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
| 107 capture_params.allow_resolution_change = false; | 108 capture_params.allow_resolution_change = false; |
| 108 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 109 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 video_capture_device_factory_->GetDeviceNames(&names); | 147 video_capture_device_factory_->GetDeviceNames(&names); |
| 147 VideoCaptureParams capture_params; | 148 VideoCaptureParams capture_params; |
| 148 capture_params.requested_format.frame_size.SetSize(640, 480); | 149 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 149 capture_params.requested_format.frame_rate = 30; | 150 capture_params.requested_format.frame_rate = 30; |
| 150 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 151 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
| 151 capture_params.allow_resolution_change = true; | 152 capture_params.allow_resolution_change = true; |
| 152 | 153 |
| 153 ASSERT_GT(static_cast<int>(names.size()), 0); | 154 ASSERT_GT(static_cast<int>(names.size()), 0); |
| 154 | 155 |
| 155 scoped_ptr<VideoCaptureDevice> device( | 156 scoped_ptr<VideoCaptureDevice> device( |
| 156 video_capture_device_factory_->Create(names.front())); | 157 video_capture_device_factory_->Create( |
| 158 base::MessageLoopProxy::current(), names.front())); |
| 157 ASSERT_TRUE(device); | 159 ASSERT_TRUE(device); |
| 158 | 160 |
| 159 // Configure the FakeVideoCaptureDevice to use all its formats as roster. | 161 // Configure the FakeVideoCaptureDevice to use all its formats as roster. |
| 160 VideoCaptureFormats formats; | 162 VideoCaptureFormats formats; |
| 161 video_capture_device_factory_->GetDeviceSupportedFormats(names.front(), | 163 video_capture_device_factory_->GetDeviceSupportedFormats(names.front(), |
| 162 &formats); | 164 &formats); |
| 163 static_cast<FakeVideoCaptureDevice*>(device.get())-> | 165 static_cast<FakeVideoCaptureDevice*>(device.get())-> |
| 164 PopulateVariableFormatsRoster(formats); | 166 PopulateVariableFormatsRoster(formats); |
| 165 | 167 |
| 166 EXPECT_CALL(*client_, OnErr()) | 168 EXPECT_CALL(*client_, OnErr()) |
| 167 .Times(0); | 169 .Times(0); |
| 168 int action_count = 200; | 170 int action_count = 200; |
| 169 | 171 |
| 170 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 172 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
| 171 | 173 |
| 172 // We set TimeWait to 200 action timeouts and this should be enough for at | 174 // We set TimeWait to 200 action timeouts and this should be enough for at |
| 173 // least action_count/kFakeCaptureCapabilityChangePeriod calls. | 175 // least action_count/kFakeCaptureCapabilityChangePeriod calls. |
| 174 for (int i = 0; i < action_count; ++i) { | 176 for (int i = 0; i < action_count; ++i) { |
| 175 WaitForCapturedFrame(); | 177 WaitForCapturedFrame(); |
| 176 } | 178 } |
| 177 device->StopAndDeAllocate(); | 179 device->StopAndDeAllocate(); |
| 178 } | 180 } |
| 179 | 181 |
| 180 }; // namespace media | 182 }; // namespace media |
| OLD | NEW |