#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
RunClosure;
_;
#if BUILDFLAG(IS_LINUX)
Invoke;
InvokeWithoutArgs;
#endif
namespace media {
namespace {
#if BUILDFLAG(IS_LINUX)
constexpr int kFrameToReceive = …;
#endif
static struct { … } const kControls[] = …;
#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
}
#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
}