| 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 76026013c34c452b9e90fff0ccde6990a38f1aa0..2354335494398a560a361a399052a32720af9a61 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,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 kFadeOutDuration = base::TimeDelta::FromSeconds(3);
|
| + const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3);
|
| const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
|
|
|
| void SetUp() override {
|
| @@ -117,8 +117,8 @@ 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, kFadeDuration, kThinningDuration);
|
| }
|
|
|
| FakeImplTaskRunnerProvider task_runner_provider_;
|
| @@ -222,9 +222,9 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) {
|
| 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);
|
| @@ -251,9 +251,9 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
|
| 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);
|
| @@ -553,7 +553,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);
|
|
|
| @@ -592,7 +592,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
|
| ExpectScrollbarsOpacity(1);
|
|
|
| // Fade the scrollbar out completely.
|
| - time += kFadeOutDuration;
|
| + time += kFadeDuration;
|
| scrollbar_controller_->Animate(time);
|
| ExpectScrollbarsOpacity(0);
|
|
|
| @@ -663,7 +663,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());
|
| @@ -739,11 +739,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);
|
| }
|
| @@ -769,20 +769,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);
|
| @@ -1008,108 +1008,125 @@ 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());
|
| + EXPECT_EQ(kFadeInDelay, 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(kFadeInDelay, 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(kFadeInDelay, 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(kFadeInDelay, 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(kFadeInDelay, 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());
|
| }
|
|
|
|
|