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

Unified Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 2795683003: [cc]Replace use of SurfaceFactory with CompositorFrameSinkSupport in tests (Closed)
Patch Set: Address comments Created 3 years, 8 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
Index: cc/surfaces/surface_hittest_unittest.cc
diff --git a/cc/surfaces/surface_hittest_unittest.cc b/cc/surfaces/surface_hittest_unittest.cc
index fc27635c231b3e031d7e5887a5f2659a52b50580..7359d1713e0ef9731538b8ec6b317c9d1def667d 100644
--- a/cc/surfaces/surface_hittest_unittest.cc
+++ b/cc/surfaces/surface_hittest_unittest.cc
@@ -5,10 +5,9 @@
#include <stddef.h>
#include "cc/output/compositor_frame.h"
+#include "cc/surfaces/compositor_frame_sink_support.h"
#include "cc/surfaces/local_surface_id_allocator.h"
#include "cc/surfaces/surface.h"
-#include "cc/surfaces/surface_factory.h"
-#include "cc/surfaces/surface_factory_client.h"
#include "cc/surfaces/surface_hittest.h"
#include "cc/surfaces/surface_manager.h"
#include "cc/test/surface_hittest_test_helpers.h"
@@ -20,8 +19,11 @@ namespace cc {
namespace {
-static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1);
-
+constexpr FrameSinkId kArbitraryFrameSinkId(1, 1);
+constexpr bool is_root = true;
+constexpr bool is_root_child = false;
+constexpr bool handles_frame_sink_id_invalidation = true;
+constexpr bool needs_sync_points = true;
Fady Samuel 2017/04/04 22:48:16 nit: linebreak.
Alex Z. 2017/04/05 14:38:55 Done.
struct TestCase {
SurfaceId input_surface_id;
gfx::Point input_point;
@@ -62,9 +64,10 @@ using namespace test;
// not crash.
TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
- SurfaceFactory root_factory(root_frame_sink_id, &manager, &client);
+ CompositorFrameSinkSupport root_support(
+ nullptr, &manager, kArbitraryFrameSinkId, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -86,9 +89,8 @@ TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
{
SurfaceHittest hittest(nullptr, &manager);
@@ -99,16 +101,17 @@ TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
root_surface_id, gfx::Point(100, 100), &transform));
}
- root_factory.EvictSurface();
+ root_support.EvictFrame();
}
TEST(SurfaceHittestTest, Hittest_SingleSurface) {
SurfaceManager manager;
// Set up root FrameSink.
- EmptySurfaceFactoryClient root_client;
FrameSinkId root_frame_sink_id(1, 1);
- SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+ CompositorFrameSinkSupport root_support(
+ nullptr, &manager, root_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -119,9 +122,8 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
TestCase tests[] = {
{
root_surface_id,
@@ -133,21 +135,23 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface) {
RunTests(nullptr, &manager, tests, arraysize(tests));
- root_factory.EvictSurface();
+ root_support.EvictFrame();
}
TEST(SurfaceHittestTest, Hittest_ChildSurface) {
SurfaceManager manager;
// Set up root FrameSink.
- EmptySurfaceFactoryClient root_client;
FrameSinkId root_frame_sink_id(1, 1);
- SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+ CompositorFrameSinkSupport root_support(
+ nullptr, &manager, root_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Set up child FrameSink.
- EmptySurfaceFactoryClient child_client;
FrameSinkId child_frame_sink_id(2, 2);
- SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
+ CompositorFrameSinkSupport child_support(
+ nullptr, &manager, child_frame_sink_id, is_root_child,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -172,9 +176,8 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -191,9 +194,8 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
root_rect, child_solid_quad_rect);
// Submit the frame.
- child_factory.SubmitCompositorFrame(child_local_surface_id,
- std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_support.SubmitCompositorFrame(child_local_surface_id,
+ std::move(child_frame));
TestCase tests[] = {
{
@@ -246,9 +248,8 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
root_rect,
child_rect,
child_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
// 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.
@@ -272,8 +273,8 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
EXPECT_EQ(gfx::Point(25, 25), point_in_target_space);
}
- root_factory.EvictSurface();
- child_factory.EvictSurface();
+ root_support.EvictFrame();
+ child_support.EvictFrame();
}
// This test verifies that hit testing will progress to the next quad if it
@@ -282,14 +283,16 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
SurfaceManager manager;
// Set up root FrameSink.
- EmptySurfaceFactoryClient root_client;
FrameSinkId root_frame_sink_id(1, 1);
- SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+ CompositorFrameSinkSupport root_support(
+ nullptr, &manager, root_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Set up child FrameSink.
- EmptySurfaceFactoryClient child_client;
FrameSinkId child_frame_sink_id(2, 2);
- SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
+ CompositorFrameSinkSupport child_support(
+ nullptr, &manager, child_frame_sink_id, is_root_child,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -319,9 +322,8 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -338,9 +340,8 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
child_solid_quad_rect);
// Submit the frame.
- child_factory.SubmitCompositorFrame(child_local_surface_id,
- std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_support.SubmitCompositorFrame(child_local_surface_id,
+ std::move(child_frame));
TestCase tests[] = {
{
@@ -383,15 +384,16 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
RunTests(nullptr, &manager, tests, arraysize(tests));
- root_factory.EvictSurface();
- child_factory.EvictSurface();
+ root_support.EvictFrame();
+ child_support.EvictFrame();
}
TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
SurfaceManager manager;
- EmptySurfaceFactoryClient client;
FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
- SurfaceFactory factory(root_frame_sink_id, &manager, &client);
+ CompositorFrameSinkSupport support(
+ nullptr, &manager, root_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Create a CompostiorFrame with two RenderPasses.
gfx::Rect root_rect(300, 300);
@@ -437,8 +439,7 @@ TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ support.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame));
TestCase tests[] = {
// These tests just miss the RenderPassDrawQuad.
@@ -486,21 +487,23 @@ TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
RunTests(nullptr, &manager, tests, arraysize(tests));
- factory.EvictSurface();
+ support.EvictFrame();
}
TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
SurfaceManager manager;
// Set up root FrameSink.
- EmptySurfaceFactoryClient root_client;
FrameSinkId root_frame_sink_id(1, 1);
- SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
+ CompositorFrameSinkSupport root_support(
+ nullptr, &manager, root_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Set up child FrameSink.
- EmptySurfaceFactoryClient child_client;
FrameSinkId child_frame_sink_id(2, 2);
- SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
+ CompositorFrameSinkSupport child_support(
+ nullptr, &manager, child_frame_sink_id, is_root,
+ handles_frame_sink_id_invalidation, needs_sync_points);
// Creates a root surface.
gfx::Rect root_rect(300, 300);
@@ -524,9 +527,8 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
LocalSurfaceIdAllocator root_allocator;
LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
- root_factory.SubmitCompositorFrame(root_local_surface_id,
- std::move(root_frame),
- SurfaceFactory::DrawCallback());
+ root_support.SubmitCompositorFrame(root_local_surface_id,
+ std::move(root_frame));
// Creates a child surface.
RenderPass* child_pass = nullptr;
@@ -541,9 +543,8 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
root_rect, child_solid_quad_rect);
// Submit the frame.
- child_factory.SubmitCompositorFrame(child_local_surface_id,
- std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_support.SubmitCompositorFrame(child_local_surface_id,
+ std::move(child_frame));
TestCase test_expectations_without_insets[] = {
{root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
@@ -622,8 +623,8 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
EXPECT_EQ(0, accept_delegate.reject_target_overrides());
EXPECT_EQ(2, accept_delegate.accept_target_overrides());
- root_factory.EvictSurface();
- child_factory.EvictSurface();
+ root_support.EvictFrame();
+ child_support.EvictFrame();
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698