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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 375093002: Initial attempt at counting layers in the compositor thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add UMA for number of layers in a compositor frame Created 6 years, 5 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
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 9f2a5a2fba0e08a42a81d104ac7bd29a86eb1297..079fc9d124f07420aeea5837da9bbb2951222c99 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6723,5 +6723,56 @@ TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) {
external_transform, layer->draw_properties().target_space_transform);
}
+TEST_F(LayerTreeHostImplTest, TestLayerCountingZeroInit) {
Ian Vollick 2014/07/10 03:16:23 Nice tests!
dneto 2014/07/10 18:44:17 Thanks, but obviated by danakj's suggestion. :-)
+ EXPECT_EQ(0u, host_impl_->num_layers_for_testing());
+}
+
+TEST_F(LayerTreeHostImplTest, TestLayerCountingRootOnly) {
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
+ SetupRootLayerImpl(root.Pass());
+ DrawFrame();
+ EXPECT_EQ(1u, host_impl_->num_layers_for_testing());
+}
+
+TEST_F(LayerTreeHostImplTest, TestLayerCountingSmallTree) {
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
+ root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2));
+ root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3));
+ root->child_at(1)->AddChild(LayerImpl::Create(host_impl_->active_tree(), 4));
+ SetupRootLayerImpl(root.Pass());
+ DrawFrame();
+ EXPECT_EQ(4u, host_impl_->num_layers_for_testing());
+}
+
+TEST_F(LayerTreeHostImplTest, TestLayerCountingWithSequenceOfTrees) {
+ // The first tree has two nodes.
+ scoped_ptr<LayerImpl> root0 = LayerImpl::Create(host_impl_->active_tree(), 1);
+ root0->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2));
+ SetupRootLayerImpl(root0.Pass());
+ DrawFrame();
+ EXPECT_EQ(2u, host_impl_->num_layers_for_testing());
+
+ // We haven't changed anything. The count should stay the same.
+ // In particular the count should not accumulate.
+ DrawFrame();
+ EXPECT_EQ(2u, host_impl_->num_layers_for_testing());
+
+ // Set a new tree, with just a root.
+ // Should have a lower count now.
+ host_impl_->ResetTreesForTesting();
+ scoped_ptr<LayerImpl> root1 = LayerImpl::Create(host_impl_->active_tree(), 1);
+ SetupRootLayerImpl(root1.Pass());
+ DrawFrame();
+ EXPECT_EQ(1u, host_impl_->num_layers_for_testing());
+
+ // And it should go back up when we use a tree with more nodes.
+ host_impl_->ResetTreesForTesting();
+ scoped_ptr<LayerImpl> root2 = LayerImpl::Create(host_impl_->active_tree(), 1);
+ root2->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2));
+ SetupRootLayerImpl(root2.Pass());
+ DrawFrame();
+ EXPECT_EQ(2u, host_impl_->num_layers_for_testing());
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698