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

Unified Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 1663433002: Adds an interface to SurfaceHittestDelegate in order to override (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/surfaces/surface_hittest_delegate.h ('k') | cc/test/surface_hittest_test_helpers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_hittest_unittest.cc
diff --git a/cc/surfaces/surface_hittest_unittest.cc b/cc/surfaces/surface_hittest_unittest.cc
index 5970d45e3ad79617aa313e448a005f00d9dd772e..9c1309c4a37c792f41e539b2033f850cac6acaec 100644
--- a/cc/surfaces/surface_hittest_unittest.cc
+++ b/cc/surfaces/surface_hittest_unittest.cc
@@ -505,10 +505,11 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
CreateCompositorFrame(child_rect, &child_pass);
// Add a solid quad in the child surface.
- gfx::Rect child_solid_quad_rect(200, 200);
+ gfx::Rect child_solid_quad_rect(190, 190);
CreateSolidColorDrawQuad(
child_pass,
- gfx::Transform(),
+ gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
root_rect, child_solid_quad_rect);
// Submit the frame.
@@ -517,78 +518,81 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
SurfaceFactory::DrawCallback());
TestCase test_expectations_without_insets[] = {
- {
- root_surface_id,
- gfx::Point(50, 50),
- child_surface_id,
- gfx::Point(0, 0)
- },
- {
- root_surface_id,
- gfx::Point(60, 60),
- child_surface_id,
- gfx::Point(10, 10)
- },
- {
- root_surface_id,
- gfx::Point(239, 239),
- child_surface_id,
- gfx::Point(189, 189)
- },
- {
- root_surface_id,
- gfx::Point(249, 249),
- child_surface_id,
- gfx::Point(199, 199)
- },
+ {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
+ {root_surface_id, gfx::Point(60, 60), child_surface_id,
+ gfx::Point(10, 10)},
+ {root_surface_id, gfx::Point(239, 239), child_surface_id,
+ gfx::Point(189, 189)},
+ {root_surface_id, gfx::Point(244, 244), child_surface_id,
+ gfx::Point(194, 194)},
+ {root_surface_id, gfx::Point(50, 50), root_surface_id,
+ gfx::Point(50, 50)},
+ {root_surface_id, gfx::Point(249, 249), root_surface_id,
+ gfx::Point(249, 249)},
};
- TestSurfaceHittestDelegate delegate;
- RunTests(&delegate, &manager, test_expectations_without_insets,
+ TestSurfaceHittestDelegate empty_delegate;
+ RunTests(&empty_delegate, &manager, test_expectations_without_insets,
arraysize(test_expectations_without_insets));
// Verify that insets have NOT affected hit targeting.
- EXPECT_EQ(0, delegate.target_overrides());
+ EXPECT_EQ(0, empty_delegate.reject_target_overrides());
+ EXPECT_EQ(0, empty_delegate.accept_target_overrides());
+
+ TestCase test_expectations_with_reject_insets[] = {
+ // Point (55, 55) falls outside the child surface due to the insets
+ // introduced above.
+ {root_surface_id, gfx::Point(55, 55), root_surface_id,
+ gfx::Point(55, 55)},
+ // These two points still fall within the child surface.
+ {root_surface_id, gfx::Point(60, 60), child_surface_id,
+ gfx::Point(10, 10)},
+ {root_surface_id, gfx::Point(239, 239), child_surface_id,
+ gfx::Point(189, 189)},
+ // Point (244, 244) falls outside the child surface due to the insets
+ // introduced above.
+ {root_surface_id, gfx::Point(244, 244), root_surface_id,
+ gfx::Point(244, 244)},
+ // Next two points also fall within within the insets indroduced above.
+ {root_surface_id, gfx::Point(50, 50), root_surface_id,
+ gfx::Point(50, 50)},
+ {root_surface_id, gfx::Point(249, 249), root_surface_id,
+ gfx::Point(249, 249)},
+ };
- delegate.AddInsetsForSurface(child_surface_id, gfx::Insets(10, 10, 10, 10));
+ TestSurfaceHittestDelegate reject_delegate;
+ reject_delegate.AddInsetsForRejectSurface(child_surface_id,
+ gfx::Insets(10, 10, 10, 10));
+ RunTests(&reject_delegate, &manager, test_expectations_with_reject_insets,
+ arraysize(test_expectations_with_reject_insets));
- TestCase test_expectations_with_insets[] = {
- // Point (50, 50) falls outside the child surface due to the insets
- // introduced above.
- {
- root_surface_id,
- gfx::Point(50, 50),
- root_surface_id,
- gfx::Point(50, 50)
- },
- // These two points still fall within the child surface.
- {
- root_surface_id,
- gfx::Point(60, 60),
- child_surface_id,
- gfx::Point(10, 10)
- },
- {
- root_surface_id,
- gfx::Point(239, 239),
- child_surface_id,
- gfx::Point(189, 189)
- },
- // Point (249, 249) falls outside the child surface due to the insets
- // introduced above.
- {
- root_surface_id,
- gfx::Point(249, 249),
- root_surface_id,
- gfx::Point(249, 249)
- },
+ // Verify that insets have affected hit targeting.
+ EXPECT_EQ(4, reject_delegate.reject_target_overrides());
+ EXPECT_EQ(0, reject_delegate.accept_target_overrides());
+
+ TestCase test_expectations_with_accept_insets[] = {
+ {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
+ {root_surface_id, gfx::Point(60, 60), child_surface_id,
+ gfx::Point(10, 10)},
+ {root_surface_id, gfx::Point(239, 239), child_surface_id,
+ gfx::Point(189, 189)},
+ {root_surface_id, gfx::Point(244, 244), child_surface_id,
+ gfx::Point(194, 194)},
+ // Next two points fall within within the insets indroduced above.
+ {root_surface_id, gfx::Point(50, 50), child_surface_id, gfx::Point(0, 0)},
+ {root_surface_id, gfx::Point(249, 249), child_surface_id,
+ gfx::Point(199, 199)},
};
- RunTests(&delegate, &manager, test_expectations_with_insets,
- arraysize(test_expectations_with_insets));
+ TestSurfaceHittestDelegate accept_delegate;
+ accept_delegate.AddInsetsForAcceptSurface(child_surface_id,
+ gfx::Insets(5, 5, 5, 5));
+ RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets,
+ arraysize(test_expectations_with_accept_insets));
// Verify that insets have affected hit targeting.
- EXPECT_EQ(2, delegate.target_overrides());
+ EXPECT_EQ(0, accept_delegate.reject_target_overrides());
+ EXPECT_EQ(2, accept_delegate.accept_target_overrides());
factory.Destroy(root_surface_id);
}
« no previous file with comments | « cc/surfaces/surface_hittest_delegate.h ('k') | cc/test/surface_hittest_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698