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

Unified Diff: cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc

Issue 23978008: Suppress scrollbar animation if the scroll gesture does not scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayerTreeHostImpl unit tests Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/scrollbar_animation_controller_linear_fade.cc ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
index 4a11ba6bd23c70add9a7e0c4f02b32f1db7d5b20..4e0dab9d2ff23b0c56a03c4c4dc0d572f256ed86 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -44,20 +44,43 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) {
EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
}
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollGesture) {
+TEST_F(ScrollbarAnimationControllerLinearFadeTest,
+ HiddenAfterNonScrollingGesture) {
+ scrollbar_controller_->DidScrollGestureBegin();
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
+ EXPECT_FALSE(scrollbar_controller_->Animate(base::TimeTicks()));
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(100);
+ EXPECT_FALSE(scrollbar_controller_->Animate(time));
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+ scrollbar_controller_->DidScrollGestureEnd(time);
+
+ time += base::TimeDelta::FromSeconds(100);
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
+ EXPECT_FALSE(scrollbar_controller_->Animate(time));
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+}
+
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollingGesture) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollGestureBegin();
- EXPECT_TRUE(scrollbar_controller_->IsScrollGestureInProgress());
+ scrollbar_controller_->Animate(time);
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollUpdate(time);
EXPECT_FALSE(scrollbar_controller_->IsAnimating());
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
time += base::TimeDelta::FromSeconds(100);
scrollbar_controller_->Animate(time);
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
scrollbar_controller_->DidScrollGestureEnd(time);
- EXPECT_FALSE(scrollbar_controller_->IsScrollGestureInProgress());
EXPECT_TRUE(scrollbar_controller_->IsAnimating());
EXPECT_EQ(2, scrollbar_controller_->DelayBeforeStart(time).InSeconds());
@@ -80,6 +103,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollGesture) {
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollGestureBegin();
+ scrollbar_controller_->DidScrollUpdate(time);
scrollbar_controller_->DidScrollGestureEnd(time);
time += base::TimeDelta::FromSeconds(1);
@@ -106,8 +130,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollGesture) {
TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
- EXPECT_FALSE(scrollbar_controller_->IsScrollGestureInProgress());
+ scrollbar_controller_->DidScrollUpdate(time);
EXPECT_TRUE(scrollbar_controller_->IsAnimating());
EXPECT_EQ(2, scrollbar_controller_->DelayBeforeStart(time).InSeconds());
scrollbar_controller_->Animate(time);
@@ -116,7 +139,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
- scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
+ scrollbar_controller_->DidScrollUpdate(time);
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->Animate(time);
@@ -135,7 +158,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidProgrammaticallyUpdateScroll(time);
+ scrollbar_controller_->DidScrollUpdate(time);
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
@@ -157,5 +180,67 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
}
+TEST_F(ScrollbarAnimationControllerLinearFadeTest,
+ AnimationPreservedByNonScrollingGesture) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollUpdate(time);
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(3);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollGestureBegin();
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollGestureEnd(time);
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ EXPECT_FALSE(scrollbar_controller_->Animate(time));
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+}
+
+TEST_F(ScrollbarAnimationControllerLinearFadeTest,
+ AnimationOverriddenByScrollingGesture) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollUpdate(time);
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(3);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollGestureBegin();
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollUpdate(time);
+ EXPECT_FALSE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollGestureEnd(time);
+ EXPECT_TRUE(scrollbar_controller_->IsAnimating());
+ EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/animation/scrollbar_animation_controller_linear_fade.cc ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698