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 5d2d939cf0fe60944ee4be6595283524d5630187..17179cd06599eebd2c2e1611d64c7d0a3ffc1321 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -124,6 +124,7 @@ class LayerTreeHostImplTest : public testing::Test, |
did_notify_ready_to_activate_ = true; |
host_impl_->ActivateSyncTree(); |
} |
+ void NotifyReadyToDraw() override {} |
void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } |
void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) override { |
did_request_redraw_ = true; |
@@ -772,27 +773,40 @@ TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
// Trying to scroll to the left/top will not succeed. |
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); |
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10))); |
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); |
+ EXPECT_FALSE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); |
+ EXPECT_FALSE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); |
+ EXPECT_FALSE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); |
// Scrolling to the right/bottom will succeed. |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10)).did_scroll); |
// Scrolling to left/top will now succeed. |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); |
// Scrolling diagonally against an edge will succeed. |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10)).did_scroll); |
// Trying to scroll more than the available space will also succeed. |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)).did_scroll); |
} |
TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { |
@@ -2574,6 +2588,14 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { |
EXPECT_EQ(InputHandler::ScrollStarted, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
+ |
+ // scrolling down at the max extents no longer hides the top controls |
+ EXPECT_EQ(0.f, |
+ settings_.top_controls_height - |
+ host_impl_->active_tree()->total_top_controls_content_offset()); |
+ |
+ // forcefully hide the top controls by 25px |
+ host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
host_impl_->ScrollEnd(); |
EXPECT_EQ(scroll_delta.y(), |
@@ -3705,6 +3727,7 @@ TEST_F(LayerTreeHostImplTest, |
} |
TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
+ InputHandlerScrollResult scroll_result; |
SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
host_impl_->SetViewportSize(gfx::Size(50, 50)); |
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); |
@@ -3714,38 +3737,105 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
// In-bounds scrolling does not affect overscroll. |
EXPECT_EQ(InputHandler::ScrollStarted, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_FALSE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
// Overscroll events are reflected immediately. |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50)); |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
// In-bounds scrolling resets accumulated overscroll for the scrolled axes. |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50)); |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_FALSE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)); |
+ EXPECT_FALSE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_FALSE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(-5, 0), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(-5, -10), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(-5, 10), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
// Overscroll accumulates within the scope of ScrollBegin/ScrollEnd as long |
// as no scroll occurs. |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ EXPECT_FALSE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -30), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ EXPECT_FALSE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -50), host_impl_->accumulated_root_overscroll()); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
// Overscroll resets on valid scroll. |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_FALSE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
+ scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
+ EXPECT_TRUE(scroll_result.did_scroll); |
+ EXPECT_TRUE(scroll_result.did_overscroll_root); |
+ EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
+ EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
+ host_impl_->accumulated_root_overscroll()); |
+ |
host_impl_->ScrollEnd(); |
} |
@@ -5981,7 +6071,8 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { |
pile_tile_size, content_layer_bounds)); |
scoped_ptr<FakePictureLayerImpl> scoped_content_layer = |
- FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); |
+ FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
+ 3, pile); |
LayerImpl* content_layer = scoped_content_layer.get(); |
scrolling_layer->AddChild(scoped_content_layer.Pass()); |
content_layer->SetBounds(content_layer_bounds); |
@@ -6527,7 +6618,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
gfx::Vector2d scroll_delta(0, -2); |
EXPECT_EQ(InputHandler::ScrollStarted, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta)); |
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
// The grand child should have scrolled up to its limit. |
scroll_info = host_impl_->ProcessScrollDeltas(); |
@@ -6537,7 +6628,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
// The child should have received the bubbled delta, but the locked |
// scrolling layer should remain set as the grand child. |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta)); |
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
scroll_info = host_impl_->ProcessScrollDeltas(); |
ASSERT_EQ(2u, scroll_info->scrolls.size()); |
ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
@@ -6547,7 +6638,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
// The first |ScrollBy| after the fling should re-lock the scrolling |
// layer to the first layer that scrolled, which is the child. |
EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta)); |
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
// The child should have scrolled up to its limit. |
@@ -6557,7 +6648,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta); |
// As the locked layer is at it's limit, no further scrolling can occur. |
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta)); |
+ EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
host_impl_->ScrollEnd(); |
} |
@@ -6955,7 +7046,8 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { |
// Scrolling normally should not trigger any forwarding. |
EXPECT_EQ(InputHandler::ScrollStarted, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); |
host_impl_->ScrollEnd(); |
EXPECT_EQ(0, set_needs_commit_count); |
@@ -6967,7 +7059,8 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { |
scroll_layer->SetHaveScrollEventHandlers(true); |
EXPECT_EQ(InputHandler::ScrollStarted, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); |
host_impl_->ScrollEnd(); |
EXPECT_EQ(0, set_needs_commit_count); |
@@ -7022,7 +7115,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
// Scroll just the top controls and verify that the scroll succeeds. |
const float residue = 10; |
float offset = top_controls_height_ - residue; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->TotalScrollOffset().ToString()); |
@@ -7030,7 +7124,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
// Scroll across the boundary |
const float content_scroll = 20; |
offset = residue + content_scroll; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(-top_controls_height_, |
host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), |
@@ -7038,7 +7133,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
// Now scroll back to the top of the content |
offset = -content_scroll; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(-top_controls_height_, |
host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
@@ -7046,13 +7142,15 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
// And scroll the top controls completely into view |
offset = -top_controls_height_; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->TotalScrollOffset().ToString()); |
// And attempt to scroll past the end |
- EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_FALSE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->TotalScrollOffset().ToString()); |
@@ -7076,7 +7174,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
// Scroll the top controls partially. |
const float residue = 35; |
float offset = top_controls_height_ - residue; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->TotalScrollOffset().ToString()); |
@@ -7144,7 +7243,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
// Scroll the top controls partially. |
const float residue = 15; |
float offset = top_controls_height_ - residue; |
- EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
scroll_layer->TotalScrollOffset().ToString()); |
@@ -7184,6 +7284,68 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); |
} |
+TEST_F(LayerTreeHostImplWithTopControlsTest, |
+ TopControlsScrollDeltaInOverScroll) { |
+ // test varifies that the overscroll delta should not have accumulated in |
+ // the top controls if we do a hide and show without releasing finger. |
+ |
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
+ host_impl_->SetViewportSize(gfx::Size(100, 100)); |
+ host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
+ false); |
+ DrawFrame(); |
+ |
+ EXPECT_EQ(InputHandler::ScrollStarted, |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
+ EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ |
+ float offset = 50; |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
+ EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ EXPECT_EQ(gfx::Vector2dF().ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
+ EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
+ |
+ // Should have fully scrolled |
+ EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ |
+ float overscrollamount = 10; |
+ |
+ // Overscroll the content |
+ EXPECT_FALSE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) |
+ .did_scroll); |
+ EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
+ host_impl_->accumulated_root_overscroll().ToString()); |
+ |
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) |
+ .did_scroll); |
+ EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ |
+ EXPECT_TRUE( |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); |
+ EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
+ scroll_layer->TotalScrollOffset().ToString()); |
+ |
+ // Top controls should be fully visible |
+ EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ |
+ host_impl_->ScrollEnd(); |
+} |
+ |
class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
public: |
void SetupVirtualViewportLayers(const gfx::Size& content_size, |
@@ -7398,7 +7560,7 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
LayerImpl* pending_layer = pending_tree->root_layer(); |
std::vector<PictureLayerImpl::Pair> layer_pairs; |
- host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
EXPECT_EQ(1u, layer_pairs.size()); |
EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
EXPECT_EQ(nullptr, layer_pairs[0].active); |
@@ -7415,7 +7577,7 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
host_impl_->CreatePendingTree(); |
layer_pairs.clear(); |
- host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
EXPECT_EQ(1u, layer_pairs.size()); |
EXPECT_EQ(active_layer, layer_pairs[0].active); |
EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
@@ -7424,7 +7586,7 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
host_impl_->ActivateSyncTree(); |
layer_pairs.clear(); |
- host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
EXPECT_EQ(1u, layer_pairs.size()); |
EXPECT_EQ(active_layer, layer_pairs[0].active); |
EXPECT_EQ(nullptr, layer_pairs[0].pending); |
@@ -7438,7 +7600,7 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; |
layer_pairs.clear(); |
- host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
EXPECT_EQ(2u, layer_pairs.size()); |
// The pair ordering is flaky, so make it consistent. |