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 ccad25333badf94a0c0d22764fcf49199555aa4a..ca0eca2d6f00297dff1fbd4293cf109ea6de0122 100644 |
| --- a/cc/trees/layer_tree_host_unittest_animation.cc |
| +++ b/cc/trees/layer_tree_host_unittest_animation.cc |
| @@ -104,9 +104,8 @@ class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback |
| int num_animates_; |
| }; |
| -// Temporarily suppressed per crbug.com/280706. |
| -//MULTI_THREAD_TEST_F( |
| -// LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback); |
| +MULTI_THREAD_TEST_F( |
| + LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback); |
| // Add a layer animation and confirm that |
| // LayerTreeHostImpl::updateAnimationState does get called and continues to |
| @@ -294,6 +293,110 @@ class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded |
| SINGLE_AND_MULTI_THREAD_TEST_F( |
| LayerTreeHostAnimationTestTickAnimationWhileBackgrounded); |
| +// Ensures that animations do not tick when we are backgrounded and |
| +// and the active tree's root layer is null. |
| +class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree |
| + : public LayerTreeHostAnimationTest { |
| + public: |
| + virtual void BeginTest() OVERRIDE { |
| + PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
| + } |
| + |
| + virtual void NotifyAnimationFinished(double time) OVERRIDE { |
| + // Replace animated commits with a null root layer commit. |
| + layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); |
| + } |
| + |
| + virtual void DidCommit() OVERRIDE { |
| + // This alternates setting the root tree null and root tree with animation. |
|
danakj
2013/08/29 17:22:17
"setting the root tree null" - i think you mean se
|
| + switch (layer_tree_host()->source_frame_number()) { |
| + case 1: |
| + // Wait for NotifyAnimationFinished to set the root layer to null. |
| + break; |
| + case 2: |
| + SetupTree(); |
| + PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
|
danakj
2013/08/29 17:22:17
This is going to be racey, you're post-tasking the
|
| + break; |
| + case 3: |
| + // Wait for NotifyAnimationFinished to set the root layer to null. |
| + break; |
| + case 4: |
| + EndTest(); |
| + break; |
| + } |
| + } |
| + |
| + virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| + // At the start of every commit, block activations and make sure |
| + // we are backgrounded. |
| + host_impl->BlockNotifyReadyToActivateForTesting(true); |
| + PostSetVisibleToMainThread(false); |
| + } |
| + |
| + virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| + if (host_impl->settings().impl_side_painting) { |
| + // We block activation for several ticks to make sure that, even though |
| + // there is a pending tree with animations, we still do not background |
| + // tick if the active tree has a null root layer. |
| + if (host_impl->pending_tree()->source_frame_number() < 4) { |
| + base::MessageLoopProxy::current()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind( |
| + &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: |
|
danakj
2013/08/29 17:22:17
80 col. save the Bind() result in a callback befor
|
| + UnblockActivations, |
| + base::Unretained(this), |
| + host_impl), |
| + 4 * LowFrequencyAnimationInterval()); |
| + } |
| + } else { |
| + UnblockActivations(host_impl); |
|
danakj
2013/08/29 17:22:17
if (!impl paint) do this and early out? maybe tha
|
| + } |
| + } |
| + |
| + virtual void UnblockActivations(LayerTreeHostImpl* host_impl) { |
| + host_impl->BlockNotifyReadyToActivateForTesting(false); |
| + |
| + // Initiate the next commit after a delay to give us a chance to background |
| + // tick if the root layer isn't null. |
| + base::MessageLoopProxy::current()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind( |
| + &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: |
| + InitiateNextCommit, |
| + base::Unretained(this)), |
| + 4 * LowFrequencyAnimationInterval()); |
| + } |
| + |
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| + // Verify that we are actually alternating null root layers. |
| + switch (host_impl->active_tree()->source_frame_number()) { |
| + case 1: |
| + case 3: |
| + EXPECT_FALSE(host_impl->active_tree()->root_layer()); |
| + break; |
| + case 0: |
| + case 2: |
| + EXPECT_TRUE(host_impl->active_tree()->root_layer()); |
| + break; |
| + } |
| + } |
| + |
| + virtual void InitiateNextCommit() { |
|
danakj
2013/08/29 17:22:17
not virtual?
|
| + // The next commit is blocked until we become visible again. |
| + PostSetVisibleToMainThread(true); |
| + } |
| + |
| + virtual void WillAnimateLayers(LayerTreeHostImpl* host_impl, |
| + base::TimeTicks monotonic_time) OVERRIDE { |
| + EXPECT_TRUE(host_impl->active_tree()->root_layer()); |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE {} |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F( |
| + LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree); |
| + |
| // Ensure that an animation's timing function is respected. |
| class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
| : public LayerTreeHostAnimationTest { |