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 9e8487d0f2e104c66d17436aef868060420c7113..4ece3c5c448b64d5178414883b3b2b6f85a3bf0e 100644 |
--- a/cc/input/scrollbar_animation_controller_unittest.cc |
+++ b/cc/input/scrollbar_animation_controller_unittest.cc |
@@ -67,10 +67,10 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test { |
} |
protected: |
- const base::TimeDelta kDelayBeforeStarting = base::TimeDelta::FromSeconds(2); |
- const base::TimeDelta kResizeDelayBeforeStarting = |
- base::TimeDelta::FromSeconds(5); |
- const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3); |
+ 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 kThinningDuration = base::TimeDelta::FromSeconds(2); |
void SetUp() override { |
@@ -113,8 +113,8 @@ class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test { |
scrollbar_controller_ = ScrollbarAnimationController:: |
CreateScrollbarAnimationControllerAuraOverlay( |
- scroll_layer_ptr->id(), &client_, kDelayBeforeStarting, |
- kResizeDelayBeforeStarting, kFadeDuration, kThinningDuration); |
+ scroll_layer_ptr->id(), &client_, kFadeInDelay, kFadeOutDelay, |
+ kResizeFadeOutDelay, kFadeOutDuration, kThinningDuration); |
} |
FakeImplTaskRunnerProvider task_runner_provider_; |
@@ -213,14 +213,14 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { |
ExpectScrollbarsOpacity(1); |
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
client_.start_fade().Run(); |
- // Scrollbar should fade out over kFadeDuration. |
+ // Scrollbar should fade out over kFadeOutDuration. |
scrollbar_controller_->Animate(time); |
- time += kFadeDuration; |
+ time += kFadeOutDuration; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(0); |
@@ -237,8 +237,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
@@ -262,8 +262,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
// Mouse is still near the Scrollbar. Once the thickness animation is |
- // complete, the queued delayed fade animation should be either cancelled or |
- // null. |
+ // complete, the queued delayed fade out animation should be either cancelled |
+ // or null. |
EXPECT_TRUE(client_.start_fade().is_null() || |
client_.start_fade().IsCancelled()); |
} |
@@ -278,8 +278,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
@@ -303,8 +303,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
// Mouse is still over the Scrollbar. Once the thickness animation is |
- // complete, the queued delayed fade animation should be either cancelled or |
- // null. |
+ // complete, the queued delayed fade out animation should be either cancelled |
+ // or null. |
EXPECT_TRUE(client_.start_fade().is_null() || |
client_.start_fade().IsCancelled()); |
} |
@@ -320,8 +320,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
// Now move the mouse over the scrollbar and capture it. It should become |
@@ -333,7 +333,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
EXPECT_FLOAT_EQ(kIdleThicknessScale, |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
- // The fade animation should have been cleared or cancelled. |
+ // The fade out animation should have been cleared or cancelled. |
EXPECT_TRUE(client_.start_fade().is_null() || |
client_.start_fade().IsCancelled()); |
} |
@@ -348,8 +348,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
// Now move the mouse over the scrollbar and capture it. It should become |
@@ -361,11 +361,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
EXPECT_FLOAT_EQ(kIdleThicknessScale, |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
- // The fade animation should have been cleared or cancelled. |
+ // The fade out animation should have been cleared or cancelled. |
EXPECT_TRUE(client_.start_fade().is_null() || |
client_.start_fade().IsCancelled()); |
- // Then move mouse away, The fade animation should have been cleared or |
+ // Then move mouse away, The fade out animation should have been cleared or |
// cancelled. |
scrollbar_controller_->DidMouseMoveNear( |
VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); |
@@ -384,8 +384,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
@@ -404,7 +404,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { |
EXPECT_TRUE(client_.start_fade().is_null() || |
client_.start_fade().IsCancelled()); |
- // Make sure the queued fade animation is still null or cancelled after |
+ // Make sure the queued fade out animation is still null or cancelled after |
// capturing the scrollbar. |
scrollbar_controller_->DidMouseDown(); |
EXPECT_TRUE(client_.start_fade().is_null() || |
@@ -421,8 +421,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
@@ -472,8 +472,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
@@ -511,8 +511,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- // A fade animation should have been enqueued. Start it. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // A fade out animation should have been enqueued. Start it. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
client_.start_fade().Run(); |
@@ -520,7 +520,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
ExpectScrollbarsOpacity(1); |
// Proceed half way through the fade out animation. |
- time += kFadeDuration / 2; |
+ time += kFadeOutDuration / 2; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(.5f); |
@@ -551,7 +551,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { |
scrollbar_controller_->DidScrollUpdate(false); |
scrollbar_controller_->DidScrollEnd(); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
EXPECT_FALSE(client_.start_fade().IsCancelled()); |
client_.start_fade().Run(); |
@@ -559,7 +559,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { |
ExpectScrollbarsOpacity(1); |
// Fade the scrollbar out completely. |
- time += kFadeDuration; |
+ time += kFadeOutDuration; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(0); |
@@ -630,7 +630,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) { |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
// Scrollbar should still be thick and visible. |
- time += kFadeDuration; |
+ time += kFadeOutDuration; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(1); |
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
@@ -638,29 +638,29 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) { |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
} |
-// Tests that main thread scroll updates immediatley queue a fade animation |
+// Tests that main thread scroll updates immediatley queue a fade out animation |
// without requiring a ScrollEnd. |
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
MainThreadScrollQueuesFade) { |
ASSERT_TRUE(client_.start_fade().is_null()); |
// A ScrollUpdate without a ScrollBegin indicates a main thread scroll update |
- // so we should schedule a fade animation without waiting for a ScrollEnd |
+ // so we should schedule a fade out animation without waiting for a ScrollEnd |
// (which will never come). |
scrollbar_controller_->DidScrollUpdate(false); |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
client_.start_fade().Reset(); |
- // If we got a ScrollBegin, we shouldn't schedule the fade animation until we |
- // get a corresponding ScrollEnd. |
+ // If we got a ScrollBegin, we shouldn't schedule the fade out animation until |
+ // we get a corresponding ScrollEnd. |
scrollbar_controller_->DidScrollBegin(); |
scrollbar_controller_->DidScrollUpdate(false); |
EXPECT_TRUE(client_.start_fade().is_null()); |
scrollbar_controller_->DidScrollEnd(); |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
} |
// Make sure that if the scroll update is as a result of a resize, we use the |
@@ -670,7 +670,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { |
scrollbar_controller_->DidScrollUpdate(true); |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kResizeDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kResizeFadeOutDelay, client_.delay()); |
client_.delay() = base::TimeDelta(); |
@@ -681,7 +681,7 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { |
scrollbar_controller_->DidScrollEnd(); |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
} |
// Tests that the fade effect is animated. |
@@ -697,8 +697,8 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { |
// Appearance is instant. |
ExpectScrollbarsOpacity(1); |
- // An animation should have been enqueued. |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ // An fade out animation should have been enqueued. |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
EXPECT_FALSE(client_.start_fade().is_null()); |
client_.start_fade().Run(); |
@@ -706,11 +706,11 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(1); |
- time += kFadeDuration / 2; |
+ time += kFadeOutDuration / 2; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(.5f); |
- time += kFadeDuration / 2; |
+ time += kFadeOutDuration / 2; |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(0); |
} |
@@ -729,27 +729,27 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { |
scrollbar_controller_->DidScrollEnd(); |
- // Play out the fade animation. We shouldn't notify that the scrollbars are |
- // hidden until the animation is completly over. We can (but don't have to) |
- // notify during the animation that the scrollbars are still visible. |
+ // Play out the fade out animation. We shouldn't notify that the scrollbars |
+ // are hidden until the animation is completly over. We can (but don't have |
+ // to) notify during the animation that the scrollbars are still visible. |
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); |
ASSERT_FALSE(client_.start_fade().is_null()); |
client_.start_fade().Run(); |
scrollbar_controller_->Animate(time); |
- time += kFadeDuration / 4; |
+ time += kFadeOutDuration / 4; |
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
scrollbar_controller_->Animate(time); |
- time += kFadeDuration / 4; |
+ time += kFadeOutDuration / 4; |
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
scrollbar_controller_->Animate(time); |
- time += kFadeDuration / 4; |
+ time += kFadeOutDuration / 4; |
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
scrollbar_controller_->Animate(time); |
ExpectScrollbarsOpacity(.25f); |
Mock::VerifyAndClearExpectations(&client_); |
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
- time += kFadeDuration / 4; |
+ time += kFadeOutDuration / 4; |
scrollbar_controller_->Animate(time); |
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
ExpectScrollbarsOpacity(0); |
@@ -852,9 +852,9 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { |
EXPECT_FLOAT_EQ(kIdleThicknessScale, |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
- // An animation should have been enqueued. |
+ // An fade out animation should have been enqueued. |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
} |
// Move mouse near both scrollbars at the same time. |
@@ -944,9 +944,9 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
EXPECT_FLOAT_EQ(kIdleThicknessScale, |
h_scrollbar_layer_->thumb_thickness_scale_factor()); |
- // An animation should have been enqueued. |
+ // An fade out animation should have been enqueued. |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
} |
// Ensure we have a delay fadeout animation after mouse leave without a mouse |
@@ -970,9 +970,46 @@ TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { |
// Mouse leave. |
scrollbar_controller_->DidMouseLeave(); |
- // An animation should have been enqueued. |
+ // An fade out animation should have been enqueued. |
EXPECT_FALSE(client_.start_fade().is_null()); |
- EXPECT_EQ(kDelayBeforeStarting, client_.delay()); |
+ EXPECT_EQ(kFadeOutDelay, client_.delay()); |
+} |
+ |
+// Scrollbars should schedule a delay fade in when mouse hover hidden scrollbar. |
+TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) { |
+ base::TimeTicks time; |
+ time += base::TimeDelta::FromSeconds(1); |
+ |
+ // Move mouse over scrollbar. |
+ scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
+ |
+ // An fade in animation should have been enqueued. |
+ EXPECT_FALSE(client_.start_fade().is_null()); |
+ EXPECT_EQ(kFadeInDelay, client_.delay()); |
+ |
+ // Play the delay animation. |
+ client_.start_fade().Run(); |
+ EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
+} |
+ |
+// Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then |
+// move out. |
+TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
bokan
2017/02/27 23:13:56
Please add another test that moving the mouse with
|
+ MouseHoverThenOutShouldCancelFadeIn) { |
+ base::TimeTicks time; |
+ time += base::TimeDelta::FromSeconds(1); |
+ |
+ // Move mouse over scrollbar. |
+ scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
+ |
+ // An fade in animation should have been enqueued. |
+ EXPECT_FALSE(client_.start_fade().is_null()); |
+ EXPECT_EQ(kFadeInDelay, client_.delay()); |
+ |
+ // Move mouse out of scrollbar,delay fade in should be canceled. |
+ scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
+ EXPECT_TRUE(client_.start_fade().is_null() || |
+ client_.start_fade().IsCancelled()); |
} |
class ScrollbarAnimationControllerAndroidTest |