Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: media/capture/video/video_capture_device_unittest.cc

Issue 2983473002: Android Tango depth camera capture support.
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/video/video_capture_device_unittest.cc
diff --git a/media/capture/video/video_capture_device_unittest.cc b/media/capture/video/video_capture_device_unittest.cc
index 4aa5f48360564d9bf2302bdb6871411ae8d16eb5..317de69ba508355fdf32bd11c665383b4bd87920 100644
--- a/media/capture/video/video_capture_device_unittest.cc
+++ b/media/capture/video/video_capture_device_unittest.cc
@@ -291,31 +291,38 @@ class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> {
run_loop_->Run();
}
- bool FindUsableDevices() {
+ std::unique_ptr<VideoCaptureDeviceDescriptor> FindUsableDeviceDescriptor() {
video_capture_device_factory_->GetDeviceDescriptors(
device_descriptors_.get());
#if defined(OS_ANDROID)
- // Android deprecated/legacy devices capture on a single thread, which is
- // occupied by the tests, so nothing gets actually delivered.
+ // Android deprecated/legacy devices and Tango cameras capture on a single
+ // thread, which is occupied by the tests, so nothing gets actually
+ // delivered.
// TODO(mcasas): use those devices' test mode to deliver frames in a
// background thread, https://crbug.com/626857
for (const auto& descriptor : *device_descriptors_) {
- if (VideoCaptureDeviceFactoryAndroid::IsLegacyOrDeprecatedDevice(
- descriptor.device_id)) {
- return false;
+ if (!VideoCaptureDeviceFactoryAndroid::IsLegacyOrDeprecatedDevice(
+ descriptor.device_id) &&
+ descriptor.capture_api != VideoCaptureApi::ANDROID_TANGO) {
+ LOG(INFO) << "Using camera " << descriptor.display_name << " ("
+ << descriptor.model_id << ")";
+ return std::unique_ptr<VideoCaptureDeviceDescriptor>(
+ new VideoCaptureDeviceDescriptor(descriptor));
}
}
+ LOG(WARNING) << "No usable camera found";
+ return nullptr;
#endif
- if (device_descriptors_->empty())
+ if (device_descriptors_->empty()) {
LOG(WARNING) << "No camera found";
- else {
- LOG(INFO) << "Using camera " << device_descriptors_->front().display_name
- << " (" << device_descriptors_->front().model_id << ")";
+ return nullptr;
}
-
- return !device_descriptors_->empty();
+ LOG(INFO) << "Using camera " << device_descriptors_->front().display_name
+ << " (" << device_descriptors_->front().model_id << ")";
+ return std::unique_ptr<VideoCaptureDeviceDescriptor>(
+ new VideoCaptureDeviceDescriptor(device_descriptors_->front()));
}
const VideoCaptureFormat& last_format() const { return last_format_; }
@@ -323,7 +330,7 @@ class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> {
std::unique_ptr<VideoCaptureDeviceDescriptor>
GetFirstDeviceDescriptorSupportingPixelFormat(
const VideoPixelFormat& pixel_format) {
- if (!FindUsableDevices())
+ if (!FindUsableDeviceDescriptor())
return nullptr;
for (const auto& descriptor : *device_descriptors_) {
@@ -410,11 +417,12 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) {
// Allocates the first enumerated device, and expects a frame.
TEST_P(VideoCaptureDeviceTest, CaptureWithSize) {
- if (!FindUsableDevices())
+ auto descriptor = FindUsableDeviceDescriptor();
+ if (!descriptor)
return;
const gfx::Size& size = GetParam();
- if (!IsCaptureSizeSupported(device_descriptors_->front(), size))
+ if (!IsCaptureSizeSupported(*descriptor, size))
return;
const int width = size.width();
const int height = size.height();
@@ -451,12 +459,12 @@ INSTANTIATE_TEST_CASE_P(VideoCaptureDeviceTests,
// Allocates a device with an uncommon resolution and verifies frames are
// captured in a close, much more typical one.
TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) {
- if (!FindUsableDevices())
+ auto descriptor = FindUsableDeviceDescriptor();
+ if (!descriptor)
return;
std::unique_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->CreateDevice(
- device_descriptors_->front()));
+ video_capture_device_factory_->CreateDevice(*descriptor));
ASSERT_TRUE(device);
EXPECT_CALL(*video_capture_client_, OnError(_, _)).Times(0);
@@ -478,15 +486,15 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) {
// Cause hangs on Windows, Linux. Fails Android. https://crbug.com/417824
TEST_F(VideoCaptureDeviceTest, DISABLED_ReAllocateCamera) {
- if (!FindUsableDevices())
+ auto descriptor = FindUsableDeviceDescriptor();
+ if (!descriptor)
return;
// First, do a number of very fast device start/stops.
for (int i = 0; i <= 5; i++) {
ResetWithNewClient();
std::unique_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->CreateDevice(
- device_descriptors_->front()));
+ video_capture_device_factory_->CreateDevice(*descriptor));
gfx::Size resolution;
if (i % 2)
resolution = gfx::Size(640, 480);
@@ -571,7 +579,8 @@ TEST_F(VideoCaptureDeviceTest, NoCameraSupportsPixelFormatMax) {
// Starts the camera and verifies that a photo can be taken. The correctness of
// the photo is enforced by MockImageCaptureClient.
TEST_F(VideoCaptureDeviceTest, MAYBE_TakePhoto) {
- if (!FindUsableDevices())
+ auto descriptor = FindUsableDeviceDescriptor();
+ if (!descriptor)
return;
#if defined(OS_CHROMEOS)
@@ -590,8 +599,7 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_TakePhoto) {
#endif
std::unique_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->CreateDevice(
- device_descriptors_->front()));
+ video_capture_device_factory_->CreateDevice(*descriptor));
ASSERT_TRUE(device);
EXPECT_CALL(*video_capture_client_, OnError(_, _)).Times(0);
@@ -623,7 +631,8 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_TakePhoto) {
// Starts the camera and verifies that the photo capabilities can be retrieved.
TEST_F(VideoCaptureDeviceTest, MAYBE_GetPhotoState) {
- if (!FindUsableDevices())
+ auto descriptor = FindUsableDeviceDescriptor();
+ if (!descriptor)
return;
#if defined(OS_CHROMEOS)
@@ -642,8 +651,7 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_GetPhotoState) {
#endif
std::unique_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->CreateDevice(
- device_descriptors_->front()));
+ video_capture_device_factory_->CreateDevice(*descriptor));
ASSERT_TRUE(device);
EXPECT_CALL(*video_capture_client_, OnError(_, _)).Times(0);

Powered by Google App Engine
This is Rietveld 408576698