Chromium Code Reviews| Index: cc/layers/layer_unittest.cc |
| diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc |
| index afc6c359397f36004d90ecb1cd7390ba5b6116e6..aec6dfb5e38238e81d9165912d18177de821cc39 100644 |
| --- a/cc/layers/layer_unittest.cc |
| +++ b/cc/layers/layer_unittest.cc |
| @@ -53,6 +53,25 @@ 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()); |
| + |
| namespace cc { |
| // This class is a friend of Layer, and is used as a wrapper for all the tests |
| @@ -501,6 +520,92 @@ TEST_F(LayerTest, BasicCreateAndDestroy) { |
| test_layer->SetLayerTreeHost(nullptr); |
| } |
| +TEST_F(LayerTest, LayerPropertyChangedForSubtree) { |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
| + scoped_refptr<Layer> root = Layer::Create(layer_settings_); |
| + scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
| + scoped_refptr<Layer> grand_child = Layer::Create(layer_settings_); |
| + scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); |
| + scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); |
| + |
| + layer_tree_host_->SetRootLayer(root); |
| + root->AddChild(child); |
| + child->AddChild(grand_child); |
| + SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; |
| + scoped_ptr<LayerImpl> root_impl = |
| + LayerImpl::Create(host_impl_.active_tree(), 1); |
| + scoped_ptr<LayerImpl> child_impl = |
| + LayerImpl::Create(host_impl_.active_tree(), 2); |
| + scoped_ptr<LayerImpl> grand_child_impl = |
| + LayerImpl::Create(host_impl_.active_tree(), 3); |
| + scoped_ptr<LayerImpl> dummy_layer1_impl = |
| + LayerImpl::Create(host_impl_.active_tree(), 4); |
| + scoped_ptr<LayerImpl> dummy_layer2_impl = |
| + LayerImpl::Create(host_impl_.active_tree(), 5); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get()); |
| + dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); |
|
jaydasika
2016/02/11 01:48:38
When we add the mask layer, we need to push it als
|
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get())); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get())); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get()); |
| + dummy_layer2->PushPropertiesTo(dummy_layer1_impl.get())); |
|
jaydasika
2016/02/11 01:48:38
Adding replica layer and we need to push its prope
ajuma
2016/02/11 14:22:16
Nit: push to layer2, not layer1. Actually, it migh
|
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get())); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->Set3dSortingContextId(1)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get()); |
| + dummy_layer2->PushPropertiesTo(dummy_layer1_impl.get())); |
|
jaydasika
2016/02/11 01:48:38
Replica layer gets a transform node (because its a
ajuma
2016/02/11 14:22:16
Here too, push to layer2, and it might be clearer
jaydasika
2016/02/11 19:24:24
Done.
|
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetDoubleSided(false)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get())); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetHideLayerAndSubtree(true)); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| + root->PushPropertiesTo(root_impl.get()); |
| + child->PushPropertiesTo(child_impl.get()); |
| + grand_child->PushPropertiesTo(grand_child_impl.get())); |
| + |
| + EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBlendMode(arbitrary_blend_mode)); |
| +} |
| + |
| TEST_F(LayerTest, AddAndRemoveChild) { |
| scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
| scoped_refptr<Layer> child = Layer::Create(layer_settings_); |