| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 scoped_ptr<VideoCaptureDevice> device( | 127 scoped_ptr<VideoCaptureDevice> device( |
| 128 video_capture_device_factory_->Create(names->front())); | 128 video_capture_device_factory_->Create(names->front())); |
| 129 ASSERT_TRUE(device); | 129 ASSERT_TRUE(device); |
| 130 | 130 |
| 131 EXPECT_CALL(*client_, OnErr()).Times(0); | 131 EXPECT_CALL(*client_, OnErr()).Times(0); |
| 132 | 132 |
| 133 VideoCaptureParams capture_params; | 133 VideoCaptureParams capture_params; |
| 134 capture_params.requested_format.frame_size.SetSize(640, 480); | 134 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 135 capture_params.requested_format.frame_rate = 30; | 135 capture_params.requested_format.frame_rate = 30; |
| 136 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 136 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
| 137 capture_params.allow_resolution_change = false; | |
| 138 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 137 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
| 139 WaitForCapturedFrame(); | 138 WaitForCapturedFrame(); |
| 140 EXPECT_EQ(last_format().frame_size.width(), 640); | 139 EXPECT_EQ(last_format().frame_size.width(), 640); |
| 141 EXPECT_EQ(last_format().frame_size.height(), 480); | 140 EXPECT_EQ(last_format().frame_size.height(), 480); |
| 142 EXPECT_EQ(last_format().frame_rate, 30); | 141 EXPECT_EQ(last_format().frame_rate, 30); |
| 143 device->StopAndDeAllocate(); | 142 device->StopAndDeAllocate(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { | 145 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { |
| 147 scoped_ptr<VideoCaptureDevice::Names> names(EnumerateDevices()); | 146 scoped_ptr<VideoCaptureDevice::Names> names(EnumerateDevices()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 170 } | 169 } |
| 171 | 170 |
| 172 // Disabled, http://crbug.com/407061 . | 171 // Disabled, http://crbug.com/407061 . |
| 173 TEST_F(FakeVideoCaptureDeviceTest, DISABLED_CaptureVariableResolution) { | 172 TEST_F(FakeVideoCaptureDeviceTest, DISABLED_CaptureVariableResolution) { |
| 174 scoped_ptr<VideoCaptureDevice::Names> names(EnumerateDevices()); | 173 scoped_ptr<VideoCaptureDevice::Names> names(EnumerateDevices()); |
| 175 | 174 |
| 176 VideoCaptureParams capture_params; | 175 VideoCaptureParams capture_params; |
| 177 capture_params.requested_format.frame_size.SetSize(640, 480); | 176 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 178 capture_params.requested_format.frame_rate = 30; | 177 capture_params.requested_format.frame_rate = 30; |
| 179 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 178 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
| 180 capture_params.allow_resolution_change = true; | 179 capture_params.resolution_change_policy = |
| 180 RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT; |
| 181 | 181 |
| 182 ASSERT_GT(static_cast<int>(names->size()), 0); | 182 ASSERT_GT(static_cast<int>(names->size()), 0); |
| 183 | 183 |
| 184 scoped_ptr<VideoCaptureDevice> device( | 184 scoped_ptr<VideoCaptureDevice> device( |
| 185 video_capture_device_factory_->Create(names->front())); | 185 video_capture_device_factory_->Create(names->front())); |
| 186 ASSERT_TRUE(device); | 186 ASSERT_TRUE(device); |
| 187 | 187 |
| 188 // Configure the FakeVideoCaptureDevice to use all its formats as roster. | 188 // Configure the FakeVideoCaptureDevice to use all its formats as roster. |
| 189 VideoCaptureFormats formats; | 189 VideoCaptureFormats formats; |
| 190 video_capture_device_factory_->GetDeviceSupportedFormats(names->front(), | 190 video_capture_device_factory_->GetDeviceSupportedFormats(names->front(), |
| 191 &formats); | 191 &formats); |
| 192 static_cast<FakeVideoCaptureDevice*>(device.get())-> | 192 static_cast<FakeVideoCaptureDevice*>(device.get())-> |
| 193 PopulateVariableFormatsRoster(formats); | 193 PopulateVariableFormatsRoster(formats); |
| 194 | 194 |
| 195 EXPECT_CALL(*client_, OnErr()) | 195 EXPECT_CALL(*client_, OnErr()) |
| 196 .Times(0); | 196 .Times(0); |
| 197 int action_count = 200; | 197 int action_count = 200; |
| 198 | 198 |
| 199 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 199 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
| 200 | 200 |
| 201 // We set TimeWait to 200 action timeouts and this should be enough for at | 201 // We set TimeWait to 200 action timeouts and this should be enough for at |
| 202 // least action_count/kFakeCaptureCapabilityChangePeriod calls. | 202 // least action_count/kFakeCaptureCapabilityChangePeriod calls. |
| 203 for (int i = 0; i < action_count; ++i) { | 203 for (int i = 0; i < action_count; ++i) { |
| 204 WaitForCapturedFrame(); | 204 WaitForCapturedFrame(); |
| 205 } | 205 } |
| 206 device->StopAndDeAllocate(); | 206 device->StopAndDeAllocate(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 }; // namespace media | 209 }; // namespace media |
| OLD | NEW |