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

Unified 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: Add framework for base Layer class properties 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/layer_proto_converter_unittest.cc
diff --git a/cc/layers/layer_proto_converter_unittest.cc b/cc/layers/layer_proto_converter_unittest.cc
index 040be9760abd8c27686266e661fd463af5ed133a..fb73a9933ea8f49c5afb3d0bc5013e333baeef8b 100644
--- a/cc/layers/layer_proto_converter_unittest.cc
+++ b/cc/layers/layer_proto_converter_unittest.cc
@@ -107,4 +107,58 @@ TEST(LayerProtoConverterTest, TestSwappingRoot) {
EXPECT_EQ(child_c_node->id(), child_c->id());
}
+TEST(LayerProtoConverterTest, DeserializeLayerProperties) {
+ /* Test deserialization of a tree that looks like:
+ root*+
+ / \
+ a b+
+ \
+ c*
+ */
+ proto::LayerUpdate updates;
+
+ scoped_refptr<Layer> root = Layer::Create(LayerSettings());
+ proto::LayerProperties* root_props = updates.add_layers();
+ root_props->set_id(root->id());
+ root_props->set_needs_push_properties(true);
+ root_props->set_num_dependents_need_push_properties(1);
+ root_props->mutable_base();
+
+ scoped_refptr<Layer> a = Layer::Create(LayerSettings());
+ proto::LayerProperties* a_props = updates.add_layers();
+ a_props->set_id(a->id());
+ a_props->set_needs_push_properties(false);
+ a_props->set_num_dependents_need_push_properties(0);
+ root->AddChild(a);
+
+ scoped_refptr<Layer> b = Layer::Create(LayerSettings());
+ proto::LayerProperties* b_props = updates.add_layers();
+ b_props->set_id(b->id());
+ b_props->set_needs_push_properties(false);
+ b_props->set_num_dependents_need_push_properties(1);
+ root->AddChild(b);
+
+ scoped_refptr<Layer> c = Layer::Create(LayerSettings());
+ proto::LayerProperties* c_props = updates.add_layers();
+ c_props->set_id(c->id());
+ c_props->set_needs_push_properties(true);
+ c_props->set_num_dependents_need_push_properties(0);
+ c_props->mutable_base();
+ b->AddChild(c);
+
+ LayerProtoConverter::DeserializeLayerProperties(root, updates);
+
+ EXPECT_TRUE(root->needs_push_properties());
+ EXPECT_TRUE(root->descendant_needs_push_properties());
+
+ EXPECT_FALSE(a->needs_push_properties());
+ EXPECT_FALSE(a->descendant_needs_push_properties());
+
+ EXPECT_FALSE(b->needs_push_properties());
+ EXPECT_TRUE(b->descendant_needs_push_properties());
+
+ EXPECT_TRUE(c->needs_push_properties());
+ EXPECT_FALSE(c->descendant_needs_push_properties());
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698