chromium/third_party/blink/renderer/modules/mediastream/video_track_adapter_unittest.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/video_track_adapter.h"

#include <limits>

#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/ranges.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/base/limits.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/modules/mediastream/mock_encoded_video_frame.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_video_source.h"
#include "third_party/blink/renderer/modules/mediastream/video_track_adapter_settings.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/video_frame_utils.h"
#include "third_party/webrtc_overrides/low_precision_timer.h"
#include "third_party/webrtc_overrides/metronome_source.h"

namespace blink {

_;
AnyNumber;
NiceMock;

// Most VideoTrackAdapter functionality is tested in MediaStreamVideoSourceTest.
// These tests focus on the computation of cropped frame sizes in edge cases
// that cannot be easily reproduced by a mocked video source, such as tests
// involving frames of zero size.
// Such frames can be produced by sources in the wild (e.g., element capture).

// Test that cropped sizes with zero-area input frames are correctly computed.
// Aspect ratio limits should be ignored.
TEST(VideoTrackAdapterTest, ZeroInputArea) {}

// Test that zero-size cropped areas are correctly computed. Aspect ratio
// limits should be ignored.
TEST(VideoTrackAdapterTest, ZeroOutputArea) {}

// Test that large frames are handled correctly.
TEST(VideoTrackAdapterTest, LargeFrames) {}

// Test that regular frames are not rescaled if settings do not specify a target
// resolution.
TEST(VideoTrackAdapterTest, NoRescaling) {}

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

TEST_F(VideoTrackAdapterFixtureTest, DeliverFrame_GpuMemoryBuffer) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DeliversHWFrameVisibleRectWithEvenOriginAndWidth) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DeliversSWFrameVisibleRectWithEvenOriginAndWidth) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DeliversHWFrameVisibleRectWithEvenOriginAndHeight) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DeliversSWFrameVisibleRectWithEvenOriginAndHeight) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DeliversSWFrameOddVisibleRectWithEvenOriginAndHeight) {}

// Tests that we run the |settings_callback| for any additional tracks that
// share a VideoFrameResolutionAdapter with an existing track. This ensures that
// the additional track's default frame_size and frame_rate are updated to match
// incoming frames.
TEST_F(VideoTrackAdapterFixtureTest,
       DeliverPortraitFrame_RunSettingsCallbackForSecondTrack) {}

TEST_F(VideoTrackAdapterFixtureTest, FrameRateReduction) {}

TEST_F(VideoTrackAdapterFixtureTest, ArbitraryFrameRateReduction) {}

TEST_F(VideoTrackAdapterFixtureTest, StreamWithJitterFrameRateReduction) {}

TEST_F(VideoTrackAdapterFixtureTest, DoNotDropFramesIfFrameRatesMatch) {}

TEST_F(VideoTrackAdapterFixtureTest, FrameRateReductionSlightMismatch) {}

TEST_F(VideoTrackAdapterFixtureTest, DoNotDropFramesIfNoTargetFrameRate) {}

TEST_F(VideoTrackAdapterFixtureTest, DropFramesIfTargetFrameRateIsInfinite) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DoNotDropFramesIfTimeBetweenFramesIsNegative) {}

TEST_F(VideoTrackAdapterFixtureTest,
       DoNotDropFramesIfTimeBetweenFramesIsTooLong) {}

TEST_F(VideoTrackAdapterFixtureTest, DropFramesIfTimeBetweenFramesIsTooShort) {}

TEST_F(VideoTrackAdapterFixtureTest, DropFramesIfTimeBetweenFramesIsZero) {}

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

TEST_F(VideoTrackAdapterEncodedTest, DeliverEncodedVideoFrame) {}

}  // namespace blink