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

Unified Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2843293004: 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
« 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 ead11c253f6c5507793f2c8ad8bec459f424bb75..ebb22757703d1ffd67689a7f7527dc79809c3bb4 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 {
@@ -115,8 +114,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_, kFadeDelay,
+ kResizeFadeOutDelay, kFadeDuration, kThinningDuration);
}
FakeImplTaskRunnerProvider task_runner_provider_;
@@ -216,13 +215,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);
@@ -245,13 +244,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);
@@ -269,7 +268,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());
@@ -310,7 +309,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());
@@ -352,7 +351,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
@@ -380,7 +379,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
@@ -416,7 +415,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());
@@ -453,7 +452,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());
@@ -504,7 +503,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());
@@ -543,7 +542,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();
@@ -551,7 +550,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);
@@ -582,7 +581,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();
@@ -590,7 +589,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
ExpectScrollbarsOpacity(1);
// Fade the scrollbar out completely.
- time += kFadeOutDuration;
+ time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
@@ -661,7 +660,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());
@@ -680,7 +679,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();
@@ -691,7 +690,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
@@ -712,7 +711,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.
@@ -729,7 +728,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();
@@ -737,11 +736,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);
}
@@ -767,20 +766,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);
@@ -885,7 +884,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.
@@ -977,7 +976,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
@@ -1003,111 +1002,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