Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest_animation.cc |
| diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc |
| index aeeb4f5a54b5efc975e0d43f6d61f783f66660e0..99d2a4a8e864a1d2858c5a633213bf49b71489f0 100644 |
| --- a/cc/trees/layer_tree_host_unittest_animation.cc |
| +++ b/cc/trees/layer_tree_host_unittest_animation.cc |
| @@ -1244,5 +1244,68 @@ class LayerTreeHostAnimationTestFrozenAnimationTickTime |
| // Only the non-impl-paint multi-threaded compositor freezes animations. |
| MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); |
| +class LayerTreeHostAnimationTestAddAnimationAfterAnimating |
| + : public LayerTreeHostAnimationTest { |
| + public: |
| + LayerTreeHostAnimationTestAddAnimationAfterAnimating() |
| + : num_swap_buffers_(0) {} |
| + |
| + virtual void SetupTree() OVERRIDE { |
| + LayerTreeHostAnimationTest::SetupTree(); |
| + content_ = Layer::Create(); |
| + content_->SetBounds(gfx::Size(4, 4)); |
| + layer_tree_host()->root_layer()->AddChild(content_); |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| + |
| + virtual void DidCommit() OVERRIDE { |
| + switch (layer_tree_host()->source_frame_number()) { |
| + case 1: |
| + // First frame: add an animation to the root layer. |
| + AddAnimatedTransformToLayer(layer_tree_host()->root_layer(), 0.1, 5, 5); |
| + break; |
| + case 2: |
| + // Second frame: add an animation to the content layer. The root layer |
| + // animation has caused us to animate already during this frame. |
| + AddOpacityTransitionToLayer(content_.get(), 0.1, 5, 5, false); |
| + break; |
| + } |
| + } |
| + |
| + virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
| + bool result) OVERRIDE { |
| + // The third frame is when both animations have started. Check that both |
| + // have a valid start time. |
| + if (++num_swap_buffers_ == 3) { |
| + EndTest(); |
| + AnimationRegistrar::AnimationControllerMap copy = |
| + host_impl->animation_registrar()->active_animation_controllers(); |
| + ASSERT_EQ(2u, copy.size()); |
|
ajuma
2014/04/28 13:33:42
EXPECT_EQ
Sami
2014/04/28 16:02:05
D'oh, done.
|
| + for (AnimationRegistrar::AnimationControllerMap::iterator iter = |
| + copy.begin(); |
| + iter != copy.end(); |
| + ++iter) { |
| + int id = ((*iter).second->id()); |
| + if (id == host_impl->RootLayer()->id()) { |
| + Animation* anim = (*iter).second->GetAnimation(Animation::Transform); |
| + ASSERT_GT(anim->start_time(), 0); |
|
ajuma
2014/04/28 13:33:42
EXPECT_GT
Sami
2014/04/28 16:02:05
Done.
|
| + } else if (id == host_impl->RootLayer()->children()[0]->id()) { |
| + Animation* anim = (*iter).second->GetAnimation(Animation::Opacity); |
| + ASSERT_GT(anim->start_time(), 0); |
|
ajuma
2014/04/28 13:33:42
EXPECT_GT
Sami
2014/04/28 16:02:05
Done.
|
| + } |
| + } |
| + } |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE {} |
| + |
| + private: |
| + scoped_refptr<Layer> content_; |
| + int num_swap_buffers_; |
| +}; |
| + |
| +MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
|
ajuma
2014/04/28 13:33:42
Can this be SINGLE_AND_MULTI_THREAD_TEST_F?
Sami
2014/04/28 16:02:05
Indeed it can.
|
| + |
| } // namespace |
| } // namespace cc |