| Index: cc/surfaces/surface_hittest_unittest.cc
|
| diff --git a/cc/surfaces/surface_hittest_unittest.cc b/cc/surfaces/surface_hittest_unittest.cc
|
| index 92c61b8d0845207b3e5a33bc0a5382f93f7df42b..9bb7128183706a825a7434e2e41181cbc2871867 100644
|
| --- a/cc/surfaces/surface_hittest_unittest.cc
|
| +++ b/cc/surfaces/surface_hittest_unittest.cc
|
| @@ -3,18 +3,13 @@
|
| // found in the LICENSE file.
|
|
|
| #include "cc/output/compositor_frame.h"
|
| -#include "cc/output/delegated_frame_data.h"
|
| -#include "cc/quads/render_pass.h"
|
| -#include "cc/quads/render_pass_draw_quad.h"
|
| -#include "cc/quads/render_pass_id.h"
|
| -#include "cc/quads/solid_color_draw_quad.h"
|
| -#include "cc/quads/surface_draw_quad.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_id_allocator.h"
|
| #include "cc/surfaces/surface_manager.h"
|
| +#include "cc/test/surface_hittest_test_helpers.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/skia/include/core/SkColor.h"
|
| #include "ui/gfx/geometry/size.h"
|
| @@ -52,103 +47,10 @@ void RunTests(SurfaceManager* manager, TestCase* tests, size_t test_count) {
|
| }
|
| }
|
|
|
| -class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
|
| - public:
|
| - void ReturnResources(const ReturnedResourceArray& resources) override {}
|
| - void SetBeginFrameSource(SurfaceId surface_id,
|
| - BeginFrameSource* begin_frame_source) override {}
|
| -};
|
| -
|
| -void CreateSharedQuadState(RenderPass* pass,
|
| - const gfx::Transform& transform,
|
| - const gfx::Rect& root_rect) {
|
| - SharedQuadState* child_shared_state =
|
| - pass->CreateAndAppendSharedQuadState();
|
| - child_shared_state->SetAll(transform,
|
| - root_rect.size(),
|
| - root_rect, root_rect, false, 1.0f,
|
| - SkXfermode::kSrcOver_Mode, 0);
|
| -}
|
| -
|
| -void CreateSolidColorDrawQuad(RenderPass* pass,
|
| - const gfx::Transform& transform,
|
| - const gfx::Rect& root_rect,
|
| - const gfx::Rect& quad_rect) {
|
| - CreateSharedQuadState(pass, transform, root_rect);
|
| - SolidColorDrawQuad* color_quad =
|
| - pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
|
| - color_quad->SetNew(pass->shared_quad_state_list.back(),
|
| - quad_rect, quad_rect,
|
| - SK_ColorYELLOW, false);
|
| -}
|
| -
|
| -void CreateRenderPassDrawQuad(RenderPass* pass,
|
| - const gfx::Transform& transform,
|
| - const gfx::Rect& root_rect,
|
| - const gfx::Rect& quad_rect,
|
| - const RenderPassId& render_pass_id) {
|
| - CreateSharedQuadState(pass, transform, root_rect);
|
| - RenderPassDrawQuad* render_pass_quad =
|
| - pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
|
| - render_pass_quad->SetNew(pass->shared_quad_state_list.back(),
|
| - quad_rect, quad_rect,
|
| - render_pass_id,
|
| - ResourceId(),
|
| - gfx::Vector2dF(),
|
| - gfx::Size(),
|
| - FilterOperations(),
|
| - gfx::Vector2dF(),
|
| - FilterOperations());
|
| -}
|
| -
|
| -void CreateSurfaceDrawQuad(RenderPass* pass,
|
| - const gfx::Transform& transform,
|
| - const gfx::Rect& root_rect,
|
| - const gfx::Rect& quad_rect,
|
| - SurfaceId surface_id) {
|
| - CreateSharedQuadState(pass, transform, root_rect);
|
| - SurfaceDrawQuad* surface_quad =
|
| - pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
|
| - surface_quad->SetNew(pass->shared_quad_state_list.back(),
|
| - quad_rect, quad_rect,
|
| - surface_id);
|
| -}
|
| -
|
| -void CreateRenderPass(const RenderPassId& render_pass_id,
|
| - const gfx::Rect& rect,
|
| - const gfx::Transform& transform_to_root_target,
|
| - RenderPassList* render_pass_list) {
|
| - scoped_ptr<RenderPass> render_pass = RenderPass::Create();
|
| - render_pass->SetNew(render_pass_id, rect, rect, transform_to_root_target);
|
| - render_pass_list->push_back(render_pass.Pass());
|
| -}
|
| -
|
| -scoped_ptr<CompositorFrame> CreateCompositorFrameWithRenderPassList(
|
| - RenderPassList* render_pass_list) {
|
| - scoped_ptr<DelegatedFrameData> root_delegated_frame_data(
|
| - new DelegatedFrameData);
|
| - root_delegated_frame_data->render_pass_list.swap(*render_pass_list);
|
| - scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
|
| - root_frame->delegated_frame_data = root_delegated_frame_data.Pass();
|
| - return root_frame.Pass();
|
| -}
|
| -
|
| -scoped_ptr<CompositorFrame> CreateCompositorFrame(
|
| - const gfx::Rect& root_rect,
|
| - RenderPass** render_pass) {
|
| - RenderPassList render_pass_list;
|
| - RenderPassId root_id(1, 1);
|
| - CreateRenderPass(root_id, root_rect, gfx::Transform(), &render_pass_list);
|
| -
|
| - scoped_ptr<CompositorFrame> root_frame =
|
| - CreateCompositorFrameWithRenderPassList(&render_pass_list);
|
| -
|
| - *render_pass = root_frame->delegated_frame_data->render_pass_list.back();
|
| - return root_frame.Pass();
|
| -}
|
| -
|
| } // namespace
|
|
|
| +using namespace test;
|
| +
|
| // This test verifies that hit testing on a surface that does not exist does
|
| // not crash.
|
| TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
|
| @@ -218,7 +120,7 @@ TEST(SurfaceHittestTest, Hittest_SingleSurface) {
|
| },
|
| };
|
|
|
| - RunTests(&manager, tests, sizeof(tests) / sizeof(*tests));
|
| + RunTests(&manager, tests, arraysize(tests));
|
|
|
| factory.Destroy(root_surface_id);
|
| }
|
| @@ -313,7 +215,7 @@ TEST(SurfaceHittestTest, Hittest_ChildSurface) {
|
| }
|
| };
|
|
|
| - RunTests(&manager, tests, sizeof(tests) / sizeof(*tests));
|
| + RunTests(&manager, tests, arraysize(tests));
|
|
|
| // Submit another root frame, with a slightly perturbed child Surface.
|
| root_frame = CreateCompositorFrame(root_rect, &root_pass);
|
| @@ -453,7 +355,7 @@ TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
|
| }
|
| };
|
|
|
| - RunTests(&manager, tests, sizeof(tests) / sizeof(*tests));
|
| + RunTests(&manager, tests, arraysize(tests));
|
|
|
| factory.Destroy(root_surface_id);
|
| factory.Destroy(child_surface_id);
|
| @@ -557,7 +459,7 @@ TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
|
| }
|
| };
|
|
|
| - RunTests(&manager, tests, sizeof(tests) / sizeof(*tests));
|
| + RunTests(&manager, tests, arraysize(tests));
|
|
|
| factory.Destroy(root_surface_id);
|
| }
|
|
|