chromium/services/accessibility/BUILD.gn

# Copyright 2022 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/chromeos/ui_mode.gni")
import("//services/accessibility/buildflags.gni")

buildflag_header("buildflags") {
  header = "buildflags.h"
  flags = [
    "ENABLE_ACCESSIBILITY_SERVICE=$enable_accessibility_service_internal",
    "SUPPORTS_OS_ACCESSIBILITY_SERVICE=$supports_os_accessibility_service",
  ]
}

source_set("lib") {
  public_deps = [
    "//services/accessibility/public/mojom",
    "//ui/accessibility:ax_base",
  ]

  if (supports_os_accessibility_service) {
    sources = [
      "assistive_technology_controller_impl.cc",
      "assistive_technology_controller_impl.h",
      "features/autoclick_client_interface_binder.cc",
      "features/autoclick_client_interface_binder.h",
      "features/automation_client_interface_binder.cc",
      "features/automation_client_interface_binder.h",
      "features/automation_internal_bindings.cc",
      "features/automation_internal_bindings.h",
      "features/bindings_isolate_holder.cc",
      "features/bindings_isolate_holder.h",
      "features/devtools/debug_command_queue.cc",
      "features/devtools/debug_command_queue.h",
      "features/devtools/os_devtools_agent.cc",
      "features/devtools/os_devtools_agent.h",
      "features/devtools/os_devtools_session.cc",
      "features/devtools/os_devtools_session.h",
      "features/interface_binder.h",
      "features/mojo/mojo.cc",
      "features/mojo/mojo.h",
      "features/mojo/mojo_handle.cc",
      "features/mojo/mojo_handle.h",
      "features/mojo/mojo_watch_callback.cc",
      "features/mojo/mojo_watch_callback.h",
      "features/mojo/mojo_watcher.cc",
      "features/mojo/mojo_watcher.h",
      "features/registered_wrappable.cc",
      "features/registered_wrappable.h",
      "features/speech_recognition_interface_binder.cc",
      "features/speech_recognition_interface_binder.h",
      "features/sync_os_state_api_bindings.cc",
      "features/sync_os_state_api_bindings.h",
      "features/text_decoder.cc",
      "features/text_decoder.h",
      "features/text_encoder.cc",
      "features/text_encoder.h",
      "features/tts_interface_binder.cc",
      "features/tts_interface_binder.h",
      "features/user_input_interface_binder.cc",
      "features/user_input_interface_binder.h",
      "features/user_interface_interface_binder.cc",
      "features/user_interface_interface_binder.h",
      "features/v8_bindings_utils.cc",
      "features/v8_bindings_utils.h",
      "features/v8_manager.cc",
      "features/v8_manager.h",
      "features/v8_utils.cc",
      "features/v8_utils.h",
      "os_accessibility_service.cc",
      "os_accessibility_service.h",
    ]
    public_deps += [
      "public/mojom:os_service_mojom",
      "//gin",
      "//ui/accessibility:accessibility",
    ]
    deps = [
      "public/mojom:os_service_mojom_js__generator",
      "//third_party/inspector_protocol:crdtp",
    ]
    configs += [ "//v8:external_startup_data" ]
  } else {
    sources = [
      "automation_impl.cc",
      "automation_impl.h",
      "browser_accessibility_service.cc",
      "browser_accessibility_service.h",
    ]
  }
}

static_library("test_support") {
  testonly = true

  sources = [
    "fake_service_client.cc",
    "fake_service_client.h",
  ]

  deps = [
    ":buildflags",
    ":lib",
  ]

  if (supports_os_accessibility_service) {
    sources += [
      "features/mojo/test/js_test_interface.cc",
      "features/mojo/test/js_test_interface.h",
    ]
    deps += [
      "//base/test:test_support",
      "//services/accessibility/features/mojo/test:mojom_js_api",
      "//services/accessibility/public/mojom:os_service_mojom",
    ]
  }
}

source_set("tests") {
  testonly = true

  deps = [
    ":lib",
    ":test_support",
    "//base/test:test_support",
    "//testing/gtest",
    "//ui/gfx:test_support",
  ]

  if (supports_os_accessibility_service) {
    sources = [
      "assistive_technology_controller_impl_unittest.cc",
      "features/v8_manager_unittest.cc",
      "features/v8_utils_unittest.cc",
      "os_accessibility_service_unittest.cc",
    ]
    deps += [ "//base" ]
    if (!is_fuchsia) {
      # TODO(b:262637320): Get this working on Fuchsia, which cannot
      # currently ReadFileToString and therefore can't run tests which
      # load JS files.
      sources += [
        "features/atp_js_api_test.cc",
        "features/automation_internal_bindings_unittest.cc",
        "features/devtools/os_devtools_unittest.cc",
      ]
      deps += [
        "//services/accessibility/features/javascript:js_api_copied_files",
        "//third_party/inspector_protocol:crdtp",
      ]
      data_deps = [
        "//mojo/public/mojom/base",
        "//services/accessibility/features/javascript:js_api_files",
        "//services/accessibility/features/mojo/test:test_support_data",
        "//services/accessibility/public/mojom:os_accessibility_service_js",
        "//skia/public/mojom:mojom_js",
        "//ui/events/mojom:mojom_js",
        "//ui/gfx/geometry/mojom:mojom_js",
      ]
    }
  } else {
    sources = [ "browser_accessibility_service_unittest.cc" ]
  }
}