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 e128013c25ebe18f5e19259a9be646dc5abd041c..cf6213d5c30ec70284c100682e5fe0fb4527b313 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -7479,6 +7479,49 @@ TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
} |
} |
+TEST_F(LayerTreeHostImplVirtualViewportTest, |
+ DiagonalScrollBubblesPerfectlyToInner) { |
+ gfx::Size content_size = gfx::Size(100, 160); |
+ gfx::Size outer_viewport = gfx::Size(50, 80); |
+ gfx::Size inner_viewport = gfx::Size(25, 40); |
+ |
+ SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
+ |
+ LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
+ LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
+ DrawFrame(); |
+ { |
+ gfx::Vector2dF inner_expected; |
+ gfx::Vector2dF outer_expected; |
+ EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); |
+ EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); |
+ |
+ // Make sure the scroll goes to the outer viewport first. |
+ EXPECT_EQ(InputHandler::ScrollStarted, |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
+ EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
+ |
+ // Scroll near the edge of the outer viewport. |
+ gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
+ host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
+ outer_expected += scroll_delta; |
+ |
+ EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); |
+ EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); |
+ |
+ // Now diagonal scroll across the outer viewport boundary in a single event. |
+ // The entirety of the scroll should be consumed, as bubbling between inner |
+ // and outer viewport layers is perfect. |
+ host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); |
+ outer_expected += scroll_delta; |
+ inner_expected += scroll_delta; |
+ host_impl_->ScrollEnd(); |
+ |
+ EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); |
+ EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); |
+ } |
+} |
+ |
class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { |
public: |
void SetUp() override { |