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 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2572 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 2572 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
2573 | 2573 |
2574 // Scroll the viewports to max scroll offset. | 2574 // Scroll the viewports to max scroll offset. |
2575 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 2575 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
2576 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 2576 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
2577 | 2577 |
2578 gfx::ScrollOffset viewport_offset = | 2578 gfx::ScrollOffset viewport_offset = |
2579 host_impl_->active_tree()->TotalScrollOffset(); | 2579 host_impl_->active_tree()->TotalScrollOffset(); |
2580 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 2580 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
2581 | 2581 |
2582 // Hide the top controls by 25px. | 2582 // Scroll up the content by 25.f. |
2583 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2583 gfx::Vector2dF scroll_delta(0.f, -25.f); |
aelias_OOO_until_Jul13
2014/11/04 06:07:55
You're making this test no longer try to scroll ag
| |
2584 EXPECT_EQ(InputHandler::ScrollStarted, | 2584 EXPECT_EQ(InputHandler::ScrollStarted, |
2585 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2585 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
2586 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2586 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2587 host_impl_->ScrollEnd(); | 2587 host_impl_->ScrollEnd(); |
2588 | 2588 |
2589 EXPECT_EQ(scroll_delta.y(), | 2589 // Top controls should not have moved |
2590 EXPECT_EQ(0.f, | |
2590 settings_.top_controls_height - | 2591 settings_.top_controls_height - |
2591 host_impl_->active_tree()->total_top_controls_content_offset()); | 2592 host_impl_->active_tree()->total_top_controls_content_offset()); |
2592 | 2593 |
2593 inner_scroll->ClampScrollToMaxScrollOffset(); | 2594 inner_scroll->ClampScrollToMaxScrollOffset(); |
2594 outer_scroll->ClampScrollToMaxScrollOffset(); | 2595 outer_scroll->ClampScrollToMaxScrollOffset(); |
2595 | 2596 |
2596 // We should still be fully scrolled. | 2597 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
2597 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 2598 |
2598 host_impl_->active_tree()->TotalScrollOffset()); | 2599 // Hide top controls by 25.f |
2600 scroll_delta = gfx::Vector2dF(0.f, 25.f); | |
2601 EXPECT_EQ(InputHandler::ScrollStarted, | |
2602 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | |
2603 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | |
2604 host_impl_->ScrollEnd(); | |
2605 | |
2606 // The viewport offset shouldn't have changed. | |
2607 EXPECT_EQ(viewport_offset, host_impl_->active_tree()->TotalScrollOffset()); | |
2599 | 2608 |
2600 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 2609 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
2601 | 2610 |
2602 // Bring the top controls down by 25px. | 2611 // Bring the top controls down by 25px. |
2603 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 2612 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
2604 EXPECT_EQ(InputHandler::ScrollStarted, | 2613 EXPECT_EQ(InputHandler::ScrollStarted, |
2605 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2614 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
2606 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2615 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2607 host_impl_->ScrollEnd(); | 2616 host_impl_->ScrollEnd(); |
2608 | 2617 |
(...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7191 host_impl_->top_controls_manager()->ControlsTopOffset(); | 7200 host_impl_->top_controls_manager()->ControlsTopOffset(); |
7192 | 7201 |
7193 if (new_offset != old_offset) { | 7202 if (new_offset != old_offset) { |
7194 EXPECT_TRUE(did_request_redraw_); | 7203 EXPECT_TRUE(did_request_redraw_); |
7195 EXPECT_TRUE(did_request_commit_); | 7204 EXPECT_TRUE(did_request_commit_); |
7196 } | 7205 } |
7197 } | 7206 } |
7198 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); | 7207 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); |
7199 } | 7208 } |
7200 | 7209 |
7210 TEST_F(LayerTreeHostImplWithTopControlsTest, | |
7211 TopControlsScrollDeltaInOverScroll) { | |
7212 // test varifies that the overscroll delta should not have accumulated in | |
7213 // the top controls if we do a hide and show without releasing finger. | |
7214 | |
7215 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | |
7216 host_impl_->SetViewportSize(gfx::Size(100, 100)); | |
7217 host_impl_->top_controls_manager()->UpdateTopControlsState( | |
7218 BOTH, SHOWN, false); | |
7219 DrawFrame(); | |
7220 | |
7221 EXPECT_EQ(InputHandler::ScrollStarted, | |
7222 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | |
7223 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | |
7224 | |
7225 float offset = 50; | |
7226 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); | |
7227 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | |
7228 EXPECT_EQ(gfx::Vector2dF().ToString(), | |
7229 scroll_layer->TotalScrollOffset().ToString()); | |
7230 | |
7231 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); | |
7232 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | |
7233 scroll_layer->TotalScrollOffset().ToString()); | |
7234 | |
7235 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); | |
7236 // Should have fully scrolled | |
7237 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | |
7238 scroll_layer->TotalScrollOffset().ToString()); | |
7239 | |
7240 float overscrollamount = 10; | |
7241 // Overscroll the content | |
7242 EXPECT_FALSE( | |
7243 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount))); | |
7244 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | |
7245 scroll_layer->TotalScrollOffset().ToString()); | |
7246 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | |
7247 host_impl_->accumulated_root_overscroll().ToString()); | |
7248 | |
7249 EXPECT_TRUE( | |
7250 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset))); | |
7251 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | |
7252 scroll_layer->TotalScrollOffset().ToString()); | |
7253 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | |
7254 | |
7255 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset))); | |
7256 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | |
7257 scroll_layer->TotalScrollOffset().ToString()); | |
7258 // Top controls should be fully visible | |
7259 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | |
7260 | |
7261 host_impl_->ScrollEnd(); | |
7262 } | |
7263 | |
7201 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 7264 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
7202 public: | 7265 public: |
7203 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 7266 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
7204 const gfx::Size& outer_viewport, | 7267 const gfx::Size& outer_viewport, |
7205 const gfx::Size& inner_viewport) { | 7268 const gfx::Size& inner_viewport) { |
7206 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 7269 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
7207 const int kOuterViewportClipLayerId = 6; | 7270 const int kOuterViewportClipLayerId = 6; |
7208 const int kOuterViewportScrollLayerId = 7; | 7271 const int kOuterViewportScrollLayerId = 7; |
7209 const int kInnerViewportScrollLayerId = 2; | 7272 const int kInnerViewportScrollLayerId = 2; |
7210 const int kInnerViewportClipLayerId = 4; | 7273 const int kInnerViewportClipLayerId = 4; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7516 // surface. | 7579 // surface. |
7517 EXPECT_EQ(0, num_lost_surfaces_); | 7580 EXPECT_EQ(0, num_lost_surfaces_); |
7518 host_impl_->DidLoseOutputSurface(); | 7581 host_impl_->DidLoseOutputSurface(); |
7519 EXPECT_EQ(1, num_lost_surfaces_); | 7582 EXPECT_EQ(1, num_lost_surfaces_); |
7520 host_impl_->DidLoseOutputSurface(); | 7583 host_impl_->DidLoseOutputSurface(); |
7521 EXPECT_LE(1, num_lost_surfaces_); | 7584 EXPECT_LE(1, num_lost_surfaces_); |
7522 } | 7585 } |
7523 | 7586 |
7524 } // namespace | 7587 } // namespace |
7525 } // namespace cc | 7588 } // namespace cc |
OLD | NEW |