Chromium Code Reviews| Index: cc/surfaces/surface_unittest.cc |
| diff --git a/cc/surfaces/surface_unittest.cc b/cc/surfaces/surface_unittest.cc |
| index c20f313d9cb3d80ce8c2da054ef9e5271b24f0b4..13b7dc0d40df21080617d9a7e4afdd56929da3e2 100644 |
| --- a/cc/surfaces/surface_unittest.cc |
| +++ b/cc/surfaces/surface_unittest.cc |
| @@ -5,10 +5,9 @@ |
| #include "cc/surfaces/surface.h" |
| #include "base/memory/ptr_util.h" |
| #include "cc/output/copy_output_result.h" |
| +#include "cc/surfaces/compositor_frame_sink_support.h" |
| #include "cc/surfaces/local_surface_id_allocator.h" |
| #include "cc/surfaces/surface_dependency_tracker.h" |
| -#include "cc/surfaces/surface_factory.h" |
| -#include "cc/surfaces/surface_factory_client.h" |
| #include "cc/surfaces/surface_manager.h" |
| #include "cc/test/begin_frame_args_test.h" |
| #include "cc/test/fake_external_begin_frame_source.h" |
| @@ -20,35 +19,21 @@ namespace cc { |
| namespace { |
| static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
|
Fady Samuel
2017/04/03 22:33:25
get rid of static keyword.
I probably introduced
Alex Z.
2017/04/04 14:10:33
Done.
|
| - |
| -class FakeSurfaceFactoryClient : public SurfaceFactoryClient { |
| - public: |
| - FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {} |
| - |
| - void ReturnResources(const ReturnedResourceArray& resources) override {} |
| - |
| - void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override { |
| - begin_frame_source_ = begin_frame_source; |
| - } |
| - |
| - BeginFrameSource* begin_frame_source() { return begin_frame_source_; } |
| - |
| - private: |
| - BeginFrameSource* begin_frame_source_; |
| -}; |
| +static constexpr bool is_root = true; |
| +static constexpr bool handles_frame_sink_id_invalidation = true; |
| +static constexpr bool need_sync_points = true; |
|
Fady Samuel
2017/04/03 22:33:25
Get rid of static if in anonymous namespace.
Alex Z.
2017/04/04 14:10:33
Done.
|
| TEST(SurfaceTest, SurfaceLifetime) { |
| SurfaceManager manager; |
| - FakeSurfaceFactoryClient surface_factory_client; |
| - SurfaceFactory factory(kArbitraryFrameSinkId, &manager, |
| - &surface_factory_client); |
| + CompositorFrameSinkSupport support( |
| + nullptr, &manager, kArbitraryFrameSinkId, is_root, |
| + handles_frame_sink_id_invalidation, need_sync_points); |
| LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); |
| SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
| - factory.SubmitCompositorFrame(local_surface_id, CompositorFrame(), |
| - SurfaceFactory::DrawCallback()); |
| + support.SubmitCompositorFrame(local_surface_id, CompositorFrame()); |
| EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
| - factory.EvictSurface(); |
| + support.EvictFrame(); |
| EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); |
| } |
| @@ -71,21 +56,20 @@ void TestCopyResultCallback(bool* called, |
| // aggregated on the next frame. |
| TEST(SurfaceTest, CopyRequestLifetime) { |
| SurfaceManager manager; |
| - FakeSurfaceFactoryClient surface_factory_client; |
| - SurfaceFactory factory(kArbitraryFrameSinkId, &manager, |
| - &surface_factory_client); |
| + CompositorFrameSinkSupport support( |
| + nullptr, &manager, kArbitraryFrameSinkId, is_root, |
| + handles_frame_sink_id_invalidation, need_sync_points); |
| LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); |
| SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
| CompositorFrame frame; |
| frame.render_pass_list.push_back(RenderPass::Create()); |
| - factory.SubmitCompositorFrame(local_surface_id, std::move(frame), |
| - SurfaceFactory::DrawCallback()); |
| + support.SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| Surface* surface = manager.GetSurfaceForId(surface_id); |
| ASSERT_TRUE(!!surface); |
| bool copy_called = false; |
| - factory.RequestCopyOfSurface(CopyOutputRequest::CreateRequest( |
| + support.RequestCopyOfSurface(CopyOutputRequest::CreateRequest( |
| base::Bind(&TestCopyResultCallback, ©_called))); |
| EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
| EXPECT_FALSE(copy_called); |
| @@ -99,8 +83,7 @@ TEST(SurfaceTest, CopyRequestLifetime) { |
| frame.render_pass_list.back()->id = i * 3 + start_id + 1; |
| frame.render_pass_list.push_back(RenderPass::Create()); |
| frame.render_pass_list.back()->id = i * 3 + start_id + 2; |
| - factory.SubmitCompositorFrame(local_surface_id, std::move(frame), |
| - SurfaceFactory::DrawCallback()); |
| + support.SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| } |
| int last_pass_id = (max_frame - 1) * 3 + start_id + 2; |
| @@ -120,7 +103,7 @@ TEST(SurfaceTest, CopyRequestLifetime) { |
| copy_requests.find(last_pass_id)->second->SendEmptyResult(); |
| EXPECT_TRUE(copy_called); |
| - factory.EvictSurface(); |
| + support.EvictFrame(); |
| } |
| } // namespace |