Chromium Code Reviews| Index: cc/layer_tree_host_common_unittest.cc |
| diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc |
| index 3724971481965ee38f3ab54f8f52b95460c83997..2b9c0ff4fd2f94f51fd8f665d8b8a90003423011 100644 |
| --- a/cc/layer_tree_host_common_unittest.cc |
| +++ b/cc/layer_tree_host_common_unittest.cc |
| @@ -6,9 +6,11 @@ |
| #include "cc/content_layer.h" |
| #include "cc/content_layer_client.h" |
| +#include "cc/heads_up_display_layer_impl.h" |
| #include "cc/layer.h" |
| #include "cc/layer_animation_controller.h" |
| #include "cc/layer_impl.h" |
| +#include "cc/layer_tree_impl.h" |
| #include "cc/math_util.h" |
| #include "cc/proxy.h" |
| #include "cc/single_thread_proxy.h" |
| @@ -2962,6 +2964,58 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
| EXPECT_EQ(12345, resultLayer->id()); |
| } |
| +TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) |
| +{ |
| + FakeImplProxy proxy; |
| + FakeLayerTreeHostImpl hostImpl(&proxy); |
| + scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345); |
| + scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::create(hostImpl.activeTree(), 11111); |
| + |
| + gfx::Transform identityMatrix; |
| + gfx::PointF anchor(0, 0); |
|
danakj
2013/02/19 20:08:12
0.f
|
| + gfx::PointF position(0, 0); |
|
danakj
2013/02/19 20:08:12
0.f
|
| + gfx::Size bounds(100, 100); |
| + setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anchor, position, bounds, false); |
| + root->setDrawsContent(true); |
| + |
| + // Create hud and add it as a child of root. |
| + gfx::Size hudBounds(200, 200); |
| + hud->setForceRenderSurface(true); |
|
danakj
2013/02/19 20:08:12
why this? the hud doesn't own a surface in product
|
| + setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anchor, position, hudBounds, false); |
| + hud->setDrawsContent(true); |
|
danakj
2013/02/19 20:08:12
not needed for the hud. it always draws content.
|
| + |
| + hostImpl.activeTree()->set_hud_layer(hud.get()); |
|
danakj
2013/02/19 20:08:12
I really dislike that this unit test is now needin
|
| + root->addChild(hud.PassAs<LayerImpl>()); |
| + |
| + std::vector<LayerImpl*> renderSurfaceLayerList; |
| + int dummyMaxTextureSize = 512; |
| + LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| + |
| + // Sanity check the scenario we just created. |
| + ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| + ASSERT_EQ(2u, root->renderSurface()->layerList().size()); |
| + |
| + // Hit testing for a point inside HUD, but outside root should return null |
| + gfx::Point testPoint(101, 101); |
| + LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); |
| + EXPECT_FALSE(resultLayer); |
| + |
| + testPoint = gfx::Point(-1, -1); |
| + resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); |
| + EXPECT_FALSE(resultLayer); |
| + |
| + // Hit testing for a point inside should return the root layer, never the HUD layer. |
| + testPoint = gfx::Point(1, 1); |
| + resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); |
| + ASSERT_TRUE(resultLayer); |
| + EXPECT_EQ(12345, resultLayer->id()); |
| + |
| + testPoint = gfx::Point(99, 99); |
| + resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); |
| + ASSERT_TRUE(resultLayer); |
| + EXPECT_EQ(12345, resultLayer->id()); |
| +} |
| + |
| TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| { |
| FakeImplProxy proxy; |