blob: 7fba23ce37408d5c617c827236ce0f12ae10a056 [file] [log] [blame]
# Copyright 2017 The Chromium Authors. All rights reserved.
# 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/browser/vr/features.gni")
import("//chrome/common/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//tools/grit/repack.gni")
if (is_android) {
import("//build/config/android/rules.gni")
}
assert(enable_vr)
buildflag_header("vr_buildflags") {
header = "vr_buildflags.h"
flags = [ "USE_VR_ASSETS_COMPONENT=$use_vr_assets_component" ]
}
use_command_buffer = is_win
config("vr_gl_mode") {
if (use_command_buffer) {
defines = [
"VR_USE_COMMAND_BUFFER",
"GL_GLEXT_PROTOTYPES",
]
} else {
defines = [ "VR_USE_NATIVE_GL" ]
}
}
component("vr_ui") {
sources = [
"animation.cc",
"animation.h",
"databinding/binding.h",
"databinding/binding_base.h",
"databinding/vector_binding.h",
"databinding/vector_element_binding.h",
"elements/button.cc",
"elements/button.h",
"elements/content_element.cc",
"elements/content_element.h",
"elements/controller.cc",
"elements/controller.h",
"elements/corner_radii.h",
"elements/disc_button.cc",
"elements/disc_button.h",
"elements/draw_phase.cc",
"elements/draw_phase.h",
"elements/environment/background.cc",
"elements/environment/background.h",
"elements/environment/grid.cc",
"elements/environment/grid.h",
"elements/environment/stars.cc",
"elements/environment/stars.h",
"elements/full_screen_rect.cc",
"elements/full_screen_rect.h",
"elements/indicator_spec.cc",
"elements/indicator_spec.h",
"elements/invisible_hit_target.cc",
"elements/invisible_hit_target.h",
"elements/keyboard.cc",
"elements/keyboard.h",
"elements/laser.cc",
"elements/laser.h",
"elements/linear_layout.cc",
"elements/linear_layout.h",
"elements/omnibox_formatting.cc",
"elements/omnibox_formatting.h",
"elements/omnibox_text_field.cc",
"elements/omnibox_text_field.h",
"elements/oval.cc",
"elements/oval.h",
"elements/platform_ui_element.cc",
"elements/platform_ui_element.h",
"elements/rect.cc",
"elements/rect.h",
"elements/render_text_wrapper.cc",
"elements/render_text_wrapper.h",
"elements/repositioner.cc",
"elements/repositioner.h",
"elements/resizer.cc",
"elements/resizer.h",
"elements/reticle.cc",
"elements/reticle.h",
"elements/scaled_depth_adjuster.cc",
"elements/scaled_depth_adjuster.h",
"elements/scrollable_element.cc",
"elements/scrollable_element.h",
"elements/shadow.cc",
"elements/shadow.h",
"elements/spinner.cc",
"elements/spinner.h",
"elements/text.cc",
"elements/text.h",
"elements/text_button.cc",
"elements/text_button.h",
"elements/text_input.cc",
"elements/text_input.h",
"elements/textured_element.cc",
"elements/textured_element.h",
"elements/throbber.cc",
"elements/throbber.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/url_text.cc",
"elements/url_text.h",
"elements/vector_icon.cc",
"elements/vector_icon.h",
"elements/vector_icon_button.cc",
"elements/vector_icon_button.h",
"elements/viewport_aware_root.cc",
"elements/viewport_aware_root.h",
"font_fallback.cc",
"font_fallback.h",
"font_fallback_android.cc",
"font_fallback_linux.cc",
"font_fallback_win.cc",
"frame_lifecycle.cc",
"frame_lifecycle.h",
"model/color_scheme.cc",
"model/color_scheme.h",
"model/modal_prompt_type.cc",
"model/modal_prompt_type.h",
"model/model.cc",
"model/model.h",
"model/platform_toast.cc",
"model/platform_toast.h",
"renderers/base_quad_renderer.cc",
"renderers/base_quad_renderer.h",
"renderers/base_renderer.cc",
"renderers/base_renderer.h",
"renderers/external_textured_quad_renderer.cc",
"renderers/external_textured_quad_renderer.h",
"renderers/radial_gradient_quad_renderer.cc",
"renderers/radial_gradient_quad_renderer.h",
"renderers/texture_copy_renderer.cc",
"renderers/texture_copy_renderer.h",
"renderers/textured_quad_renderer.cc",
"renderers/textured_quad_renderer.h",
"renderers/transparent_quad_renderer.cc",
"renderers/transparent_quad_renderer.h",
"sequence.cc",
"sequence.h",
"skia_surface_provider.h",
"skia_surface_provider_factory.h",
"target_property.cc",
"target_property.h",
"transition.cc",
"transition.h",
"ui.cc",
"ui.h",
"ui_element_renderer.cc",
"ui_element_renderer.h",
"ui_input_manager.cc",
"ui_input_manager.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",
]
sources += [
"ui_input_manager_for_testing.cc",
"ui_input_manager_for_testing.h",
]
deps = [
":vr_base",
"//base",
"//cc/animation",
"//chrome/app:generated_resources",
"//chrome/common:constants",
"//components/url_formatter",
"//media",
"//net",
"//skia",
]
defines = [ "VR_UI_IMPLEMENTATION" ]
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 = [
"base_scheduler_delegate.cc",
"base_scheduler_delegate.h",
"browser_renderer.cc",
"browser_renderer.h",
"browser_renderer_browser_interface.h",
"frame_type.h",
"gesture_detector.cc",
"gesture_detector.h",
"graphics_delegate.h",
"input_delegate.h",
"location_bar_helper.cc",
"location_bar_helper.h",
"platform_controller.h",
"scheduler_browser_renderer_interface.h",
"scheduler_delegate.h",
"service/browser_xr_runtime.cc",
"service/browser_xr_runtime.h",
"service/vr_service_impl.cc",
"service/vr_service_impl.h",
"service/xr_device_impl.cc",
"service/xr_device_impl.h",
"service/xr_runtime_manager.cc",
"service/xr_runtime_manager.h",
"service/xr_runtime_manager_observer.h",
"sounds_manager_audio_delegate.cc",
"sounds_manager_audio_delegate.h",
"vr_export.h",
"vr_web_contents_observer.cc",
"vr_web_contents_observer.h",
]
sources += [
"input_delegate_for_testing.cc",
"input_delegate_for_testing.h",
"platform_controller_for_testing.cc",
"platform_controller_for_testing.h",
]
public_deps = [
":vr_base",
]
deps = [
"//base",
"//cc/animation",
"//cc/paint",
"//chrome/common:constants",
"//components/omnibox/browser",
"//components/omnibox/browser",
"//components/rappor/public:public",
"//components/ukm/content",
"//content/public/browser",
"//device/vr",
"//device/vr/buildflags:buildflags",
"//device/vr/public/mojom",
"//media",
"//net",
"//services/audio/public/cpp",
"//services/metrics/public/cpp:ukm_builders",
"//skia",
"//ui/base",
"//ui/display",
]
if (is_win) {
sources += [
"service/isolated_device_provider.cc",
"service/isolated_device_provider.h",
"service/vr_ui_host.cc",
"service/vr_ui_host.h",
"win/graphics_delegate_win.cc",
"win/graphics_delegate_win.h",
"win/input_delegate_win.cc",
"win/input_delegate_win.h",
"win/scheduler_delegate_win.cc",
"win/scheduler_delegate_win.h",
"win/vr_browser_renderer_thread_win.cc",
"win/vr_browser_renderer_thread_win.h",
]
deps += [ "//services/ws/public/cpp/gpu" ]
# Windows doesn't have app bundles, so include the UI directly.
deps += [ ":vr_ui" ]
}
defines = [ "VR_IMPLEMENTATION" ]
if (!use_command_buffer) {
sources += [
"base_graphics_delegate.cc",
"base_graphics_delegate.h",
]
deps += [ "//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 = [
"assets_component_update_status.h",
"assets_load_status.h",
"assets_loader.cc",
"assets_loader.h",
"audio_delegate.h",
"browser_ui_interface.h",
"content_input_delegate.cc",
"content_input_delegate.h",
"exit_vr_prompt_choice.h",
"fov_rectangle.h",
"gl_bindings.h",
"gl_texture_location.h",
"input_event.cc",
"input_event.h",
"keyboard_delegate.h",
"keyboard_ui_interface.h",
"macros.h",
"metrics/metrics_helper.cc",
"metrics/metrics_helper.h",
"metrics/session_metrics_helper.cc",
"metrics/session_metrics_helper.h",
"mode.h",
"model/assets.cc",
"model/assets.h",
"model/camera_model.h",
"model/capturing_state_model.h",
"model/controller_model.cc",
"model/controller_model.h",
"model/hosted_platform_ui.h",
"model/location_bar_state.cc",
"model/location_bar_state.h",
"model/omnibox_suggestions.cc",
"model/omnibox_suggestions.h",
"model/reticle_model.h",
"model/speech_recognition_model.h",
"model/text_input_info.cc",
"model/text_input_info.h",
"model/ui_mode.h",
"model/web_vr_model.h",
"platform_input_handler.h",
"platform_ui_input_delegate.cc",
"platform_ui_input_delegate.h",
"pose_util.cc",
"pose_util.h",
"render_info.h",
"scheduler_ui_interface.h",
"speech_recognizer.cc",
"speech_recognizer.h",
"text_edit_action.cc",
"text_edit_action.h",
"text_input_delegate.cc",
"text_input_delegate.h",
"ui_browser_interface.h",
"ui_initial_state.cc",
"ui_initial_state.h",
"ui_interface.h",
"ui_support.cc",
"ui_support.h",
"ui_test_input.h",
"ui_unsupported_mode.h",
"vr_base_export.h",
"vr_geometry_util.cc",
"vr_geometry_util.h",
"vr_gl_util.cc",
"vr_gl_util.h",
]
sources += [
"keyboard_delegate_for_testing.cc",
"keyboard_delegate_for_testing.h",
]
defines = [ "VR_BASE_IMPLEMENTATION" ]
public_deps = [
":vr_buildflags",
":vr_gl_bindings",
"//components/omnibox/browser",
"//components/strings:components_strings_grit",
"//content/public/common",
"//ui/base",
]
deps = [
"//base",
"//chrome/app:generated_resources",
"//chrome/app/vector_icons",
"//chrome/browser/vr/vector_icons",
"//components/omnibox/browser:vector_icons",
"//components/rappor:rappor",
"//components/security_state/core",
"//components/ukm/content",
"//components/url_formatter",
"//components/vector_icons",
"//content/public/browser:browser",
"//media",
"//net",
"//services/metrics/public/cpp:ukm_builders",
"//skia",
]
}
source_set("vr_gl_bindings") {
sources = [
"gl_bindings.h",
]
public_configs = [ ":vr_gl_mode" ]
if (use_command_buffer) {
public_deps = [
"//gpu/command_buffer/client:gles2_c_lib",
]
} else {
public_deps = [
"//ui/gl",
]
}
}
test("vr_common_unittests") {
sources = [
"animation_unittest.cc",
"base_scheduler_delegate_unittest.cc",
"browser_renderer_unittest.cc",
"databinding/binding_unittest.cc",
"databinding/vector_binding_unittest.cc",
"elements/button_unittest.cc",
"elements/content_element_unittest.cc",
"elements/disc_button_unittest.cc",
"elements/linear_layout_unittest.cc",
"elements/omnibox_formatting_unittest.cc",
"elements/omnibox_text_field_unittest.cc",
"elements/oval_unittest.cc",
"elements/rect_unittest.cc",
"elements/repositioner_unittest.cc",
"elements/resizer_unittest.cc",
"elements/scaled_depth_adjuster_unittest.cc",
"elements/scrollable_element_unittest.cc",
"elements/shadow_unittest.cc",
"elements/spinner_unittest.cc",
"elements/text_input_unittest.cc",
"elements/text_unittest.cc",
"elements/throbber_unittest.cc",
"elements/transient_element_unittest.cc",
"elements/ui_element_unittest.cc",
"elements/url_text_unittest.cc",
"elements/vector_icon_button_unittest.cc",
"elements/vector_icon_unittest.cc",
"elements/viewport_aware_root_unittest.cc",
"gesture_detector_unittest.cc",
"model/text_input_info_unittest.cc",
"platform_ui_input_delegate_unittest.cc",
"service/xr_runtime_manager_unittest.cc",
"speech_recognizer_unittest.cc",
"test/paths.cc",
"test/paths.h",
"test/run_all_unittests.cc",
"test/ui_test.cc",
"test/ui_test.h",
"ui_input_manager_unittest.cc",
"ui_scene_unittest.cc",
"ui_unittest.cc",
"vr_geometry_util_unittest.cc",
]
# TODO(mthiesse, crbug.com/769373): The dependency on device/vr:fakes requires
# some workarounds for tests, since we are static-linking to the fakes instead
# of loading them from a dll on Windows.
defines = [ "DEVICE_VR_IMPLEMENTATION" ]
deps = [
":vr_test_support",
"//components/url_formatter",
"//components/vector_icons",
"//mojo/public/cpp/bindings",
"//services/network:test_support",
"//testing/gmock",
"//ui/gfx/geometry",
]
if (is_android) {
deps += [ "//ui/android:ui_java" ]
}
}
test("vr_pixeltests") {
testonly = true
sources = [
"test/run_all_pixeltests.cc",
"test/ui_pixel_test.cc",
"test/ui_pixel_test.h",
"ui_pixeltest.cc",
]
deps = [
":vr_gl_test_support",
":vr_test_support",
]
if (is_android) {
deps += [ "//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/mock_content_input_delegate.cc",
"test/mock_content_input_delegate.h",
"test/mock_keyboard_delegate.cc",
"test/mock_keyboard_delegate.h",
"test/mock_render_text.cc",
"test/mock_render_text.h",
"test/mock_text_input_delegate.cc",
"test/mock_text_input_delegate.h",
"test/mock_ui_browser_interface.cc",
"test/mock_ui_browser_interface.h",
"test/vr_test_suite.cc",
"test/vr_test_suite.h",
]
public_deps = [
":vr_common",
":vr_test_pak",
":vr_ui",
"//base/test:test_support",
"//cc:test_support",
"//components/omnibox/browser:browser",
"//components/omnibox/browser:vector_icons",
"//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:fakes",
# TODO(cjgrant): Figure out why including //ui/android:ui_java here
# doesn't propagate to individual test executable targets.
]
data = [
"$root_out_dir/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 = [
":vr_gl_bindings",
"//base/test:test_support",
"//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",
]
}
# This is split out here instead of being part of //chrome/test:browser_tests
# because the tests have hardware requirements and this is cleaner than trying
# to conditionally skip tests based on hardware (browser tests don't have
# the equivalent to Android's @Restriction annotation that allows you to
# easily skip tests at runtime).
if (!is_android) {
group("xr_browser_tests") {
testonly = true
data_deps = [
":xr_browser_tests_binary",
":xr_browser_tests_runner",
]
if (is_win) {
# The .exe is necessary even though the target isn't an actual executable
# since mb.py automatically appends .exe when looking for runtime deps
# on Windows.
write_runtime_deps = "$root_out_dir/$target_name.exe.runtime_deps"
} else {
write_runtime_deps = "$root_out_dir/$target_name.runtime_deps"
}
}
test("xr_browser_tests_binary") {
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
# Common infrastructure.
sources = [
"test/mock_xr_device_hook_base.cc",
"test/mock_xr_device_hook_base.h",
"test/webvr_browser_test.cc",
"test/webvr_browser_test.h",
"test/webxr_browser_test.cc",
"test/webxr_browser_test.h",
"test/webxr_vr_browser_test.cc",
"test/webxr_vr_browser_test.h",
"test/xr_browser_test.cc",
"test/xr_browser_test.h",
]
# Common/partially common tests.
sources += [
"webxr_vr_spatial_tracking_test.cc",
"webxr_vr_transition_browser_test.cc",
]
# Common dependencies.
deps = [
":vr_common",
"//base",
"//chrome:packed_resources",
"//chrome/test:browser_tests_runner",
"//chrome/test:test_support",
"//chrome/test:test_support_ui",
"//device/base",
"//device/vr:vr",
"//device/vr/buildflags:buildflags",
"//device/vr/public/mojom:mojom",
"//device/vr/public/mojom:test_mojom",
"//services/service_manager/sandbox",
]
data_deps = []
# Common data
data = [
"//chrome/test/data/xr/e2e_test_files/",
"//third_party/blink/web_tests/resources/testharness.js",
"$root_out_dir/locales/",
"$root_out_dir/chrome_100_percent.pak",
"$root_out_dir/chrome_200_percent.pak",
"$root_out_dir/resources.pak",
]
# Windows-only tests and dependencies.
if (is_win) {
# Infrastructure.
sources += [
"test/browser_test_browser_renderer_browser_interface.cc",
"test/browser_test_browser_renderer_browser_interface.h",
"test/ui_utils.cc",
"test/ui_utils.h",
]
# Tests.
sources += [
"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_request_browser_test.cc",
"webxr_vr_pixel_browser_test.cc",
"webxr_vr_tab_browser_test.cc",
]
deps += [
"//components/content_settings/core/browser:browser",
"//third_party/openvr:openvr",
]
data_deps += [ "//device/vr:openvr_mock" ]
}
}
# TODO(https://crbug.com/816629): Migrate this to a generic wrapper script
# once the functionality is available on all platforms.
copy("xr_browser_tests_runner") {
testonly = true
sources = [
"test/run_xr_browser_tests.py",
]
outputs = [
"$root_out_dir/run_xr_browser_tests.py",
]
}
}