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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 | 3661 |
3662 EXPECT_EQ(top_controls_height_, | 3662 EXPECT_EQ(top_controls_height_, |
3663 host_impl_->top_controls_manager()->ContentTopOffset()); | 3663 host_impl_->top_controls_manager()->ContentTopOffset()); |
3664 | 3664 |
3665 // Send a gesture scroll that will scroll the outer viewport, make sure the | 3665 // Send a gesture scroll that will scroll the outer viewport, make sure the |
3666 // top controls get scrolled. | 3666 // top controls get scrolled. |
3667 gfx::Vector2dF scroll_delta(0.f, 15.f); | 3667 gfx::Vector2dF scroll_delta(0.f, 15.f); |
3668 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3668 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3669 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3669 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3670 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3670 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
3671 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3671 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
3672 host_impl_->CurrentlyScrollingLayer()); | 3672 host_impl_->CurrentlyScrollingLayer()); |
3673 host_impl_->ScrollEnd(); | 3673 host_impl_->ScrollEnd(); |
3674 | 3674 |
3675 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3675 EXPECT_FLOAT_EQ(scroll_delta.y(), |
3676 top_controls_height_ - | 3676 top_controls_height_ - |
3677 host_impl_->top_controls_manager()->ContentTopOffset()); | 3677 host_impl_->top_controls_manager()->ContentTopOffset()); |
3678 | 3678 |
3679 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 3679 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
3680 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3680 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3681 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3681 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3682 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3682 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
3683 | 3683 |
3684 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 3684 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
3685 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3685 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
3686 host_impl_->CurrentlyScrollingLayer()); | 3686 host_impl_->CurrentlyScrollingLayer()); |
3687 | 3687 |
3688 host_impl_->ScrollEnd(); | 3688 host_impl_->ScrollEnd(); |
3689 | 3689 |
3690 // Position the viewports such that the inner viewport will be scrolled. | 3690 // Position the viewports such that the inner viewport will be scrolled. |
3691 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 3691 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
3692 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 3692 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
3693 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 3693 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
3694 | 3694 |
3695 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 3695 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
(...skipping 4047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7743 { | 7743 { |
7744 gfx::Vector2dF inner_expected; | 7744 gfx::Vector2dF inner_expected; |
7745 gfx::Vector2dF outer_expected; | 7745 gfx::Vector2dF outer_expected; |
7746 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7746 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7747 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7747 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7748 | 7748 |
7749 // Scrolling the viewport always sets the outer scroll layer as the | 7749 // Scrolling the viewport always sets the outer scroll layer as the |
7750 // currently scrolling layer. | 7750 // currently scrolling layer. |
7751 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7751 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7752 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7752 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7753 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7753 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7754 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7754 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7755 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7755 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7756 | 7756 |
7757 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 7757 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
7758 inner_viewport.height() / 2.f); | 7758 inner_viewport.height() / 2.f); |
7759 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7759 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7760 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7760 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7761 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll); | 7761 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7762 | 7762 |
7763 host_impl_->ScrollEnd(); | 7763 host_impl_->ScrollEnd(); |
7764 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 7764 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
7765 | 7765 |
7766 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7766 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7767 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7767 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7768 | 7768 |
7769 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 7769 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
7770 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7770 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7771 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7771 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7772 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7772 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7773 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7773 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7774 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7774 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7775 | 7775 |
7776 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7776 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7777 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7777 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7778 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7778 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7779 | 7779 |
7780 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7780 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7781 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7781 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7782 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7782 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
7783 | 7783 |
7784 host_impl_->ScrollEnd(); | 7784 host_impl_->ScrollEnd(); |
7785 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 7785 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
7786 | 7786 |
7787 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7787 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7788 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7788 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7789 } | 7789 } |
7790 } | 7790 } |
7791 | 7791 |
7792 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7792 TEST_F(LayerTreeHostImplVirtualViewportTest, |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8556 // Hold an unowned pointer to the output surface to use for mock expectations. | 8556 // Hold an unowned pointer to the output surface to use for mock expectations. |
8557 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 8557 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
8558 | 8558 |
8559 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 8559 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
8560 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 8560 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
8561 host_impl_->BeginCommit(); | 8561 host_impl_->BeginCommit(); |
8562 } | 8562 } |
8563 | 8563 |
8564 } // namespace | 8564 } // namespace |
8565 } // namespace cc | 8565 } // namespace cc |
OLD | NEW |