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

Unified Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 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_factory_unittest.cc ('k') | cc/surfaces/surface_id_allocator.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 b4744c99fc5f395490c7f1531eddf0b6a5ca4761..64e85a09f967d06fe507891b03f0fb66c6b2fda8 100644
--- a/cc/surfaces/surface_hittest_unittest.cc
+++ b/cc/surfaces/surface_hittest_unittest.cc
@@ -63,7 +63,8 @@ using namespace test;
TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
SurfaceManager manager;
EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+ FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
+ SurfaceFactory root_factory(root_frame_sink_id, &manager, &client);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -80,11 +81,11 @@ TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
child_surface_id);
// Submit the root frame.
- SurfaceIdAllocator root_allocator(FrameSinkId(2, 2));
+ SurfaceIdAllocator root_allocator(root_frame_sink_id);
SurfaceId root_surface_id = root_allocator.GenerateId();
- factory.Create(root_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.Create(root_surface_id);
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
{
SurfaceHittest hittest(nullptr, &manager);
@@ -95,13 +96,16 @@ TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
root_surface_id, gfx::Point(100, 100), &transform));
}
- factory.Destroy(root_surface_id);
+ root_factory.Destroy(root_surface_id);
}
TEST(SurfaceHittestTest, Hittest_SingleSurface) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+
+ // Set up root FrameSink.
+ EmptySurfaceFactoryClient root_client;
+ FrameSinkId root_frame_sink_id(1, 1);
+ SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -109,11 +113,11 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface) {
CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
// Submit the root frame.
- SurfaceIdAllocator root_allocator(FrameSinkId(2, 2));
+ SurfaceIdAllocator root_allocator(root_frame_sink_id);
SurfaceId root_surface_id = root_allocator.GenerateId();
- factory.Create(root_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.Create(root_surface_id);
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
TestCase tests[] = {
{
root_surface_id,
@@ -125,13 +129,21 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface) {
RunTests(nullptr, &manager, tests, arraysize(tests));
- factory.Destroy(root_surface_id);
+ root_factory.Destroy(root_surface_id);
}
TEST(SurfaceHittestTest, Hittest_ChildSurface) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+
+ // Set up root FrameSink.
+ EmptySurfaceFactoryClient root_client;
+ FrameSinkId root_frame_sink_id(1, 1);
+ SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+
+ // Set up child FrameSink.
+ EmptySurfaceFactoryClient child_client;
+ FrameSinkId child_frame_sink_id(2, 2);
+ SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -139,7 +151,7 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
// Add a reference to the child surface on the root surface.
- SurfaceIdAllocator child_allocator(FrameSinkId(3, 3));
+ SurfaceIdAllocator child_allocator(child_frame_sink_id);
SurfaceId child_surface_id = child_allocator.GenerateId();
gfx::Rect child_rect(200, 200);
CreateSurfaceDrawQuad(root_pass,
@@ -152,11 +164,11 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
child_surface_id);
// Submit the root frame.
- SurfaceIdAllocator root_allocator(FrameSinkId(2, 2));
+ SurfaceIdAllocator root_allocator(root_frame_sink_id);
SurfaceId root_surface_id = root_allocator.GenerateId();
- factory.Create(root_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.Create(root_surface_id);
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -173,9 +185,9 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
root_rect, child_solid_quad_rect);
// Submit the frame.
- factory.Create(child_surface_id);
- factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.Create(child_surface_id);
+ child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
+ SurfaceFactory::DrawCallback());
TestCase tests[] = {
{
@@ -228,8 +240,8 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
root_rect,
child_rect,
child_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
// Verify that point (100, 100) no longer falls on the child surface.
// Verify that the transform to the child surface's space has also shifted.
@@ -253,16 +265,24 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
EXPECT_EQ(gfx::Point(25, 25), point_in_target_space);
}
- factory.Destroy(root_surface_id);
- factory.Destroy(child_surface_id);
+ root_factory.Destroy(root_surface_id);
+ child_factory.Destroy(child_surface_id);
}
// This test verifies that hit testing will progress to the next quad if it
// encounters an invalid RenderPassDrawQuad for whatever reason.
TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+
+ // Set up root FrameSink.
+ EmptySurfaceFactoryClient root_client;
+ FrameSinkId root_frame_sink_id(1, 1);
+ SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+
+ // Set up child FrameSink.
+ EmptySurfaceFactoryClient child_client;
+ FrameSinkId child_frame_sink_id(2, 2);
+ SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -277,7 +297,7 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
RenderPassId(1337, 1337));
// Add a reference to the child surface on the root surface.
- SurfaceIdAllocator child_allocator(FrameSinkId(3, 3));
+ SurfaceIdAllocator child_allocator(child_frame_sink_id);
SurfaceId child_surface_id = child_allocator.GenerateId();
gfx::Rect child_rect(200, 200);
CreateSurfaceDrawQuad(root_pass,
@@ -290,11 +310,11 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
child_surface_id);
// Submit the root frame.
- SurfaceIdAllocator root_allocator(FrameSinkId(2, 2));
+ SurfaceIdAllocator root_allocator(root_frame_sink_id);
SurfaceId root_surface_id = root_allocator.GenerateId();
- factory.Create(root_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.Create(root_surface_id);
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -311,9 +331,9 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
child_solid_quad_rect);
// Submit the frame.
- factory.Create(child_surface_id);
- factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.Create(child_surface_id);
+ child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
+ SurfaceFactory::DrawCallback());
TestCase tests[] = {
{
@@ -356,14 +376,14 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
RunTests(nullptr, &manager, tests, arraysize(tests));
- factory.Destroy(root_surface_id);
- factory.Destroy(child_surface_id);
+ root_factory.Destroy(root_surface_id);
+ child_factory.Destroy(child_surface_id);
}
TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
SurfaceManager manager;
EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+ SurfaceFactory factory(kArbitraryFrameSinkId, &manager, &client);
// Create a CompostiorFrame with two RenderPasses.
gfx::Rect root_rect(300, 300);
@@ -465,8 +485,16 @@ TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
- SurfaceFactory factory(&manager, &client);
+
+ // Set up root FrameSink.
+ EmptySurfaceFactoryClient root_client;
+ FrameSinkId root_frame_sink_id(1, 1);
+ SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+
+ // Set up child FrameSink.
+ EmptySurfaceFactoryClient child_client;
+ FrameSinkId child_frame_sink_id(2, 2);
+ SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -474,7 +502,7 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
// Add a reference to the child surface on the root surface.
- SurfaceIdAllocator child_allocator(FrameSinkId(3, 3));
+ SurfaceIdAllocator child_allocator(child_frame_sink_id);
SurfaceId child_surface_id = child_allocator.GenerateId();
gfx::Rect child_rect(200, 200);
CreateSurfaceDrawQuad(
@@ -486,11 +514,11 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
root_rect, child_rect, child_surface_id);
// Submit the root frame.
- SurfaceIdAllocator root_allocator(FrameSinkId(2, 2));
+ SurfaceIdAllocator root_allocator(root_frame_sink_id);
SurfaceId root_surface_id = root_allocator.GenerateId();
- factory.Create(root_surface_id);
- factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_factory.Create(root_surface_id);
+ root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
+ SurfaceFactory::DrawCallback());
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -505,9 +533,9 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
root_rect, child_solid_quad_rect);
// Submit the frame.
- factory.Create(child_surface_id);
- factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.Create(child_surface_id);
+ child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
+ SurfaceFactory::DrawCallback());
TestCase test_expectations_without_insets[] = {
{root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
@@ -586,7 +614,8 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
EXPECT_EQ(0, accept_delegate.reject_target_overrides());
EXPECT_EQ(2, accept_delegate.accept_target_overrides());
- factory.Destroy(root_surface_id);
+ root_factory.Destroy(root_surface_id);
+ child_factory.Destroy(child_surface_id);
}
} // namespace cc
« no previous file with comments | « cc/surfaces/surface_factory_unittest.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698