Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 2253143002: Revert of cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "ui/gfx/geometry/size.h" 42 #include "ui/gfx/geometry/size.h"
43 #include "ui/gfx/geometry/vector2d_f.h" 43 #include "ui/gfx/geometry/vector2d_f.h"
44 #include "ui/gfx/transform.h" 44 #include "ui/gfx/transform.h"
45 45
46 using ::testing::AnyNumber; 46 using ::testing::AnyNumber;
47 using ::testing::AtLeast; 47 using ::testing::AtLeast;
48 using ::testing::Mock; 48 using ::testing::Mock;
49 using ::testing::StrictMock; 49 using ::testing::StrictMock;
50 using ::testing::_; 50 using ::testing::_;
51 51
52 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ 52 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \
53 do { \ 53 do { \
54 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((expect)); \ 54 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \
55 code_to_test; \ 55 code_to_test; \
56 Mock::VerifyAndClearExpectations(layer_tree_); \ 56 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \
57 } while (false) 57 } while (false)
58 58
59 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ 59 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
60 code_to_test; \ 60 code_to_test; \
61 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ 61 root->layer_tree_host()->BuildPropertyTreesForTesting(); \
62 EXPECT_TRUE(root->subtree_property_changed()); \ 62 EXPECT_TRUE(root->subtree_property_changed()); \
63 EXPECT_TRUE( \ 63 EXPECT_TRUE( \
64 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ 64 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \
65 EXPECT_TRUE(child->subtree_property_changed()); \ 65 EXPECT_TRUE(child->subtree_property_changed()); \
66 EXPECT_TRUE( \ 66 EXPECT_TRUE( \
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 layer_dest_root->SetLayerTreeHost(nullptr); 881 layer_dest_root->SetLayerTreeHost(nullptr);
882 } 882 }
883 883
884 TestTaskGraphRunner task_graph_runner_; 884 TestTaskGraphRunner task_graph_runner_;
885 FakeLayerTreeHostClient fake_client_; 885 FakeLayerTreeHostClient fake_client_;
886 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; 886 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
887 }; 887 };
888 888
889 namespace { 889 namespace {
890 890
891 class MockLayerTree : public LayerTree {
892 public:
893 MockLayerTree(std::unique_ptr<AnimationHost> animation_host,
894 LayerTreeHost* layer_tree_host)
895 : LayerTree(std::move(animation_host), layer_tree_host) {}
896 ~MockLayerTree() override {}
897
898 MOCK_METHOD0(SetNeedsFullTreeSync, void());
899 };
900
901 class MockLayerTreeHost : public LayerTreeHost { 891 class MockLayerTreeHost : public LayerTreeHost {
902 public: 892 public:
903 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, 893 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client,
904 LayerTreeHost::InitParams* params) 894 LayerTreeHost::InitParams* params)
905 : LayerTreeHost( 895 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
906 params,
907 CompositorMode::SINGLE_THREADED,
908 base::MakeUnique<MockLayerTree>(std::move(params->animation_host),
909 this)) {
910 InitializeSingleThreaded(single_thread_client, 896 InitializeSingleThreaded(single_thread_client,
911 base::ThreadTaskRunnerHandle::Get(), nullptr); 897 base::ThreadTaskRunnerHandle::Get(), nullptr);
912 } 898 }
913 899
914 MOCK_METHOD0(SetNeedsCommit, void()); 900 MOCK_METHOD0(SetNeedsCommit, void());
915 MOCK_METHOD0(SetNeedsUpdateLayers, void()); 901 MOCK_METHOD0(SetNeedsUpdateLayers, void());
902 MOCK_METHOD0(SetNeedsFullTreeSync, void());
916 }; 903 };
917 904
918 class LayerTest : public testing::Test { 905 class LayerTest : public testing::Test {
919 public: 906 public:
920 LayerTest() 907 LayerTest()
921 : host_impl_(LayerTreeSettings(), 908 : host_impl_(LayerTreeSettings(),
922 &task_runner_provider_, 909 &task_runner_provider_,
923 &shared_bitmap_manager_, 910 &shared_bitmap_manager_,
924 &task_graph_runner_) { 911 &task_graph_runner_) {
925 timeline_impl_ = 912 timeline_impl_ =
926 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 913 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
927 timeline_impl_->set_is_impl_only(true); 914 timeline_impl_->set_is_impl_only(true);
928 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); 915 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_);
929 } 916 }
930 917
931 const LayerTreeSettings& settings() { return settings_; } 918 const LayerTreeSettings& settings() { return settings_; }
932 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } 919 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; }
933 920
934 protected: 921 protected:
935 void SetUp() override { 922 void SetUp() override {
936 LayerTreeHost::InitParams params; 923 LayerTreeHost::InitParams params;
937 params.client = &fake_client_; 924 params.client = &fake_client_;
938 params.settings = &settings_; 925 params.settings = &settings_;
939 params.task_graph_runner = &task_graph_runner_; 926 params.task_graph_runner = &task_graph_runner_;
940 params.animation_host = 927 params.animation_host =
941 AnimationHost::CreateForTesting(ThreadInstance::MAIN); 928 AnimationHost::CreateForTesting(ThreadInstance::MAIN);
942 929
943 layer_tree_host_.reset( 930 layer_tree_host_.reset(
944 new StrictMock<MockLayerTreeHost>(&single_thread_client_, &params)); 931 new StrictMock<MockLayerTreeHost>(&single_thread_client_, &params));
945 layer_tree_ = static_cast<StrictMock<MockLayerTree>*>(
946 layer_tree_host_->GetLayerTree());
947 } 932 }
948 933
949 void TearDown() override { 934 void TearDown() override {
950 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 935 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
951 Mock::VerifyAndClearExpectations(layer_tree_); 936 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
952 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber());
953 parent_ = nullptr; 937 parent_ = nullptr;
954 child1_ = nullptr; 938 child1_ = nullptr;
955 child2_ = nullptr; 939 child2_ = nullptr;
956 child3_ = nullptr; 940 child3_ = nullptr;
957 grand_child1_ = nullptr; 941 grand_child1_ = nullptr;
958 grand_child2_ = nullptr; 942 grand_child2_ = nullptr;
959 grand_child3_ = nullptr; 943 grand_child3_ = nullptr;
960 944
961 layer_tree_->SetRootLayer(nullptr); 945 layer_tree_host_->SetRootLayer(nullptr);
962 layer_tree_host_ = nullptr; 946 layer_tree_host_ = nullptr;
963 layer_tree_ = nullptr;
964 } 947 }
965 948
966 void VerifyTestTreeInitialState() const { 949 void VerifyTestTreeInitialState() const {
967 ASSERT_EQ(3U, parent_->children().size()); 950 ASSERT_EQ(3U, parent_->children().size());
968 EXPECT_EQ(child1_, parent_->children()[0]); 951 EXPECT_EQ(child1_, parent_->children()[0]);
969 EXPECT_EQ(child2_, parent_->children()[1]); 952 EXPECT_EQ(child2_, parent_->children()[1]);
970 EXPECT_EQ(child3_, parent_->children()[2]); 953 EXPECT_EQ(child3_, parent_->children()[2]);
971 EXPECT_EQ(parent_.get(), child1_->parent()); 954 EXPECT_EQ(parent_.get(), child1_->parent());
972 EXPECT_EQ(parent_.get(), child2_->parent()); 955 EXPECT_EQ(parent_.get(), child2_->parent());
973 EXPECT_EQ(parent_.get(), child3_->parent()); 956 EXPECT_EQ(parent_.get(), child3_->parent());
(...skipping 13 matching lines...) Expand all
987 970
988 void CreateSimpleTestTree() { 971 void CreateSimpleTestTree() {
989 parent_ = Layer::Create(); 972 parent_ = Layer::Create();
990 child1_ = Layer::Create(); 973 child1_ = Layer::Create();
991 child2_ = Layer::Create(); 974 child2_ = Layer::Create();
992 child3_ = Layer::Create(); 975 child3_ = Layer::Create();
993 grand_child1_ = Layer::Create(); 976 grand_child1_ = Layer::Create();
994 grand_child2_ = Layer::Create(); 977 grand_child2_ = Layer::Create();
995 grand_child3_ = Layer::Create(); 978 grand_child3_ = Layer::Create();
996 979
997 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); 980 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
998 layer_tree_->SetRootLayer(parent_); 981 layer_tree_host_->SetRootLayer(parent_);
999 982
1000 parent_->AddChild(child1_); 983 parent_->AddChild(child1_);
1001 parent_->AddChild(child2_); 984 parent_->AddChild(child2_);
1002 parent_->AddChild(child3_); 985 parent_->AddChild(child3_);
1003 child1_->AddChild(grand_child1_); 986 child1_->AddChild(grand_child1_);
1004 child1_->AddChild(grand_child2_); 987 child1_->AddChild(grand_child2_);
1005 child2_->AddChild(grand_child3_); 988 child2_->AddChild(grand_child3_);
1006 989
1007 Mock::VerifyAndClearExpectations(layer_tree_); 990 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
1008 991
1009 VerifyTestTreeInitialState(); 992 VerifyTestTreeInitialState();
1010 } 993 }
1011 994
1012 FakeImplTaskRunnerProvider task_runner_provider_; 995 FakeImplTaskRunnerProvider task_runner_provider_;
1013 TestSharedBitmapManager shared_bitmap_manager_; 996 TestSharedBitmapManager shared_bitmap_manager_;
1014 TestTaskGraphRunner task_graph_runner_; 997 TestTaskGraphRunner task_graph_runner_;
1015 FakeLayerTreeHostImpl host_impl_; 998 FakeLayerTreeHostImpl host_impl_;
1016 999
1017 StubLayerTreeHostSingleThreadClient single_thread_client_; 1000 StubLayerTreeHostSingleThreadClient single_thread_client_;
1018 FakeLayerTreeHostClient fake_client_; 1001 FakeLayerTreeHostClient fake_client_;
1019 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; 1002 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_;
1020 StrictMock<MockLayerTree>* layer_tree_;
1021 scoped_refptr<Layer> parent_; 1003 scoped_refptr<Layer> parent_;
1022 scoped_refptr<Layer> child1_; 1004 scoped_refptr<Layer> child1_;
1023 scoped_refptr<Layer> child2_; 1005 scoped_refptr<Layer> child2_;
1024 scoped_refptr<Layer> child3_; 1006 scoped_refptr<Layer> child3_;
1025 scoped_refptr<Layer> grand_child1_; 1007 scoped_refptr<Layer> grand_child1_;
1026 scoped_refptr<Layer> grand_child2_; 1008 scoped_refptr<Layer> grand_child2_;
1027 scoped_refptr<Layer> grand_child3_; 1009 scoped_refptr<Layer> grand_child3_;
1028 1010
1029 scoped_refptr<AnimationTimeline> timeline_impl_; 1011 scoped_refptr<AnimationTimeline> timeline_impl_;
1030 1012
1031 LayerTreeSettings settings_; 1013 LayerTreeSettings settings_;
1032 }; 1014 };
1033 1015
1034 TEST_F(LayerTest, BasicCreateAndDestroy) { 1016 TEST_F(LayerTest, BasicCreateAndDestroy) {
1035 scoped_refptr<Layer> test_layer = Layer::Create(); 1017 scoped_refptr<Layer> test_layer = Layer::Create();
1036 ASSERT_TRUE(test_layer.get()); 1018 ASSERT_TRUE(test_layer.get());
1037 1019
1038 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); 1020 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
1039 test_layer->SetLayerTreeHost(layer_tree_host_.get()); 1021 test_layer->SetLayerTreeHost(layer_tree_host_.get());
1040 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 1022 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
1041 1023
1042 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); 1024 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
1043 test_layer->SetLayerTreeHost(nullptr); 1025 test_layer->SetLayerTreeHost(nullptr);
1044 } 1026 }
1045 1027
1046 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { 1028 TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
1047 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); 1029 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1));
1048 scoped_refptr<Layer> root = Layer::Create(); 1030 scoped_refptr<Layer> root = Layer::Create();
1049 scoped_refptr<Layer> child = Layer::Create(); 1031 scoped_refptr<Layer> child = Layer::Create();
1050 scoped_refptr<Layer> child2 = Layer::Create(); 1032 scoped_refptr<Layer> child2 = Layer::Create();
1051 scoped_refptr<Layer> grand_child = Layer::Create(); 1033 scoped_refptr<Layer> grand_child = Layer::Create();
1052 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); 1034 scoped_refptr<Layer> dummy_layer1 = Layer::Create();
1053 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); 1035 scoped_refptr<Layer> dummy_layer2 = Layer::Create();
1054 1036
1055 layer_tree_->SetRootLayer(root); 1037 layer_tree_host_->SetRootLayer(root);
1056 root->AddChild(child); 1038 root->AddChild(child);
1057 root->AddChild(child2); 1039 root->AddChild(child2);
1058 child->AddChild(grand_child); 1040 child->AddChild(grand_child);
1059 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 1041 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
1060 child->SetForceRenderSurfaceForTesting(true); 1042 child->SetForceRenderSurfaceForTesting(true);
1061 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 1043 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
1062 child2->SetScrollParent(grand_child.get()); 1044 child2->SetScrollParent(grand_child.get());
1063 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; 1045 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode;
1064 std::unique_ptr<LayerImpl> root_impl = 1046 std::unique_ptr<LayerImpl> root_impl =
1065 LayerImpl::Create(host_impl_.active_tree(), root->id()); 1047 LayerImpl::Create(host_impl_.active_tree(), root->id());
1066 std::unique_ptr<LayerImpl> child_impl = 1048 std::unique_ptr<LayerImpl> child_impl =
1067 LayerImpl::Create(host_impl_.active_tree(), child->id()); 1049 LayerImpl::Create(host_impl_.active_tree(), child->id());
1068 std::unique_ptr<LayerImpl> child2_impl = 1050 std::unique_ptr<LayerImpl> child2_impl =
1069 LayerImpl::Create(host_impl_.active_tree(), child2->id()); 1051 LayerImpl::Create(host_impl_.active_tree(), child2->id());
1070 std::unique_ptr<LayerImpl> grand_child_impl = 1052 std::unique_ptr<LayerImpl> grand_child_impl =
1071 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); 1053 LayerImpl::Create(host_impl_.active_tree(), grand_child->id());
1072 std::unique_ptr<LayerImpl> dummy_layer1_impl = 1054 std::unique_ptr<LayerImpl> dummy_layer1_impl =
1073 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); 1055 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id());
1074 std::unique_ptr<LayerImpl> dummy_layer2_impl = 1056 std::unique_ptr<LayerImpl> dummy_layer2_impl =
1075 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id()); 1057 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id());
1076 1058
1077 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1); 1059 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
1078 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); 1060 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get()));
1079 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1061 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1080 root->PushPropertiesTo(root_impl.get()); 1062 root->PushPropertiesTo(root_impl.get());
1081 child->PushPropertiesTo(child_impl.get()); 1063 child->PushPropertiesTo(child_impl.get());
1082 child2->PushPropertiesTo(child2_impl.get()); 1064 child2->PushPropertiesTo(child2_impl.get());
1083 grand_child->PushPropertiesTo(grand_child_impl.get()); 1065 grand_child->PushPropertiesTo(grand_child_impl.get());
1084 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); 1066 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get()));
1085 1067
1086 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1068 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1087 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); 1069 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true));
1088 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1070 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1089 root->PushPropertiesTo(root_impl.get()); 1071 root->PushPropertiesTo(root_impl.get());
1090 child->PushPropertiesTo(child_impl.get()); 1072 child->PushPropertiesTo(child_impl.get());
1091 child2->PushPropertiesTo(child2_impl.get()); 1073 child2->PushPropertiesTo(child2_impl.get());
1092 grand_child->PushPropertiesTo(grand_child_impl.get())); 1074 grand_child->PushPropertiesTo(grand_child_impl.get()));
1093 1075
1094 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1076 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1095 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); 1077 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true));
1096 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1078 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1097 root->PushPropertiesTo(root_impl.get()); 1079 root->PushPropertiesTo(root_impl.get());
1098 child->PushPropertiesTo(child_impl.get()); 1080 child->PushPropertiesTo(child_impl.get());
1099 child2->PushPropertiesTo(child2_impl.get()); 1081 child2->PushPropertiesTo(child2_impl.get());
1100 grand_child->PushPropertiesTo(grand_child_impl.get())); 1082 grand_child->PushPropertiesTo(grand_child_impl.get()));
1101 1083
1102 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1); 1084 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
1103 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); 1085 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get()));
1104 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1086 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1105 root->PushPropertiesTo(root_impl.get()); 1087 root->PushPropertiesTo(root_impl.get());
1106 child->PushPropertiesTo(child_impl.get()); 1088 child->PushPropertiesTo(child_impl.get());
1107 child2->PushPropertiesTo(child2_impl.get()); 1089 child2->PushPropertiesTo(child2_impl.get());
1108 grand_child->PushPropertiesTo(grand_child_impl.get()); 1090 grand_child->PushPropertiesTo(grand_child_impl.get());
1109 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get())); 1091 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get()));
1110 1092
1111 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1093 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1112 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); 1094 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1154
1173 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1155 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1174 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 1156 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
1175 root->SetBackgroundFilters(arbitrary_filters)); 1157 root->SetBackgroundFilters(arbitrary_filters));
1176 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1158 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1177 root->PushPropertiesTo(root_impl.get())); 1159 root->PushPropertiesTo(root_impl.get()));
1178 1160
1179 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 1161 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
1180 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1162 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1181 root->SetPosition(arbitrary_point_f); 1163 root->SetPosition(arbitrary_point_f);
1182 TransformNode* node = layer_tree_->property_trees()->transform_tree.Node( 1164 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node(
1183 root->transform_tree_index()); 1165 root->transform_tree_index());
1184 EXPECT_TRUE(node->transform_changed); 1166 EXPECT_TRUE(node->transform_changed);
1185 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1167 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1186 root->PushPropertiesTo(root_impl.get()); 1168 root->PushPropertiesTo(root_impl.get());
1187 child->PushPropertiesTo(child_impl.get()); 1169 child->PushPropertiesTo(child_impl.get());
1188 child2->PushPropertiesTo(child2_impl.get()); 1170 child2->PushPropertiesTo(child2_impl.get());
1189 grand_child->PushPropertiesTo(grand_child_impl.get()); 1171 grand_child->PushPropertiesTo(grand_child_impl.get());
1190 layer_tree_->property_trees()->ResetAllChangeTracking()); 1172 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1191 EXPECT_FALSE(node->transform_changed); 1173 EXPECT_FALSE(node->transform_changed);
1192 1174
1193 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1175 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1194 child->SetPosition(arbitrary_point_f); 1176 child->SetPosition(arbitrary_point_f);
1195 node = layer_tree_->property_trees()->transform_tree.Node( 1177 node = layer_tree_host_->property_trees()->transform_tree.Node(
1196 child->transform_tree_index()); 1178 child->transform_tree_index());
1197 EXPECT_TRUE(node->transform_changed); 1179 EXPECT_TRUE(node->transform_changed);
1198 // child2 is not in the subtree of child, but its scroll parent is. So, its 1180 // child2 is not in the subtree of child, but its scroll parent is. So, its
1199 // to_screen will be effected by change in position of child2. 1181 // to_screen will be effected by change in position of child2.
1200 layer_tree_->property_trees()->transform_tree.UpdateTransforms( 1182 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms(
1201 child2->transform_tree_index()); 1183 child2->transform_tree_index());
1202 node = layer_tree_->property_trees()->transform_tree.Node( 1184 node = layer_tree_host_->property_trees()->transform_tree.Node(
1203 child2->transform_tree_index()); 1185 child2->transform_tree_index());
1204 EXPECT_TRUE(node->transform_changed); 1186 EXPECT_TRUE(node->transform_changed);
1205 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1187 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1206 child->PushPropertiesTo(child_impl.get()); 1188 child->PushPropertiesTo(child_impl.get());
1207 grand_child->PushPropertiesTo(grand_child_impl.get()); 1189 grand_child->PushPropertiesTo(grand_child_impl.get());
1208 layer_tree_->property_trees()->ResetAllChangeTracking()); 1190 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1209 node = layer_tree_->property_trees()->transform_tree.Node( 1191 node = layer_tree_host_->property_trees()->transform_tree.Node(
1210 child->transform_tree_index()); 1192 child->transform_tree_index());
1211 EXPECT_FALSE(node->transform_changed); 1193 EXPECT_FALSE(node->transform_changed);
1212 1194
1213 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); 1195 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
1214 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1196 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1215 root->SetTransformOrigin(arbitrary_point_3f); 1197 root->SetTransformOrigin(arbitrary_point_3f);
1216 node = layer_tree_->property_trees()->transform_tree.Node( 1198 node = layer_tree_host_->property_trees()->transform_tree.Node(
1217 root->transform_tree_index()); 1199 root->transform_tree_index());
1218 EXPECT_TRUE(node->transform_changed); 1200 EXPECT_TRUE(node->transform_changed);
1219 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1201 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1220 root->PushPropertiesTo(root_impl.get()); 1202 root->PushPropertiesTo(root_impl.get());
1221 child->PushPropertiesTo(child_impl.get()); 1203 child->PushPropertiesTo(child_impl.get());
1222 child2->PushPropertiesTo(child2_impl.get()); 1204 child2->PushPropertiesTo(child2_impl.get());
1223 grand_child->PushPropertiesTo(grand_child_impl.get()); 1205 grand_child->PushPropertiesTo(grand_child_impl.get());
1224 layer_tree_->property_trees()->ResetAllChangeTracking()); 1206 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1225 1207
1226 gfx::Transform arbitrary_transform; 1208 gfx::Transform arbitrary_transform;
1227 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 1209 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
1228 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1210 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1229 root->SetTransform(arbitrary_transform); 1211 root->SetTransform(arbitrary_transform);
1230 node = layer_tree_->property_trees()->transform_tree.Node( 1212 node = layer_tree_host_->property_trees()->transform_tree.Node(
1231 root->transform_tree_index()); 1213 root->transform_tree_index());
1232 EXPECT_TRUE(node->transform_changed); 1214 EXPECT_TRUE(node->transform_changed);
1233 } 1215 }
1234 1216
1235 TEST_F(LayerTest, AddAndRemoveChild) { 1217 TEST_F(LayerTest, AddAndRemoveChild) {
1236 scoped_refptr<Layer> parent = Layer::Create(); 1218 scoped_refptr<Layer> parent = Layer::Create();
1237 scoped_refptr<Layer> child = Layer::Create(); 1219 scoped_refptr<Layer> child = Layer::Create();
1238 1220
1239 // Upon creation, layers should not have children or parent. 1221 // Upon creation, layers should not have children or parent.
1240 ASSERT_EQ(0U, parent->children().size()); 1222 ASSERT_EQ(0U, parent->children().size());
1241 EXPECT_FALSE(child->parent()); 1223 EXPECT_FALSE(child->parent());
1242 1224
1243 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); 1225 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
1244 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); 1226 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child));
1245 1227
1246 ASSERT_EQ(1U, parent->children().size()); 1228 ASSERT_EQ(1U, parent->children().size());
1247 EXPECT_EQ(child.get(), parent->children()[0]); 1229 EXPECT_EQ(child.get(), parent->children()[0]);
1248 EXPECT_EQ(parent.get(), child->parent()); 1230 EXPECT_EQ(parent.get(), child->parent());
1249 EXPECT_EQ(parent.get(), child->RootLayer()); 1231 EXPECT_EQ(parent.get(), child->RootLayer());
1250 1232
1251 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); 1233 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent());
1252 } 1234 }
1253 1235
1254 TEST_F(LayerTest, AddSameChildTwice) { 1236 TEST_F(LayerTest, AddSameChildTwice) {
1255 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); 1237 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1));
1256 1238
1257 scoped_refptr<Layer> parent = Layer::Create(); 1239 scoped_refptr<Layer> parent = Layer::Create();
1258 scoped_refptr<Layer> child = Layer::Create(); 1240 scoped_refptr<Layer> child = Layer::Create();
1259 1241
1260 layer_tree_->SetRootLayer(parent); 1242 layer_tree_host_->SetRootLayer(parent);
1261 1243
1262 ASSERT_EQ(0u, parent->children().size()); 1244 ASSERT_EQ(0u, parent->children().size());
1263 1245
1264 parent->AddChild(child); 1246 parent->AddChild(child);
1265 ASSERT_EQ(1u, parent->children().size()); 1247 ASSERT_EQ(1u, parent->children().size());
1266 EXPECT_EQ(parent.get(), child->parent()); 1248 EXPECT_EQ(parent.get(), child->parent());
1267 1249
1268 parent->AddChild(child); 1250 parent->AddChild(child);
1269 ASSERT_EQ(1u, parent->children().size()); 1251 ASSERT_EQ(1u, parent->children().size());
1270 EXPECT_EQ(parent.get(), child->parent()); 1252 EXPECT_EQ(parent.get(), child->parent());
1271 } 1253 }
1272 1254
1273 TEST_F(LayerTest, InsertChild) { 1255 TEST_F(LayerTest, InsertChild) {
1274 scoped_refptr<Layer> parent = Layer::Create(); 1256 scoped_refptr<Layer> parent = Layer::Create();
1275 scoped_refptr<Layer> child1 = Layer::Create(); 1257 scoped_refptr<Layer> child1 = Layer::Create();
1276 scoped_refptr<Layer> child2 = Layer::Create(); 1258 scoped_refptr<Layer> child2 = Layer::Create();
1277 scoped_refptr<Layer> child3 = Layer::Create(); 1259 scoped_refptr<Layer> child3 = Layer::Create();
1278 scoped_refptr<Layer> child4 = Layer::Create(); 1260 scoped_refptr<Layer> child4 = Layer::Create();
1279 1261
1280 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); 1262 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
1281 1263
1282 ASSERT_EQ(0U, parent->children().size()); 1264 ASSERT_EQ(0U, parent->children().size());
1283 1265
1284 // Case 1: inserting to empty list. 1266 // Case 1: inserting to empty list.
1285 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); 1267 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0));
1286 ASSERT_EQ(1U, parent->children().size()); 1268 ASSERT_EQ(1U, parent->children().size());
1287 EXPECT_EQ(child3, parent->children()[0]); 1269 EXPECT_EQ(child3, parent->children()[0]);
1288 EXPECT_EQ(parent.get(), child3->parent()); 1270 EXPECT_EQ(parent.get(), child3->parent());
1289 1271
1290 // Case 2: inserting to beginning of list 1272 // Case 2: inserting to beginning of list
(...skipping 14 matching lines...) Expand all
1305 // Case 4: inserting to end of list 1287 // Case 4: inserting to end of list
1306 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3)); 1288 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3));
1307 1289
1308 ASSERT_EQ(4U, parent->children().size()); 1290 ASSERT_EQ(4U, parent->children().size());
1309 EXPECT_EQ(child1, parent->children()[0]); 1291 EXPECT_EQ(child1, parent->children()[0]);
1310 EXPECT_EQ(child2, parent->children()[1]); 1292 EXPECT_EQ(child2, parent->children()[1]);
1311 EXPECT_EQ(child3, parent->children()[2]); 1293 EXPECT_EQ(child3, parent->children()[2]);
1312 EXPECT_EQ(child4, parent->children()[3]); 1294 EXPECT_EQ(child4, parent->children()[3]);
1313 EXPECT_EQ(parent.get(), child4->parent()); 1295 EXPECT_EQ(parent.get(), child4->parent());
1314 1296
1315 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); 1297 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
1316 } 1298 }
1317 1299
1318 TEST_F(LayerTest, InsertChildPastEndOfList) { 1300 TEST_F(LayerTest, InsertChildPastEndOfList) {
1319 scoped_refptr<Layer> parent = Layer::Create(); 1301 scoped_refptr<Layer> parent = Layer::Create();
1320 scoped_refptr<Layer> child1 = Layer::Create(); 1302 scoped_refptr<Layer> child1 = Layer::Create();
1321 scoped_refptr<Layer> child2 = Layer::Create(); 1303 scoped_refptr<Layer> child2 = Layer::Create();
1322 1304
1323 ASSERT_EQ(0U, parent->children().size()); 1305 ASSERT_EQ(0U, parent->children().size());
1324 1306
1325 // insert to an out-of-bounds index 1307 // insert to an out-of-bounds index
1326 parent->InsertChild(child1, 53); 1308 parent->InsertChild(child1, 53);
1327 1309
1328 ASSERT_EQ(1U, parent->children().size()); 1310 ASSERT_EQ(1U, parent->children().size());
1329 EXPECT_EQ(child1, parent->children()[0]); 1311 EXPECT_EQ(child1, parent->children()[0]);
1330 1312
1331 // insert another child to out-of-bounds, when list is not already empty. 1313 // insert another child to out-of-bounds, when list is not already empty.
1332 parent->InsertChild(child2, 2459); 1314 parent->InsertChild(child2, 2459);
1333 1315
1334 ASSERT_EQ(2U, parent->children().size()); 1316 ASSERT_EQ(2U, parent->children().size());
1335 EXPECT_EQ(child1, parent->children()[0]); 1317 EXPECT_EQ(child1, parent->children()[0]);
1336 EXPECT_EQ(child2, parent->children()[1]); 1318 EXPECT_EQ(child2, parent->children()[1]);
1337 } 1319 }
1338 1320
1339 TEST_F(LayerTest, InsertSameChildTwice) { 1321 TEST_F(LayerTest, InsertSameChildTwice) {
1340 scoped_refptr<Layer> parent = Layer::Create(); 1322 scoped_refptr<Layer> parent = Layer::Create();
1341 scoped_refptr<Layer> child1 = Layer::Create(); 1323 scoped_refptr<Layer> child1 = Layer::Create();
1342 scoped_refptr<Layer> child2 = Layer::Create(); 1324 scoped_refptr<Layer> child2 = Layer::Create();
1343 1325
1344 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); 1326 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
1345 1327
1346 ASSERT_EQ(0U, parent->children().size()); 1328 ASSERT_EQ(0U, parent->children().size());
1347 1329
1348 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); 1330 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0));
1349 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); 1331 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1));
1350 1332
1351 ASSERT_EQ(2U, parent->children().size()); 1333 ASSERT_EQ(2U, parent->children().size());
1352 EXPECT_EQ(child1, parent->children()[0]); 1334 EXPECT_EQ(child1, parent->children()[0]);
1353 EXPECT_EQ(child2, parent->children()[1]); 1335 EXPECT_EQ(child2, parent->children()[1]);
1354 1336
1355 // Inserting the same child again should cause the child to be removed and 1337 // Inserting the same child again should cause the child to be removed and
1356 // re-inserted at the new location. 1338 // re-inserted at the new location.
1357 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); 1339 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1));
1358 1340
1359 // child1 should now be at the end of the list. 1341 // child1 should now be at the end of the list.
1360 ASSERT_EQ(2U, parent->children().size()); 1342 ASSERT_EQ(2U, parent->children().size());
1361 EXPECT_EQ(child2, parent->children()[0]); 1343 EXPECT_EQ(child2, parent->children()[0]);
1362 EXPECT_EQ(child1, parent->children()[1]); 1344 EXPECT_EQ(child1, parent->children()[1]);
1363 1345
1364 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); 1346 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
1365 } 1347 }
1366 1348
1367 TEST_F(LayerTest, ReplaceChildWithNewChild) { 1349 TEST_F(LayerTest, ReplaceChildWithNewChild) {
1368 CreateSimpleTestTree(); 1350 CreateSimpleTestTree();
1369 scoped_refptr<Layer> child4 = Layer::Create(); 1351 scoped_refptr<Layer> child4 = Layer::Create();
1370 1352
1371 EXPECT_FALSE(child4->parent()); 1353 EXPECT_FALSE(child4->parent());
1372 1354
1373 EXPECT_SET_NEEDS_FULL_TREE_SYNC( 1355 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1374 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); 1356 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 // and child2 should no longer have a parent. 1393 // and child2 should no longer have a parent.
1412 ASSERT_EQ(0U, test_layer->children().size()); 1394 ASSERT_EQ(0U, test_layer->children().size());
1413 EXPECT_FALSE(child2_->parent()); 1395 EXPECT_FALSE(child2_->parent());
1414 } 1396 }
1415 1397
1416 TEST_F(LayerTest, DeleteRemovedScrollParent) { 1398 TEST_F(LayerTest, DeleteRemovedScrollParent) {
1417 scoped_refptr<Layer> parent = Layer::Create(); 1399 scoped_refptr<Layer> parent = Layer::Create();
1418 scoped_refptr<Layer> child1 = Layer::Create(); 1400 scoped_refptr<Layer> child1 = Layer::Create();
1419 scoped_refptr<Layer> child2 = Layer::Create(); 1401 scoped_refptr<Layer> child2 = Layer::Create();
1420 1402
1421 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); 1403 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
1422 1404
1423 ASSERT_EQ(0U, parent->children().size()); 1405 ASSERT_EQ(0U, parent->children().size());
1424 1406
1425 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); 1407 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0));
1426 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); 1408 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1));
1427 1409
1428 ASSERT_EQ(2U, parent->children().size()); 1410 ASSERT_EQ(2U, parent->children().size());
1429 EXPECT_EQ(child1, parent->children()[0]); 1411 EXPECT_EQ(child1, parent->children()[0]);
1430 EXPECT_EQ(child2, parent->children()[1]); 1412 EXPECT_EQ(child2, parent->children()[1]);
1431 1413
1432 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); 1414 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get()));
1433 1415
1434 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); 1416 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent());
1435 1417
1436 child1->ResetNeedsPushPropertiesForTesting(); 1418 child1->ResetNeedsPushPropertiesForTesting();
1437 1419
1438 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); 1420 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr);
1439 1421
1440 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child1.get())); 1422 EXPECT_TRUE(
1423 layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
1424 child1.get()));
1441 1425
1442 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); 1426 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
1443 } 1427 }
1444 1428
1445 TEST_F(LayerTest, DeleteRemovedScrollChild) { 1429 TEST_F(LayerTest, DeleteRemovedScrollChild) {
1446 scoped_refptr<Layer> parent = Layer::Create(); 1430 scoped_refptr<Layer> parent = Layer::Create();
1447 scoped_refptr<Layer> child1 = Layer::Create(); 1431 scoped_refptr<Layer> child1 = Layer::Create();
1448 scoped_refptr<Layer> child2 = Layer::Create(); 1432 scoped_refptr<Layer> child2 = Layer::Create();
1449 1433
1450 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); 1434 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
1451 1435
1452 ASSERT_EQ(0U, parent->children().size()); 1436 ASSERT_EQ(0U, parent->children().size());
1453 1437
1454 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); 1438 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0));
1455 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); 1439 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1));
1456 1440
1457 ASSERT_EQ(2U, parent->children().size()); 1441 ASSERT_EQ(2U, parent->children().size());
1458 EXPECT_EQ(child1, parent->children()[0]); 1442 EXPECT_EQ(child1, parent->children()[0]);
1459 EXPECT_EQ(child2, parent->children()[1]); 1443 EXPECT_EQ(child2, parent->children()[1]);
1460 1444
1461 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); 1445 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get()));
1462 1446
1463 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); 1447 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent());
1464 1448
1465 child2->ResetNeedsPushPropertiesForTesting(); 1449 child2->ResetNeedsPushPropertiesForTesting();
1466 1450
1467 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); 1451 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr);
1468 1452
1469 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child2.get())); 1453 EXPECT_TRUE(
1454 layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
1455 child2.get()));
1470 1456
1471 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); 1457 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
1472 } 1458 }
1473 1459
1474 TEST_F(LayerTest, ReplaceChildWithSameChild) { 1460 TEST_F(LayerTest, ReplaceChildWithSameChild) {
1475 CreateSimpleTestTree(); 1461 CreateSimpleTestTree();
1476 1462
1477 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the 1463 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the
1478 // same child. 1464 // same child.
1479 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); 1465 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
1480 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(0); 1466 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0);
1481 parent_->ReplaceChild(child2_.get(), child2_); 1467 parent_->ReplaceChild(child2_.get(), child2_);
1482 1468
1483 VerifyTestTreeInitialState(); 1469 VerifyTestTreeInitialState();
1484 } 1470 }
1485 1471
1486 TEST_F(LayerTest, RemoveAllChildren) { 1472 TEST_F(LayerTest, RemoveAllChildren) {
1487 CreateSimpleTestTree(); 1473 CreateSimpleTestTree();
1488 1474
1489 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); 1475 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren());
1490 1476
(...skipping 14 matching lines...) Expand all
1505 new_children.push_back(child1); 1491 new_children.push_back(child1);
1506 new_children.push_back(child2); 1492 new_children.push_back(child2);
1507 1493
1508 // Set up and verify initial test conditions: child1 has a parent, child2 has 1494 // Set up and verify initial test conditions: child1 has a parent, child2 has
1509 // no parent. 1495 // no parent.
1510 old_parent->AddChild(child1); 1496 old_parent->AddChild(child1);
1511 ASSERT_EQ(0U, new_parent->children().size()); 1497 ASSERT_EQ(0U, new_parent->children().size());
1512 EXPECT_EQ(old_parent.get(), child1->parent()); 1498 EXPECT_EQ(old_parent.get(), child1->parent());
1513 EXPECT_FALSE(child2->parent()); 1499 EXPECT_FALSE(child2->parent());
1514 1500
1515 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(new_parent)); 1501 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1502 1, layer_tree_host_->SetRootLayer(new_parent));
1516 1503
1517 EXPECT_SET_NEEDS_FULL_TREE_SYNC( 1504 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1518 AtLeast(1), new_parent->SetChildren(new_children)); 1505 AtLeast(1), new_parent->SetChildren(new_children));
1519 1506
1520 ASSERT_EQ(2U, new_parent->children().size()); 1507 ASSERT_EQ(2U, new_parent->children().size());
1521 EXPECT_EQ(new_parent.get(), child1->parent()); 1508 EXPECT_EQ(new_parent.get(), child1->parent());
1522 EXPECT_EQ(new_parent.get(), child2->parent()); 1509 EXPECT_EQ(new_parent.get(), child2->parent());
1523 1510
1524 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); 1511 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
1525 } 1512 }
1526 1513
1527 TEST_F(LayerTest, HasAncestor) { 1514 TEST_F(LayerTest, HasAncestor) {
1528 scoped_refptr<Layer> parent = Layer::Create(); 1515 scoped_refptr<Layer> parent = Layer::Create();
1529 EXPECT_FALSE(parent->HasAncestor(parent.get())); 1516 EXPECT_FALSE(parent->HasAncestor(parent.get()));
1530 1517
1531 scoped_refptr<Layer> child = Layer::Create(); 1518 scoped_refptr<Layer> child = Layer::Create();
1532 parent->AddChild(child); 1519 parent->AddChild(child);
1533 1520
1534 EXPECT_FALSE(child->HasAncestor(child.get())); 1521 EXPECT_FALSE(child->HasAncestor(child.get()));
1535 EXPECT_TRUE(child->HasAncestor(parent.get())); 1522 EXPECT_TRUE(child->HasAncestor(parent.get()));
1536 EXPECT_FALSE(parent->HasAncestor(child.get())); 1523 EXPECT_FALSE(parent->HasAncestor(child.get()));
1537 1524
1538 scoped_refptr<Layer> child_child = Layer::Create(); 1525 scoped_refptr<Layer> child_child = Layer::Create();
1539 child->AddChild(child_child); 1526 child->AddChild(child_child);
1540 1527
1541 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); 1528 EXPECT_FALSE(child_child->HasAncestor(child_child.get()));
1542 EXPECT_TRUE(child_child->HasAncestor(parent.get())); 1529 EXPECT_TRUE(child_child->HasAncestor(parent.get()));
1543 EXPECT_TRUE(child_child->HasAncestor(child.get())); 1530 EXPECT_TRUE(child_child->HasAncestor(child.get()));
1544 EXPECT_FALSE(parent->HasAncestor(child.get())); 1531 EXPECT_FALSE(parent->HasAncestor(child.get()));
1545 EXPECT_FALSE(parent->HasAncestor(child_child.get())); 1532 EXPECT_FALSE(parent->HasAncestor(child_child.get()));
1546 } 1533 }
1547 1534
1548 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { 1535 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) {
1549 CreateSimpleTestTree(); 1536 CreateSimpleTestTree();
1550 1537
1551 // For this test we don't care about SetNeedsFullTreeSync calls. 1538 // For this test we don't care about SetNeedsFullTreeSync calls.
1552 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); 1539 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
1553 1540
1554 scoped_refptr<Layer> child4 = Layer::Create(); 1541 scoped_refptr<Layer> child4 = Layer::Create();
1555 1542
1556 EXPECT_EQ(parent_.get(), parent_->RootLayer()); 1543 EXPECT_EQ(parent_.get(), parent_->RootLayer());
1557 EXPECT_EQ(parent_.get(), child1_->RootLayer()); 1544 EXPECT_EQ(parent_.get(), child1_->RootLayer());
1558 EXPECT_EQ(parent_.get(), child2_->RootLayer()); 1545 EXPECT_EQ(parent_.get(), child2_->RootLayer());
1559 EXPECT_EQ(parent_.get(), child3_->RootLayer()); 1546 EXPECT_EQ(parent_.get(), child3_->RootLayer());
1560 EXPECT_EQ(child4.get(), child4->RootLayer()); 1547 EXPECT_EQ(child4.get(), child4->RootLayer());
1561 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); 1548 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer());
1562 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); 1549 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); 1587 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer());
1601 } 1588 }
1602 1589
1603 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { 1590 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) {
1604 // The semantics for SetNeedsDisplay which are tested here: 1591 // The semantics for SetNeedsDisplay which are tested here:
1605 // 1. sets NeedsDisplay flag appropriately. 1592 // 1. sets NeedsDisplay flag appropriately.
1606 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to 1593 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to
1607 // SetNeedsDisplay. 1594 // SetNeedsDisplay.
1608 1595
1609 scoped_refptr<Layer> test_layer = Layer::Create(); 1596 scoped_refptr<Layer> test_layer = Layer::Create();
1610 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1597 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1598 1, layer_tree_host_->SetRootLayer(test_layer));
1611 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); 1599 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
1612 1600
1613 gfx::Size test_bounds = gfx::Size(501, 508); 1601 gfx::Size test_bounds = gfx::Size(501, 508);
1614 1602
1615 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); 1603 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2);
1616 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); 1604 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502);
1617 1605
1618 // Before anything, test_layer should not be dirty. 1606 // Before anything, test_layer should not be dirty.
1619 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1607 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1620 1608
(...skipping 30 matching lines...) Expand all
1651 // Case 4: SetNeedsDisplay() with a non-drawable layer 1639 // Case 4: SetNeedsDisplay() with a non-drawable layer
1652 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); 1640 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false));
1653 test_layer->ResetNeedsDisplayForTesting(); 1641 test_layer->ResetNeedsDisplayForTesting();
1654 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1642 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1655 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); 1643 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect));
1656 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); 1644 EXPECT_TRUE(test_layer->NeedsDisplayForTesting());
1657 } 1645 }
1658 1646
1659 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { 1647 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) {
1660 scoped_refptr<Layer> test_layer = Layer::Create(); 1648 scoped_refptr<Layer> test_layer = Layer::Create();
1661 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1649 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1650 layer_tree_host_->SetRootLayer(test_layer));
1662 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); 1651 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
1663 1652
1664 // sanity check of initial test condition 1653 // sanity check of initial test condition
1665 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1654 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1666 1655
1667 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0; 1656 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0;
1668 reasons |= MainThreadScrollingReason::kEventHandlers; 1657 reasons |= MainThreadScrollingReason::kEventHandlers;
1669 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll; 1658 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll;
1670 reasons |= MainThreadScrollingReason::kScrollbarScrolling; 1659 reasons |= MainThreadScrollingReason::kScrollbarScrolling;
1671 1660
(...skipping 29 matching lines...) Expand all
1701 EXPECT_EQ(reasons_after_clearing, 1690 EXPECT_EQ(reasons_after_clearing,
1702 test_layer->main_thread_scrolling_reasons()); 1691 test_layer->main_thread_scrolling_reasons());
1703 1692
1704 // Check that adding an existing condition doesn't set needs commit. 1693 // Check that adding an existing condition doesn't set needs commit.
1705 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons( 1694 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons(
1706 MainThreadScrollingReason::kEventHandlers)); 1695 MainThreadScrollingReason::kEventHandlers));
1707 } 1696 }
1708 1697
1709 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { 1698 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
1710 scoped_refptr<Layer> test_layer = Layer::Create(); 1699 scoped_refptr<Layer> test_layer = Layer::Create();
1711 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1700 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1701 1, layer_tree_host_->SetRootLayer(test_layer));
1712 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); 1702 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
1713 1703
1714 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); 1704 scoped_refptr<Layer> dummy_layer1 = Layer::Create();
1715 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); 1705 scoped_refptr<Layer> dummy_layer2 = Layer::Create();
1716 1706
1717 // sanity check of initial test condition 1707 // sanity check of initial test condition
1718 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1708 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1719 1709
1720 // Next, test properties that should call SetNeedsCommit (but not 1710 // Next, test properties that should call SetNeedsCommit (but not
1721 // SetNeedsDisplay). All properties need to be set to new values in order for 1711 // SetNeedsDisplay). All properties need to be set to new values in order for
(...skipping 30 matching lines...) Expand all
1752 1742
1753 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( 1743 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer(
1754 dummy_layer1.get())); 1744 dummy_layer1.get()));
1755 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetReplicaLayer( 1745 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetReplicaLayer(
1756 dummy_layer2.get())); 1746 dummy_layer2.get()));
1757 1747
1758 // The above tests should not have caused a change to the needs_display flag. 1748 // The above tests should not have caused a change to the needs_display flag.
1759 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1749 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1760 1750
1761 // As layers are removed from the tree, they will cause a tree sync. 1751 // As layers are removed from the tree, they will cause a tree sync.
1762 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((AnyNumber())); 1752 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber()));
1763 } 1753 }
1764 1754
1765 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { 1755 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) {
1766 scoped_refptr<Layer> test_layer = Layer::Create(); 1756 scoped_refptr<Layer> test_layer = Layer::Create();
1767 std::unique_ptr<LayerImpl> impl_layer = 1757 std::unique_ptr<LayerImpl> impl_layer =
1768 LayerImpl::Create(host_impl_.active_tree(), 1); 1758 LayerImpl::Create(host_impl_.active_tree(), 1);
1769 1759
1770 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1760 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1761 layer_tree_host_->SetRootLayer(test_layer));
1771 1762
1772 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer)); 1763 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer));
1773 host_impl_.active_tree()->BuildLayerListForTesting(); 1764 host_impl_.active_tree()->BuildLayerListForTesting();
1774 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); 1765 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1);
1775 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); 1766 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5));
1776 test_layer->PushPropertiesTo(impl_layer_ptr); 1767 test_layer->PushPropertiesTo(impl_layer_ptr);
1777 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), 1768 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f),
1778 impl_layer_ptr->update_rect()); 1769 impl_layer_ptr->update_rect());
1779 1770
1780 // The LayerImpl's update_rect() should be accumulated here, since we did not 1771 // The LayerImpl's update_rect() should be accumulated here, since we did not
(...skipping 10 matching lines...) Expand all
1791 test_layer->PushPropertiesTo(impl_layer_ptr); 1782 test_layer->PushPropertiesTo(impl_layer_ptr);
1792 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), 1783 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f),
1793 impl_layer_ptr->update_rect()); 1784 impl_layer_ptr->update_rect());
1794 } 1785 }
1795 1786
1796 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { 1787 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) {
1797 scoped_refptr<Layer> test_layer = Layer::Create(); 1788 scoped_refptr<Layer> test_layer = Layer::Create();
1798 std::unique_ptr<LayerImpl> impl_layer = 1789 std::unique_ptr<LayerImpl> impl_layer =
1799 LayerImpl::Create(host_impl_.active_tree(), 1); 1790 LayerImpl::Create(host_impl_.active_tree(), 1);
1800 1791
1801 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1792 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1793 layer_tree_host_->SetRootLayer(test_layer));
1802 1794
1803 gfx::Transform transform; 1795 gfx::Transform transform;
1804 transform.Rotate(45.0); 1796 transform.Rotate(45.0);
1805 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); 1797 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform));
1806 1798
1807 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); 1799 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1808 1800
1809 test_layer->PushPropertiesTo(impl_layer.get()); 1801 test_layer->PushPropertiesTo(impl_layer.get());
1810 1802
1811 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); 1803 EXPECT_TRUE(impl_layer->LayerPropertyChanged());
1812 } 1804 }
1813 1805
1814 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { 1806 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) {
1815 scoped_refptr<Layer> test_layer = Layer::Create(); 1807 scoped_refptr<Layer> test_layer = Layer::Create();
1816 std::unique_ptr<LayerImpl> impl_layer = 1808 std::unique_ptr<LayerImpl> impl_layer =
1817 LayerImpl::Create(host_impl_.active_tree(), 1); 1809 LayerImpl::Create(host_impl_.active_tree(), 1);
1818 1810
1819 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 1811 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1812 layer_tree_host_->SetRootLayer(test_layer));
1820 1813
1821 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); 1814 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f));
1822 1815
1823 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); 1816 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1824 1817
1825 test_layer->PushPropertiesTo(impl_layer.get()); 1818 test_layer->PushPropertiesTo(impl_layer.get());
1826 1819
1827 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); 1820 EXPECT_TRUE(impl_layer->LayerPropertyChanged());
1828 } 1821 }
1829 1822
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 // layers. 1908 // layers.
1916 parent->AddChild(child); 1909 parent->AddChild(child);
1917 child->SetMaskLayer(mask.get()); 1910 child->SetMaskLayer(mask.get());
1918 child->SetReplicaLayer(replica.get()); 1911 child->SetReplicaLayer(replica.get());
1919 replica->SetMaskLayer(replica_mask.get()); 1912 replica->SetMaskLayer(replica_mask.get());
1920 1913
1921 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); 1914 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr);
1922 1915
1923 LayerTreeHostFactory factory; 1916 LayerTreeHostFactory factory;
1924 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); 1917 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
1925 LayerTree* layer_tree = layer_tree_host->GetLayerTree();
1926 // Setting the root layer should set the host pointer for all layers in the 1918 // Setting the root layer should set the host pointer for all layers in the
1927 // tree. 1919 // tree.
1928 layer_tree->SetRootLayer(parent.get()); 1920 layer_tree_host->SetRootLayer(parent.get());
1929 1921
1930 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); 1922 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
1931 1923
1932 // Clearing the root layer should also clear out the host pointers for all 1924 // Clearing the root layer should also clear out the host pointers for all
1933 // layers in the tree. 1925 // layers in the tree.
1934 layer_tree->SetRootLayer(nullptr); 1926 layer_tree_host->SetRootLayer(nullptr);
1935 1927
1936 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); 1928 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr);
1937 } 1929 }
1938 1930
1939 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { 1931 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) {
1940 scoped_refptr<Layer> parent = Layer::Create(); 1932 scoped_refptr<Layer> parent = Layer::Create();
1941 LayerTreeHostFactory factory; 1933 LayerTreeHostFactory factory;
1942 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); 1934 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
1943 LayerTree* layer_tree = layer_tree_host->GetLayerTree();
1944 1935
1945 layer_tree->SetRootLayer(parent.get()); 1936 layer_tree_host->SetRootLayer(parent.get());
1946 1937
1947 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); 1938 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get());
1948 1939
1949 // Adding a subtree to a layer already associated with a host should set the 1940 // Adding a subtree to a layer already associated with a host should set the
1950 // host pointer on all layers in that subtree. 1941 // host pointer on all layers in that subtree.
1951 scoped_refptr<Layer> child = Layer::Create(); 1942 scoped_refptr<Layer> child = Layer::Create();
1952 scoped_refptr<Layer> grand_child = Layer::Create(); 1943 scoped_refptr<Layer> grand_child = Layer::Create();
1953 child->AddChild(grand_child); 1944 child->AddChild(grand_child);
1954 1945
1955 // Masks, replicas, and replica masks should pick up the new host too. 1946 // Masks, replicas, and replica masks should pick up the new host too.
1956 scoped_refptr<Layer> child_mask = Layer::Create(); 1947 scoped_refptr<Layer> child_mask = Layer::Create();
1957 child->SetMaskLayer(child_mask.get()); 1948 child->SetMaskLayer(child_mask.get());
1958 scoped_refptr<Layer> child_replica = Layer::Create(); 1949 scoped_refptr<Layer> child_replica = Layer::Create();
1959 child->SetReplicaLayer(child_replica.get()); 1950 child->SetReplicaLayer(child_replica.get());
1960 scoped_refptr<Layer> child_replica_mask = Layer::Create(); 1951 scoped_refptr<Layer> child_replica_mask = Layer::Create();
1961 child_replica->SetMaskLayer(child_replica_mask.get()); 1952 child_replica->SetMaskLayer(child_replica_mask.get());
1962 1953
1963 parent->AddChild(child); 1954 parent->AddChild(child);
1964 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); 1955 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
1965 1956
1966 layer_tree->SetRootLayer(nullptr); 1957 layer_tree_host->SetRootLayer(nullptr);
1967 } 1958 }
1968 1959
1969 TEST_F(LayerLayerTreeHostTest, ChangeHost) { 1960 TEST_F(LayerLayerTreeHostTest, ChangeHost) {
1970 scoped_refptr<Layer> parent = Layer::Create(); 1961 scoped_refptr<Layer> parent = Layer::Create();
1971 scoped_refptr<Layer> child = Layer::Create(); 1962 scoped_refptr<Layer> child = Layer::Create();
1972 scoped_refptr<Layer> mask = Layer::Create(); 1963 scoped_refptr<Layer> mask = Layer::Create();
1973 scoped_refptr<Layer> replica = Layer::Create(); 1964 scoped_refptr<Layer> replica = Layer::Create();
1974 scoped_refptr<Layer> replica_mask = Layer::Create(); 1965 scoped_refptr<Layer> replica_mask = Layer::Create();
1975 1966
1976 // Same setup as the previous test. 1967 // Same setup as the previous test.
1977 parent->AddChild(child); 1968 parent->AddChild(child);
1978 child->SetMaskLayer(mask.get()); 1969 child->SetMaskLayer(mask.get());
1979 child->SetReplicaLayer(replica.get()); 1970 child->SetReplicaLayer(replica.get());
1980 replica->SetMaskLayer(replica_mask.get()); 1971 replica->SetMaskLayer(replica_mask.get());
1981 1972
1982 LayerTreeHostFactory factory; 1973 LayerTreeHostFactory factory;
1983 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); 1974 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create();
1984 first_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); 1975 first_layer_tree_host->SetRootLayer(parent.get());
1985 1976
1986 AssertLayerTreeHostMatchesForSubtree(parent.get(), 1977 AssertLayerTreeHostMatchesForSubtree(parent.get(),
1987 first_layer_tree_host.get()); 1978 first_layer_tree_host.get());
1988 1979
1989 // Now re-root the tree to a new host (simulating what we do on a context lost 1980 // Now re-root the tree to a new host (simulating what we do on a context lost
1990 // event). This should update the host pointers for all layers in the tree. 1981 // event). This should update the host pointers for all layers in the tree.
1991 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); 1982 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create();
1992 second_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); 1983 second_layer_tree_host->SetRootLayer(parent.get());
1993 1984
1994 AssertLayerTreeHostMatchesForSubtree(parent.get(), 1985 AssertLayerTreeHostMatchesForSubtree(parent.get(),
1995 second_layer_tree_host.get()); 1986 second_layer_tree_host.get());
1996 1987
1997 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); 1988 second_layer_tree_host->SetRootLayer(nullptr);
1998 } 1989 }
1999 1990
2000 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { 1991 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {
2001 scoped_refptr<Layer> first_parent = Layer::Create(); 1992 scoped_refptr<Layer> first_parent = Layer::Create();
2002 scoped_refptr<Layer> first_child = Layer::Create(); 1993 scoped_refptr<Layer> first_child = Layer::Create();
2003 scoped_refptr<Layer> second_parent = Layer::Create(); 1994 scoped_refptr<Layer> second_parent = Layer::Create();
2004 scoped_refptr<Layer> second_child = Layer::Create(); 1995 scoped_refptr<Layer> second_child = Layer::Create();
2005 scoped_refptr<Layer> second_grand_child = Layer::Create(); 1996 scoped_refptr<Layer> second_grand_child = Layer::Create();
2006 1997
2007 // First put all children under the first parent and set the first host. 1998 // First put all children under the first parent and set the first host.
2008 first_parent->AddChild(first_child); 1999 first_parent->AddChild(first_child);
2009 second_child->AddChild(second_grand_child); 2000 second_child->AddChild(second_grand_child);
2010 first_parent->AddChild(second_child); 2001 first_parent->AddChild(second_child);
2011 2002
2012 LayerTreeHostFactory factory; 2003 LayerTreeHostFactory factory;
2013 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); 2004 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create();
2014 first_layer_tree_host->GetLayerTree()->SetRootLayer(first_parent.get()); 2005 first_layer_tree_host->SetRootLayer(first_parent.get());
2015 2006
2016 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), 2007 AssertLayerTreeHostMatchesForSubtree(first_parent.get(),
2017 first_layer_tree_host.get()); 2008 first_layer_tree_host.get());
2018 2009
2019 // Now reparent the subtree starting at second_child to a layer in a different 2010 // Now reparent the subtree starting at second_child to a layer in a different
2020 // tree. 2011 // tree.
2021 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); 2012 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create();
2022 second_layer_tree_host->GetLayerTree()->SetRootLayer(second_parent.get()); 2013 second_layer_tree_host->SetRootLayer(second_parent.get());
2023 2014
2024 second_parent->AddChild(second_child); 2015 second_parent->AddChild(second_child);
2025 2016
2026 // The moved layer and its children should point to the new host. 2017 // The moved layer and its children should point to the new host.
2027 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); 2018 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host());
2028 EXPECT_EQ(second_layer_tree_host.get(), 2019 EXPECT_EQ(second_layer_tree_host.get(),
2029 second_grand_child->layer_tree_host()); 2020 second_grand_child->layer_tree_host());
2030 2021
2031 // Test over, cleanup time. 2022 // Test over, cleanup time.
2032 first_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); 2023 first_layer_tree_host->SetRootLayer(nullptr);
2033 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); 2024 second_layer_tree_host->SetRootLayer(nullptr);
2034 } 2025 }
2035 2026
2036 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { 2027 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) {
2037 scoped_refptr<Layer> parent = Layer::Create(); 2028 scoped_refptr<Layer> parent = Layer::Create();
2038 scoped_refptr<Layer> mask = Layer::Create(); 2029 scoped_refptr<Layer> mask = Layer::Create();
2039 scoped_refptr<Layer> replica = Layer::Create(); 2030 scoped_refptr<Layer> replica = Layer::Create();
2040 scoped_refptr<Layer> mask_child = Layer::Create(); 2031 scoped_refptr<Layer> mask_child = Layer::Create();
2041 scoped_refptr<Layer> replica_child = Layer::Create(); 2032 scoped_refptr<Layer> replica_child = Layer::Create();
2042 scoped_refptr<Layer> mask_replacement = Layer::Create(); 2033 scoped_refptr<Layer> mask_replacement = Layer::Create();
2043 scoped_refptr<Layer> replica_replacement = Layer::Create(); 2034 scoped_refptr<Layer> replica_replacement = Layer::Create();
2044 2035
2045 parent->SetMaskLayer(mask.get()); 2036 parent->SetMaskLayer(mask.get());
2046 parent->SetReplicaLayer(replica.get()); 2037 parent->SetReplicaLayer(replica.get());
2047 mask->AddChild(mask_child); 2038 mask->AddChild(mask_child);
2048 replica->AddChild(replica_child); 2039 replica->AddChild(replica_child);
2049 2040
2050 LayerTreeHostFactory factory; 2041 LayerTreeHostFactory factory;
2051 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); 2042 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
2052 layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); 2043 layer_tree_host->SetRootLayer(parent.get());
2053 2044
2054 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); 2045 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
2055 2046
2056 // Replacing the mask should clear out the old mask's subtree's host pointers. 2047 // Replacing the mask should clear out the old mask's subtree's host pointers.
2057 parent->SetMaskLayer(mask_replacement.get()); 2048 parent->SetMaskLayer(mask_replacement.get());
2058 EXPECT_EQ(nullptr, mask->layer_tree_host()); 2049 EXPECT_EQ(nullptr, mask->layer_tree_host());
2059 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); 2050 EXPECT_EQ(nullptr, mask_child->layer_tree_host());
2060 2051
2061 // Same for replacing a replica layer. 2052 // Same for replacing a replica layer.
2062 parent->SetReplicaLayer(replica_replacement.get()); 2053 parent->SetReplicaLayer(replica_replacement.get());
2063 EXPECT_EQ(nullptr, replica->layer_tree_host()); 2054 EXPECT_EQ(nullptr, replica->layer_tree_host());
2064 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); 2055 EXPECT_EQ(nullptr, replica_child->layer_tree_host());
2065 2056
2066 // Test over, cleanup time. 2057 // Test over, cleanup time.
2067 layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); 2058 layer_tree_host->SetRootLayer(nullptr);
2068 } 2059 }
2069 2060
2070 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { 2061 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) {
2071 scoped_refptr<Layer> root = Layer::Create(); 2062 scoped_refptr<Layer> root = Layer::Create();
2072 scoped_refptr<Layer> child = Layer::Create(); 2063 scoped_refptr<Layer> child = Layer::Create();
2073 root->AddChild(child); 2064 root->AddChild(child);
2074 LayerTreeHostFactory factory; 2065 LayerTreeHostFactory factory;
2075 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); 2066 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
2076 layer_tree_host->GetLayerTree()->SetRootLayer(root); 2067 layer_tree_host->SetRootLayer(root);
2077 } 2068 }
2078 2069
2079 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { 2070 TEST_F(LayerTest, SafeOpaqueBackgroundColor) {
2080 LayerTreeHostFactory factory; 2071 LayerTreeHostFactory factory;
2081 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); 2072 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
2082 LayerTree* layer_tree = layer_tree_host->GetLayerTree();
2083 2073
2084 scoped_refptr<Layer> layer = Layer::Create(); 2074 scoped_refptr<Layer> layer = Layer::Create();
2085 layer_tree->SetRootLayer(layer); 2075 layer_tree_host->SetRootLayer(layer);
2086 2076
2087 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { 2077 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) {
2088 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { 2078 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) {
2089 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { 2079 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) {
2090 layer->SetContentsOpaque(!!contents_opaque); 2080 layer->SetContentsOpaque(!!contents_opaque);
2091 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED 2081 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED
2092 : SK_ColorTRANSPARENT); 2082 : SK_ColorTRANSPARENT);
2093 layer_tree->set_background_color(host_opaque ? SK_ColorRED 2083 layer_tree_host->set_background_color(
2094 : SK_ColorTRANSPARENT); 2084 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT);
2095 2085
2096 layer_tree->property_trees()->needs_rebuild = true; 2086 layer_tree_host->property_trees()->needs_rebuild = true;
2097 layer_tree_host->BuildPropertyTreesForTesting(); 2087 layer_tree_host->BuildPropertyTreesForTesting();
2098 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); 2088 SkColor safe_color = layer->SafeOpaqueBackgroundColor();
2099 if (contents_opaque) { 2089 if (contents_opaque) {
2100 EXPECT_EQ(SkColorGetA(safe_color), 255u) 2090 EXPECT_EQ(SkColorGetA(safe_color), 255u)
2101 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 2091 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
2102 << host_opaque << "\n"; 2092 << host_opaque << "\n";
2103 } else { 2093 } else {
2104 EXPECT_NE(SkColorGetA(safe_color), 255u) 2094 EXPECT_NE(SkColorGetA(safe_color), 255u)
2105 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 2095 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
2106 << host_opaque << "\n"; 2096 << host_opaque << "\n";
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 // When the layer is destroyed, the other three requests should be aborted. 2209 // When the layer is destroyed, the other three requests should be aborted.
2220 layer = nullptr; 2210 layer = nullptr;
2221 EXPECT_EQ(1, did_receive_first_result_from_this_source); 2211 EXPECT_EQ(1, did_receive_first_result_from_this_source);
2222 EXPECT_EQ(1, did_receive_result_from_different_source); 2212 EXPECT_EQ(1, did_receive_result_from_different_source);
2223 EXPECT_EQ(1, did_receive_result_from_anonymous_source); 2213 EXPECT_EQ(1, did_receive_result_from_anonymous_source);
2224 EXPECT_EQ(1, did_receive_second_result_from_this_source); 2214 EXPECT_EQ(1, did_receive_second_result_from_this_source);
2225 } 2215 }
2226 2216
2227 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { 2217 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) {
2228 scoped_refptr<Layer> layer = Layer::Create(); 2218 scoped_refptr<Layer> layer = Layer::Create();
2229 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(layer)); 2219 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer));
2230 2220
2231 LayerInternalsForTest layer_internals(layer.get()); 2221 LayerInternalsForTest layer_internals(layer.get());
2232 2222
2233 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 2223 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
2234 layer_internals.OnOpacityAnimated(0.5f); 2224 layer_internals.OnOpacityAnimated(0.5f);
2235 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 2225 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
2236 2226
2237 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 2227 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
2238 gfx::Transform transform; 2228 gfx::Transform transform;
2239 transform.Rotate(45.0); 2229 transform.Rotate(45.0);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( 2525 VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization(
2536 scrollbar_layers[i]); 2526 scrollbar_layers[i]);
2537 } 2527 }
2538 } 2528 }
2539 2529
2540 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { 2530 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) {
2541 scoped_refptr<Layer> test_layer = Layer::Create(); 2531 scoped_refptr<Layer> test_layer = Layer::Create();
2542 std::unique_ptr<LayerImpl> impl_layer = 2532 std::unique_ptr<LayerImpl> impl_layer =
2543 LayerImpl::Create(host_impl_.active_tree(), 1); 2533 LayerImpl::Create(host_impl_.active_tree(), 1);
2544 2534
2545 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); 2535 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
2536 layer_tree_host_->SetRootLayer(test_layer));
2546 2537
2547 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); 2538 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
2548 2539
2549 test_layer->SetElementId(ElementId(2, 0)); 2540 test_layer->SetElementId(ElementId(2, 0));
2550 test_layer->SetMutableProperties(MutableProperty::kTransform); 2541 test_layer->SetMutableProperties(MutableProperty::kTransform);
2551 2542
2552 EXPECT_FALSE(impl_layer->element_id()); 2543 EXPECT_FALSE(impl_layer->element_id());
2553 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2544 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2554 2545
2555 test_layer->PushPropertiesTo(impl_layer.get()); 2546 test_layer->PushPropertiesTo(impl_layer.get());
2556 2547
2557 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 2548 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
2558 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2549 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2559 } 2550 }
2560 2551
2561 } // namespace 2552 } // namespace
2562 } // namespace cc 2553 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698