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

Unified Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2816923002: change overlay scrollbar hover show to hover fade in (Closed)
Patch Set: Created 3 years, 8 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
Index: cc/input/scrollbar_animation_controller_unittest.cc
diff --git a/cc/input/scrollbar_animation_controller_unittest.cc b/cc/input/scrollbar_animation_controller_unittest.cc
index ead11c253f6c5507793f2c8ad8bec459f424bb75..1003cc13c057d2e553013509c4dbe9f3f1f07205 100644
--- a/cc/input/scrollbar_animation_controller_unittest.cc
+++ b/cc/input/scrollbar_animation_controller_unittest.cc
@@ -26,8 +26,8 @@ const float kIdleThicknessScale =
const float kDefaultMouseMoveDistanceToTriggerAnimation =
SingleScrollbarAnimationControllerThinning::
kDefaultMouseMoveDistanceToTriggerAnimation;
-const float kMouseMoveDistanceToTriggerShow =
- ScrollbarAnimationController::kMouseMoveDistanceToTriggerShow;
+const float kMouseMoveDistanceToTriggerFadeIn =
+ ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
const int kThumbThickness = 10;
class MockScrollbarAnimationControllerClient
@@ -73,6 +73,7 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
const base::TimeDelta kShowDelay = base::TimeDelta::FromSeconds(4);
const base::TimeDelta kFadeOutDelay = base::TimeDelta::FromSeconds(2);
const base::TimeDelta kResizeFadeOutDelay = base::TimeDelta::FromSeconds(5);
+ const base::TimeDelta kFadeInDuration = base::TimeDelta::FromSeconds(3);
const base::TimeDelta kFadeOutDuration = base::TimeDelta::FromSeconds(3);
const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
@@ -116,7 +117,8 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
scrollbar_controller_ = ScrollbarAnimationController::
CreateScrollbarAnimationControllerAuraOverlay(
scroll_layer_ptr->id(), &client_, kShowDelay, kFadeOutDelay,
- kResizeFadeOutDelay, kFadeOutDuration, kThinningDuration);
+ kResizeFadeOutDelay, kFadeInDuration, kFadeOutDuration,
+ kThinningDuration);
}
FakeImplTaskRunnerProvider task_runner_provider_;
@@ -1006,17 +1008,17 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) {
EXPECT_EQ(kFadeOutDelay, client_.delay());
}
-// Scrollbars should schedule a delay show when mouse hover the show scrollbar
-// region of a hidden scrollbar.
-TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) {
+// Scrollbars should schedule a delay fade in when mouse hover the show
+// scrollbar region of a hidden scrollbar.
+TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- // Move mouse hover the show scrollbar region of scrollbar.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 1);
+ // Move mouse hover the fade in scrollbar region of scrollbar.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1);
- // An show animation should have been enqueued.
+ // An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kShowDelay, client_.delay());
@@ -1024,30 +1026,35 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) {
// Play the delay animation.
client_.start_fade().Run();
EXPECT_TRUE(client_.start_fade().IsCancelled());
+
+ scrollbar_controller_->Animate(time);
+ time += kFadeInDuration;
bokan 2017/04/13 14:38:14 Please add a step in here before the animation fin
chaopeng 2017/04/13 15:15:37 Done.
+ scrollbar_controller_->Animate(time);
+
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
}
-// Scrollbars should not schedule a new delay show when the mouse hovers inside
-// a scrollbar already scheduled a delay show.
+// Scrollbars should not schedule a new delay fade in when the mouse hovers
+// inside a scrollbar already scheduled a delay fade in.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
MouseHoverScrollbarAndMoveInside) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- // Move mouse hover the show scrollbar region of scrollbar.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 1);
+ // Move mouse hover the fade in scrollbar region of scrollbar.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1);
- // An show animation should have been enqueued.
+ // An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kShowDelay, client_.delay());
base::Closure& fade = client_.start_fade();
- // Move mouse still hover the show scrollbar region of scrollbar should not
+ // Move mouse still hover the fade in scrollbar region of scrollbar should not
// post a new show.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 2);
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 2);
EXPECT_TRUE(fade.Equals(client_.start_fade()));
}
@@ -1059,18 +1066,18 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- // Move mouse hover the show scrollbar region of scrollbar.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 1);
+ // Move mouse hover the fade in scrollbar region of scrollbar.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1);
- // An show animation should have been enqueued.
+ // An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kShowDelay, client_.delay());
// Move mouse far away,delay show should be canceled.
scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow);
+ kMouseMoveDistanceToTriggerFadeIn);
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
@@ -1082,11 +1089,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- // Move mouse hover the show scrollbar region of scrollbar.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 1);
+ // Move mouse hover the fade in scrollbar region of scrollbar.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1);
- // An show animation should have been enqueued.
+ // An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kShowDelay, client_.delay());
@@ -1096,11 +1103,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
- // Move mouse hover the show scrollbar region of scrollbar.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 1);
+ // Move mouse hover the fade in scrollbar region of scrollbar.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1);
- // An show animation should have been enqueued.
+ // An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kShowDelay, client_.delay());
@@ -1108,6 +1115,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
// Play the delay animation.
client_.start_fade().Run();
EXPECT_TRUE(client_.start_fade().IsCancelled());
+
+ scrollbar_controller_->Animate(time);
+ time += kFadeInDuration;
+ scrollbar_controller_->Animate(time);
+
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
}

Powered by Google App Engine
This is Rietveld 408576698