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

Unified Diff: cc/input/scrollbar_animation_controller_thinning_unittest.cc

Issue 2384053002: cancel overlay-scrollbar hover state when moving pointer out of window for ChromeOS (Closed)
Patch Set: remove fix for not chromeos Created 4 years, 2 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/scrollbar_animation_controller_thinning_unittest.cc
diff --git a/cc/input/scrollbar_animation_controller_thinning_unittest.cc b/cc/input/scrollbar_animation_controller_thinning_unittest.cc
index 4824879f67af4f5436a0429e4bdf336051a84d3c..4801f4e0e068d47a38fa8e57f462e381db70d84c 100644
--- a/cc/input/scrollbar_animation_controller_thinning_unittest.cc
+++ b/cc/input/scrollbar_animation_controller_thinning_unittest.cc
@@ -518,5 +518,80 @@ TEST_F(ScrollbarAnimationControllerThinningTest, MouseCaptureAndReleaseOnBar) {
}
}
+// Move mouse on scrollbar then move out of window. Confirm that the bar gets
+// thin and light.
+TEST_F(ScrollbarAnimationControllerThinningTest, MouseExitWindowFromScrollbar) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+
+ // Move in
+ scrollbar_controller_->DidMouseMoveNear(0);
+
+ scrollbar_controller_->Animate(time);
+ time += base::TimeDelta::FromSeconds(kDuration);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ // move out of window
+ scrollbar_controller_->DidMouseLeave();
+
+ // get thin and light
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
+}
+
+// Move mouse on scrollbar and capture then move out of window. Confirm that
+// the bar stays thick and dark.
+TEST_F(ScrollbarAnimationControllerThinningTest,
+ MouseCapturedAndExitWindowFromScrollbar) {
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+
+ // Move in
+ scrollbar_controller_->DidMouseMoveNear(0);
+
+ scrollbar_controller_->Animate(time);
+ time += base::TimeDelta::FromSeconds(kDuration);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ // Capture
+ scrollbar_controller_->DidCaptureScrollbarBegin();
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
+
+ // move out of window
+ scrollbar_controller_->DidMouseLeave();
+
+ // test for 10 seconds, stay thick and dark
+ for (int i = 0; i < 10; ++i) {
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->Animate(time);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
+ }
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698