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

Unified Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2816923002: change overlay scrollbar hover show to hover fade in (Closed)
Patch Set: combine fade_in_delay and fade_out_delay to fade_delay 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
« no previous file with comments | « cc/input/scrollbar_animation_controller.cc ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9c2572a5dd5e56ad7c57418ee3569cb70eb08bd6..663238e14b9fd1a1a63e074486bfba8f83685f0d 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
@@ -70,10 +70,9 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
}
protected:
- const base::TimeDelta kShowDelay = base::TimeDelta::FromSeconds(4);
- const base::TimeDelta kFadeOutDelay = base::TimeDelta::FromSeconds(2);
+ const base::TimeDelta kFadeDelay = base::TimeDelta::FromSeconds(4);
const base::TimeDelta kResizeFadeOutDelay = base::TimeDelta::FromSeconds(5);
- const base::TimeDelta kFadeOutDuration = base::TimeDelta::FromSeconds(3);
+ const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3);
const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
void SetUp() override {
@@ -119,8 +118,8 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
scrollbar_controller_ = ScrollbarAnimationController::
CreateScrollbarAnimationControllerAuraOverlay(
- scroll_layer_ptr->element_id(), &client_, kShowDelay, kFadeOutDelay,
- kResizeFadeOutDelay, kFadeOutDuration, kThinningDuration);
+ scroll_layer_ptr->element_id(), &client_, kFadeDelay,
+ kResizeFadeOutDelay, kFadeDuration, kThinningDuration);
}
FakeImplTaskRunnerProvider task_runner_provider_;
@@ -220,13 +219,13 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) {
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
client_.start_fade().Run();
- // Scrollbar should fade out over kFadeOutDuration.
+ // Scrollbar should fade out over kFadeDuration.
scrollbar_controller_->Animate(time);
- time += kFadeOutDuration;
+ time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
@@ -249,13 +248,13 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
client_.start_fade().Run();
- // Scrollbar should fade out over kFadeOutDuration.
+ // Scrollbar should fade out over kFadeDuration.
scrollbar_controller_->Animate(time);
- time += kFadeOutDuration;
+ time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
@@ -273,7 +272,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) {
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
@@ -314,7 +313,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) {
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
@@ -356,7 +355,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
// Now move the mouse over the scrollbar and capture it. It should become
@@ -384,7 +383,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
// Now move the mouse over the scrollbar and capture it. It should become
@@ -420,7 +419,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) {
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
@@ -457,7 +456,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) {
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
@@ -508,7 +507,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) {
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
@@ -547,7 +546,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
scrollbar_controller_->DidScrollEnd();
// A fade out animation should have been enqueued. Start it.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
client_.start_fade().Run();
@@ -555,7 +554,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
ExpectScrollbarsOpacity(1);
// Proceed half way through the fade out animation.
- time += kFadeOutDuration / 2;
+ time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.5f);
@@ -586,7 +585,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
client_.start_fade().Run();
@@ -594,7 +593,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
ExpectScrollbarsOpacity(1);
// Fade the scrollbar out completely.
- time += kFadeOutDuration;
+ time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
@@ -665,7 +664,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) {
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Scrollbar should still be thick and visible.
- time += kFadeOutDuration;
+ time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
@@ -684,7 +683,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
// (which will never come).
scrollbar_controller_->DidScrollUpdate();
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
client_.start_fade().Reset();
@@ -695,7 +694,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
EXPECT_TRUE(client_.start_fade().is_null());
scrollbar_controller_->DidScrollEnd();
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
}
// Make sure that if the scroll update is as a result of a resize, we use the
@@ -716,7 +715,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) {
scrollbar_controller_->DidScrollEnd();
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
}
// Tests that the fade effect is animated.
@@ -733,7 +732,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) {
ExpectScrollbarsOpacity(1);
// An fade out animation should have been enqueued.
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
client_.start_fade().Run();
@@ -741,11 +740,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) {
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
- time += kFadeOutDuration / 2;
+ time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.5f);
- time += kFadeOutDuration / 2;
+ time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
}
@@ -771,20 +770,20 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) {
ASSERT_FALSE(client_.start_fade().is_null());
client_.start_fade().Run();
scrollbar_controller_->Animate(time);
- time += kFadeOutDuration / 4;
+ time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
- time += kFadeOutDuration / 4;
+ time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
- time += kFadeOutDuration / 4;
+ time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.25f);
Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
- time += kFadeOutDuration / 4;
+ time += kFadeDuration / 4;
scrollbar_controller_->Animate(time);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
ExpectScrollbarsOpacity(0);
@@ -889,7 +888,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) {
// An fade out animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
}
// Move mouse near both scrollbars at the same time.
@@ -981,7 +980,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
// An fade out animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, client_.delay());
}
// Ensure we have a delay fadeout animation after mouse leave without a mouse
@@ -1007,111 +1006,128 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) {
// An fade out animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
- EXPECT_EQ(kFadeOutDelay, client_.delay());
+ EXPECT_EQ(kFadeDelay, 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());
+ EXPECT_EQ(kFadeDelay, client_.delay());
// Play the delay animation.
client_.start_fade().Run();
EXPECT_TRUE(client_.start_fade().IsCancelled());
+
+ scrollbar_controller_->Animate(time);
+ time += kFadeDuration / 2;
+ scrollbar_controller_->Animate(time);
+
+ ExpectScrollbarsOpacity(0.5);
+ EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
+
+ time += kFadeDuration / 2;
+ scrollbar_controller_->Animate(time);
+
+ ExpectScrollbarsOpacity(1);
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());
+ EXPECT_EQ(kFadeDelay, client_.delay());
base::Closure& fade = client_.start_fade();
- // Move mouse still hover the show scrollbar region of scrollbar should not
- // post a new show.
- scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow - 2);
+ // Move mouse still hover the fade in scrollbar region of scrollbar should not
+ // post a new fade in.
+ scrollbar_controller_->DidMouseMoveNear(
+ VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 2);
EXPECT_TRUE(fade.Equals(client_.start_fade()));
}
-// Scrollbars should cancel delay show when mouse hover hidden scrollbar then
+// Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
// move far away.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
- MouseHoverThenOutShouldCancelShow) {
+ MouseHoverThenOutShouldCancelFadeIn) {
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());
+ EXPECT_EQ(kFadeDelay, client_.delay());
- // Move mouse far away,delay show should be canceled.
+ // Move mouse far away,delay fade in should be canceled.
scrollbar_controller_->DidMouseMoveNear(VERTICAL,
- kMouseMoveDistanceToTriggerShow);
+ kMouseMoveDistanceToTriggerFadeIn);
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
-// Scrollbars should cancel delay show when mouse hover hidden scrollbar then
+// Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
// move out of window.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
- MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) {
+ MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) {
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());
+ EXPECT_EQ(kFadeDelay, client_.delay());
- // Move mouse out of window,delay show should be canceled.
+ // Move mouse out of window,delay fade in should be canceled.
scrollbar_controller_->DidMouseLeave();
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());
+ EXPECT_EQ(kFadeDelay, client_.delay());
// Play the delay animation.
client_.start_fade().Run();
EXPECT_TRUE(client_.start_fade().IsCancelled());
+
+ scrollbar_controller_->Animate(time);
+ time += kFadeDuration;
+ scrollbar_controller_->Animate(time);
+
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
}
« no previous file with comments | « cc/input/scrollbar_animation_controller.cc ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698