Index: cc/trees/layer_tree_host_common_unittest.cc |
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc |
index 700bca43eafee460b8ea28a1e991e8f267a59c77..db2181aeedba2ca0f21a03769c8d5a27fb578ed0 100644 |
--- a/cc/trees/layer_tree_host_common_unittest.cc |
+++ b/cc/trees/layer_tree_host_common_unittest.cc |
@@ -6025,6 +6025,90 @@ TEST_F(LayerTreeHostCommonTest, |
EXPECT_EQ(456, result_layer->id()); |
} |
+TEST_F(LayerTreeHostCommonTest, |
+ HitCheckingTouchHandlerOverlappingRegions) { |
+ gfx::Transform identity_matrix; |
+ gfx::PointF anchor; |
+ |
+ FakeImplProxy proxy; |
+ FakeLayerTreeHostImpl host_impl(&proxy); |
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
+ SetLayerPropertiesForTesting(root.get(), |
+ identity_matrix, |
+ identity_matrix, |
+ anchor, |
+ gfx::PointF(), |
+ gfx::Size(100, 100), |
+ false); |
+ { |
+ scoped_ptr<LayerImpl> touch_layer = |
+ LayerImpl::Create(host_impl.active_tree(), 123); |
+ // this layer is positioned, and hit testing should correctly know where the |
+ // layer is located. |
+ gfx::PointF position; |
+ gfx::Size bounds(50, 50); |
+ SetLayerPropertiesForTesting(touch_layer.get(), |
+ identity_matrix, |
+ identity_matrix, |
+ anchor, |
+ position, |
+ bounds, |
+ false); |
+ touch_layer->SetDrawsContent(true); |
+ touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
+ root->AddChild(touch_layer.Pass()); |
+ } |
+ |
+ { |
+ scoped_ptr<LayerImpl> notouch_layer = |
+ LayerImpl::Create(host_impl.active_tree(), 1234); |
+ // this layer is positioned, and hit testing should correctly know where the |
+ // layer is located. |
+ gfx::PointF position(0, 25); |
+ gfx::Size bounds(50, 50); |
+ SetLayerPropertiesForTesting(notouch_layer.get(), |
+ identity_matrix, |
+ identity_matrix, |
+ anchor, |
+ position, |
+ bounds, |
+ false); |
+ notouch_layer->SetDrawsContent(true); |
+ root->AddChild(notouch_layer.Pass()); |
+ } |
+ |
+ LayerImplList render_surface_layer_list; |
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
+ root.get(), root->bounds(), &render_surface_layer_list); |
+ inputs.can_adjust_raster_scales = true; |
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
+ |
+ // Sanity check the scenario we just created. |
+ ASSERT_EQ(1u, render_surface_layer_list.size()); |
+ ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
+ ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id()); |
+ ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id()); |
+ |
+ gfx::Point test_point(35, 35); |
+ LayerImpl* result_layer = |
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
+ test_point, render_surface_layer_list); |
+ EXPECT_FALSE(result_layer); |
+ |
+ test_point = gfx::Point(35, 15); |
+ result_layer = |
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
+ test_point, render_surface_layer_list); |
+ ASSERT_TRUE(result_layer); |
+ EXPECT_EQ(123, result_layer->id()); |
+ |
+ test_point = gfx::Point(35, 65); |
+ result_layer = |
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
+ test_point, render_surface_layer_list); |
+ EXPECT_FALSE(result_layer); |
+} |
+ |
class NoScaleContentLayer : public ContentLayer { |
public: |
static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { |