// 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 "components/viz/service/hit_test/hit_test_aggregator.h" #include <map> #include <memory> #include <optional> #include <utility> #include "base/memory/raw_ptr.h" #include "components/viz/common/hit_test/hit_test_region_list.h" #include "components/viz/common/surfaces/frame_sink_id.h" #include "components/viz/common/surfaces/surface_id.h" #include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" #include "components/viz/service/frame_sinks/compositor_frame_sink_support.h" #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" #include "components/viz/service/hit_test/hit_test_aggregator_delegate.h" #include "components/viz/service/surfaces/surface_manager.h" #include "components/viz/test/compositor_frame_helpers.h" #include "components/viz/test/surface_id_allocator_set.h" #include "components/viz/test/test_latest_local_surface_id_lookup_delegate.h" #include "testing/gtest/include/gtest/gtest.h" namespace viz { namespace { constexpr uint32_t kDisplayClientId = …; constexpr FrameSinkId kDisplayFrameSink(kDisplayClientId, 0); class TestHostFrameSinkManager : public HostFrameSinkManager { … }; class TestFrameSinkManagerImpl : public FrameSinkManagerImpl { … }; } // namespace class TestHitTestAggregator final : public HitTestAggregator { … }; class HitTestAggregatorTest : public testing::Test { … }; // TODO(gklassen): Add tests for 3D use cases as suggested by and with // input from rjkroege. // One surface. // // +----------+ // | | // | | // | | // +----------+ // TEST_F(HitTestAggregatorTest, OneSurface) { … } // One opaque embedder with two regions. // // +e-------------+ // | +r1-+ +r2--+ | // | | | | | | // | | | | | | // | +---+ +----+ | // +--------------+ // TEST_F(HitTestAggregatorTest, OneEmbedderTwoRegions) { … } // One embedder with two children. // // +e-------------+ // | +c1-+ +c2--+ | // | | | | | | // | | | | | | // | +---+ +----+ | // +--------------+ // TEST_F(HitTestAggregatorTest, OneEmbedderTwoChildren) { … } // Occluded child frame (OOPIF). // // +e-----------+ // | +c--+ | // | | +div-+ | // | | | | | // | | +----+ | // | +---+ | // +------------+ // TEST_F(HitTestAggregatorTest, OccludedChildFrame) { … } // Foreground child frame (OOPIF). // Same as the previous test except the child is foreground. // // +e-----------+ // | +c--+ | // | | |div-+ | // | | | | | // | | |----+ | // | +---+ | // +------------+ // TEST_F(HitTestAggregatorTest, ForegroundChildFrame) { … } // One embedder with a clipped child with a tab and transparent background. // // +e-------------+ // | +c---------| Point maps to // | 1 |+a--+ | ----- ------- // | || 2 | 3 | 1 e // | |+b--------| 2 a // | || | 3 e (transparent area in c) // | || 4 | 4 b // +--------------+ // TEST_F(HitTestAggregatorTest, ClippedChildWithTabAndTransparentBackground) { … } // Three children deep. // // +e------------+ // | +c1-------+ | // | | +c2---+ | | // | | | +c3-| | | // | | | | | | | // | | | +---| | | // | | +-----+ | | // | +---------+ | // +-------------+ // TEST_F(HitTestAggregatorTest, ThreeChildrenDeep) { … } // Missing / late child. // // +e-----------+ // | +c--+ | // | | |div-+ | // | | | | | // | | |----+ | // | +---+ | // +------------+ // TEST_F(HitTestAggregatorTest, MissingChildFrame) { … } // Exceed limits to ensure that bounds and resize work. // // A tree of embedders each with 8 children and 4 levels deep = 4096 regions. // This will exceed initial allocation and force a resize. // // +e--------------------------------------------------------+ // | +c1----------++c2----------++c3----------++c4----------+| // | | +c1--------|| +c1--------|| +c1--------|| +c1--------|| // | | | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| // | | | | || || | | || || | | || || | | || || // | | | +---++---|| | +---++---|| | +---++---|| | +---++---|| // | +------------++------------++------------++------------+| // | +c5----------++c6----------++c7----------++c8----------+| // | | +c1--------|| +c1--------|| +c1--------|| +c1--------|| // | | | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| // | | | | || || | | || || | | || || | | || || // | | | +---++---|| | +---++---|| | +---++---|| | +---++---|| // | +------------++------------++------------++------------+| // +---------------------------------------------------------+ // TEST_F(HitTestAggregatorTest, ExceedLimits) { … } TEST_F(HitTestAggregatorTest, DiscardedSurfaces) { … } // Region c1 is transparent and on top of e, c2 is a child of e, d1 is a // child of c1. // // +e/c1----------+ // | | Point maps to // | +c2-+ | ----- ------- // | | 1 | | 1 c2 // | +d1--------| // | | | // | | | // +--------------+ // TEST_F(HitTestAggregatorTest, TransparentOverlayRegions) { … } TEST_F(HitTestAggregatorTest, HitTestDataNotUpdated) { … } } // namespace viz