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

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

Issue 1423523002: Add support for (de)serializing cc::Layer properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serialize-layer-hierarchy
Patch Set: Addressed comments from dtrainor@ Created 5 years, 1 month 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
OLDNEW
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
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 /* Testing deserialization of properties for a tree that looks like this:
112 root*+
113 / \
114 a b+
115 \
116 c*
117 Layers marked with * have changed properties.
118 Layers marked with + have descendants with changed properties.
119 */
120 proto::LayerUpdate updates;
121
122 scoped_refptr<Layer> root = Layer::Create(LayerSettings());
123 proto::LayerProperties* root_props = updates.add_layers();
124 root_props->set_id(root->id());
125 root_props->set_needs_push_properties(true);
126 root_props->set_num_dependents_need_push_properties(1);
127 root_props->mutable_base();
128
129 scoped_refptr<Layer> a = Layer::Create(LayerSettings());
130 proto::LayerProperties* a_props = updates.add_layers();
131 a_props->set_id(a->id());
132 a_props->set_needs_push_properties(false);
133 a_props->set_num_dependents_need_push_properties(0);
134 root->AddChild(a);
135
136 scoped_refptr<Layer> b = Layer::Create(LayerSettings());
137 proto::LayerProperties* b_props = updates.add_layers();
138 b_props->set_id(b->id());
139 b_props->set_needs_push_properties(false);
140 b_props->set_num_dependents_need_push_properties(1);
141 root->AddChild(b);
142
143 scoped_refptr<Layer> c = Layer::Create(LayerSettings());
144 proto::LayerProperties* c_props = updates.add_layers();
145 c_props->set_id(c->id());
146 c_props->set_needs_push_properties(true);
147 c_props->set_num_dependents_need_push_properties(0);
148 c_props->mutable_base();
149 b->AddChild(c);
150
151 LayerProtoConverter::DeserializeLayerProperties(root, updates);
152
153 EXPECT_TRUE(root->needs_push_properties());
154 EXPECT_TRUE(root->descendant_needs_push_properties());
155
156 EXPECT_FALSE(a->needs_push_properties());
157 EXPECT_FALSE(a->descendant_needs_push_properties());
158
159 EXPECT_FALSE(b->needs_push_properties());
160 EXPECT_TRUE(b->descendant_needs_push_properties());
161
162 EXPECT_TRUE(c->needs_push_properties());
163 EXPECT_FALSE(c->descendant_needs_push_properties());
164 }
165
110 } // namespace cc 166 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698