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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2471523002: Make touch events uncancelable during fling when they are on the current active scroll layer (Closed)
Patch Set: rename both functions Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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 f2702a30d84dc2cfe4923d137fb62333cb0415db..23f4169d7384b3715e5bb01fad0bd234c829704c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -808,7 +808,8 @@ TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
// Touch handler regions determine whether touch events block scroll.
root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10)));
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(10, 10)),
+ EventListenerProperties::kBlocking);
// But they don't influence the actual handling of the scroll gestures.
InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
@@ -818,11 +819,14 @@ TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
status.main_thread_scrolling_reasons);
host_impl_->ScrollEnd(EndState().get());
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(10, 30)),
+ EventListenerProperties::kBlocking);
root->SetTouchEventHandlerRegion(gfx::Rect());
- EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(10, 30)),
+ EventListenerProperties::kNone);
child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(10, 30)),
+ EventListenerProperties::kBlocking);
}
TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) {
@@ -9928,6 +9932,79 @@ TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) {
EXPECT_FALSE(last_on_draw_frame_->has_no_damage);
}
+TEST_F(LayerTreeHostImplTest, TouchInsideOrOutsideFlingLayer) {
+ gfx::Size surface_size(100, 100);
+ gfx::Size inner_size(50, 50);
bokan 2016/11/15 22:42:40 Please use CreateBasicVirtualViewportLayers to ini
lanwei 2016/11/16 21:13:28 Done.
+ std::unique_ptr<LayerImpl> root =
+ LayerImpl::Create(host_impl_->active_tree(), 1);
+ root->test_properties()->force_render_surface = true;
+
+ std::unique_ptr<LayerImpl> root_scrolling_layer =
+ CreateScrollableLayer(2, surface_size, root.get());
+ auto* root_scrolling = root_scrolling_layer.get();
+ root->test_properties()->AddChild(std::move(root_scrolling_layer));
+
+ std::unique_ptr<LayerImpl> child_layer =
+ CreateScrollableLayer(3, surface_size, root.get());
+ auto* child = child_layer.get();
+ root_scrolling->test_properties()->AddChild(std::move(child_layer));
+
+ std::unique_ptr<LayerImpl> grand_child_layer =
+ CreateScrollableLayer(4, inner_size, root.get());
+ child->test_properties()->AddChild(std::move(grand_child_layer));
+
+ host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
+ host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ host_impl_->active_tree()->DidBecomeActive();
+
+ host_impl_->SetViewportSize(surface_size);
+ DrawFrame();
+ {
+ std::unique_ptr<ScrollAndScaleSet> scroll_info;
+ LayerImpl* child = host_impl_->active_tree()
bokan 2016/11/15 22:42:40 We've already saved the child and grand_child poin
lanwei 2016/11/16 21:13:28 Done.
+ ->root_layer_for_testing()
+ ->test_properties()
+ ->children[0]
+ ->test_properties()
+ ->children[0];
+ LayerImpl* grand_child = child->test_properties()->children[0];
+ child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
+ grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(10, 10)),
+ EventListenerProperties::kBlocking);
+ // Flinging the child layer.
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_
+ ->ScrollBegin(BeginState(gfx::Point(60, 60)).get(),
+ InputHandler::TOUCHSCREEN)
+ .thread);
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->FlingScrollBegin().thread);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child);
+ // Touch on the child layer, which is an active fling layer, the touch
+ // event handler will force to be passive.
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(70, 80)),
+ EventListenerProperties::kBlockingAndPassiveDueToFling);
+ // Touch on the grand child layer, which is a descendant of an active fling
+ // layer, the touch event handler will force to be passive.
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(20, 30)),
+ EventListenerProperties::kBlockingAndPassiveDueToFling);
+
+ // Now flinging on the grand child layer.
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_
+ ->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
+ InputHandler::TOUCHSCREEN)
+ .thread);
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->FlingScrollBegin().thread);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
+ // Touch on the child layer, the touch event handler will still be blocking.
+ EXPECT_EQ(host_impl_->DoTouchHandlersBlockScrollAt(gfx::Point(60, 60)),
+ EventListenerProperties::kBlocking);
+ }
+}
+
class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest {
protected:
std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override {

Powered by Google App Engine
This is Rietveld 408576698