| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/trees/property_tree.h" | 5 #include "cc/trees/property_tree.h" |
| 6 | 6 |
| 7 #include "cc/input/main_thread_scrolling_reason.h" | 7 #include "cc/input/main_thread_scrolling_reason.h" |
| 8 #include "cc/proto/property_tree.pb.h" | 8 #include "cc/proto/property_tree.pb.h" |
| 9 #include "cc/test/geometry_test_utils.h" | 9 #include "cc/test/geometry_test_utils.h" |
| 10 #include "cc/trees/draw_property_utils.h" | 10 #include "cc/trees/draw_property_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 TEST(PropertyTreeSerializationTest, TransformNodeDataSerialization) { | 16 TEST(PropertyTreeSerializationTest, TransformNodeDataSerialization) { |
| 17 TransformNodeData original; | 17 TransformNodeData original; |
| 18 original.pre_local.Translate3d(1.f, 2.f, 3.f); | 18 original.pre_local.Translate3d(1.f, 2.f, 3.f); |
| 19 original.local.Translate3d(3.f, 1.f, 5.f); | 19 original.local.Translate3d(3.f, 1.f, 5.f); |
| 20 original.post_local.Translate3d(1.f, 8.f, 3.f); | 20 original.post_local.Translate3d(1.f, 8.f, 3.f); |
| 21 original.to_parent.Translate3d(3.2f, 2.f, 3.f); | 21 original.to_parent.Translate3d(3.2f, 2.f, 3.f); |
| 22 original.source_node_id = 5; | 22 original.source_node_id = 5; |
| 23 original.needs_local_transform_update = false; | 23 original.needs_local_transform_update = false; |
| 24 original.is_invertible = false; | 24 original.is_invertible = false; |
| 25 original.ancestors_are_invertible = false; | 25 original.ancestors_are_invertible = false; |
| 26 original.has_potential_animation = false; | 26 original.has_potential_animation = false; |
| 27 original.to_screen_is_potentially_animated = false; | 27 original.to_screen_is_potentially_animated = false; |
| 28 original.has_only_translation_animations = false; | 28 original.has_only_translation_animations = false; |
| 29 original.to_screen_has_scale_animation = false; | |
| 30 original.flattens_inherited_transform = false; | 29 original.flattens_inherited_transform = false; |
| 31 original.node_and_ancestors_are_flat = false; | 30 original.node_and_ancestors_are_flat = false; |
| 32 original.node_and_ancestors_have_only_integer_translation = false; | 31 original.node_and_ancestors_have_only_integer_translation = false; |
| 33 original.scrolls = false; | 32 original.scrolls = false; |
| 34 original.needs_sublayer_scale = false; | 33 original.needs_sublayer_scale = false; |
| 35 original.affected_by_inner_viewport_bounds_delta_x = false; | 34 original.affected_by_inner_viewport_bounds_delta_x = false; |
| 36 original.affected_by_inner_viewport_bounds_delta_y = false; | 35 original.affected_by_inner_viewport_bounds_delta_y = false; |
| 37 original.affected_by_outer_viewport_bounds_delta_x = false; | 36 original.affected_by_outer_viewport_bounds_delta_x = false; |
| 38 original.affected_by_outer_viewport_bounds_delta_y = false; | 37 original.affected_by_outer_viewport_bounds_delta_y = false; |
| 39 original.in_subtree_of_page_scale_layer = false; | 38 original.in_subtree_of_page_scale_layer = false; |
| 40 original.post_local_scale_factor = 0.5f; | 39 original.post_local_scale_factor = 0.5f; |
| 41 original.local_maximum_animation_target_scale = 0.6f; | |
| 42 original.local_starting_animation_scale = 0.7f; | |
| 43 original.combined_maximum_animation_target_scale = 0.8f; | |
| 44 original.combined_starting_animation_scale = 0.9f; | |
| 45 original.sublayer_scale = gfx::Vector2dF(0.5f, 0.5f); | 40 original.sublayer_scale = gfx::Vector2dF(0.5f, 0.5f); |
| 46 original.scroll_offset = gfx::ScrollOffset(1.5f, 1.5f); | 41 original.scroll_offset = gfx::ScrollOffset(1.5f, 1.5f); |
| 47 original.scroll_snap = gfx::Vector2dF(0.4f, 0.4f); | 42 original.scroll_snap = gfx::Vector2dF(0.4f, 0.4f); |
| 48 original.source_offset = gfx::Vector2dF(2.5f, 2.4f); | 43 original.source_offset = gfx::Vector2dF(2.5f, 2.4f); |
| 49 original.source_to_parent = gfx::Vector2dF(3.2f, 3.2f); | 44 original.source_to_parent = gfx::Vector2dF(3.2f, 3.2f); |
| 50 | 45 |
| 51 proto::TreeNode proto; | 46 proto::TreeNode proto; |
| 52 original.ToProtobuf(&proto); | 47 original.ToProtobuf(&proto); |
| 53 TransformNodeData result; | 48 TransformNodeData result; |
| 54 result.FromProtobuf(proto); | 49 result.FromProtobuf(proto); |
| 55 | 50 |
| 56 EXPECT_EQ(original, result); | 51 EXPECT_EQ(original, result); |
| 57 } | 52 } |
| 58 | 53 |
| 59 TEST(PropertyTreeSerializationTest, TransformNodeSerialization) { | 54 TEST(PropertyTreeSerializationTest, TransformNodeSerialization) { |
| 60 TransformNode original; | 55 TransformNode original; |
| 61 original.id = 3; | 56 original.id = 3; |
| 62 original.parent_id = 2; | 57 original.parent_id = 2; |
| 63 original.owner_id = 4; | 58 original.owner_id = 4; |
| 64 | 59 |
| 65 proto::TreeNode proto; | 60 proto::TreeNode proto; |
| 66 original.ToProtobuf(&proto); | 61 original.ToProtobuf(&proto); |
| 67 TransformNode result; | 62 TransformNode result; |
| 68 result.FromProtobuf(proto); | 63 result.FromProtobuf(proto); |
| 69 | 64 |
| 70 EXPECT_EQ(original, result); | 65 EXPECT_EQ(original, result); |
| 71 } | 66 } |
| 72 | 67 |
| 73 TEST(PropertyTreeSerializationTest, TransformTreeSerialization) { | 68 TEST(PropertyTreeSerializationTest, TransformTreeSerialization) { |
| 74 TransformTree original; | 69 PropertyTrees property_trees; |
| 70 TransformTree& original = property_trees.transform_tree; |
| 75 TransformNode& root = *original.Node(0); | 71 TransformNode& root = *original.Node(0); |
| 76 root.id = 0; | 72 root.id = 0; |
| 77 root.owner_id = 1; | 73 root.owner_id = 1; |
| 78 original.SetTargetId(root.id, 3); | 74 original.SetTargetId(root.id, 3); |
| 79 original.SetContentTargetId(root.id, 4); | 75 original.SetContentTargetId(root.id, 4); |
| 80 TransformNode second; | 76 TransformNode second; |
| 81 second.owner_id = 2; | 77 second.owner_id = 2; |
| 82 second.data.local.Translate3d(2.f, 2.f, 0.f); | 78 second.data.local.Translate3d(2.f, 2.f, 0.f); |
| 83 second.data.source_node_id = 0; | 79 second.data.source_node_id = 0; |
| 84 second.id = original.Insert(second, 0); | 80 second.id = original.Insert(second, 0); |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 | 1151 |
| 1156 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( | 1152 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
| 1157 PropertyTreeTestSingularTransformSnapTest); | 1153 PropertyTreeTestSingularTransformSnapTest); |
| 1158 | 1154 |
| 1159 #undef DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F | 1155 #undef DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F |
| 1160 #undef SERIALIZED_PROPERTY_TREE_TEST_F | 1156 #undef SERIALIZED_PROPERTY_TREE_TEST_F |
| 1161 #undef DIRECT_PROPERTY_TREE_TEST_F | 1157 #undef DIRECT_PROPERTY_TREE_TEST_F |
| 1162 | 1158 |
| 1163 } // namespace | 1159 } // namespace |
| 1164 } // namespace cc | 1160 } // namespace cc |
| OLD | NEW |