Index: cc/trees/layer_tree_impl.cc |
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc |
index a3820cadf48c430da188832506f1aaff16456963..037838da3784c913aba9a050c315bb12888dfb1d 100644 |
--- a/cc/trees/layer_tree_impl.cc |
+++ b/cc/trees/layer_tree_impl.cc |
@@ -100,6 +100,17 @@ void LayerTreeImpl::Shutdown() { |
} |
void LayerTreeImpl::ReleaseResources() { |
+#if DCHECK_IS_ON() |
+ // These DCHECKs catch tests that add layers to the tree but fail to build the |
+ // layer list afterward. |
+ LayerListIterator<LayerImpl> it(root_layer_for_testing_); |
+ size_t i = 0; |
+ for (; it != LayerListIterator<LayerImpl>(nullptr); ++it, ++i) { |
+ DCHECK_LT(i, layer_list_.size()); |
+ DCHECK_EQ(layer_list_[i], *it); |
+ } |
+#endif |
+ |
if (!LayerListIsEmpty()) { |
LayerTreeHostCommon::CallFunctionForEveryLayer( |
this, [](LayerImpl* layer) { layer->ReleaseResources(); }); |