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

Unified Diff: cc/input/single_scrollbar_animation_controller_thinning_unittest.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: add tests 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
Index: cc/input/single_scrollbar_animation_controller_thinning_unittest.cc
diff --git a/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc b/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc
index e5e652b3d1a70525126196df65a439c30d042676..cecccc4cccc9977c33e098235f6918f4c69d1e7e 100644
--- a/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc
+++ b/cc/input/single_scrollbar_animation_controller_thinning_unittest.cc
@@ -23,9 +23,9 @@ namespace {
const float kIdleThicknessScale =
SingleScrollbarAnimationControllerThinning::kIdleThicknessScale;
-const float kDefaultMouseMoveDistanceToTriggerAnimation =
+const float kMouseMoveDistanceToTriggerExpand =
SingleScrollbarAnimationControllerThinning::
- kDefaultMouseMoveDistanceToTriggerAnimation;
+ kMouseMoveDistanceToTriggerExpand;
class MockSingleScrollbarAnimationControllerClient
: public ScrollbarAnimationControllerClient {
@@ -120,7 +120,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseNear) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidMouseMoveNear(1);
+ scrollbar_controller_->DidMouseMove(1);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
scrollbar_layer_->thumb_thickness_scale_factor());
@@ -131,15 +131,14 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseNear) {
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// Subsequent moves within the nearness threshold should not change anything.
- scrollbar_controller_->DidMouseMoveNear(2);
+ scrollbar_controller_->DidMouseMove(2);
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// Now move away from bar.
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
@@ -153,7 +152,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
scrollbar_layer_->thumb_thickness_scale_factor());
@@ -164,7 +163,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) {
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// Subsequent moves should not change anything.
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
scrollbar_controller_->Animate(time);
@@ -172,16 +171,14 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) {
// Moving off the scrollbar but still withing the "near" threshold should do
// nothing.
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation - 1.f);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand - 1.f);
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// Now move away from bar.
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
@@ -191,13 +188,13 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) {
// First move the pointer over the scrollbar off of it. Make sure the thinning
// animation kicked off in DidMouseMoveOffScrollbar gets overridden by the
-// thickening animation in the DidMouseMoveNear call.
+// thickening animation in the DidMouseMove call.
TEST_F(SingleScrollbarAnimationControllerThinningTest,
MouseNearThenAwayWhileAnimating) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
scrollbar_layer_->thumb_thickness_scale_factor());
@@ -208,7 +205,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// This is tricky. The DidMouseLeave() is sent before the
- // subsequent DidMouseMoveNear(), if the mouse moves in that direction.
+ // subsequent DidMouseMove(), if the mouse moves in that direction.
// This results in the thumb thinning. We want to make sure that when the
// thumb starts expanding it doesn't first narrow to the idle thinness.
time += base::TimeDelta::FromSeconds(1);
@@ -225,7 +222,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
// Now we get a notification for the mouse moving over the scroller. The
// animation is reset to the thickening direction but we won't start
// thickening until the new animation catches up to the current thickness.
- scrollbar_controller_->DidMouseMoveNear(1);
+ scrollbar_controller_->DidMouseMove(1);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
scrollbar_layer_->thumb_thickness_scale_factor());
@@ -263,7 +260,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
time += base::TimeDelta::FromSeconds(1);
// Move over the scrollbar.
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
@@ -281,8 +278,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
// Move outside the "near" threshold. Because the scrollbar is captured it
// should remain thick.
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
@@ -308,7 +304,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
time += base::TimeDelta::FromSeconds(1);
// Move over scrollbar.
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
@@ -323,8 +319,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
// Move away from scrollbar. Nothing should change.
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
@@ -333,7 +328,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest,
// Move over scrollbar and release. Since we're near the scrollbar, it should
// remain thick.
- scrollbar_controller_->DidMouseMoveNear(0);
+ scrollbar_controller_->DidMouseMove(0);
scrollbar_controller_->DidMouseUp();
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->Animate(time);
@@ -349,7 +344,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, ThicknessAnimated) {
// Move mouse near scrollbar. Test that at half the duration time, the
// thickness is half way through its animation.
- scrollbar_controller_->DidMouseMoveNear(1);
+ scrollbar_controller_->DidMouseMove(1);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
scrollbar_layer_->thumb_thickness_scale_factor());
@@ -365,8 +360,7 @@ TEST_F(SingleScrollbarAnimationControllerThinningTest, ThicknessAnimated) {
// Move mouse away from scrollbar. Same check.
time += base::TimeDelta::FromSeconds(1);
- scrollbar_controller_->DidMouseMoveNear(
- kDefaultMouseMoveDistanceToTriggerAnimation);
+ scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());

Powered by Google App Engine
This is Rietveld 408576698