| 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..1dd33d5a6cbf1527fae2a79e23151984346544d3 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,9 +70,10 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
|
| }
|
|
|
| protected:
|
| - const base::TimeDelta kShowDelay = base::TimeDelta::FromSeconds(4);
|
| + const base::TimeDelta kFadeInDelay = 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);
|
|
|
| @@ -115,8 +116,9 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
|
|
|
| scrollbar_controller_ = ScrollbarAnimationController::
|
| CreateScrollbarAnimationControllerAuraOverlay(
|
| - scroll_layer_ptr->id(), &client_, kShowDelay, kFadeOutDelay,
|
| - kResizeFadeOutDelay, kFadeOutDuration, kThinningDuration);
|
| + scroll_layer_ptr->id(), &client_, kFadeInDelay, kFadeOutDelay,
|
| + 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,83 +1026,95 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) {
|
| // Play the delay animation.
|
| client_.start_fade().Run();
|
| EXPECT_TRUE(client_.start_fade().IsCancelled());
|
| +
|
| + scrollbar_controller_->Animate(time);
|
| + time += kFadeInDuration / 2;
|
| + scrollbar_controller_->Animate(time);
|
| +
|
| + ExpectScrollbarsOpacity(0.5);
|
| + EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
|
| +
|
| + time += kFadeInDuration / 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());
|
|
|
| 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());
|
|
|
| - // 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());
|
|
|
| - // 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());
|
| @@ -1108,6 +1122,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());
|
| }
|
|
|
|
|