OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 layer_size.height())); | 1773 layer_size.height())); |
1774 root->SetBounds(layer_size); | 1774 root->SetBounds(layer_size); |
1775 root->SetContentBounds(layer_size); | 1775 root->SetContentBounds(layer_size); |
1776 root->SetPosition(gfx::PointF()); | 1776 root->SetPosition(gfx::PointF()); |
1777 root->SetAnchorPoint(gfx::PointF()); | 1777 root->SetAnchorPoint(gfx::PointF()); |
1778 root->SetDrawsContent(false); | 1778 root->SetDrawsContent(false); |
1779 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1779 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1780 host_impl_->active_tree()->FindRootScrollLayer(); | 1780 host_impl_->active_tree()->FindRootScrollLayer(); |
1781 DrawFrame(); | 1781 DrawFrame(); |
1782 | 1782 |
1783 EXPECT_EQ(InputHandler::ScrollIgnored, | 1783 EXPECT_EQ(InputHandler::ScrollStarted, |
1784 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 1784 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
1785 | 1785 |
1786 host_impl_->top_controls_manager()->ScrollBegin(); | 1786 host_impl_->top_controls_manager()->ScrollBegin(); |
1787 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 1787 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
1788 host_impl_->top_controls_manager()->ScrollEnd(); | 1788 host_impl_->top_controls_manager()->ScrollEnd(); |
1789 EXPECT_EQ(host_impl_->top_controls_manager()->content_top_offset(), 0.f); | 1789 EXPECT_EQ(host_impl_->top_controls_manager()->content_top_offset(), 0.f); |
1790 | 1790 |
| 1791 host_impl_->ScrollEnd(); |
| 1792 |
1791 EXPECT_EQ(InputHandler::ScrollStarted, | 1793 EXPECT_EQ(InputHandler::ScrollStarted, |
1792 host_impl_->ScrollBegin(gfx::Point(), | 1794 host_impl_->ScrollBegin(gfx::Point(), |
1793 InputHandler::Gesture)); | 1795 InputHandler::Gesture)); |
1794 } | 1796 } |
1795 | 1797 |
1796 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 1798 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
1797 // Test the configuration where a non-composited root layer is embedded in a | 1799 // Test the configuration where a non-composited root layer is embedded in a |
1798 // scrollable outer layer. | 1800 // scrollable outer layer. |
1799 gfx::Size surface_size(10, 10); | 1801 gfx::Size surface_size(10, 10); |
1800 | 1802 |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2715 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2717 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2716 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); | 2718 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); |
2717 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2719 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2718 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 2720 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
2719 host_impl_->ScrollEnd(); | 2721 host_impl_->ScrollEnd(); |
2720 } | 2722 } |
2721 } | 2723 } |
2722 | 2724 |
2723 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 2725 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
2724 LayerTreeSettings settings; | 2726 LayerTreeSettings settings; |
2725 settings.always_overscroll = true; | |
2726 CreateHostImpl(settings, CreateOutputSurface()); | 2727 CreateHostImpl(settings, CreateOutputSurface()); |
2727 | 2728 |
2728 SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 2729 SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
2729 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2730 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2730 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); | 2731 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); |
2731 DrawFrame(); | 2732 DrawFrame(); |
2732 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2733 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2733 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 2734 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
2734 | 2735 |
2735 // Even though the layer can't scroll the overscroll still happens. | 2736 // Even though the layer can't scroll the overscroll still happens. |
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5431 &set_needs_redraw_count)); | 5432 &set_needs_redraw_count)); |
5432 // Empty damage rect won't signal the monitor. | 5433 // Empty damage rect won't signal the monitor. |
5433 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 5434 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
5434 EXPECT_EQ(0, set_needs_commit_count); | 5435 EXPECT_EQ(0, set_needs_commit_count); |
5435 EXPECT_EQ(2, set_needs_redraw_count); | 5436 EXPECT_EQ(2, set_needs_redraw_count); |
5436 } | 5437 } |
5437 } | 5438 } |
5438 | 5439 |
5439 } // namespace | 5440 } // namespace |
5440 } // namespace cc | 5441 } // namespace cc |
OLD | NEW |