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

Unified Diff: cc/layers/layer_unittest.cc

Issue 1688563002: cc :: Move some tracking of layer_property_changed to main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « cc/layers/layer_impl_unittest.cc ('k') | cc/proto/layer.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer_unittest.cc
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index afc6c359397f36004d90ecb1cd7390ba5b6116e6..19b7eefb448fffd9abdc581148c9a8d03cabe477 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()));
+
+ 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_layer2_impl.get()));
+
+ 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_layer2_impl.get()));
+
+ 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_);
« no previous file with comments | « cc/layers/layer_impl_unittest.cc ('k') | cc/proto/layer.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698