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

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

Issue 2118993002: Detemplatize cc property nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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_impl.cc ('k') | cc/layers/layer_utils.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 13 matching lines...) Expand all
24 #include "cc/test/fake_layer_tree_host_client.h" 24 #include "cc/test/fake_layer_tree_host_client.h"
25 #include "cc/test/fake_layer_tree_host_impl.h" 25 #include "cc/test/fake_layer_tree_host_impl.h"
26 #include "cc/test/geometry_test_utils.h" 26 #include "cc/test/geometry_test_utils.h"
27 #include "cc/test/layer_internals_for_test.h" 27 #include "cc/test/layer_internals_for_test.h"
28 #include "cc/test/layer_test_common.h" 28 #include "cc/test/layer_test_common.h"
29 #include "cc/test/test_gpu_memory_buffer_manager.h" 29 #include "cc/test/test_gpu_memory_buffer_manager.h"
30 #include "cc/test/test_shared_bitmap_manager.h" 30 #include "cc/test/test_shared_bitmap_manager.h"
31 #include "cc/test/test_task_graph_runner.h" 31 #include "cc/test/test_task_graph_runner.h"
32 #include "cc/trees/layer_tree_host.h" 32 #include "cc/trees/layer_tree_host.h"
33 #include "cc/trees/single_thread_proxy.h" 33 #include "cc/trees/single_thread_proxy.h"
34 #include "cc/trees/transform_node.h"
34 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 #include "third_party/skia/include/core/SkColor.h" 37 #include "third_party/skia/include/core/SkColor.h"
37 #include "ui/gfx/geometry/point3_f.h" 38 #include "ui/gfx/geometry/point3_f.h"
38 #include "ui/gfx/geometry/point_f.h" 39 #include "ui/gfx/geometry/point_f.h"
39 #include "ui/gfx/geometry/scroll_offset.h" 40 #include "ui/gfx/geometry/scroll_offset.h"
40 #include "ui/gfx/geometry/size.h" 41 #include "ui/gfx/geometry/size.h"
41 #include "ui/gfx/geometry/vector2d_f.h" 42 #include "ui/gfx/geometry/vector2d_f.h"
42 #include "ui/gfx/transform.h" 43 #include "ui/gfx/transform.h"
43 44
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 1147 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
1147 root->SetBackgroundFilters(arbitrary_filters)); 1148 root->SetBackgroundFilters(arbitrary_filters));
1148 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1149 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1149 root->PushPropertiesTo(root_impl.get())); 1150 root->PushPropertiesTo(root_impl.get()));
1150 1151
1151 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 1152 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
1152 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1153 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1153 root->SetPosition(arbitrary_point_f); 1154 root->SetPosition(arbitrary_point_f);
1154 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( 1155 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node(
1155 root->transform_tree_index()); 1156 root->transform_tree_index());
1156 EXPECT_TRUE(node->data.transform_changed); 1157 EXPECT_TRUE(node->transform_changed);
1157 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1158 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1158 root->PushPropertiesTo(root_impl.get()); 1159 root->PushPropertiesTo(root_impl.get());
1159 child->PushPropertiesTo(child_impl.get()); 1160 child->PushPropertiesTo(child_impl.get());
1160 child2->PushPropertiesTo(child2_impl.get()); 1161 child2->PushPropertiesTo(child2_impl.get());
1161 grand_child->PushPropertiesTo(grand_child_impl.get()); 1162 grand_child->PushPropertiesTo(grand_child_impl.get());
1162 layer_tree_host_->property_trees()->ResetAllChangeTracking()); 1163 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1163 EXPECT_FALSE(node->data.transform_changed); 1164 EXPECT_FALSE(node->transform_changed);
1164 1165
1165 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1166 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1166 child->SetPosition(arbitrary_point_f); 1167 child->SetPosition(arbitrary_point_f);
1167 node = layer_tree_host_->property_trees()->transform_tree.Node( 1168 node = layer_tree_host_->property_trees()->transform_tree.Node(
1168 child->transform_tree_index()); 1169 child->transform_tree_index());
1169 EXPECT_TRUE(node->data.transform_changed); 1170 EXPECT_TRUE(node->transform_changed);
1170 // child2 is not in the subtree of child, but its scroll parent is. So, its 1171 // child2 is not in the subtree of child, but its scroll parent is. So, its
1171 // to_screen will be effected by change in position of child2. 1172 // to_screen will be effected by change in position of child2.
1172 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( 1173 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms(
1173 child2->transform_tree_index()); 1174 child2->transform_tree_index());
1174 node = layer_tree_host_->property_trees()->transform_tree.Node( 1175 node = layer_tree_host_->property_trees()->transform_tree.Node(
1175 child2->transform_tree_index()); 1176 child2->transform_tree_index());
1176 EXPECT_TRUE(node->data.transform_changed); 1177 EXPECT_TRUE(node->transform_changed);
1177 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1178 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1178 child->PushPropertiesTo(child_impl.get()); 1179 child->PushPropertiesTo(child_impl.get());
1179 grand_child->PushPropertiesTo(grand_child_impl.get()); 1180 grand_child->PushPropertiesTo(grand_child_impl.get());
1180 layer_tree_host_->property_trees()->ResetAllChangeTracking()); 1181 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1181 node = layer_tree_host_->property_trees()->transform_tree.Node( 1182 node = layer_tree_host_->property_trees()->transform_tree.Node(
1182 child->transform_tree_index()); 1183 child->transform_tree_index());
1183 EXPECT_FALSE(node->data.transform_changed); 1184 EXPECT_FALSE(node->transform_changed);
1184 1185
1185 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); 1186 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
1186 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1187 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1187 root->SetTransformOrigin(arbitrary_point_3f); 1188 root->SetTransformOrigin(arbitrary_point_3f);
1188 node = layer_tree_host_->property_trees()->transform_tree.Node( 1189 node = layer_tree_host_->property_trees()->transform_tree.Node(
1189 root->transform_tree_index()); 1190 root->transform_tree_index());
1190 EXPECT_TRUE(node->data.transform_changed); 1191 EXPECT_TRUE(node->transform_changed);
1191 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 1192 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1192 root->PushPropertiesTo(root_impl.get()); 1193 root->PushPropertiesTo(root_impl.get());
1193 child->PushPropertiesTo(child_impl.get()); 1194 child->PushPropertiesTo(child_impl.get());
1194 child2->PushPropertiesTo(child2_impl.get()); 1195 child2->PushPropertiesTo(child2_impl.get());
1195 grand_child->PushPropertiesTo(grand_child_impl.get()); 1196 grand_child->PushPropertiesTo(grand_child_impl.get());
1196 layer_tree_host_->property_trees()->ResetAllChangeTracking()); 1197 layer_tree_host_->property_trees()->ResetAllChangeTracking());
1197 1198
1198 gfx::Transform arbitrary_transform; 1199 gfx::Transform arbitrary_transform;
1199 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 1200 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
1200 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1201 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1201 root->SetTransform(arbitrary_transform); 1202 root->SetTransform(arbitrary_transform);
1202 node = layer_tree_host_->property_trees()->transform_tree.Node( 1203 node = layer_tree_host_->property_trees()->transform_tree.Node(
1203 root->transform_tree_index()); 1204 root->transform_tree_index());
1204 EXPECT_TRUE(node->data.transform_changed); 1205 EXPECT_TRUE(node->transform_changed);
1205 } 1206 }
1206 1207
1207 TEST_F(LayerTest, AddAndRemoveChild) { 1208 TEST_F(LayerTest, AddAndRemoveChild) {
1208 scoped_refptr<Layer> parent = Layer::Create(); 1209 scoped_refptr<Layer> parent = Layer::Create();
1209 scoped_refptr<Layer> child = Layer::Create(); 1210 scoped_refptr<Layer> child = Layer::Create();
1210 1211
1211 // Upon creation, layers should not have children or parent. 1212 // Upon creation, layers should not have children or parent.
1212 ASSERT_EQ(0U, parent->children().size()); 1213 ASSERT_EQ(0U, parent->children().size());
1213 EXPECT_FALSE(child->parent()); 1214 EXPECT_FALSE(child->parent());
1214 1215
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2534 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2534 2535
2535 test_layer->PushPropertiesTo(impl_layer.get()); 2536 test_layer->PushPropertiesTo(impl_layer.get());
2536 2537
2537 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 2538 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
2538 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2539 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2539 } 2540 }
2540 2541
2541 } // namespace 2542 } // namespace
2542 } // namespace cc 2543 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698