Index: cc/trees/layer_tree_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc |
index b6cf7f23148086434762b7d1c74c644493137d9c..42b34b9e84848a6faa54855618c99620da155f7e 100644 |
--- a/cc/trees/layer_tree_impl_unittest.cc |
+++ b/cc/trees/layer_tree_impl_unittest.cc |
@@ -380,6 +380,74 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { |
ASSERT_FALSE(result_layer); |
} |
+TEST_F(LayerTreeImplTest, HitTestingSiblings) { |
+ // This tests hit testing when the test point hits only one of the siblings. |
+ gfx::Transform identity_matrix; |
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
+ SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(100, 100), true, false, |
+ true); |
+ scoped_ptr<LayerImpl> child1 = |
+ LayerImpl::Create(host_impl().active_tree(), 2); |
+ SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(25, 25), true, false, |
+ false); |
+ child1->SetMasksToBounds(true); |
+ child1->SetDrawsContent(true); |
+ scoped_ptr<LayerImpl> child2 = |
+ LayerImpl::Create(host_impl().active_tree(), 3); |
+ SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(75, 75), true, false, |
+ false); |
+ child2->SetMasksToBounds(true); |
+ child2->SetDrawsContent(true); |
+ root->AddChild(std::move(child1)); |
+ root->AddChild(std::move(child2)); |
+ |
+ host_impl().SetViewportSize(root->bounds()); |
+ host_impl().active_tree()->SetRootLayer(std::move(root)); |
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
+ |
+ gfx::PointF test_point(50.f, 50.f); |
+ LayerImpl* result_layer = |
+ host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
+ ASSERT_TRUE(result_layer); |
+ EXPECT_EQ(3, result_layer->id()); |
+} |
+ |
+TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { |
+ gfx::Transform identity_matrix; |
+ int max_texture_size = |
+ host_impl().active_tree()->resource_provider()->max_texture_size(); |
+ gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); |
+ |
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
+ SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), bounds, true, false, true); |
+ |
+ scoped_ptr<LayerImpl> surface = |
+ LayerImpl::Create(host_impl().active_tree(), 2); |
+ SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), bounds, true, false, true); |
+ surface->SetMasksToBounds(true); |
+ surface->SetDrawsContent(true); |
+ |
+ root->AddChild(std::move(surface)); |
+ host_impl().SetViewportSize(root->bounds()); |
+ host_impl().active_tree()->SetRootLayer(std::move(root)); |
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
+ |
+ gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); |
+ LayerImpl* result_layer = |
+ host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
+ ASSERT_TRUE(result_layer); |
ajuma
2016/01/06 14:18:55
EXPECT_TRUE
(it would make sense to use ASSERT if
jaydasika
2016/01/06 19:31:20
Done.
|
+ |
+ test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); |
+ result_layer = |
+ host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
+ ASSERT_FALSE(result_layer); |
ajuma
2016/01/06 14:18:55
EXPECT_FALSE
jaydasika
2016/01/06 19:31:20
Done.
|
+} |
+ |
TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { |
scoped_ptr<LayerImpl> root = |
LayerImpl::Create(host_impl().active_tree(), 12345); |