chromium/chrome/browser/chromeos/extensions/telemetry/api/events/BUILD.gn

# Copyright 2023 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/chromeos/ui_mode.gni")
import("//chrome/common/chromeos/extensions/api/api_sources.gni")
import("//extensions/buildflags/buildflags.gni")

assert(enable_extensions,
       "Cannot depend on extensions because enable_extensions=false.")

source_set("events") {
  sources = [
    "events_api.cc",
    "events_api.h",
  ]

  deps = [
    ":event_converters",
    ":event_manager",
    ":event_router",
    "//base",
    "//build:chromeos_buildflags",
    "//chrome/browser/chromeos/extensions/telemetry/api/common",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//extensions/browser",
    "//url",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//chrome/browser/profiles:profile",
      "//chrome/browser/ui",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }
}

source_set("event_router") {
  sources = [
    "event_observation_crosapi.cc",
    "event_observation_crosapi.h",
    "event_router.cc",
    "event_router.h",
    "remote_event_service_strategy.cc",
    "remote_event_service_strategy.h",
  ]

  deps = [
    ":event_converters",
    "//base",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//content/public/browser",
    "//extensions/common",
    "//mojo/public/cpp/bindings",
  ]

  if (is_chromeos_ash) {
    deps += [ "//chromeos/ash/components/telemetry_extension/events" ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }

  public_deps = [ "//extensions/browser" ]
}

source_set("event_manager") {
  sources = [
    "event_manager.cc",
    "event_manager.h",
  ]

  deps = [
    ":event_router",
    "//base",
    "//chrome/browser/chromeos/extensions/telemetry/api/common",
    "//chrome/browser/chromeos/extensions/telemetry/api/common:util",
    "//chrome/common/chromeos/extensions",
    "//chromeos/crosapi/mojom",
    "//content/public/browser",
  ]

  public_deps = [
    "//extensions/browser",
    "//extensions/common",
  ]
}

source_set("event_converters") {
  sources = [
    "events_api_converters.cc",
    "events_api_converters.h",
  ]

  deps = [
    "//base",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//third_party/abseil-cpp:absl",
  ]
}

source_set("test_support") {
  testonly = true
  sources = [
    "fake_events_service.cc",
    "fake_events_service.h",
  ]

  deps = [ "//base/test:test_support" ]

  public_deps = [
    "//chromeos/crosapi/mojom",
    "//mojo/public/cpp/bindings",
  ]

  if (is_chromeos_ash) {
    sources += [
      "fake_events_service_factory.cc",
      "fake_events_service_factory.h",
    ]

    public_deps += [ "//chromeos/ash/components/telemetry_extension/events" ]
  }
}

source_set("browser_tests") {
  testonly = true
  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  sources = [ "events_api_browsertest.cc" ]

  deps = [
    ":events",
    ":test_support",
    "//chrome/browser/chromeos/extensions/telemetry/api/common:test_support",
    "//chrome/browser/ui",
    "//chrome/test:test_support_ui",
    "//chromeos/crosapi/mojom",
    "//content/test:test_support",
    "//extensions/common",
    "//mojo/public/cpp/bindings",
    "//testing/gtest",
    "//url",
  ]

  data = [ "//chrome/test/data" ]

  if (is_chromeos_ash) {
    deps += [ "//chrome/browser/profiles:profile" ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "event_manager_unittest.cc",
    "events_api_converters_unittest.cc",
  ]

  deps = [
    ":event_converters",
    ":event_manager",
    ":event_router",
    ":test_support",
    "//chrome/browser/chromeos/extensions/telemetry/api/common:common",
    "//chrome/browser/ui",
    "//chrome/common/chromeos/extensions",
    "//chrome/common/chromeos/extensions/api",
    "//chrome/test:test_support",
    "//chromeos/crosapi/mojom",
    "//content/public/browser",
    "//net",
    "//net:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//chrome/common",
      "//chromeos/constants",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }
}

source_set("extensions_unittests") {
  testonly = true
  sources = [
    "event_observation_crosapi_unittest.cc",
    "event_router_unittest.cc",
  ]

  deps = [
    ":event_router",
    "//base/test:test_support",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//content/test:test_support",
    "//extensions:test_support",
    "//extensions/common",
    "//mojo/public/cpp/bindings",
    "//testing/gtest",
  ]
}