| 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 e9b877d0ba6b154e6c41aaf029d78519d0132b6a..75da696d1aaae3e883eb457e33b9e6ec783dbf14 100644
|
| --- a/cc/trees/layer_tree_host_unittest_animation.cc
|
| +++ b/cc/trees/layer_tree_host_unittest_animation.cc
|
| @@ -223,235 +223,6 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted
|
|
|
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted);
|
|
|
| -// Ensures that animations continue to be ticked when we are backgrounded.
|
| -class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded
|
| - : public LayerTreeHostAnimationTest {
|
| - public:
|
| - LayerTreeHostAnimationTestTickAnimationWhileBackgrounded()
|
| - : num_begin_frames_(0) {}
|
| -
|
| - void BeginTest() override {
|
| - PostAddLongAnimationToMainThread(layer_tree_host()->root_layer());
|
| - }
|
| -
|
| - // Use WillAnimateLayers to set visible false before the animation runs and
|
| - // causes a commit, so we block the second visible animate in single-thread
|
| - // mode.
|
| - void WillAnimateLayers(LayerTreeHostImpl* host_impl,
|
| - base::TimeTicks monotonic_time) override {
|
| - // Verify that the host can draw, it's just not visible.
|
| - EXPECT_TRUE(host_impl->CanDraw());
|
| - if (num_begin_frames_ < 2) {
|
| - if (!num_begin_frames_) {
|
| - // We have a long animation running. It should continue to tick even
|
| - // if we are not visible.
|
| - PostSetVisibleToMainThread(false);
|
| - }
|
| - num_begin_frames_++;
|
| - return;
|
| - }
|
| - EndTest();
|
| - }
|
| -
|
| - void AfterTest() override {}
|
| -
|
| - private:
|
| - int num_begin_frames_;
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(
|
| - LayerTreeHostAnimationTestTickAnimationWhileBackgrounded);
|
| -
|
| -// Ensures that animation time remains monotonic when we switch from foreground
|
| -// to background ticking and back, even if we're skipping draws due to
|
| -// checkerboarding when in the foreground.
|
| -class LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic
|
| - : public LayerTreeHostAnimationTest {
|
| - public:
|
| - LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic()
|
| - : has_background_ticked_(false), num_foreground_animates_(0) {}
|
| -
|
| - void InitializeSettings(LayerTreeSettings* settings) override {
|
| - // Make sure that drawing many times doesn't cause a checkerboarded
|
| - // animation to start so we avoid flake in this test.
|
| - settings->timeout_and_draw_when_animation_checkerboards = false;
|
| - }
|
| -
|
| - void BeginTest() override {
|
| - PostAddLongAnimationToMainThread(layer_tree_host()->root_layer());
|
| - }
|
| -
|
| - void AnimateLayers(LayerTreeHostImpl* host_impl,
|
| - base::TimeTicks monotonic_time) override {
|
| - EXPECT_GE(monotonic_time, last_tick_time_);
|
| - last_tick_time_ = monotonic_time;
|
| - if (host_impl->visible()) {
|
| - num_foreground_animates_++;
|
| - if (num_foreground_animates_ > 1 && !has_background_ticked_)
|
| - PostSetVisibleToMainThread(false);
|
| - else if (has_background_ticked_)
|
| - EndTest();
|
| - } else {
|
| - has_background_ticked_ = true;
|
| - PostSetVisibleToMainThread(true);
|
| - }
|
| - }
|
| -
|
| - DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
|
| - LayerTreeHostImpl::FrameData* frame,
|
| - DrawResult draw_result) override {
|
| - if (TestEnded())
|
| - return draw_result;
|
| - return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
|
| - }
|
| -
|
| - void AfterTest() override {}
|
| -
|
| - private:
|
| - bool has_background_ticked_;
|
| - int num_foreground_animates_;
|
| - base::TimeTicks last_tick_time_;
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(
|
| - LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic);
|
| -
|
| -// Ensures that animations do not tick when we are backgrounded and
|
| -// and we have an empty active tree.
|
| -class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree
|
| - : public LayerTreeHostAnimationTest {
|
| - protected:
|
| - LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree()
|
| - : active_tree_was_animated_(false) {}
|
| -
|
| - base::TimeDelta BackgroundAnimationInterval(LayerTreeHostImpl* host_impl) {
|
| - return base::TimeDelta::FromSecondsD(
|
| - 1.0 / host_impl->settings().background_animation_rate);
|
| - }
|
| -
|
| - void BeginTest() override {
|
| - PostAddAnimationToMainThread(layer_tree_host()->root_layer());
|
| - }
|
| -
|
| - void NotifyAnimationFinished(base::TimeTicks monotonic_time,
|
| - Animation::TargetProperty target_property,
|
| - int group) override {
|
| - // Replace animated commits with an empty tree.
|
| - layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL));
|
| - }
|
| -
|
| - void DidCommit() override {
|
| - // This alternates setting an empty tree and a non-empty tree with an
|
| - // animation.
|
| - switch (layer_tree_host()->source_frame_number()) {
|
| - case 1:
|
| - // Wait for NotifyAnimationFinished to commit an empty tree.
|
| - break;
|
| - case 2:
|
| - SetupTree();
|
| - AddOpacityTransitionToLayer(
|
| - layer_tree_host()->root_layer(), 0.000001, 0, 0.5, true);
|
| - break;
|
| - case 3:
|
| - // Wait for NotifyAnimationFinished to commit an empty tree.
|
| - break;
|
| - case 4:
|
| - EndTest();
|
| - break;
|
| - }
|
| - }
|
| -
|
| - void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
|
| - // At the start of every commit, block activations and make sure
|
| - // we are backgrounded.
|
| - if (host_impl->settings().impl_side_painting)
|
| - host_impl->BlockNotifyReadyToActivateForTesting(true);
|
| - PostSetVisibleToMainThread(false);
|
| - }
|
| -
|
| - void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
|
| - if (!host_impl->settings().impl_side_painting) {
|
| - // There are no activations to block if we're not impl-side-painting,
|
| - // so just advance the test immediately.
|
| - if (host_impl->active_tree()->source_frame_number() < 3)
|
| - UnblockActivations(host_impl);
|
| - return;
|
| - }
|
| -
|
| - // 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 is empty.
|
| - if (host_impl->pending_tree()->source_frame_number() < 3) {
|
| - base::MessageLoopProxy::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(
|
| - &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
|
| - UnblockActivations,
|
| - base::Unretained(this), host_impl),
|
| - 4 * BackgroundAnimationInterval(host_impl));
|
| - }
|
| - }
|
| -
|
| - virtual void UnblockActivations(LayerTreeHostImpl* host_impl) {
|
| - if (host_impl->settings().impl_side_painting)
|
| - host_impl->BlockNotifyReadyToActivateForTesting(false);
|
| - }
|
| -
|
| - void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
|
| - active_tree_was_animated_ = false;
|
| -
|
| - // Verify that commits are actually alternating with empty / non-empty
|
| - // trees.
|
| - int frame_number = host_impl->active_tree()->source_frame_number();
|
| - switch (frame_number) {
|
| - case 0:
|
| - case 2:
|
| - EXPECT_TRUE(host_impl->active_tree()->root_layer())
|
| - << "frame: " << frame_number;
|
| - break;
|
| - case 1:
|
| - case 3:
|
| - EXPECT_FALSE(host_impl->active_tree()->root_layer())
|
| - << "frame: " << frame_number;
|
| - break;
|
| - }
|
| -
|
| - if (host_impl->active_tree()->source_frame_number() < 3) {
|
| - // Initiate the next commit after a delay to give us a chance to
|
| - // background tick if the active tree isn't empty.
|
| - base::MessageLoopProxy::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(
|
| - &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
|
| - InitiateNextCommit,
|
| - base::Unretained(this), host_impl),
|
| - 4 * BackgroundAnimationInterval(host_impl));
|
| - }
|
| - }
|
| -
|
| - void WillAnimateLayers(LayerTreeHostImpl* host_impl,
|
| - base::TimeTicks monotonic_time) override {
|
| - EXPECT_TRUE(host_impl->active_tree()->root_layer());
|
| - active_tree_was_animated_ = true;
|
| - }
|
| -
|
| - void InitiateNextCommit(LayerTreeHostImpl* host_impl) {
|
| - // Verify that we actually animated when we should have.
|
| - bool has_active_tree = host_impl->active_tree()->root_layer();
|
| - EXPECT_EQ(has_active_tree, active_tree_was_animated_);
|
| -
|
| - // The next commit is blocked until we become visible again.
|
| - PostSetVisibleToMainThread(true);
|
| - }
|
| -
|
| - void AfterTest() override {}
|
| -
|
| - bool active_tree_was_animated_;
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
|
| - LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree);
|
| -
|
| // Ensure that an animation's timing function is respected.
|
| class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
|
| : public LayerTreeHostAnimationTest {
|
|
|