#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
#include <string>
#include <tuple>
#include <utility>
#include "base/functional/bind.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/with_feature_override.h"
#include "base/time/time.h"
#include "base/token.h"
#include "build/build_config.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "components/viz/common/quads/compositor_frame.h"
#include "components/viz/common/quads/compositor_frame_transition_directive.h"
#include "components/viz/common/quads/shared_element_draw_quad.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/common/surfaces/subtree_capture_id.h"
#include "components/viz/common/surfaces/surface_id.h"
#include "components/viz/common/surfaces/surface_info.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/surfaces/surface.h"
#include "components/viz/test/begin_frame_args_test.h"
#include "components/viz/test/compositor_frame_helpers.h"
#include "components/viz/test/fake_compositor_frame_sink_client.h"
#include "components/viz/test/fake_external_begin_frame_source.h"
#include "components/viz/test/fake_surface_observer.h"
#include "components/viz/test/mock_compositor_frame_sink_client.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_shared_image_interface_provider.h"
#include "components/viz/test/viz_test_suite.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h"
#include "services/viz/public/mojom/compositing/compositor_frame_sink.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
_;
Contains;
Eq;
Invoke;
IsEmpty;
Key;
Ne;
SizeIs;
UnorderedElementsAre;
namespace viz {
namespace {
constexpr bool kIsRoot = …;
constexpr FrameSinkId kArbitraryFrameSinkId(1, 1);
constexpr FrameSinkId kAnotherArbitraryFrameSinkId(2, 2);
constexpr gfx::Size kDefaultSize(20, 20);
constexpr gfx::Rect kDefaultOutputRect(kDefaultSize);
const base::UnguessableToken kArbitraryToken = …;
const base::UnguessableToken kAnotherArbitraryToken = …;
const uint64_t kBeginFrameSourceId = …;
MATCHER_P(SurfaceInfoWithId, surface_id, "") { … }
void StubResultCallback(std::unique_ptr<CopyOutputResult> result) { … }
gpu::SyncToken GenTestSyncToken(int id) { … }
bool BeginFrameArgsAreEquivalent(const BeginFrameArgs& first,
const BeginFrameArgs& second) { … }
std::string PostTestCaseNameTuple(
const ::testing::TestParamInfo<std::tuple<bool, bool>>& info) { … }
std::string PostTestCaseNameBool(const ::testing::TestParamInfo<bool>& info) { … }
}
class MockFrameSinkManagerClient : public mojom::FrameSinkManagerClient { … };
class CompositorFrameSinkSupportTestBase : public testing::Test { … };
class CompositorFrameSinkSupportTest
: public testing::WithParamInterface<bool>,
public CompositorFrameSinkSupportTestBase { … };
CompositorFrameSinkSupportTest::CompositorFrameSinkSupportTest() { … }
class OnBeginFrameAcksCompositorFrameSinkSupportTest
: public CompositorFrameSinkSupportTestBase,
public testing::WithParamInterface<std::tuple<bool, bool>> { … };
OnBeginFrameAcksCompositorFrameSinkSupportTest::
OnBeginFrameAcksCompositorFrameSinkSupportTest() { … }
void OnBeginFrameAcksCompositorFrameSinkSupportTest::
MaybeSendCompositorFrameAck() { … }
void OnBeginFrameAcksCompositorFrameSinkSupportTest::MaybeTestOnBeginFrame(
uint64_t sequence_number) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest, ResourceLifetimeSimple) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
ResourceLifetimeSimpleWithProviderHoldingAlive) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
ResourceReusedBeforeReturn) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
ResourceRefMultipleTimes) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest, ResourceLifetime) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest, AddDuringEviction) { … }
TEST_P(CompositorFrameSinkSupportTest, MonotonicallyIncreasingLocalSurfaceIds) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
ProhibitsUnprivilegedCopyRequests) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
EvictLastActivatedSurface) { … }
TEST_P(CompositorFrameSinkSupportTest, ResurectAndImmediatelyEvict) { … }
TEST_P(CompositorFrameSinkSupportTest, EvictSurfaceWithTemporaryReference) { … }
TEST_P(CompositorFrameSinkSupportTest, EvictOlderSurfaces) { … }
void CopyRequestTestCallback(bool* called,
base::OnceClosure finished,
std::unique_ptr<CopyOutputResult> result) { … }
TEST_P(CompositorFrameSinkSupportTest, CopyRequestOnSubtree) { … }
TEST_P(CompositorFrameSinkSupportTest, DuplicateCopyRequest) { … }
TEST_P(CompositorFrameSinkSupportTest, SurfaceInfo) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest, FrameSizeMismatch) { … }
TEST_P(CompositorFrameSinkSupportTest, DeviceScaleFactorMismatch) { … }
TEST_P(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
NeedsBeginFrameResetAfterPresentationFeedback) { … }
TEST_P(OnBeginFrameAcksCompositorFrameSinkSupportTest,
AutoNeedsBeginFrameOnUnsolicitedFrame) { … }
TEST_P(CompositorFrameSinkSupportTest, FrameIndexCarriedOverToNewSurface) { … }
TEST_P(CompositorFrameSinkSupportTest,
OldSurfaceTakesCopyOutputRequestsFromClient) { … }
TEST_P(CompositorFrameSinkSupportTest,
OldSurfaceDoesNotTakeCopyOutputRequestsFromNewLocalId) { … }
TEST_P(CompositorFrameSinkSupportTest,
LastSurfaceTakesCopyOutputRequestsFromClient) { … }
TEST_P(CompositorFrameSinkSupportTest,
OnFrameTokenUpdateAfterFirstSurfaceActivation) { … }
TEST_P(CompositorFrameSinkSupportTest,
OnlyExactSurfaceCanTakeExactOutputRequest) { … }
TEST_P(CompositorFrameSinkSupportTest, OnFrameTokenUpdate) { … }
TEST_P(CompositorFrameSinkSupportTest,
DisallowEmbedTokenReuseAcrossFrameSinks) { … }
TEST_P(CompositorFrameSinkSupportTest, SubmitAfterReparenting) { … }
TEST_P(CompositorFrameSinkSupportTest, EvictThenReparent) { … }
TEST_P(CompositorFrameSinkSupportTest, HitTestRegionValidation) { … }
TEST_P(CompositorFrameSinkSupportTest, ThrottleUnresponsiveClient) { … }
TEST_P(CompositorFrameSinkSupportTest, BeginFrameInterval) { … }
TEST_P(CompositorFrameSinkSupportTest, HandlesSmallErrorInBeginFrameTimes) { … }
TEST_P(CompositorFrameSinkSupportTest,
UsesThrottledIntervalInPresentationFeedback) { … }
TEST_P(CompositorFrameSinkSupportTest, ForceFullFrameToActivateSurface) { … }
TEST_P(CompositorFrameSinkSupportTest,
ReleaseTransitionDirectiveClearsFrameSinkManagerEntry) { … }
TEST_P(CompositorFrameSinkSupportTest, ViewTransitionBlitRequestTextureQuad) { … }
TEST_P(CompositorFrameSinkSupportTest,
GetRequestRegionProperties_NoSurfaceWithActiveFrame) { … }
TEST_P(CompositorFrameSinkSupportTest,
GetRequestRegionProperties_SurfaceWithNoCaptureIdentifier) { … }
TEST_P(CompositorFrameSinkSupportTest,
GetRequestRegionProperties_RenderPassWithSubtreeSize) { … }
TEST_P(CompositorFrameSinkSupportTest,
GetRequestRegionProperties_RenderPassWithNoSubtreeSize) { … }
TEST_P(
CompositorFrameSinkSupportTest,
GetRequestRegionProperties_RenderPassWithNoSubtreeSizeShouldClipToViewport) { … }
TEST_P(CompositorFrameSinkSupportTest,
GetRequestRegionProperties_RenderPassWithCaptureBounds) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}