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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('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 0b9d976cd25cb65553060b7076a82d19ec5a2e54..51377d249d1657e8b38e87f327f89766080f4a4c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -2319,6 +2319,8 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
const gfx::Size& outer_viewport_size,
const gfx::Size& scroll_layer_size) {
CreateHostImpl(settings_, CreateOutputSurface());
+ host_impl_->SetTopControlsLayoutHeight(
+ settings_.top_controls_height);
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl_->active_tree(), 1);
@@ -2364,8 +2366,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
outer_viewport_scroll_layer_id);
host_impl_->SetViewportSize(inner_viewport_size);
- host_impl_->SetTopControlsLayoutHeight(
- settings_.top_controls_height);
LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer();
EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
}
@@ -2402,6 +2402,81 @@ TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) {
inner_viewport_scroll_layer->FixedContainerSizeDelta());
}
+// In this test, the outer viewport is initially unscrollable. We test that a
+// scroll initiated on the inner viewport, causing the top controls to show and
+// thus making the outer viewport scrollable, still scrolls the outer viewport.
+TEST_F(LayerTreeHostImplTopControlsTest,
+ TopControlsOuterViewportBecomesScrollable) {
+ SetupTopControlsAndScrollLayerWithVirtualViewport(
+ gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100));
+ DrawFrame();
+
+ LayerImpl *inner_scroll =
+ host_impl_->active_tree()->InnerViewportScrollLayer();
+ LayerImpl *inner_container =
+ host_impl_->active_tree()->InnerViewportContainerLayer();
+ LayerImpl *outer_scroll =
+ host_impl_->active_tree()->OuterViewportScrollLayer();
+ LayerImpl *outer_container =
+ host_impl_->active_tree()->OuterViewportContainerLayer();
+
+ // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer.
+ outer_scroll->SetDrawsContent(true);
+ host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 1.f, 2.f);
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f));
+
+ // The entire scroll delta should have been used to hide the top controls.
+ // The viewport layers should be resized back to their full sizes.
+ EXPECT_EQ(0.f,
+ host_impl_->active_tree()->total_top_controls_content_offset());
+ EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height());
+ EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height());
+
+ // The inner viewport should be scrollable by 50px * page_scale.
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f));
+ EXPECT_EQ(50.f, inner_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset());
+
+ host_impl_->ScrollEnd();
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
+
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f));
+
+ // The entire scroll delta should have been used to show the top controls.
+ // The outer viewport should be resized to accomodate and scrolled to the
+ // bottom of the document to keep the viewport in place.
+ EXPECT_EQ(50.f,
+ host_impl_->active_tree()->total_top_controls_content_offset());
+ EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height());
+ EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height());
+ EXPECT_EQ(25.f, outer_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y());
+
+ // Now when we continue scrolling, make sure the outer viewport gets scrolled
+ // since it wasn't scrollable when the scroll began.
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f));
+ EXPECT_EQ(15.f, outer_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y());
+
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f));
+ EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y());
+
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f));
+ host_impl_->ScrollEnd();
+
+ EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y());
+ EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y());
+}
+
// Test that the fixed position container delta is appropriately adjusted
// by the top controls showing/hiding and page scale doesn't affect it.
TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698