chromium/third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_video_device_test.cc

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

#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_video_device.h"

#include <algorithm>
#include <optional>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "media/base/limits.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints.h"
#include "third_party/blink/renderer/modules/mediastream/mock_constraint_factory.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {

namespace {

const char kDeviceID1[] =;
const char kDeviceID2[] =;
const char kDeviceID3[] =;
const char kDeviceID4[] =;
const char kDeviceID5[] =;

const char kGroupID1[] =;
const char kGroupID2[] =;
const char kGroupID3[] =;
const char kGroupID4[] =;
const char kGroupID5[] =;

void CheckTrackAdapterSettingsEqualsResolution(
    const VideoCaptureSettings& settings) {}

void CheckTrackAdapterSettingsEqualsFrameRate(
    const VideoCaptureSettings& settings,
    std::optional<double> value = std::nullopt) {}

void CheckTrackAdapterSettingsEqualsFormat(
    const VideoCaptureSettings& settings) {}

double AspectRatio(const media::VideoCaptureFormat& format) {}

VideoCaptureSettings SelectSettingsVideoDeviceCapture(
    const VideoDeviceCaptureCapabilities& capabilities,
    const MediaConstraints& constraints) {}

}  // namespace

class MediaStreamConstraintsUtilVideoDeviceTest : public testing::Test {};

// The Unconstrained test checks the default selection criteria.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, Unconstrained) {}

// The "Overconstrained" tests verify that failure of any single required
// constraint results in failure to select a candidate.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnDeviceID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnGroupID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnFacingMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnEmptyFacingMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnInvalidResizeMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnEmptyResizeMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnHeight) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnNoiseReduction) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       OverconstrainedOnMandatoryPanTiltZoom) {}

// The "Mandatory" and "Ideal" tests check that various selection criteria work
// for each individual constraint in the basic constraint set.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryDeviceID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryGroupID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryFacingMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryNoiseReduction) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactHeight) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinHeight) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxHeight) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryHeightRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealHeight) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryWidthRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryFrameRateRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryAspectRatioRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryResizeMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealResizeMode) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       IdealResizeModeResolutionGreaterThanNative) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       IdealResizeModeResolutionLessThanNative) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealResizeFarFromNative) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, TwoIdealResizeValues) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryPanTiltZoomRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, PresentPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       PresentPanTiltZoomOnSystemWithoutPanTiltZoomCamera) {}

// The "Advanced" tests check selection criteria involving advanced constraint
// sets.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedMinMaxResolutionFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedResolutionAndFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedNoiseReduction) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryNoiseReduction) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryExactResolution) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryMaxMinResolutionFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryMinMaxResolutionFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryExactAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryAspectRatioRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryExactFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryFrameRateRange) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryWidthFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryHeightFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedDeviceID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedGroupID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryDeviceID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryDeviceIDAndResolution) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryGroupID) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryAspectRatioWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryImageCapture) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedContradictoryPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedResize) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       AdvancedResolutionResizeFrameRate) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedPanTiltZoom) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, BasicContradictoryWidth) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       BasicContradictoryWidthAspectRatio) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, BasicImageCapture) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       BasicContradictoryImageCapture) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       BasicContradictoryPanTiltZoom) {}

// The "NoDevices" tests verify that the algorithm returns the expected result
// when there are no candidates to choose from.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesNoConstraints) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesWithConstraints) {}

// This test verifies that having a device that reports a frame rate lower than
// 1 fps works.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, InvalidFrameRateDevice) {}

// This test verifies that an inverted default resolution is not preferred over
// the actual default resolution.
TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, InvertedDefaultResolution) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       SelectEligibleSettingsVideoDeviceCapture_NoEligibleDevices) {}

TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
       SelectEligibleSettingsVideoDeviceCapture_IncludesEligibleDevices) {}

}  // namespace blink