# Copyright 2014 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/config/features.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")
import("//extensions/buildflags/buildflags.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("//tools/json_schema_compiler/json_schema_api.gni")
import("//ui/base/ui_features.gni")
if (is_win) {
import("//build/toolchain/win/midl.gni")
}
if (is_android) {
import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")
}
mojom("ax_constants_mojo") {
generate_java = true
sources = [ "ax_constants.mojom" ]
}
mojom_component("ax_enums_mojo") {
generate_java = true
sources = [ "ax_enums.mojom" ]
macro_prefix = "UI_ACCESSIBILITY_AX_MOJOM"
output_prefix = "ui_accessibility_ax_mojom"
}
mojom_component("ax_features_mojo") {
sources = [ "ax_features.mojom" ]
macro_prefix = "UI_ACCESSIBILITY_AX_FEATURES_MOJOM"
output_prefix = "ui_accessibility_ax_features_mojom"
}
# A tiny subset of accessibility code that's allowed to be
# included by Blink. The rule of thumb (for now) is that it's
# anything platform-neutral (no platform/ directory) that
# relates to data structs (actions, nodes, trees, etc) and interfaces. No heavy weight logic yet.
component("ax_base") {
defines = [ "AX_BASE_IMPLEMENTATION" ]
sources = [
"accessibility_features.cc",
"accessibility_features.h",
"accessibility_prefs.cc",
"accessibility_prefs.h",
"accessibility_switches.cc",
"accessibility_switches.h",
"ax_action_data.cc",
"ax_action_data.h",
"ax_action_handler.cc",
"ax_action_handler.h",
"ax_action_handler_base.cc",
"ax_action_handler_base.h",
"ax_action_handler_registry.cc",
"ax_action_handler_registry.h",
"ax_action_target.h",
"ax_base_export.h",
"ax_bit_map.h",
"ax_enum_util.cc",
"ax_enum_util.h",
"ax_error_types.h",
"ax_event.cc",
"ax_event.h",
"ax_event_intent.cc",
"ax_event_intent.h",
"ax_mode.cc",
"ax_mode.h",
"ax_mode_histogram_logger.cc",
"ax_mode_histogram_logger.h",
"ax_node_data.cc",
"ax_node_data.h",
"ax_node_id_forward.h",
"ax_relative_bounds.cc",
"ax_relative_bounds.h",
"ax_role_properties.cc",
"ax_role_properties.h",
"ax_text_attributes.cc",
"ax_text_attributes.h",
"ax_tree_checks.h",
"ax_tree_data.cc",
"ax_tree_data.h",
"ax_tree_id.cc",
"ax_tree_id.h",
"ax_tree_source.h",
"ax_tree_source_observer.h",
"ax_tree_update.cc",
"ax_tree_update.h",
"ax_tree_update_forward.h",
"ax_updates_and_events.cc",
"ax_updates_and_events.h",
]
if (!is_chromeos && !is_fuchsia) {
sources += [
"ax_enum_localization_util.cc",
"ax_enum_localization_util.h",
]
}
public_deps = [
":ax_constants_mojo",
":ax_enums_mojo",
":ax_features_mojo",
"//base",
"//ui/gfx",
"//ui/gfx/geometry",
]
if (!is_chromeos) {
public_deps += [
"//base:i18n",
"//ui/base",
"//ui/strings",
]
}
deps = [ "//build:chromeos_buildflags" ]
if (is_chromeos_ash) {
deps += [ "//ash/constants" ]
}
if (is_android) {
sources += [ "android/accessibility_features_map.cc" ]
deps += [ ":ax_base_jni_headers" ]
}
}
#if (is_win) {
# midl("ichromeaccessible") {
# sources = [
# "platform/ichromeaccessible.idl",
# ]
# }
#}
group("accessibility") {
public_deps = [
":accessibility_internal",
"//ui/accessibility/platform",
]
}
component("accessibility_internal") {
defines = [ "AX_IMPLEMENTATION" ]
sources = [
"ax_action_target.h",
"ax_active_popup.cc",
"ax_active_popup.h",
"ax_clipping_behavior.h",
"ax_computed_node_data.cc",
"ax_computed_node_data.h",
"ax_coordinate_system.h",
"ax_event_generator.cc",
"ax_event_generator.h",
"ax_export.h",
"ax_hypertext.cc",
"ax_hypertext.h",
"ax_language_detection.cc",
"ax_language_detection.h",
"ax_mode_observer.cc",
"ax_mode_observer.h",
"ax_node.cc",
"ax_node.h",
"ax_node_position.cc",
"ax_node_position.h",
"ax_offscreen_result.h",
"ax_position.cc",
"ax_position.h",
"ax_range.h",
"ax_selection.cc",
"ax_selection.h",
"ax_serializable_tree.cc",
"ax_serializable_tree.h",
"ax_table_info.cc",
"ax_table_info.h",
"ax_text_utils.cc",
"ax_text_utils.h",
"ax_tree.cc",
"ax_tree.h",
"ax_tree_combiner.cc",
"ax_tree_combiner.h",
"ax_tree_manager.cc",
"ax_tree_manager.h",
"ax_tree_manager_base.cc",
"ax_tree_manager_base.h",
"ax_tree_manager_map.cc",
"ax_tree_manager_map.h",
"ax_tree_observer.cc",
"ax_tree_observer.h",
"ax_tree_serializer.cc",
"ax_tree_serializer.h",
"ax_tree_source_annotator.h",
"ax_tree_source_checker.h",
"ax_tree_update_util.cc",
"ax_tree_update_util.h",
"null_ax_action_target.cc",
"null_ax_action_target.h",
"test_single_ax_tree_manager.cc",
"test_single_ax_tree_manager.h",
]
deps = [
"//base",
"//components/crash/core/common:crash_key",
"//third_party/cld_3/src/src:cld_3",
]
public_deps = [
":ax_base",
"//skia",
]
if (is_fuchsia) {
public_deps += [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.accessibility.semantics:fuchsia.accessibility.semantics_cpp" ]
}
if (use_aura) {
sources += [
"aura/aura_window_properties.cc",
"aura/aura_window_properties.h",
]
public_deps += [ "//ui/aura" ]
}
}
if (is_android || is_chromeos_ash) {
source_set("ax_assistant") {
sources = [
"ax_assistant_structure.cc",
"ax_assistant_structure.h",
]
deps = [ ":accessibility" ]
public_deps = [ ":ax_enums_mojo" ]
}
}
static_library("test_support") {
testonly = true
sources = [
"platform/ax_platform_for_test.cc",
"platform/ax_platform_for_test.h",
"platform/ax_platform_node_test_helper.cc",
"platform/ax_platform_node_test_helper.h",
"platform/inspect/ax_inspect_test_helper.cc",
"platform/inspect/ax_inspect_test_helper.h",
"platform/provide_ax_platform_for_tests.cc",
"platform/provide_ax_platform_for_tests.h",
"platform/test_ax_node_id_delegate.cc",
"platform/test_ax_node_id_delegate.h",
"platform/test_ax_platform_tree_manager_delegate.cc",
"platform/test_ax_platform_tree_manager_delegate.h",
"test_ax_node_helper.cc",
"test_ax_node_helper.h",
"test_ax_tree_update.cc",
"test_ax_tree_update.h",
"tree_generator.cc",
"tree_generator.h",
]
if (has_native_accessibility) {
sources += [
"platform/test_ax_node_wrapper.cc",
"platform/test_ax_node_wrapper.h",
]
}
public_deps = [
":accessibility",
"//base",
"//base/test:test_support",
"//third_party/abseil-cpp:absl",
]
}
test("accessibility_unittests") {
testonly = true
sources = [
"ax_bit_map_unittest.cc",
"ax_computed_node_data_unittest.cc",
"ax_enum_util_unittest.cc",
"ax_event_generator_unittest.cc",
"ax_generated_tree_unittest.cc",
"ax_language_detection_unittest.cc",
"ax_mode_histogram_logger_unittest.cc",
"ax_mode_unittest.cc",
"ax_node_data_unittest.cc",
"ax_node_position_unittest.cc",
"ax_node_unittest.cc",
"ax_range_unittest.cc",
"ax_role_properties_unittest.cc",
"ax_selection_unittest.cc",
"ax_table_info_unittest.cc",
"ax_text_utils_unittest.cc",
"ax_tree_combiner_unittest.cc",
"ax_tree_id_unittest.cc",
"ax_tree_manager_base_unittest.cc",
"ax_tree_manager_unittest.cc",
"ax_tree_serializer_unittest.cc",
"ax_tree_source_checker_unittest.cc",
"ax_tree_unittest.cc",
"ax_tree_update_util_unittest.cc",
"mojom/ax_action_data_mojom_traits_unittest.cc",
"mojom/ax_event_intent_mojom_traits_unittest.cc",
"mojom/ax_event_mojom_traits_unittest.cc",
"mojom/ax_mode_mojom_traits_unittest.cc",
"mojom/ax_node_data_mojom_traits_unittest.cc",
"mojom/ax_relative_bounds_mojom_traits_unittest.cc",
"mojom/ax_tree_data_mojom_traits_unittest.cc",
"mojom/ax_tree_id_mojom_traits_unittest.cc",
"mojom/ax_tree_update_mojom_traits_unittest.cc",
"null_ax_action_target_unittest.cc",
"platform/ax_platform_node_unittest.cc",
"platform/ax_platform_node_unittest.h",
"platform/ax_platform_unittest.cc",
"platform/ax_unique_id_unittest.cc",
"platform/inspect/ax_inspect_scenario_unittest.cc",
"platform/inspect/ax_inspect_test_helper_unittest.cc",
"platform/inspect/ax_inspect_utils_unittest.cc",
"platform/inspect/ax_property_node_unittest.cc",
"platform/inspect/ax_script_instruction_unittest.cc",
"run_all_unittests.cc",
]
deps = [
":accessibility",
":test_support",
"//base/test:test_support",
"//ipc",
"//mojo/core/embedder",
"//mojo/core/test:test_support",
"//mojo/public/cpp/test_support:test_utils",
"//skia",
"//testing/gmock",
"//testing/gtest",
"//ui/accessibility/mojom",
"//ui/gfx:test_support",
]
if (enable_extensions) {
sources += [
"platform/automation/automation_api_util_unittest.cc",
"platform/automation/automation_tree_manager_owner_unittest.cc",
]
public_deps = [ "//gin" ]
configs += [ "//v8:external_startup_data" ]
if (is_fuchsia) {
additional_manifest_fragments = [
# TODO(crbug.com/40055105): Investigate removing the requirement
# for VmexResource.
"//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
"//build/config/fuchsia/test/network.shard.test-cml",
"//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
]
}
}
if (is_fuchsia) {
sources += [
"platform/fuchsia/accessibility_bridge_fuchsia_unittest.cc",
"platform/fuchsia/browser_accessibility_fuchsia_unittest.cc",
"platform/fuchsia/browser_accessibility_manager_fuchsia_unittest.cc",
"platform/fuchsia/semantic_provider_unittest.cc",
]
deps += [
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.accessibility.semantics:fuchsia.accessibility.semantics_cpp",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.math:fuchsia.math_hlcpp",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.views:fuchsia.ui.views_cpp_hlcpp_conversion",
"//third_party/fuchsia-sdk/sdk/pkg/inspect",
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
]
}
if (has_native_accessibility) {
# This test depends heavily on NativeViewAccessible, which is only
# implemented on these platforms.
sources += [ "platform/ax_platform_node_base_unittest.cc" ]
if (is_win) {
sources += [
"platform/ax_fragment_root_win_unittest.cc",
"platform/ax_platform_node_textchildprovider_win_unittest.cc",
"platform/ax_platform_node_textprovider_win_unittest.cc",
"platform/ax_platform_node_textrangeprovider_win_unittest.cc",
"platform/ax_platform_node_win_unittest.cc",
"platform/ax_platform_node_win_unittest.h",
"platform/browser_accessibility_manager_win_unittest.cc",
"platform/browser_accessibility_win_unittest.cc",
"platform/iaccessible2/scoped_co_mem_array_unittest.cc",
]
deps += [
"//third_party/iaccessible2",
"//ui/accessibility/platform:ichromeaccessible",
]
libs = [
"oleacc.lib",
"uiautomationcore.lib",
]
}
if (is_mac) {
sources += [ "platform/browser_accessibility_mac_unittest.mm" ]
deps += [ "//ui/base:test_support" ]
}
if (use_atk) {
sources += [
"platform/atk_util_auralinux_unittest.cc",
"platform/ax_platform_node_auralinux_unittest.cc",
"platform/browser_accessibility_auralinux_unittest.cc",
"platform/browser_accessibility_manager_auralinux_unittest.cc",
]
configs += [ "//build/config/linux/atk" ]
}
}
}
fuzzer_test("ax_tree_fuzzer") {
sources = [ "ax_tree_fuzzer.cc" ]
deps = [ ":accessibility" ]
}
fuzzer_test("ax_table_fuzzer") {
sources = [ "ax_table_fuzzer.cc" ]
deps = [ ":accessibility" ]
seed_corpus = "fuzz_corpus"
}
fuzzer_test("ax_node_position_fuzzer") {
sources = [
"ax_node_position_fuzzer.cc",
"ax_tree_fuzzer_util.cc",
"ax_tree_fuzzer_util.h",
]
deps = [
":accessibility",
":test_support",
"//base/test:test_support",
]
}
if (is_win) {
fuzzer_test("ax_platform_node_textrangeprovider_win_fuzzer") {
sources = [
"ax_tree_fuzzer_util.cc",
"ax_tree_fuzzer_util.h",
"platform/ax_platform_node_textrangeprovider_win_fuzzer.cc",
]
deps = [
":accessibility",
":test_support",
"//base/test:test_support",
]
}
}
if (is_android) {
java_cpp_features("java_features_srcjar") {
# External code should depend on ":accessibility_features_java" instead.
visibility = [ ":*" ]
sources = [ "//ui/accessibility/accessibility_features.cc" ]
template = "//ui/accessibility/android/java_templates/AccessibilityFeatures.java.tmpl"
}
# A minimal library used to expose accessibility features to webview.
android_library("accessibility_features_java") {
srcjar_deps = [ ":java_features_srcjar" ]
}
generate_jni("ax_base_jni_headers") {
sources = [ "android/java/src/org/chromium/ui/accessibility/AccessibilityFeaturesMap.java" ]
}
generate_jni("ax_jni_headers") {
sources = [
"android/java/src/org/chromium/ui/accessibility/AccessibilityAutofillHelper.java",
"android/java/src/org/chromium/ui/accessibility/AccessibilityState.java",
]
}
source_set("ax_base_android") {
sources = [
"android/accessibility_state.cc",
"android/accessibility_state.h",
]
deps = [
":ax_jni_headers",
"//base",
]
}
android_library("accessibility_features_native_map_java") {
srcjar_deps = [ ":ax_base_jni_headers" ]
sources = [ "android/java/src/org/chromium/ui/accessibility/AccessibilityFeaturesMap.java" ]
deps = [
"//base:base_java",
"//third_party/jni_zero:jni_zero_java",
]
}
android_library("ax_base_java") {
srcjar_deps = [ ":ax_jni_headers" ]
sources = [
"android/java/src/org/chromium/ui/accessibility/AccessibilityAutofillHelper.java",
"android/java/src/org/chromium/ui/accessibility/AccessibilityState.java",
]
deps = [
"//base:base_java",
"//build/android:build_java",
"//third_party/androidx:androidx_annotation_annotation_jvm_java",
"//third_party/jni_zero:jni_zero_java",
]
}
robolectric_library("ui_accessibility_junit_tests") {
testonly = true
sources = [ "android/javatests/src/org/chromium/ui/accessibility/AccessibilityStateTest.java" ]
deps = [
":ax_base_java",
"//base:base_java_test_support",
"//base:base_junit_test_support",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit:junit",
]
}
}
test("accessibility_perftests") {
testonly = true
sources = [ "ax_node_position_perftest.cc" ]
deps = [
":test_support",
"//base",
"//base/test:test_support",
"//mojo/core/test:run_all_unittests",
"//skia",
"//testing/gmock",
"//testing/gtest",
"//testing/perf",
"//ui/accessibility/mojom",
]
}