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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2090223002: Clamp compositor's top controls shown ratio on commit from main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clamp from helper method Created 4 years, 6 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 | « no previous file | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 7a358b5f376e615bc93ddbc8641617e649e7a369..7edf6f1198f735ddc28b6af2484a355a66672693 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -4236,6 +4236,32 @@ TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
host_impl_->top_controls_manager()->ScrollEnd();
}
+// Push a top controls ratio from the main thread that we didn't send as a delta
+// and make sure that the ratio is clamped to the [0, 1] range.
+TEST_F(LayerTreeHostImplTopControlsTest, TopControlsPushUnsentRatio) {
+ SetupTopControlsAndScrollLayerWithVirtualViewport(
+ gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100));
+ DrawFrame();
+
+ // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer.
+ LayerImpl* inner_scroll =
+ host_impl_->active_tree()->InnerViewportScrollLayer();
+ inner_scroll->SetDrawsContent(true);
+ LayerImpl* outer_scroll =
+ host_impl_->active_tree()->OuterViewportScrollLayer();
+ outer_scroll->SetDrawsContent(true);
+
+ host_impl_->active_tree()->PushTopControlsFromMainThread(1);
+ ASSERT_EQ(1.0f, host_impl_->active_tree()->CurrentTopControlsShownRatio());
+
+ host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.5f);
+ ASSERT_EQ(0.5f, host_impl_->active_tree()->CurrentTopControlsShownRatio());
+
+ host_impl_->active_tree()->PushTopControlsFromMainThread(0);
+
+ ASSERT_EQ(0, host_impl_->active_tree()->CurrentTopControlsShownRatio());
+}
+
// Test that if only the top controls are scrolled, we shouldn't request a
// commit.
TEST_F(LayerTreeHostImplTopControlsTest, TopControlsDontTriggerCommit) {
« no previous file with comments | « no previous file | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698