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

Unified Diff: cc/top_controls_manager_unittest.cc

Issue 11953040: Add a scroll threshold/marker to control hiding/showing top controls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 7 years, 11 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/top_controls_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/top_controls_manager_unittest.cc
diff --git a/cc/top_controls_manager_unittest.cc b/cc/top_controls_manager_unittest.cc
index 1cb250276faa0d86f54139b3f104dde0d2b41db9..74aa5d6804d500a4cf1e08f3908c6c855defdefa 100644
--- a/cc/top_controls_manager_unittest.cc
+++ b/cc/top_controls_manager_unittest.cc
@@ -141,6 +141,56 @@ TEST(TopControlsManagerTest, overlayModeDetection) {
client.rootScrollLayer()->scrollDelta() + remaining_scroll);
}
+TEST(TopControlsManagerTest, ensureScrollThresholdApplied) {
+ MockTopControlsManagerClient client;
+ TopControlsManager* manager = client.manager();
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 200));
+
+ manager->ScrollBegin();
+
+ // Scroll down to hide the controls entirely.
+ manager->ScrollBy(gfx::Vector2dF(0.f, 30.f));
+ EXPECT_EQ(-30.f, manager->controls_top_offset());
+ EXPECT_EQ(70.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 230));
+
+ manager->ScrollBy(gfx::Vector2dF(0.f, 30.f));
+ EXPECT_EQ(-60.f, manager->controls_top_offset());
+ EXPECT_EQ(40.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 260));
+
+ manager->ScrollBy(gfx::Vector2dF(0.f, 100.f));
+ EXPECT_EQ(-100.f, manager->controls_top_offset());
+ EXPECT_EQ(0.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 360));
+
+ // Scroll back up a bit and ensure the controls don't move until we cross
+ // the threshold.
+ manager->ScrollBy(gfx::Vector2dF(0.f, -10.f));
+ EXPECT_EQ(-100.f, manager->controls_top_offset());
+ EXPECT_EQ(0.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 350));
+
+ manager->ScrollBy(gfx::Vector2dF(0.f, -50.f));
+ EXPECT_EQ(-100.f, manager->controls_top_offset());
+ EXPECT_EQ(0.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 300));
+
+ // After hitting the threshold, further scrolling up should result in the top
+ // controls showing.
+ manager->ScrollBy(gfx::Vector2dF(0.f, -10.f));
+ EXPECT_EQ(-90.f, manager->controls_top_offset());
+ EXPECT_EQ(0.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 290));
+
+ manager->ScrollBy(gfx::Vector2dF(0.f, -50.f));
+ EXPECT_EQ(-40.f, manager->controls_top_offset());
+ EXPECT_EQ(0.f, manager->content_top_offset());
+ client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 240));
+
+ manager->ScrollEnd();
+}
+
TEST(TopControlsManagerTest, partialShownHideAnimation) {
MockTopControlsManagerClient client;
TopControlsManager* manager = client.manager();
« no previous file with comments | « cc/top_controls_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698