Skip to content

Commit

Permalink
viz: Move FakeOutputSurface + dependencies.
Browse files Browse the repository at this point in the history
This CL moves test classes from cc/test to components/viz/test. The main
classes being moved are implementations of viz types and belong in
components/viz/test.

1. FakeOutputSurface
2. TestContextProvider
3. TestContextSupport

There are a number of ancillary classes that also need to be moved.
These classes are test implementations of gpu types. The dependency
structure, where cc:test_support depends on components/viz/test,
requires the classes be moved also. It's likely the base gpu types will
eventually be moved to components/viz/service/gpu in the future.

1. OrderedTextureMap
2. TestGLES2Interface
3. TestTexture
4. TestWebGraphicsContext3D

Bug: 814475
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic1fdb0262b222b6cf6054621ef8647f63ee26bcd
Reviewed-on: https://chromium-review.googlesource.com/934624
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539169}
  • Loading branch information
kylechar authored and Commit Bot committed Feb 26, 2018
1 parent 4e9b4a4 commit dfe762f
Show file tree
Hide file tree
Showing 69 changed files with 688 additions and 671 deletions.
15 changes: 0 additions & 15 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ cc_static_library("test_support") {
"test/fake_layer_tree_host_impl_client.h",
"test/fake_mask_layer_impl.cc",
"test/fake_mask_layer_impl.h",
"test/fake_output_surface.cc",
"test/fake_output_surface.h",
"test/fake_output_surface_client.cc",
"test/fake_output_surface_client.h",
"test/fake_paint_image_generator.cc",
Expand Down Expand Up @@ -466,8 +464,6 @@ cc_static_library("test_support") {
"test/mock_layer_tree_mutator.cc",
"test/mock_layer_tree_mutator.h",
"test/mock_occlusion_tracker.h",
"test/ordered_texture_map.cc",
"test/ordered_texture_map.h",
"test/paint_op_helper.h",
"test/pixel_comparator.cc",
"test/pixel_comparator.h",
Expand Down Expand Up @@ -499,12 +495,6 @@ cc_static_library("test_support") {
"test/stub_layer_tree_host_single_thread_client.h",
"test/task_graph_runner_test_template.cc",
"test/task_graph_runner_test_template.h",
"test/test_context_provider.cc",
"test/test_context_provider.h",
"test/test_context_support.cc",
"test/test_context_support.h",
"test/test_gles2_interface.cc",
"test/test_gles2_interface.h",
"test/test_hooks.cc",
"test/test_hooks.h",
"test/test_image_factory.cc",
Expand All @@ -518,16 +508,12 @@ cc_static_library("test_support") {
"test/test_skcanvas.h",
"test/test_task_graph_runner.cc",
"test/test_task_graph_runner.h",
"test/test_texture.cc",
"test/test_texture.h",
"test/test_tile_priorities.cc",
"test/test_tile_priorities.h",
"test/test_tile_task_runner.cc",
"test/test_tile_task_runner.h",
"test/test_ukm_recorder_factory.cc",
"test/test_ukm_recorder_factory.h",
"test/test_web_graphics_context_3d.cc",
"test/test_web_graphics_context_3d.h",
"test/transfer_cache_test_helper.cc",
"test/transfer_cache_test_helper.h",
]
Expand Down Expand Up @@ -654,7 +640,6 @@ cc_test("cc_unittests") {
"scheduler/scheduler_state_machine_unittest.cc",
"scheduler/scheduler_unittest.cc",
"test/layer_tree_json_parser_unittest.cc",
"test/test_web_graphics_context_3d_unittest.cc",
"tiles/checker_image_tracker_unittest.cc",
"tiles/decoded_image_tracker_unittest.cc",
"tiles/gpu_image_decode_cache_unittest.cc",
Expand Down
1 change: 0 additions & 1 deletion cc/layers/nine_patch_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "cc/resources/scoped_ui_resource.h"
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_output_surface_client.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_task_graph_runner.h"
Expand Down
10 changes: 5 additions & 5 deletions cc/layers/picture_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#include "cc/test/skia_common.h"
#include "cc/test/test_layer_tree_host_base.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/tiles/tiling_set_raster_queue_all.h"
#include "cc/tiles/tiling_set_raster_queue_required.h"
#include "cc/trees/layer_tree_impl.h"
#include "components/viz/common/quads/draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/test/begin_frame_args_test.h"
#include "components/viz/test/test_web_graphics_context_3d.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
Expand Down Expand Up @@ -1452,8 +1452,8 @@ TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
ResetTilingsAndRasterScales();

// Change the max texture size on the output surface context.
std::unique_ptr<TestWebGraphicsContext3D> context =
TestWebGraphicsContext3D::Create();
std::unique_ptr<viz::TestWebGraphicsContext3D> context =
viz::TestWebGraphicsContext3D::Create();
context->set_max_texture_size(140);
ResetLayerTreeFrameSink(FakeLayerTreeFrameSink::Create3d(std::move(context)));

Expand Down Expand Up @@ -1487,8 +1487,8 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) {
ResetTilingsAndRasterScales();

// Change the max texture size on the output surface context.
std::unique_ptr<TestWebGraphicsContext3D> context =
TestWebGraphicsContext3D::Create();
std::unique_ptr<viz::TestWebGraphicsContext3D> context =
viz::TestWebGraphicsContext3D::Create();
context->set_max_texture_size(140);
ResetLayerTreeFrameSink(FakeLayerTreeFrameSink::Create3d(std::move(context)));

Expand Down
7 changes: 4 additions & 3 deletions cc/layers/scrollbar_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#include "cc/test/layer_tree_test.h"
#include "cc/test/mock_occlusion_tracker.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
Expand All @@ -40,6 +38,8 @@
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/tree_synchronizer.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_web_graphics_context_3d.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down Expand Up @@ -1382,7 +1382,8 @@ TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) {

// Try something extreme to be larger than max texture size, and make it a
// non-integer for funsies.
scoped_refptr<TestContextProvider> context = TestContextProvider::Create();
scoped_refptr<viz::TestContextProvider> context =
viz::TestContextProvider::Create();
// Keep the max texture size reasonable so we don't OOM on low end devices
// (crbug.com/642333).
context->UnboundTestContext3d()->set_max_texture_size(512);
Expand Down
1 change: 0 additions & 1 deletion cc/layers/surface_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host.h"
Expand Down
1 change: 0 additions & 1 deletion cc/layers/texture_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "cc/test/layer_tree_test.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
Expand Down
1 change: 1 addition & 0 deletions cc/paint/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fuzzer_test("paint_op_buffer_fuzzer") {
deps = [
"//cc:test_support",
"//cc/paint",
"//components/viz/test:test_support",
]
}

Expand Down
5 changes: 5 additions & 0 deletions cc/paint/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
specific_include_rules = {
"paint_op_buffer_fuzzer.cc": [
"+components/viz/test",
],
}
6 changes: 3 additions & 3 deletions cc/paint/paint_op_buffer_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <stdint.h>

#include "cc/paint/paint_op_buffer.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/transfer_cache_test_helper.h"
#include "components/viz/test/test_context_provider.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"

Expand All @@ -19,8 +19,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {

SkImageInfo image_info = SkImageInfo::MakeN32(
kRasterDimension, kRasterDimension, kOpaque_SkAlphaType);
scoped_refptr<cc::TestContextProvider> context_provider =
cc::TestContextProvider::Create();
scoped_refptr<viz::TestContextProvider> context_provider =
viz::TestContextProvider::Create();
context_provider->BindToCurrentThread();
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
context_provider->GrContext(), SkBudgeted::kYes, image_info);
Expand Down
11 changes: 5 additions & 6 deletions cc/raster/raster_buffer_provider_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
#include "cc/resources/resource_pool.h"
#include "cc/resources/resource_provider.h"
#include "cc/test/fake_resource_provider.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_context_support.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/tiles/tile_task_manager.h"
#include "components/viz/common/gpu/context_cache_controller.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/resources/platform_color.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_context_support.h"
#include "components/viz/test/test_gpu_memory_buffer_manager.h"
#include "components/viz/test/test_shared_bitmap_manager.h"
#include "gpu/command_buffer/client/raster_implementation_gles.h"
Expand Down Expand Up @@ -116,7 +115,7 @@ class PerfContextProvider
gpu::ContextSupport* ContextSupport() override { return &support_; }
class GrContext* GrContext() override {
if (!test_context_provider_) {
test_context_provider_ = TestContextProvider::Create();
test_context_provider_ = viz::TestContextProvider::Create();
}
return test_context_provider_->GrContext();
}
Expand All @@ -138,8 +137,8 @@ class PerfContextProvider
std::unique_ptr<PerfGLES2Interface> context_gl_;
std::unique_ptr<gpu::raster::RasterInterface> raster_context_;

scoped_refptr<TestContextProvider> test_context_provider_;
TestContextSupport support_;
scoped_refptr<viz::TestContextProvider> test_context_provider_;
viz::TestContextSupport support_;
viz::ContextCacheController cache_controller_;
base::Lock context_lock_;
gpu::Capabilities capabilities_;
Expand Down
17 changes: 9 additions & 8 deletions cc/raster/raster_buffer_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
#include "cc/resources/resource_provider.h"
#include "cc/test/fake_raster_source.h"
#include "cc/test/fake_resource_provider.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/tiles/tile_task_manager.h"
#include "components/viz/common/resources/platform_color.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_gpu_memory_buffer_manager.h"
#include "components/viz/test/test_shared_bitmap_manager.h"
#include "components/viz/test/test_web_graphics_context_3d.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -296,10 +296,11 @@ class RasterBufferProviderTest

private:
void Create3dResourceProvider() {
context_provider_ = TestContextProvider::Create();
context_provider_ = viz::TestContextProvider::Create();
context_provider_->BindToCurrentThread();
worker_context_provider_ = TestContextProvider::CreateWorker();
TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d();
worker_context_provider_ = viz::TestContextProvider::CreateWorker();
viz::TestWebGraphicsContext3D* context3d =
context_provider_->TestContext3d();
context3d->set_support_sync_query(true);
resource_provider_ = FakeResourceProvider::CreateLayerTreeResourceProvider(
context_provider_.get(), &shared_bitmap_manager_,
Expand All @@ -317,8 +318,8 @@ class RasterBufferProviderTest
}

protected:
scoped_refptr<TestContextProvider> context_provider_;
scoped_refptr<TestContextProvider> worker_context_provider_;
scoped_refptr<viz::TestContextProvider> context_provider_;
scoped_refptr<viz::TestContextProvider> worker_context_provider_;
std::unique_ptr<ResourcePool> pool_;
std::unique_ptr<LayerTreeResourceProvider> resource_provider_;
std::unique_ptr<TileTaskManager> tile_task_manager_;
Expand Down Expand Up @@ -352,7 +353,7 @@ TEST_P(RasterBufferProviderTest, FailedMapResource) {
if (GetParam() == RASTER_BUFFER_PROVIDER_TYPE_BITMAP)
return;

TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d();
viz::TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d();
context3d->set_times_map_buffer_chromium_succeeds(0);
AppendTask(0u);
ScheduleTasks();
Expand Down
5 changes: 3 additions & 2 deletions cc/raster/scoped_gpu_raster_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

#include "cc/raster/scoped_gpu_raster.h"
#include "cc/test/test_context_provider.h"
#include "components/viz/test/test_context_provider.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
Expand All @@ -16,7 +16,8 @@ class ScopedGpuRasterTest : public testing::Test {

// Releasing ScopedGpuRaster should restore GL_UNPACK_ALIGNMENT == 4.
TEST(ScopedGpuRasterTest, RestoresUnpackAlignment) {
scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
scoped_refptr<viz::TestContextProvider> provider =
viz::TestContextProvider::Create();
ASSERT_EQ(provider->BindToCurrentThread(), gpu::ContextResult::kSuccess);
gpu::gles2::GLES2Interface* gl = provider->ContextGL();
GLint unpack_alignment = 0;
Expand Down
4 changes: 2 additions & 2 deletions cc/raster/staging_buffer_pool_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "cc/test/test_context_provider.h"
#include "components/viz/test/test_context_provider.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {

TEST(StagingBufferPoolTest, ShutdownImmediatelyAfterCreation) {
auto context_provider = TestContextProvider::CreateWorker();
auto context_provider = viz::TestContextProvider::CreateWorker();
LayerTreeResourceProvider* resource_provider = nullptr;
bool use_partial_raster = false;
int max_staging_buffer_usage_in_bytes = 1024;
Expand Down
6 changes: 3 additions & 3 deletions cc/resources/layer_tree_resource_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <memory>

#include "base/bind.h"
#include "cc/test/test_context_provider.h"
#include "components/viz/common/resources/single_release_callback.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_gpu_memory_buffer_manager.h"
#include "components/viz/test/test_shared_bitmap_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
Expand All @@ -23,7 +23,7 @@ class LayerTreeResourceProviderTest : public testing::TestWithParam<bool> {
protected:
LayerTreeResourceProviderTest()
: use_gpu_(GetParam()),
context_provider_(TestContextProvider::Create()),
context_provider_(viz::TestContextProvider::Create()),
bound_(context_provider_->BindToCurrentThread()),
provider_(std::make_unique<LayerTreeResourceProvider>(
use_gpu_ ? context_provider_.get() : nullptr,
Expand Down Expand Up @@ -71,7 +71,7 @@ class LayerTreeResourceProviderTest : public testing::TestWithParam<bool> {

private:
bool use_gpu_;
scoped_refptr<TestContextProvider> context_provider_;
scoped_refptr<viz::TestContextProvider> context_provider_;
gpu::ContextResult bound_;
viz::TestSharedBitmapManager shared_bitmap_manager_;
viz::TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
Expand Down
6 changes: 3 additions & 3 deletions cc/resources/resource_pool_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "cc/resources/resource_util.h"
#include "cc/test/fake_resource_provider.h"
#include "cc/test/test_context_provider.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand All @@ -20,7 +20,7 @@ namespace cc {
class ResourcePoolTest : public testing::Test {
public:
void SetUp() override {
context_provider_ = TestContextProvider::Create();
context_provider_ = viz::TestContextProvider::Create();
context_provider_->BindToCurrentThread();
resource_provider_ = FakeResourceProvider::CreateLayerTreeResourceProvider(
context_provider_.get(), nullptr);
Expand Down Expand Up @@ -53,7 +53,7 @@ class ResourcePoolTest : public testing::Test {
}

viz::TestSharedBitmapManager shared_bitmap_manager_;
scoped_refptr<TestContextProvider> context_provider_;
scoped_refptr<viz::TestContextProvider> context_provider_;
std::unique_ptr<LayerTreeResourceProvider> resource_provider_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
std::unique_ptr<ResourcePool> resource_pool_;
Expand Down
Loading

0 comments on commit dfe762f

Please sign in to comment.