| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 EXPECT_FALSE( \ | 75 EXPECT_FALSE( \ |
| 76 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ | 76 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ |
| 77 EXPECT_FALSE(child->subtree_property_changed()); \ | 77 EXPECT_FALSE(child->subtree_property_changed()); \ |
| 78 EXPECT_FALSE( \ | 78 EXPECT_FALSE( \ |
| 79 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ | 79 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ |
| 80 EXPECT_FALSE(grand_child->subtree_property_changed()); \ | 80 EXPECT_FALSE(grand_child->subtree_property_changed()); \ |
| 81 EXPECT_FALSE( \ | 81 EXPECT_FALSE( \ |
| 82 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ | 82 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ |
| 83 grand_child.get())); | 83 grand_child.get())); |
| 84 | 84 |
| 85 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ | |
| 86 code_to_test; \ | |
| 87 root->GetLayerTree()->BuildPropertyTreesForTesting(); \ | |
| 88 EXPECT_TRUE(root->layer_property_changed()); \ | |
| 89 EXPECT_FALSE(root->subtree_property_changed()); \ | |
| 90 EXPECT_TRUE( \ | |
| 91 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ | |
| 92 EXPECT_FALSE(child->layer_property_changed()); \ | |
| 93 EXPECT_FALSE(child->subtree_property_changed()); \ | |
| 94 EXPECT_FALSE( \ | |
| 95 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ | |
| 96 EXPECT_FALSE(grand_child->layer_property_changed()); \ | |
| 97 EXPECT_FALSE(grand_child->subtree_property_changed()); \ | |
| 98 EXPECT_FALSE( \ | |
| 99 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ | |
| 100 grand_child.get())); | |
| 101 | |
| 102 namespace cc { | 85 namespace cc { |
| 103 | 86 |
| 104 // This class is a friend of Layer, and is used as a wrapper for all the tests | 87 // This class is a friend of Layer, and is used as a wrapper for all the tests |
| 105 // related to proto serialization. This is done so that it is unnecessary to | 88 // related to proto serialization. This is done so that it is unnecessary to |
| 106 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. | 89 // add FRIEND_TEST_ALL_PREFIXES in //cc/layers/layer.h for all the tests. |
| 107 // It is in the cc namespace so that it can be a friend of Layer. | 90 // It is in the cc namespace so that it can be a friend of Layer. |
| 108 // The tests still have helpful names, and a test with the name FooBar would | 91 // The tests still have helpful names, and a test with the name FooBar would |
| 109 // have a wrapper method in this class called RunFooBarTest. | 92 // have a wrapper method in this class called RunFooBarTest. |
| 110 class LayerSerializationTest : public testing::Test { | 93 class LayerSerializationTest : public testing::Test { |
| 111 protected: | 94 protected: |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 1146 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 1164 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1147 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1165 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); | 1148 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); |
| 1166 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1149 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1167 root->PushPropertiesTo(root_impl.get()); | 1150 root->PushPropertiesTo(root_impl.get()); |
| 1168 child->PushPropertiesTo(child_impl.get()); | 1151 child->PushPropertiesTo(child_impl.get()); |
| 1169 child2->PushPropertiesTo(child2_impl.get()); | 1152 child2->PushPropertiesTo(child2_impl.get()); |
| 1170 grand_child->PushPropertiesTo(grand_child_impl.get())); | 1153 grand_child->PushPropertiesTo(grand_child_impl.get())); |
| 1171 | 1154 |
| 1172 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1155 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1173 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( | 1156 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( |
| 1174 root->SetBackgroundFilters(arbitrary_filters)); | 1157 root->SetBackgroundFilters(arbitrary_filters)); |
| 1175 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1158 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1176 root->PushPropertiesTo(root_impl.get())); | 1159 root->PushPropertiesTo(root_impl.get()); |
| 1160 child->PushPropertiesTo(child_impl.get()); |
| 1161 child2->PushPropertiesTo(child2_impl.get()); |
| 1162 grand_child->PushPropertiesTo(grand_child_impl.get())); |
| 1177 | 1163 |
| 1178 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 1164 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 1179 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1165 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1180 root->SetPosition(arbitrary_point_f); | 1166 root->SetPosition(arbitrary_point_f); |
| 1181 TransformNode* node = layer_tree_->property_trees()->transform_tree.Node( | 1167 TransformNode* node = layer_tree_->property_trees()->transform_tree.Node( |
| 1182 root->transform_tree_index()); | 1168 root->transform_tree_index()); |
| 1183 EXPECT_TRUE(node->transform_changed); | 1169 EXPECT_TRUE(node->transform_changed); |
| 1184 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1170 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1185 root->PushPropertiesTo(root_impl.get()); | 1171 root->PushPropertiesTo(root_impl.get()); |
| 1186 child->PushPropertiesTo(child_impl.get()); | 1172 child->PushPropertiesTo(child_impl.get()); |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2554 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2540 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2555 | 2541 |
| 2556 test_layer->PushPropertiesTo(impl_layer.get()); | 2542 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2557 | 2543 |
| 2558 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2544 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
| 2559 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2545 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2560 } | 2546 } |
| 2561 | 2547 |
| 2562 } // namespace | 2548 } // namespace |
| 2563 } // namespace cc | 2549 } // namespace cc |
| OLD | NEW |