OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_proto_converter.h" | 5 #include "cc/layers/layer_proto_converter.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "cc/proto/layer.pb.h" | 8 #include "cc/proto/layer.pb.h" |
9 #include "cc/trees/layer_tree_settings.h" | 9 #include "cc/trees/layer_tree_settings.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(child_a_node->id(), child_a->id()); | 100 EXPECT_EQ(child_a_node->id(), child_a->id()); |
101 EXPECT_EQ(child_b_node->id(), child_b->id()); | 101 EXPECT_EQ(child_b_node->id(), child_b->id()); |
102 | 102 |
103 EXPECT_EQ(0u, child_a->children().size()); | 103 EXPECT_EQ(0u, child_a->children().size()); |
104 ASSERT_EQ(1u, child_b->children().size()); | 104 ASSERT_EQ(1u, child_b->children().size()); |
105 | 105 |
106 scoped_refptr<Layer> child_c = child_b->children()[0]; | 106 scoped_refptr<Layer> child_c = child_b->children()[0]; |
107 EXPECT_EQ(child_c_node->id(), child_c->id()); | 107 EXPECT_EQ(child_c_node->id(), child_c->id()); |
108 } | 108 } |
109 | 109 |
| 110 TEST(LayerProtoConverterTest, DeserializeLayerProperties) { |
| 111 /* Test deserialization of a tree that looks like: |
| 112 root*+ |
| 113 / \ |
| 114 a b+ |
| 115 \ |
| 116 c* |
| 117 */ |
| 118 proto::LayerUpdate updates; |
| 119 |
| 120 scoped_refptr<Layer> root = Layer::Create(LayerSettings()); |
| 121 proto::LayerProperties* root_props = updates.add_layers(); |
| 122 root_props->set_id(root->id()); |
| 123 root_props->set_needs_push_properties(true); |
| 124 root_props->set_num_dependents_need_push_properties(1); |
| 125 root_props->mutable_base(); |
| 126 |
| 127 scoped_refptr<Layer> a = Layer::Create(LayerSettings()); |
| 128 proto::LayerProperties* a_props = updates.add_layers(); |
| 129 a_props->set_id(a->id()); |
| 130 a_props->set_needs_push_properties(false); |
| 131 a_props->set_num_dependents_need_push_properties(0); |
| 132 root->AddChild(a); |
| 133 |
| 134 scoped_refptr<Layer> b = Layer::Create(LayerSettings()); |
| 135 proto::LayerProperties* b_props = updates.add_layers(); |
| 136 b_props->set_id(b->id()); |
| 137 b_props->set_needs_push_properties(false); |
| 138 b_props->set_num_dependents_need_push_properties(1); |
| 139 root->AddChild(b); |
| 140 |
| 141 scoped_refptr<Layer> c = Layer::Create(LayerSettings()); |
| 142 proto::LayerProperties* c_props = updates.add_layers(); |
| 143 c_props->set_id(c->id()); |
| 144 c_props->set_needs_push_properties(true); |
| 145 c_props->set_num_dependents_need_push_properties(0); |
| 146 c_props->mutable_base(); |
| 147 b->AddChild(c); |
| 148 |
| 149 LayerProtoConverter::DeserializeLayerProperties(root, updates); |
| 150 |
| 151 EXPECT_TRUE(root->needs_push_properties()); |
| 152 EXPECT_TRUE(root->descendant_needs_push_properties()); |
| 153 |
| 154 EXPECT_FALSE(a->needs_push_properties()); |
| 155 EXPECT_FALSE(a->descendant_needs_push_properties()); |
| 156 |
| 157 EXPECT_FALSE(b->needs_push_properties()); |
| 158 EXPECT_TRUE(b->descendant_needs_push_properties()); |
| 159 |
| 160 EXPECT_TRUE(c->needs_push_properties()); |
| 161 EXPECT_FALSE(c->descendant_needs_push_properties()); |
| 162 } |
| 163 |
110 } // namespace cc | 164 } // namespace cc |
OLD | NEW |