chromium/third_party/blink/renderer/platform/graphics/video_frame_submitter_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/platform/graphics/video_frame_submitter.h"

#include <memory>
#include <tuple>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "cc/layers/video_frame_provider.h"
#include "cc/metrics/video_playback_roughness_reporter.h"
#include "cc/test/layer_test_common.h"
#include "cc/trees/layer_tree_settings.h"
#include "cc/trees/task_runner_provider.h"
#include "components/viz/common/features.h"
#include "components/viz/test/fake_external_begin_frame_source.h"
#include "components/viz/test/test_context_provider.h"
#include "gpu/ipc/client/client_shared_image_interface.h"
#include "media/base/video_frame.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/viz/public/mojom/compositing/compositor_frame_sink.mojom-blink.h"
#include "services/viz/public/mojom/compositing/layer_context.mojom-blink.h"
#include "services/viz/public/mojom/hit_test/hit_test_region_list.mojom-blink.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/graphics/test/mock_compositor_frame_sink.h"
#include "third_party/blink/renderer/platform/graphics/test/mock_embedded_frame_sink_provider.h"
#include "third_party/blink/renderer/platform/graphics/video_frame_resource_provider.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

_;
AnyNumber;
Invoke;
Return;
StrictMock;

namespace blink {

namespace {

class MockVideoFrameProvider : public cc::VideoFrameProvider {};

class VideoMockCompositorFrameSink
    : public viz::mojom::blink::CompositorFrameSink {};

class MockVideoFrameResourceProvider
    : public blink::VideoFrameResourceProvider {};
}  // namespace

// Supports testing features::OnBeginFrameAcks, which changes the expectations
// of what IPCs are sent to the CompositorFrameSinkClient. When enabled
// OnBeginFrame also handles ReturnResources as well as
// DidReceiveCompositorFrameAck.
class VideoFrameSubmitterTest : public testing::Test,
                                public testing::WithParamInterface<bool> {};

enum class SubmissionType {};

#define EXPECT_GET_PUT_FRAME()

// Create submission state macro to ease complexity. Use a macro instead of a
// function so that line numbers are useful in test failures.
#define EXPECT_SUBMISSION(type)

TEST_P(VideoFrameSubmitterTest, StatRenderingFlipsBits) {}

TEST_P(VideoFrameSubmitterTest, StopRenderingSkipsUpdateCurrentFrame) {}

TEST_P(VideoFrameSubmitterTest, StopUsingProviderNullsProvider) {}

TEST_P(VideoFrameSubmitterTest,
       StopUsingProviderSubmitsFrameAndStopsRendering) {}

TEST_P(VideoFrameSubmitterTest, DidReceiveFrameStillSubmitsIfRendering) {}

TEST_P(VideoFrameSubmitterTest, DidReceiveFrameSubmitsFrame) {}

TEST_P(VideoFrameSubmitterTest, ShouldSubmitPreventsSubmission) {}

// Tests that when set to true SetForceSubmit forces frame submissions.
// regardless of the internal submit state.
TEST_P(VideoFrameSubmitterTest, SetForceSubmitForcesSubmission) {}

TEST_P(VideoFrameSubmitterTest, RotationInformationPassedToResourceProvider) {}

TEST_P(VideoFrameSubmitterTest, FrameTransformTakesPrecedent) {}

TEST_P(VideoFrameSubmitterTest, OnBeginFrameSubmitsFrame) {}

TEST_P(VideoFrameSubmitterTest, MissedFrameArgDoesNotProduceFrame) {}

TEST_P(VideoFrameSubmitterTest, MissingProviderDoesNotProduceFrame) {}

TEST_P(VideoFrameSubmitterTest, NoUpdateOnFrameDoesNotProduceFrame) {}

TEST_P(VideoFrameSubmitterTest, NotRenderingDoesNotProduceFrame) {}

TEST_P(VideoFrameSubmitterTest, ReturnsResourceOnCompositorAck) {}

// Tests that after submitting a frame, no frame will be submitted until an ACK
// was received. This is tested by simulating another BeginFrame message.
TEST_P(VideoFrameSubmitterTest, WaitingForAckPreventsNewFrame) {}

// Similar to above but verifies the single-frame paint path.
TEST_P(VideoFrameSubmitterTest, WaitingForAckPreventsSubmitSingleFrame) {}

// Test that after context is lost, the CompositorFrameSink is recreated but the
// SurfaceEmbedder isn't.
TEST_P(VideoFrameSubmitterTest, RecreateCompositorFrameSinkAfterContextLost) {}

// Test that after context is lost, the CompositorFrameSink is recreated but the
// SurfaceEmbedder isn't even with software compositing.
TEST_P(VideoFrameSubmitterTest,
       RecreateCompositorFrameSinkAfterContextLostSoftwareCompositing) {}

// This test simulates a race condition in which the |video_frame_provider_| is
// destroyed before OnReceivedContextProvider returns.
TEST_P(VideoFrameSubmitterTest, StopUsingProviderDuringContextLost) {}

// Test the behaviour of the ChildLocalSurfaceIdAllocator instance. It checks
// that the LocalSurfaceId is properly set at creation and updated when the
// video frames change.
TEST_P(VideoFrameSubmitterTest, FrameSizeChangeUpdatesLocalSurfaceId) {}

TEST_P(VideoFrameSubmitterTest, VideoRotationOutputRect) {}

TEST_P(VideoFrameSubmitterTest, PageVisibilityControlsSubmission) {}

TEST_P(VideoFrameSubmitterTest, PreferredInterval) {}

TEST_P(VideoFrameSubmitterTest, NoDuplicateFramesOnBeginFrame) {}

TEST_P(VideoFrameSubmitterTest, NoDuplicateFramesDidReceiveFrame) {}

TEST_P(VideoFrameSubmitterTest, ZeroSizedFramesAreNotSubmitted) {}

// Check that given enough frames with wallclock duration and enough
// presentation feedback data, VideoFrameSubmitter will call the video roughness
// reporting callback.
TEST_P(VideoFrameSubmitterTest, ProcessTimingDetails) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace blink