# 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("//chrome/android/modules/buildflags.gni")
import("//chrome/common/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("//tools/grit/repack.gni")
if (is_android) {
import("//build/config/android/rules.gni")
}
assert(enable_vr)
component("vr_ui") {
sources = [
"databinding/binding.h",
"databinding/binding_base.h",
"elements/corner_radii.h",
"elements/draw_phase.cc",
"elements/draw_phase.h",
"elements/environment/grid.cc",
"elements/environment/grid.h",
"elements/full_screen_rect.cc",
"elements/full_screen_rect.h",
"elements/indicator_spec.cc",
"elements/indicator_spec.h",
"elements/linear_layout.cc",
"elements/linear_layout.h",
"elements/rect.cc",
"elements/rect.h",
"elements/scaled_depth_adjuster.cc",
"elements/scaled_depth_adjuster.h",
"elements/text.cc",
"elements/text.h",
"elements/textured_element.cc",
"elements/textured_element.h",
"elements/transient_element.cc",
"elements/transient_element.h",
"elements/ui_element.cc",
"elements/ui_element.h",
"elements/ui_element_name.cc",
"elements/ui_element_name.h",
"elements/ui_element_type.cc",
"elements/ui_element_type.h",
"elements/ui_texture.cc",
"elements/ui_texture.h",
"elements/vector_icon.cc",
"elements/vector_icon.h",
"elements/viewport_aware_root.cc",
"elements/viewport_aware_root.h",
"frame_lifecycle.cc",
"frame_lifecycle.h",
"model/color_scheme.cc",
"model/color_scheme.h",
"model/model.cc",
"model/model.h",
"renderers/base_quad_renderer.cc",
"renderers/base_quad_renderer.h",
"renderers/base_renderer.cc",
"renderers/base_renderer.h",
"renderers/grid_renderer.cc",
"renderers/grid_renderer.h",
"renderers/radial_gradient_quad_renderer.cc",
"renderers/radial_gradient_quad_renderer.h",
"renderers/textured_quad_renderer.cc",
"renderers/textured_quad_renderer.h",
"skia_surface_provider.cc",
"skia_surface_provider.h",
"skia_surface_provider_factory.h",
"target_property.cc",
"target_property.h",
"ui.cc",
"ui.h",
"ui_element_renderer.cc",
"ui_element_renderer.h",
"ui_renderer.cc",
"ui_renderer.h",
"ui_scene.cc",
"ui_scene.h",
"ui_scene_creator.cc",
"ui_scene_creator.h",
"vr_ui_export.h",
]
if (is_win) {
sources += [
"elements/spinner.cc",
"elements/spinner.h",
]
}
deps = [
":vr_base",
"//base",
"//chrome/app:generated_resources",
"//chrome/app/vector_icons",
"//chrome/common:constants",
"//components/vector_icons",
"//device/base",
"//device/vr:vr_base",
"//device/vr/buildflags:buildflags",
"//media",
"//net",
"//skia",
"//ui/gfx/animation/keyframe",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
defines = [ "VR_UI_IMPLEMENTATION" ]
if (use_native_partitions) {
# Mark symbols in this library as belonging to the VR partition. Only
# exported symbols (module entrypoints) are affected.
cflags = [ "-fsymbol-partition=vr_partition" ]
}
if (is_android) {
sources += [ "jni_onload.cc" ]
deps += [ "//third_party/jni_zero" ]
}
if (use_command_buffer) {
sources += [
"cmd_buffer_surface_provider.cc",
"cmd_buffer_surface_provider.h",
"skia_surface_provider_factory_cmd_buffer.cc",
]
deps += [
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/skia_bindings",
]
} else {
sources += [
"native_gl_surface_provider.cc",
"native_gl_surface_provider.h",
"skia_surface_provider_factory_native_gl.cc",
]
deps += [ "//ui/gl/init" ]
}
}
component("vr_common") {
sources = [
"browser_renderer.cc",
"browser_renderer.h",
"frame_type.h",
"graphics_delegate.cc",
"graphics_delegate.h",
"vr_browser_renderer_thread.cc",
"vr_browser_renderer_thread.h",
"vr_export.h",
"vr_web_contents_observer.cc",
"vr_web_contents_observer.h",
]
public_deps = [
":vr_base",
"//device/vr/public/mojom:isolated_xr_service",
]
deps = [
":vr_ui",
"//base",
"//cc/paint",
"//chrome/common:constants",
"//components/ukm/content",
"//content/public/browser",
"//device/base",
"//device/vr:vr_util",
"//device/vr/buildflags:buildflags",
"//device/vr/public/mojom:isolated_xr_service",
"//media",
"//net",
"//services/audio/public/cpp",
"//services/metrics/public/cpp:ukm_builders",
"//skia",
"//ui/base",
"//ui/display",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
defines = [ "VR_IMPLEMENTATION" ]
if (is_win) {
sources += [
"graphics_delegate_win.cc",
"graphics_delegate_win.h",
]
deps += [ "//services/viz/public/cpp/gpu" ]
}
if (is_android) {
sources += [
"graphics_delegate_android.cc",
"graphics_delegate_android.h",
]
deps += [
"//components/webxr",
"//device/vr/android:vr_android",
"//gpu/command_buffer/service:gles2",
"//ui/gl/init",
]
}
}
# vr_base contains common dependencies of vr_common and vr_ui. It exists because
# vr_ui must not depend on vr_common.
component("vr_base") {
sources = [
"browser_ui_interface.h",
"fov_rectangle.h",
"macros.h",
"model/camera_model.h",
"model/capturing_state_model.h",
"model/web_vr_model.h",
"pose_util.cc",
"pose_util.h",
"render_info.h",
"scheduler_ui_interface.h",
"ui_interface.h",
"ui_test_input.cc",
"ui_test_input.h",
"vr_base_export.h",
"vr_geometry_util.cc",
"vr_geometry_util.h",
]
defines = [ "VR_BASE_IMPLEMENTATION" ]
public_deps = [
"//components/strings:components_strings_grit",
"//content/public/common",
"//device/vr:vr_gl_bindings",
"//device/vr/public/cpp",
"//ui/base",
]
deps = [
"//base",
"//chrome/app:generated_resources",
"//components/security_state/core",
"//components/ukm/content",
"//components/url_formatter",
"//content/public/browser",
"//device/vr/public/mojom:isolated_xr_service",
"//media",
"//net",
"//services/metrics/public/cpp:ukm_builders",
"//skia",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
}
test("vr_common_unittests") {
sources = [
"browser_renderer_unittest.cc",
"databinding/binding_unittest.cc",
"elements/linear_layout_unittest.cc",
"elements/rect_unittest.cc",
"elements/scaled_depth_adjuster_unittest.cc",
"elements/text_unittest.cc",
"elements/transient_element_unittest.cc",
"elements/ui_element_unittest.cc",
"elements/vector_icon_unittest.cc",
"elements/viewport_aware_root_unittest.cc",
"test/paths.cc",
"test/paths.h",
"test/run_all_unittests.cc",
"test/ui_test.cc",
"test/ui_test.h",
"ui_scene_unittest.cc",
"ui_unittest.cc",
]
if (is_win) {
sources += [ "elements/spinner_unittest.cc" ]
}
deps = [
":vr_test_support",
"//chrome/app/vector_icons",
"//chrome/browser",
"//chrome/test:test_support",
"//components/url_formatter",
"//components/vector_icons",
"//content/test:test_support",
"//mojo/public/cpp/bindings",
"//services/network:test_support",
"//testing/gmock",
"//ui/gfx:test_support",
"//ui/gfx/animation/keyframe",
"//ui/gfx/geometry",
]
if (is_android) {
deps += [
"//chrome:chrome_android_core",
"//ui/android:ui_java",
]
}
}
test("vr_common_perftests") {
sources = [
"test/run_all_perftests.cc",
"text_perftest.cc",
]
deps = [
":vr_gl_test_support",
":vr_test_support",
"//testing/perf",
]
if (is_android) {
deps += [ "//ui/android:ui_java" ]
}
# Needed for isolate script to execute
data_deps = [ "//testing:run_perf_test" ]
}
source_set("vr_test_support") {
testonly = true
sources = [
"test/animation_utils.cc",
"test/animation_utils.h",
"test/constants.cc",
"test/constants.h",
"test/mock_browser_ui_interface.cc",
"test/mock_browser_ui_interface.h",
"test/vr_test_suite.cc",
"test/vr_test_suite.h",
]
public_deps = [
":vr_common",
":vr_ui",
"//base/test:test_support",
"//cc:test_support",
"//components/security_state/core",
"//content/test:test_support",
"//mojo/core/embedder",
"//skia",
"//testing/gtest",
"//ui/accessibility:ax_enums_mojo",
"//ui/gfx:test_support",
# TODO(mthiesse, crbug.com/769373): Remove dependency on device/vr:fakes.
"//device/vr:vr_fakes",
# TODO(cjgrant): Figure out why including //ui/android:ui_java here
# doesn't propagate to individual test executable targets.
]
data_deps = [ ":vr_test_pak" ]
}
source_set("vr_gl_test_support") {
testonly = true
sources = [
"test/gl_test_environment.h",
"test/gl_test_environment_unittest.cc",
"test/vr_gl_test_suite.cc",
"test/vr_gl_test_suite.h",
]
public_deps = [
"//base/test:test_support",
"//device/vr:vr_gl_bindings",
"//skia",
"//testing/gtest",
]
deps = [
":vr_test_support",
"//ui/gl:test_support",
]
if (use_command_buffer) {
sources += [ "test/gl_test_environment_cmd_buffer.cc" ]
deps += [
"//gpu:gpu",
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/ipc:gl_in_process_context",
]
} else {
sources += [ "test/gl_test_environment_native_gl.cc" ]
}
}
repack("vr_test_pak") {
sources = [
"$root_gen_dir/chrome/generated_resources_en-US.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/strings/components_strings_en-US.pak",
]
output = "$root_out_dir/vr_test.pak"
deps = [
"//chrome/app:generated_resources",
"//components/resources:components_resources",
"//components/strings",
]
}
if (!is_android) {
# This should only contain that files that are useful if enable_vr = true. For
# tests/infrastructure that can be used with enable_vr = false, see
# //chrome/test:xr_browser_tests_common.
source_set("xr_browser_tests_vr_required") {
testonly = true
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
# Infrastructure
sources = [
"test/mock_xr_device_hook_base.cc",
"test/mock_xr_device_hook_base.h",
]
deps = [
":vr_common",
"//chrome/common:constants",
"//chrome/test:xr_browser_tests_common",
"//device/vr:vr",
"//device/vr/buildflags:buildflags",
"//device/vr/orientation",
"//device/vr/public/mojom:isolated_xr_service",
"//device/vr/public/mojom:test_mojom",
]
data_deps = []
# Windows-only tests and dependencies.
if (is_win) {
# Infrastructure.
sources += [
"test/ui_utils.cc",
"test/ui_utils.h",
]
# Tests.
sources += [
"webxr_vr_frame_loop_browser_test.cc",
"webxr_vr_frame_pose_browser_test.cc",
"webxr_vr_indicators_browser_test.cc",
"webxr_vr_input_browser_test.cc",
"webxr_vr_isolated_device_service_test.cc",
"webxr_vr_permission_browser_test.cc",
"webxr_vr_permission_request_browser_test.cc",
"webxr_vr_pixel_browser_test.cc",
"webxr_vr_secondary_views_browser_test.cc",
"webxr_vr_tab_browser_test.cc",
"webxr_vr_transition_browser_test.cc",
]
deps += [
":vr_common",
"//components/content_settings/core/browser",
"//device/vr:directx_helpers",
"//device/vr:openxr_data",
]
if (enable_openxr) {
deps += [ "//third_party/openxr" ]
data_deps += [ "//device/vr:openxr_mock" ]
}
}
}
}