Chromium Code Reviews| 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 5694c01aaa37565bec2f4254a0a41db9cb8092da..5d97fc29656ec39558b122843ece2c8e5af32751 100644 |
| --- a/cc/trees/layer_tree_host_impl_unittest.cc |
| +++ b/cc/trees/layer_tree_host_impl_unittest.cc |
| @@ -2579,14 +2579,15 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { |
| host_impl_->active_tree()->TotalScrollOffset(); |
| EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| - // Hide the top controls by 25px. |
| + // Try to Hide the top controls by 25px. |
| gfx::Vector2dF scroll_delta(0.f, 25.f); |
| EXPECT_EQ(InputHandler::ScrollStarted, |
| host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| host_impl_->ScrollEnd(); |
| - EXPECT_EQ(scroll_delta.y(), |
| + // top controls should not hide, since we reached max scrolloffset |
| + EXPECT_EQ(0.f, |
|
bokan
2014/11/06 16:14:57
This is fine, since scrolling down at the max exte
sujith
2014/11/07 05:06:40
Done.
|
| settings_.top_controls_height - |
| host_impl_->active_tree()->total_top_controls_content_offset()); |
| @@ -2606,8 +2607,8 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { |
| host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| host_impl_->ScrollEnd(); |
| - // The viewport offset shouldn't have changed. |
| - EXPECT_EQ(viewport_offset, |
| + // The viewport offset should have changed only by the negative offset. |
| + EXPECT_EQ(viewport_offset + gfx::ScrollOffset(0.f, -25.f), |
|
sujith
2014/11/06 09:28:00
Since the +ve scroll will not reflect, if we scrol
bokan
2014/11/06 16:14:57
If you hide the top controls as mentioned in my co
sujith
2014/11/07 05:06:40
Done.
|
| host_impl_->active_tree()->TotalScrollOffset()); |
| // Scroll the viewports to max scroll offset. |
| @@ -7198,6 +7199,63 @@ 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))); |
| + 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))); |
| + EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
| + scroll_layer->TotalScrollOffset().ToString()); |
| + |
| + EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
| + |
| + // 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))); |
| + 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))); |
| + 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))); |
| + 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, |