chromium/components/viz/test/BUILD.gn

# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/buildflag_header.gni")
import("//build/config/ui.gni")
import("//components/viz/viz.gni")
import("//ui/gl/features.gni")

# Android on x86 architecture is likely an emulator. Some multiplanar texture
# types don't work on Android emulator.
is_android_emulator = is_android && (target_cpu == "x64" || target_cpu == "x86")

# Generate a buildflag header to determine which tests should be enabled.
buildflag_header("buildflags") {
  header = "buildflags.h"

  flags = [
    "ENABLE_GL_BACKEND_TESTS=$enable_gl_backend_tests",
    "ENABLE_VULKAN_BACKEND_TESTS=$enable_vulkan_backend_tests",
    "ENABLE_SKIA_GRAPHITE_TESTS=$enable_skia_graphite_tests",
    "IS_ANDROID_EMULATOR=$is_android_emulator",
  ]
}

viz_static_library("test_support") {
  testonly = true
  sources = [
    "begin_frame_args_test.cc",
    "begin_frame_args_test.h",
    "begin_frame_source_test.cc",
    "begin_frame_source_test.h",
    "compositor_frame_helpers.cc",
    "compositor_frame_helpers.h",
    "delegated_ink_point_renderer_skia_for_test.cc",
    "delegated_ink_point_renderer_skia_for_test.h",
    "draw_quad_matchers.cc",
    "draw_quad_matchers.h",
    "fake_compositor_frame_sink_client.cc",
    "fake_compositor_frame_sink_client.h",
    "fake_delay_based_time_source.cc",
    "fake_delay_based_time_source.h",
    "fake_display_client.cc",
    "fake_display_client.h",
    "fake_external_begin_frame_source.cc",
    "fake_external_begin_frame_source.h",
    "fake_host_frame_sink_client.cc",
    "fake_host_frame_sink_client.h",
    "fake_output_surface.cc",
    "fake_output_surface.h",
    "fake_skia_output_surface.cc",
    "fake_skia_output_surface.h",
    "fake_surface_observer.cc",
    "fake_surface_observer.h",
    "gl_scaler_test_util.cc",
    "gl_scaler_test_util.h",
    "gpu_host_impl_test_api.cc",
    "gpu_host_impl_test_api.h",
    "host_frame_sink_manager_test_api.cc",
    "host_frame_sink_manager_test_api.h",
    "mock_compositor_frame_sink_client.cc",
    "mock_compositor_frame_sink_client.h",
    "mock_display_client.cc",
    "mock_display_client.h",
    "mock_helper.h",
    "overlay_candidate_matchers.cc",
    "overlay_candidate_matchers.h",
    "paths.cc",
    "paths.h",
    "stub_surface_client.cc",
    "stub_surface_client.h",
    "surface_id_allocator_set.cc",
    "surface_id_allocator_set.h",
    "test_context_provider.cc",
    "test_context_provider.h",
    "test_context_support.cc",
    "test_context_support.h",
    "test_frame_sink_manager.cc",
    "test_frame_sink_manager.h",
    "test_gles2_interface.cc",
    "test_gles2_interface.h",
    "test_gpu_service_holder.cc",
    "test_gpu_service_holder.h",
    "test_in_process_context_provider.cc",
    "test_in_process_context_provider.h",
    "test_latest_local_surface_id_lookup_delegate.cc",
    "test_latest_local_surface_id_lookup_delegate.h",
    "test_output_surface_provider.cc",
    "test_output_surface_provider.h",
    "test_raster_interface.cc",
    "test_raster_interface.h",
    "test_shared_bitmap_manager.cc",
    "test_shared_bitmap_manager.h",
    "test_shared_image_interface_provider.cc",
    "test_shared_image_interface_provider.h",
    "test_surface_id_allocator.cc",
    "test_surface_id_allocator.h",
    "test_types.cc",
    "test_types.h",
  ]

  deps = [
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/viz/host",
    "//components/viz/service",
    "//gpu:raster",
    "//gpu:test_support",
    "//gpu/command_buffer/client:gles2_implementation",
    "//gpu/command_buffer/client:raster_interface",
    "//gpu/skia_bindings",
    "//services/viz/privileged/mojom",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/base:ozone_buildflags",
    "//ui/gfx/geometry",
    "//ui/gl",
    "//ui/latency:test_support",
  ]

  public_deps = [
    ":buildflags",
    "//gpu/ipc:gl_in_process_context",
  ]

  if (enable_vulkan) {
    deps += [ "//gpu/vulkan/init" ]
  }

  if (use_dawn || skia_use_dawn) {
    deps += [
      "//third_party/dawn/src/dawn:proc",
      "//third_party/dawn/src/dawn/native",
    ]
  }
}

viz_source_set("test_suite") {
  testonly = true
  sources = [
    "viz_test_suite.cc",
    "viz_test_suite.h",
  ]
  deps = [
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//ui/events/platform",
    "//ui/gl:test_support",
  ]
}

viz_source_set("unit_tests") {
  testonly = true
  sources = [
    "begin_frame_source_test_unittest.cc",
    "mock_helper_unittest.cc",
    "test_gles2_interface_unittest.cc",
  ]
  deps = [
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}