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

Unified Diff: cc/scrollbar_animation_controller_linear_fade_unittest.cc

Issue 12408028: cc: Delay start of scrollbar animation setNeedsRedraw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to 188682 Created 7 years, 9 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/scrollbar_animation_controller_linear_fade.cc ('k') | cc/single_thread_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scrollbar_animation_controller_linear_fade_unittest.cc
diff --git a/cc/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
index e3c2c230f16c1ab0f67d28e6d32ba2cb10de8377..05131908819199639b31b1b11dffafbe52b98e04 100644
--- a/cc/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -32,7 +32,7 @@ protected:
m_scrollLayer->SetBounds(gfx::Size(50, 50));
m_scrollLayer->SetHorizontalScrollbarLayer(m_scrollbarLayer.get());
- m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), 2, 3);
+ m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), base::TimeDelta::FromSeconds(2), base::TimeDelta::FromSeconds(3));
}
FakeImplProxy m_proxy;
@@ -49,18 +49,23 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
}
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScrollGesture)
{
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didUpdateScrollOffset(time);
- m_scrollbarController->animate(time);
+ m_scrollbarController->didScrollGestureBegin();
+ EXPECT_TRUE(m_scrollbarController->isScrollGestureInProgress());
+ EXPECT_FALSE(m_scrollbarController->isAnimating());
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- time += base::TimeDelta::FromSeconds(1);
+ time += base::TimeDelta::FromSeconds(100);
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- m_scrollbarController->didUpdateScrollOffset(time);
+ m_scrollbarController->didScrollGestureEnd(time);
+
+ EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
+ EXPECT_TRUE(m_scrollbarController->isAnimating());
+ EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
@@ -79,7 +84,10 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didUpdateScrollOffset(time);
+
+ m_scrollbarController->didScrollGestureBegin();
+ m_scrollbarController->didScrollGestureEnd(time);
+
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -101,22 +109,21 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
}
-TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByProgrammaticScroll)
{
base::TimeTicks time;
- m_scrollbarController->didPinchGestureUpdate(time);
- m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
-
time += base::TimeDelta::FromSeconds(1);
+ m_scrollbarController->didProgrammaticallyUpdateScroll(time);
+ EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
+ EXPECT_TRUE(m_scrollbarController->isAnimating());
+ EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
- m_scrollbarController->didUpdateScrollOffset(time);
- m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->didProgrammaticallyUpdateScroll(time);
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
@@ -128,14 +135,15 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
- m_scrollbarController->didPinchGestureEnd(time);
+ m_scrollbarController->didProgrammaticallyUpdateScroll(time);
+ time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -143,18 +151,17 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- time += base::TimeDelta::FromSeconds(2);
+ time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
+ EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
- EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
+ EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
time += base::TimeDelta::FromSeconds(1);
m_scrollbarController->animate(time);
EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
-
}
} // namespace
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade.cc ('k') | cc/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698