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 |