chromium/media/capture/video/linux/v4l2_capture_delegate_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <fcntl.h>
#include <sys/ioctl.h>

#include "base/files/file_enumerator.h"
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "media/capture/video/linux/v4l2_capture_delegate.h"
#include "media/capture/video/mock_video_capture_device_client.h"
#include "media/capture/video/video_capture_device.h"
#include "media/capture/video/video_capture_device_descriptor.h"
#include "media/capture/video_capture_types.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_LINUX)
#include "base/command_line.h"
#include "media/capture/capture_switches.h"
#include "media/capture/video/linux/fake_device_provider.h"
#include "media/capture/video/linux/fake_v4l2_impl.h"
#include "media/capture/video/linux/video_capture_device_linux.h"
#include "media/video/fake_gpu_memory_buffer.h"
#endif  // BUILDFLAG(IS_LINUX)

RunClosure;
_;

#if BUILDFLAG(IS_LINUX)
Invoke;
InvokeWithoutArgs;
#endif  // BUILDFLAG(IS_LINUX)

namespace media {

namespace {

#if BUILDFLAG(IS_LINUX)
constexpr int kFrameToReceive =;
#endif  // BUILDFLAG(IS_LINUX)

// Base id and class identifiers for Controls to be modified and later tested
// against default values.
static struct {} const kControls[] =;

// Determines if |control_id| is special, i.e. controls another one's state, or
// if it should be denied (see https://crbug.com/697885).
#if !defined(V4L2_CID_PAN_SPEED)
#define V4L2_CID_PAN_SPEED
#endif
#if !defined(V4L2_CID_TILT_SPEED)
#define V4L2_CID_TILT_SPEED
#endif
#if !defined(V4L2_CID_PANTILT_CMD)
#define V4L2_CID_PANTILT_CMD
#endif
static bool IsSpecialOrBlockedControl(int control_id) {}

static void SetControlsToMaxValues(int device_fd) {}

static void VerifyUserControlsAreSetToDefaultValues(int device_fd) {}

class V4L2CaptureDelegateTest : public ::testing::Test {};

#if BUILDFLAG(IS_LINUX)
class MockV4l2GpuClient : public VideoCaptureDevice::Client {};

class MockCaptureHandleProvider
    : public VideoCaptureDevice::Client::Buffer::HandleProvider {};

class V4l2CaptureDelegateGPUMemoryBufferTest
    : public ::testing::TestWithParam<uint32_t> {};
#endif  // BUILDFLAG(IS_LINUX)
}  // anonymous namespace

// Fails on Linux, see crbug/732355
#if BUILDFLAG(IS_LINUX)
#define MAYBE_CreateAndDestroyAndVerifyControls
#else
#define MAYBE_CreateAndDestroyAndVerifyControls
#endif
TEST_F(V4L2CaptureDelegateTest, MAYBE_CreateAndDestroyAndVerifyControls) {}

#if BUILDFLAG(IS_LINUX)
TEST_P(V4l2CaptureDelegateGPUMemoryBufferTest, CameraCaptureOneCopy) {}

INSTANTIATE_TEST_SUITE_P();
#endif  // BUILDFLAG(IS_LINUX)
}  // namespace media