Chromium Code Reviews| 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 f0a30855568ec9ffb9e333c371c29ebacc056679..b47a62e85737709ceea5cce13f9e697b497fae1f 100644 |
| --- a/cc/trees/layer_tree_host_impl_unittest.cc |
| +++ b/cc/trees/layer_tree_host_impl_unittest.cc |
| @@ -1453,6 +1453,61 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
| host_impl_ = nullptr; |
| } |
| +TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
| + host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| + |
| + host_impl_->active_tree()->SetRootLayer( |
| + LayerImpl::Create(host_impl_->active_tree(), 1)); |
| + LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| + root->SetBounds(gfx::Size(50, 50)); |
| + root->test_properties()->force_render_surface = true; |
|
ajuma
2016/06/06 13:17:01
Nit: the root always gets a render surface, so thi
|
| + |
| + root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| + LayerImpl* child = root->children()[0]; |
| + child->SetBounds(gfx::Size(10, 10)); |
| + child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| + child->SetDrawsContent(true); |
| + |
| + // Add a translate animation. |
| + TransformOperations start; |
| + start.AppendTranslate(6.f, 7.f, 0.f); |
| + TransformOperations end; |
| + end.AppendTranslate(8.f, 9.f, 0.f); |
| + AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
| + end); |
| + |
| + base::TimeTicks now = base::TimeTicks::Now(); |
| + host_impl_->WillBeginImplFrame( |
| + CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
| + EXPECT_TRUE(did_request_next_frame_); |
| + did_request_next_frame_ = false; |
| + |
| + host_impl_->ActivateAnimations(); |
| + // On activating an animation, we should request another frame so that we'll |
| + // continue ticking the animation. |
| + EXPECT_TRUE(did_request_next_frame_); |
| + did_request_next_frame_ = false; |
| + |
| + // The next frame after activating, we'll tick the animation again. |
| + host_impl_->Animate(); |
| + // An animation exists on the active layer. Doing Animate() requests another |
| + // frame after the current one. |
| + EXPECT_TRUE(did_request_next_frame_); |
| + did_request_next_frame_ = false; |
| + |
| + // Destroy layer, unregister animation target (element). |
| + child->SetParent(nullptr); |
| + root->RemoveChildForTesting(child); |
| + child = nullptr; |
| + |
| + // Doing Animate() doesn't request another frame after the current one. |
| + host_impl_->Animate(); |
| + EXPECT_FALSE(did_request_next_frame_); |
| + |
| + host_impl_->Animate(); |
| + EXPECT_FALSE(did_request_next_frame_); |
| +} |
| + |
| class MissingTilesLayer : public LayerImpl { |
| public: |
| MissingTilesLayer(LayerTreeImpl* layer_tree_impl, int id) |