Chromium Code Reviews| 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..702a3925b7cffa2497deecb52ee1c06650a851bd 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_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)), |
| + EventListenerProperties::kBlocking); |
|
bokan
2016/11/17 15:39:28
EXPECT_EQ's arguments are (expected, actual), whic
lanwei
2016/11/18 00:54:07
Acknowledged.
|
| // 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_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)), |
|
bokan
2016/11/17 15:39:28
Ditto to these ones.
lanwei
2016/11/18 00:54:07
Done.
|
| + EventListenerProperties::kBlocking); |
| root->SetTouchEventHandlerRegion(gfx::Rect()); |
| - EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| + EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(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_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)), |
| + EventListenerProperties::kBlocking); |
| } |
| TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { |
| @@ -9928,6 +9932,75 @@ TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { |
| EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
| } |
| +TEST_F(LayerTreeHostImplTest, TouchInsideOrOutsideFlingLayer) { |
|
bokan
2016/11/17 15:39:28
Please add a short 1-2 sentence comment above desc
lanwei
2016/11/18 00:54:07
Done.
|
| + gfx::Size surface_size(100, 100); |
| + gfx::Size inner_size(50, 50); |
| + |
| + LayerImpl* root = |
| + CreateBasicVirtualViewportLayers(surface_size, surface_size); |
|
bokan
2016/11/17 15:39:28
I think the viewports should be the inner_size (we
lanwei
2016/11/18 00:54:07
Done.
|
| + root->test_properties()->force_render_surface = true; |
| + |
| + std::unique_ptr<LayerImpl> child = |
| + CreateScrollableLayer(26, surface_size, root); |
| + std::unique_ptr<LayerImpl> grand_child = |
| + CreateScrollableLayer(27, inner_size, root); |
|
bokan
2016/11/17 15:39:28
I think the clip for the grand_child should be chi
lanwei
2016/11/18 00:54:07
Sorry, I tried, but they do not work. I want to be
bokan
2016/11/18 18:41:36
Ok, thanks for trying.
|
| + LayerImpl* grand_child_layer = grand_child.get(); |
| + child->test_properties()->AddChild(std::move(grand_child)); |
| + |
| + LayerImpl* child_layer = child.get(); |
| + root->test_properties()->AddChild(std::move(child)); |
| + host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| + host_impl_->active_tree()->DidBecomeActive(); |
| + |
| + grand_child_layer->layer_tree_impl() |
| + ->property_trees() |
| + ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| + gfx::ScrollOffset(0, 5)); |
| + child_layer->layer_tree_impl() |
| + ->property_trees() |
| + ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| + gfx::ScrollOffset(3, 0)); |
| + |
| + host_impl_->SetViewportSize(surface_size); |
|
bokan
2016/11/17 15:39:28
No need for this, it's called as part of CreateBas
lanwei
2016/11/18 00:54:07
Done.
|
| + DrawFrame(); |
| + { |
| + child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| + grand_child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| + EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(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_layer); |
| + // Touch on the child layer, which is an active fling layer, the touch |
| + // event handler will force to be passive. |
| + EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(70, 80)), |
| + EventListenerProperties::kBlockingAndMaybePassiveDueToFling); |
| + // 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_->EventListenerTypeForTouchStartAt(gfx::Point(20, 30)), |
| + EventListenerProperties::kBlockingAndMaybePassiveDueToFling); |
| + |
| + // 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_layer); |
| + // Touch on the child layer, the touch event handler will still be blocking. |
| + EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(60, 60)), |
| + EventListenerProperties::kBlocking); |
| + } |
| +} |
| + |
| class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| protected: |
| std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |