Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 776943004: Properly handle viewport-flings after a bubbling scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); 7641 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2));
7642 outer_expected += scroll_delta; 7642 outer_expected += scroll_delta;
7643 inner_expected += scroll_delta; 7643 inner_expected += scroll_delta;
7644 host_impl_->ScrollEnd(); 7644 host_impl_->ScrollEnd();
7645 7645
7646 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); 7646 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7647 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); 7647 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7648 } 7648 }
7649 } 7649 }
7650 7650
7651 TEST_F(LayerTreeHostImplVirtualViewportTest,
7652 TouchFlingCanLockToViewportLayerAfterBubbling) {
7653 gfx::Size content_size = gfx::Size(100, 160);
7654 gfx::Size outer_viewport = gfx::Size(50, 80);
7655 gfx::Size inner_viewport = gfx::Size(25, 40);
7656
7657 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
7658
7659 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
7660 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
7661
7662 scoped_ptr<LayerImpl> child =
7663 CreateScrollableLayer(10, outer_viewport, outer_scroll);
7664 LayerImpl* child_scroll = child.get();
7665 outer_scroll->children()[0]->AddChild(child.Pass());
7666
7667 DrawFrame();
7668 {
7669 scoped_ptr<ScrollAndScaleSet> scroll_info;
7670
7671 gfx::Vector2d scroll_delta(0, inner_viewport.height());
7672 EXPECT_EQ(InputHandler::ScrollStarted,
7673 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
7674 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7675
7676 // The child should have scrolled up to its limit.
7677 scroll_info = host_impl_->ProcessScrollDeltas();
7678 ASSERT_EQ(1u, scroll_info->scrolls.size());
7679 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
7680 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll);
7681
7682 // The first |ScrollBy| after the fling should re-lock the scrolling
7683 // layer to the first layer that scrolled, the inner viewport scroll layer.
7684 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
7685 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7686 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
7687
7688 // The inner viewport should have scrolled up to its limit.
7689 scroll_info = host_impl_->ProcessScrollDeltas();
7690 ASSERT_EQ(2u, scroll_info->scrolls.size());
7691 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
7692 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta);
7693
7694 // As the locked layer is at its limit, no further scrolling can occur.
7695 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7696 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
7697 host_impl_->ScrollEnd();
7698 }
7699 }
7700
7651 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { 7701 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest {
7652 public: 7702 public:
7653 void SetUp() override { 7703 void SetUp() override {
7654 LayerTreeSettings settings = DefaultSettings(); 7704 LayerTreeSettings settings = DefaultSettings();
7655 settings.max_memory_for_prepaint_percentage = 50; 7705 settings.max_memory_for_prepaint_percentage = 50;
7656 CreateHostImpl(settings, CreateOutputSurface()); 7706 CreateHostImpl(settings, CreateOutputSurface());
7657 } 7707 }
7658 }; 7708 };
7659 7709
7660 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { 7710 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
7905 // surface. 7955 // surface.
7906 EXPECT_EQ(0, num_lost_surfaces_); 7956 EXPECT_EQ(0, num_lost_surfaces_);
7907 host_impl_->DidLoseOutputSurface(); 7957 host_impl_->DidLoseOutputSurface();
7908 EXPECT_EQ(1, num_lost_surfaces_); 7958 EXPECT_EQ(1, num_lost_surfaces_);
7909 host_impl_->DidLoseOutputSurface(); 7959 host_impl_->DidLoseOutputSurface();
7910 EXPECT_LE(1, num_lost_surfaces_); 7960 EXPECT_LE(1, num_lost_surfaces_);
7911 } 7961 }
7912 7962
7913 } // namespace 7963 } // namespace
7914 } // namespace cc 7964 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698