Chromium Code Reviews| Index: cc/layers/layer_unittest.cc |
| diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc |
| index a09295edc21db679a7bf94f27c248857ad1503b8..4c17c04a536c3e4fba0661291e0632e84acd7cb7 100644 |
| --- a/cc/layers/layer_unittest.cc |
| +++ b/cc/layers/layer_unittest.cc |
| @@ -53,24 +53,32 @@ using ::testing::_; |
| Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
| } while (false) |
| -#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
| - code_to_test; \ |
| - root->layer_tree_host()->BuildPropertyTreesForTesting(); \ |
| - EXPECT_TRUE(root->subtree_property_changed()); \ |
| - EXPECT_TRUE(root->needs_push_properties()); \ |
| - EXPECT_TRUE(child->subtree_property_changed()); \ |
| - EXPECT_TRUE(child->needs_push_properties()); \ |
| - EXPECT_TRUE(grand_child->subtree_property_changed()); \ |
| - EXPECT_TRUE(grand_child->needs_push_properties()); |
| - |
| -#define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ |
| - code_to_test; \ |
| - EXPECT_FALSE(root->subtree_property_changed()); \ |
| - EXPECT_FALSE(root->needs_push_properties()); \ |
| - EXPECT_FALSE(child->subtree_property_changed()); \ |
| - EXPECT_FALSE(child->needs_push_properties()); \ |
| - EXPECT_FALSE(grand_child->subtree_property_changed()); \ |
| - EXPECT_FALSE(grand_child->needs_push_properties()); |
| +#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
| + code_to_test; \ |
| + root->layer_tree_host()->BuildPropertyTreesForTesting(); \ |
| + EXPECT_TRUE(root->subtree_property_changed()); \ |
| + EXPECT_TRUE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + root.get())); \ |
| + EXPECT_TRUE(child->subtree_property_changed()); \ |
| + EXPECT_TRUE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + child.get())); \ |
| + EXPECT_TRUE(grand_child->subtree_property_changed()); \ |
| + EXPECT_TRUE( \ |
| + grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + grand_child.get())); |
| + |
| +#define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ |
| + code_to_test; \ |
| + EXPECT_FALSE(root->subtree_property_changed()); \ |
| + EXPECT_FALSE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + root.get())); \ |
| + EXPECT_FALSE(child->subtree_property_changed()); \ |
| + EXPECT_FALSE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + child.get())); \ |
| + EXPECT_FALSE(grand_child->subtree_property_changed()); \ |
| + EXPECT_FALSE( \ |
| + grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| + grand_child.get())); |
| namespace cc { |
| @@ -110,7 +118,7 @@ class LayerSerializationTest : public testing::Test { |
| // LayerUpdate. There are no descendants, so the serialization |
| // of |src| is the only entry. |
| proto::LayerUpdate layer_update; |
| - EXPECT_FALSE(src->ToLayerPropertiesProto(&layer_update)); |
| + src->ToLayerPropertiesProto(&layer_update); |
| ASSERT_EQ(1, layer_update.layers_size()); |
| proto::LayerProperties props = layer_update.layers(0); |
| @@ -1338,7 +1346,8 @@ TEST_F(LayerTest, DeleteRemovedScrollParent) { |
| EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); |
| - EXPECT_TRUE(child1->needs_push_properties()); |
| + EXPECT_TRUE( |
| + layer_tree_host_->LayerNeedsPushPropertiesForTesting(child1.get())); |
| EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| } |
| @@ -1367,7 +1376,8 @@ TEST_F(LayerTest, DeleteRemovedScrollChild) { |
| EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); |
| - EXPECT_TRUE(child2->needs_push_properties()); |
| + EXPECT_TRUE( |
| + layer_tree_host_->LayerNeedsPushPropertiesForTesting(child2.get())); |
| EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| } |
| @@ -2509,158 +2519,6 @@ TEST_F(LayerSerializationTest, |
| RunNonDestructiveDeserializationMoveChildLaterTest(); |
| } |
| -TEST_F(LayerTest, SimplePropertiesSerialization) { |
|
jaydasika
2016/03/17 23:38:37
Deleted this as what gets serialized is no longer
|
| - /* Testing serialization of properties for a tree that looks like this: |
| - root+ |
| - / \ |
| - a* b*+[mask:*,replica] |
| - / \ |
| - c d* |
| - Layers marked with * have changed properties. |
| - Layers marked with + have descendants with changed properties. |
| - Layer b also has a mask layer and a replica layer. |
| - */ |
| - scoped_refptr<Layer> layer_src_root = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_a = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_b = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_b_mask = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_b_replica = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_c = Layer::Create(LayerSettings()); |
| - scoped_refptr<Layer> layer_src_d = Layer::Create(LayerSettings()); |
| - layer_src_root->AddChild(layer_src_a); |
| - layer_src_root->AddChild(layer_src_b); |
| - layer_src_a->AddChild(layer_src_c); |
| - layer_src_b->AddChild(layer_src_d); |
| - layer_src_b->SetMaskLayer(layer_src_b_mask.get()); |
| - layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); |
| - |
| - proto::LayerUpdate layer_update_root; |
| - // Only layers with descendants that require pushing properties will |
| - // return true from ToLayerPropertiesProto and AddChild will change the |
| - // stacking order of child which will make it push properties. |
| - EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root)); |
| - proto::LayerUpdate layer_update_a; |
| - EXPECT_TRUE(layer_src_a->ToLayerPropertiesProto(&layer_update_a)); |
| - proto::LayerUpdate layer_update_b; |
| - EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b)); |
| - proto::LayerUpdate layer_update_c; |
| - EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c)); |
| - proto::LayerUpdate layer_update_d; |
| - EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d)); |
| - layer_update_root.Clear(); |
| - layer_update_a.Clear(); |
| - layer_update_b.Clear(); |
| - layer_update_c.Clear(); |
| - layer_update_d.Clear(); |
| - |
| - layer_src_a->SetNeedsPushProperties(); |
| - layer_src_b->SetNeedsPushProperties(); |
| - layer_src_b_mask->SetNeedsPushProperties(); |
| - layer_src_d->SetNeedsPushProperties(); |
| - |
| - // Only layers with descendants that require pushing properties will |
| - // return true from ToLayerPropertiesProto. |
| - EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root)); |
| - EXPECT_FALSE(layer_src_a->ToLayerPropertiesProto(&layer_update_a)); |
| - EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b)); |
| - proto::LayerUpdate layer_update_b_mask; |
| - EXPECT_FALSE(layer_src_b_mask->ToLayerPropertiesProto(&layer_update_b_mask)); |
| - proto::LayerUpdate layer_update_b_replica; |
| - EXPECT_FALSE( |
| - layer_src_b_replica->ToLayerPropertiesProto(&layer_update_b_replica)); |
| - EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c)); |
| - EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d)); |
| - |
| - // All flags for pushing properties should have been cleared. |
| - EXPECT_FALSE(layer_src_root->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_root->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_a->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_a->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b_mask->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b_mask->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b_replica->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_b_replica->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_c->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_c->descendant_needs_push_properties()); |
| - EXPECT_FALSE(layer_src_d->needs_push_properties()); |
| - EXPECT_FALSE(layer_src_d->descendant_needs_push_properties()); |
| - |
| - // Only 5 of the layers should have been serialized. |
| - ASSERT_EQ(1, layer_update_root.layers_size()); |
| - EXPECT_EQ(layer_src_root->id(), layer_update_root.layers(0).id()); |
| - proto::LayerProperties dest_root = layer_update_root.layers(0); |
| - ASSERT_EQ(1, layer_update_a.layers_size()); |
| - EXPECT_EQ(layer_src_a->id(), layer_update_a.layers(0).id()); |
| - proto::LayerProperties dest_a = layer_update_a.layers(0); |
| - ASSERT_EQ(1, layer_update_b.layers_size()); |
| - EXPECT_EQ(layer_src_b->id(), layer_update_b.layers(0).id()); |
| - proto::LayerProperties dest_b = layer_update_b.layers(0); |
| - ASSERT_EQ(1, layer_update_b_mask.layers_size()); |
| - EXPECT_EQ(layer_src_b_mask->id(), layer_update_b_mask.layers(0).id()); |
| - proto::LayerProperties dest_b_mask = layer_update_b_mask.layers(0); |
| - EXPECT_EQ(0, layer_update_b_replica.layers_size()); |
| - EXPECT_EQ(0, layer_update_c.layers_size()); |
| - ASSERT_EQ(1, layer_update_d.layers_size()); |
| - EXPECT_EQ(layer_src_d->id(), layer_update_d.layers(0).id()); |
| - proto::LayerProperties dest_d = layer_update_d.layers(0); |
| - |
| - // Ensure the properties and dependants metadata is correctly serialized. |
| - EXPECT_FALSE(dest_root.needs_push_properties()); |
| - EXPECT_EQ(2, dest_root.num_dependents_need_push_properties()); |
| - EXPECT_FALSE(dest_root.has_base()); |
| - |
| - EXPECT_TRUE(dest_a.needs_push_properties()); |
| - EXPECT_EQ(0, dest_a.num_dependents_need_push_properties()); |
| - EXPECT_TRUE(dest_a.has_base()); |
| - |
| - EXPECT_TRUE(dest_b.needs_push_properties()); |
| - EXPECT_EQ(2, dest_b.num_dependents_need_push_properties()); |
| - EXPECT_TRUE(dest_b.has_base()); |
| - |
| - EXPECT_TRUE(dest_d.needs_push_properties()); |
| - EXPECT_EQ(0, dest_d.num_dependents_need_push_properties()); |
| - EXPECT_TRUE(dest_d.has_base()); |
| - |
| - EXPECT_TRUE(dest_b_mask.needs_push_properties()); |
| - EXPECT_EQ(0, dest_b_mask.num_dependents_need_push_properties()); |
| - EXPECT_TRUE(dest_b_mask.has_base()); |
| -} |
| - |
| -TEST_F(LayerSerializationTest, SimplePropertiesDeserialization) { |
| - scoped_refptr<Layer> layer = Layer::Create(LayerSettings()); |
| - layer->SetLayerTreeHost(layer_tree_host_.get()); |
| - proto::LayerProperties properties; |
| - properties.set_id(layer->id()); |
| - |
| - properties.set_needs_push_properties(true); |
| - properties.set_num_dependents_need_push_properties(2); |
| - properties.mutable_base(); |
| - layer->FromLayerPropertiesProto(properties); |
| - EXPECT_TRUE(layer->needs_push_properties()); |
| - EXPECT_TRUE(layer->descendant_needs_push_properties()); |
| - |
| - properties.set_needs_push_properties(false); |
| - properties.mutable_base()->Clear(); |
| - layer->FromLayerPropertiesProto(properties); |
| - EXPECT_FALSE(layer->needs_push_properties()); |
| - EXPECT_TRUE(layer->descendant_needs_push_properties()); |
| - |
| - properties.set_num_dependents_need_push_properties(0); |
| - layer->FromLayerPropertiesProto(properties); |
| - EXPECT_FALSE(layer->needs_push_properties()); |
| - EXPECT_FALSE(layer->descendant_needs_push_properties()); |
| - |
| - properties.set_needs_push_properties(true); |
| - properties.mutable_base(); |
| - layer->FromLayerPropertiesProto(properties); |
| - EXPECT_TRUE(layer->needs_push_properties()); |
| - EXPECT_FALSE(layer->descendant_needs_push_properties()); |
| - |
| - layer->SetLayerTreeHost(nullptr); |
| -} |
| - |
| TEST_F(LayerSerializationTest, NoMembersChanged) { |
| RunNoMembersChangedTest(); |
| } |