Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: cc/animation/element_animations_unittest.cc

Issue 2251933002: Fix smooth scroll animation flake on janky pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UpdateTarget while animation is not started Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include "cc/animation/animation_delegate.h" 7 #include "cc/animation/animation_delegate.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_id_provider.h" 9 #include "cc/animation/animation_id_provider.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 939
940 animations_impl->Animate(kInitialTickTime + duration); 940 animations_impl->Animate(kInitialTickTime + duration);
941 animations_impl->UpdateState(true, events.get()); 941 animations_impl->UpdateState(true, events.get());
942 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( 942 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset(
943 element_id_, ElementListType::ACTIVE)); 943 element_id_, ElementListType::ACTIVE));
944 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 944 EXPECT_FALSE(animations_impl->HasActiveAnimation());
945 event = GetMostRecentPropertyUpdateEvent(events.get()); 945 event = GetMostRecentPropertyUpdateEvent(events.get());
946 EXPECT_FALSE(event); 946 EXPECT_FALSE(event);
947 } 947 }
948 948
949 // This test verifies that if an animation is added after a layer is animated,
950 // it doesn't get promoted to be in the RUNNING state. This prevents cases where
951 // a start time gets set on an animation using the stale value of
952 // last_tick_time_.
953 TEST_F(ElementAnimationsTest, UpdateStateWithoutAnimate) {
954 CreateTestLayer(true, false);
955 AttachTimelinePlayerLayer();
956 CreateImplTimelineAndPlayer();
957
958 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
959
960 auto events = host_impl_->CreateEvents();
961
962 // Add first scroll offset animation.
963 AddScrollOffsetAnimationToElementAnimations(
964 animations_impl.get(), gfx::ScrollOffset(100.f, 300.f),
965 gfx::ScrollOffset(100.f, 200.f), true);
966
967 // Calling UpdateState after Animate should promote the animation to running
968 // state.
969 animations_impl->Animate(kInitialTickTime);
970 animations_impl->UpdateState(true, events.get());
971 EXPECT_EQ(Animation::RUNNING,
972 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
973 ->run_state());
974
975 animations_impl->Animate(kInitialTickTime +
976 TimeDelta::FromMilliseconds(1500));
977 animations_impl->UpdateState(true, events.get());
978 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
979 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
980 ->run_state());
981
982 // Add second scroll offset animation.
983 AddScrollOffsetAnimationToElementAnimations(
984 animations_impl.get(), gfx::ScrollOffset(100.f, 200.f),
985 gfx::ScrollOffset(100.f, 100.f), true);
986
987 // Calling UpdateState without Animate should NOT promote the animation to
988 // running state.
989 animations_impl->UpdateState(true, events.get());
990 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
991 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
992 ->run_state());
993
994 animations_impl->Animate(kInitialTickTime +
995 TimeDelta::FromMilliseconds(2000));
996 animations_impl->UpdateState(true, events.get());
997
998 EXPECT_EQ(Animation::RUNNING,
999 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
1000 ->run_state());
1001 EXPECT_VECTOR2DF_EQ(
1002 gfx::ScrollOffset(100.f, 200.f),
1003 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
1004 }
1005
949 // Ensure that when the impl animations doesn't have a value provider, 1006 // Ensure that when the impl animations doesn't have a value provider,
950 // the main-thread animations's value provider is used to obtain the intial 1007 // the main-thread animations's value provider is used to obtain the intial
951 // scroll offset. 1008 // scroll offset.
952 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) { 1009 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) {
953 CreateTestLayer(false, false); 1010 CreateTestLayer(false, false);
954 CreateTestImplLayer(ElementListType::PENDING); 1011 CreateTestImplLayer(ElementListType::PENDING);
955 AttachTimelinePlayerLayer(); 1012 AttachTimelinePlayerLayer();
956 CreateImplTimelineAndPlayer(); 1013 CreateImplTimelineAndPlayer();
957 1014
958 scoped_refptr<ElementAnimations> animations = element_animations(); 1015 scoped_refptr<ElementAnimations> animations = element_animations();
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3735 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3679 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3736 TargetProperty::OPACITY, ElementListType::ACTIVE));
3680 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3737 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3681 TargetProperty::OPACITY, ElementListType::PENDING)); 3738 TargetProperty::OPACITY, ElementListType::PENDING));
3682 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3739 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3683 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3740 TargetProperty::OPACITY, ElementListType::ACTIVE));
3684 } 3741 }
3685 3742
3686 } // namespace 3743 } // namespace
3687 } // namespace cc 3744 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698