chromium/cc/layers/layer_unittest.cc

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

#include "cc/layers/layer.h"

#include <stddef.h>

#include <memory>
#include <utility>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/task/single_thread_task_runner.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/base/math_util.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/picture_layer.h"
#include "cc/layers/solid_color_scrollbar_layer.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/cc_test_suite.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/transform_node.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/animation/keyframe/keyframed_animation_curve.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/geometry/vector2d_f.h"

_;
AnyNumber;
AtLeast;
Mock;
StrictMock;

#define EXPECT_CALL_MOCK_DELEGATE(obj, call)

#define EXPECT_SET_NEEDS_UPDATE(expect, code_to_test)

#define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test)

#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test)

#define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test)

#define EXPECT_SET_NEEDS_COMMIT_WAS_CALLED(code_to_test)

#define EXPECT_SET_NEEDS_COMMIT_WAS_NOT_CALLED(code_to_test)

namespace cc {

namespace {

static auto kArbitrarySourceId1 =;
static auto kArbitrarySourceId2 =;

// http://google.github.io/googletest/gmock_for_dummies.html#using-mocks-in-tests
// says that it is undefined behavior if we alternate between calls to
// EXPECT_CALL_MOCK_DELEGATE() and calls to the mock functions. It is also
// undefined behavior if we set new expectations after a call to
// VerifyAndClearExpectations. So we need a way to make mocking expectations
// resettable. This delegate object could help achieve that. When we want to
// reset the expectations, we can delete and recreate the delegate object.
class MockLayerTreeHostDelegate {};

class FakeLayerTreeHost : public LayerTreeHost {};

bool LayerNeedsDisplay(Layer* layer) {}

class LayerTest : public testing::Test {};

class LayerTestWithLayerList : public LayerTest {};

TEST_F(LayerTest, BasicCreateAndDestroy) {}

TEST_F(LayerTest, LayerPropertyChangedForSubtree) {}

TEST_F(LayerTest, AddAndRemoveChild) {}

TEST_F(LayerTest, SetMaskLayer) {}

TEST_F(LayerTest, RemoveMaskLayerFromParent) {}

TEST_F(LayerTest, AddChildAfterSetMaskLayer) {}

TEST_F(LayerTest, AddSameChildTwice) {}

TEST_F(LayerTest, ReorderChildren) {}

TEST_F(LayerTest, InsertChild) {}

TEST_F(LayerTest, InsertChildPastEndOfList) {}

TEST_F(LayerTest, InsertSameChildTwice) {}

TEST_F(LayerTest, ReplaceChildWithNewChild) {}

TEST_F(LayerTest, ReplaceChildWithNewChildThatHasOtherParent) {}

TEST_F(LayerTest, ReplaceChildWithSameChild) {}

TEST_F(LayerTest, RemoveAllChildren) {}

TEST_F(LayerTest, HasAncestor) {}

TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) {}

TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) {}

TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {}

TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) {}

TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) {}

TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForRoundCorner) {}

TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) {}

TEST_F(LayerTest, MaskHasParent) {}

class LayerTreeHostFactory {};

void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) {}

class LayerLayerTreeHostTest : public testing::Test {};

TEST_F(LayerLayerTreeHostTest, EnteringTree) {}

TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) {}

TEST_F(LayerLayerTreeHostTest, ChangeHost) {}

TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {}

TEST_F(LayerLayerTreeHostTest, ReplaceMaskLayer) {}

TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) {}

TEST_F(LayerTest, SafeOpaqueBackgroundColor) {}

class DrawsContentChangeLayer : public Layer {};

TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) {}

TEST_F(LayerTest, PushUpdatesShouldHitTest) {}

void ReceiveCopyOutputResult(int* result_count,
                             std::unique_ptr<viz::CopyOutputResult> result) {}

void ReceiveCopyOutputResultAtomic(
    std::atomic<int>* result_count,
    std::unique_ptr<viz::CopyOutputResult> result) {}

TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) {}

TEST_F(LayerTest, AnimationSchedulesLayerUpdate) {}

TEST_F(LayerTest, ElementIdIsPushed) {}

TEST_F(LayerTest, SetLayerTreeHostNotUsingLayerListsManagesElementId) {}

// Triggering a commit to push animation counts and raf presence to the
// compositor is expensive and updated counts can wait until the next
// commit to be pushed. See https://crbug.com/1083244.
TEST_F(LayerTest, PushAnimationCountsLazily) {}

TEST_F(LayerTest, SetElementIdNotUsingLayerLists) {}

// Verifies that when mirror count of the layer is incremented or decremented,
// SetPropertyTreesNeedRebuild() and SetNeedsPushProperties() are called
// appropriately.
TEST_F(LayerTest, UpdateMirrorCount) {}

TEST_F(LayerTest, UpdatingCaptureBounds) {}

TEST_F(LayerTest, UpdatingClipRect) {}

TEST_F(LayerTest, UpdatingRoundedCorners) {}

}  // namespace
}  // namespace cc