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

Unified Diff: cc/layer_tree_host_common_unittest.cc

Issue 12280014: cc: Don't consider HUD layer for touches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unittest Created 7 years, 10 months 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
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..655bbaf5dd79890bc67ed3762c78748111f9fd3c 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,57 @@ 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.f, 0.f);
+ gfx::PointF position(0.f, 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);
+ setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anchor, position, hudBounds, false);
+ hud->setDrawsContent(true);
+
+ hostImpl.activeTree()->set_hud_layer(hud.get());
+ 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(1u, 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;
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698