chromium/media/capture/video/video_capture_device_client_unittest.cc

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

#include "media/capture/video/video_capture_device_client.h"

#include <stddef.h>

#include <memory>

#include "base/check.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "media/base/limits.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/capture/mojom/video_capture_buffer.mojom.h"
#include "media/capture/mojom/video_effects_manager.mojom.h"
#include "media/capture/video/mock_gpu_memory_buffer_manager.h"
#include "media/capture/video/mock_video_frame_receiver.h"
#include "media/capture/video/video_capture_buffer_pool_impl.h"
#include "media/capture/video/video_capture_buffer_tracker.h"
#include "media/capture/video/video_capture_buffer_tracker_factory.h"
#include "media/capture/video/video_capture_buffer_tracker_factory_impl.h"
#include "media/capture/video/video_frame_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/video_effects/public/mojom/video_effects_processor.mojom.h"
#include "services/video_effects/test/fake_video_effects_processor.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "media/capture/video/chromeos/video_capture_jpeg_decoder.h"
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

_;
AtLeast;
Field;
InSequence;
Invoke;
Mock;
NiceMock;
Optional;
Pointee;
SaveArg;

namespace media {

namespace {

#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<VideoCaptureJpegDecoder> ReturnNullPtrAsJpecDecoder() {
  return nullptr;
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

class FakeVideoEffectsManagerImpl : public media::mojom::VideoEffectsManager {};

class FakeVideoCaptureBufferHandle : public VideoCaptureBufferHandle {};

class FakeVideoCaptureBufferTracker : public VideoCaptureBufferTracker {};

class FakeVideoCaptureBufferTrackerFactory
    : public VideoCaptureBufferTrackerFactory {};

}  // namespace

// Test fixture for testing a unit consisting of an instance of
// VideoCaptureDeviceClient connected to a partly-mocked instance of
// VideoCaptureController, and an instance of VideoCaptureBufferPoolImpl
// as well as related threading glue that replicates how it is used in
// production.
class VideoCaptureDeviceClientTest : public ::testing::Test {};

// A small test for reference and to verify VideoCaptureDeviceClient is
// minimally functional.
TEST_F(VideoCaptureDeviceClientTest, Minimal) {}

TEST_F(VideoCaptureDeviceClientTest,
       ProgressesCaptureBeginTimestampsForOnIncomingCapturedData) {}

TEST_F(VideoCaptureDeviceClientTest,
       ProgressesCaptureBeginTimestampsForOnIncomingCapturedGfxBuffer) {}

TEST_F(VideoCaptureDeviceClientTest,
       ProgressesCaptureBeginTimestampsForOnIncomingCapturedExternalBuffer) {}

// Tests that we fail silently if no available buffers to use.
TEST_F(VideoCaptureDeviceClientTest, DropsFrameIfNoBuffer) {}

// Tests that buffer-based capture API accepts some memory-backed pixel formats.
TEST_F(VideoCaptureDeviceClientTest, DataCaptureGoodPixelFormats) {}

// Test that we receive the expected resolution for a given captured frame
// resolution and rotation. Odd resolutions are also cropped.
TEST_F(VideoCaptureDeviceClientTest, CheckRotationsAndCrops) {}

#if !BUILDFLAG(IS_CHROMEOS)
// Tests that the VideoEffectsManager remote is closed on the correct task
// runner. Destruction on the wrong task runner will cause a crash.
TEST_F(VideoCaptureDeviceClientTest, DestructionClosesVideoEffectsManager) {}
#endif  // !BUILDFLAG(IS_CHROMEOS)
}  // namespace media