chromium/chrome/browser/chromeos/extensions/telemetry/api/diagnostics/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("//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("diagnostics") {
  sources = [
    "diagnostics_api.cc",
    "diagnostics_api.h",
    "diagnostics_api_converters.cc",
    "diagnostics_api_converters.h",
    "diagnostics_api_metrics.cc",
    "diagnostics_api_metrics.h",
    "remote_diagnostics_service_strategy.cc",
    "remote_diagnostics_service_strategy.h",
  ]

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//chrome/browser/chromeos/extensions/telemetry/api/common",
    "//chrome/browser/chromeos/extensions/telemetry/api/routines:routine_manager",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//extensions/browser",
    "//extensions/common",
    "//mojo/public/cpp/bindings",
  ]

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

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

source_set("browser_tests") {
  testonly = true
  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  sources = [
    "diagnostics_api_browsertest.cc",
    "diagnostics_api_v2_browsertest.cc",
    "fake_diagnostics_service.cc",
    "fake_diagnostics_service.h",
  ]

  deps = [
    ":diagnostics",
    "//base",
    "//build:chromeos_buildflags",
    "//chrome/browser/chromeos/extensions/telemetry/api/common:test_support",
    "//chrome/browser/chromeos/extensions/telemetry/api/routines:test_support",
    "//chrome/browser/ui",
    "//chrome/test:test_support_ui",
    "//chromeos/crosapi/mojom",
    "//content/test:test_support",
    "//extensions/common",
    "//testing/gtest",
    "//third_party/abseil-cpp:absl",
  ]

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

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

    deps += [ "//chromeos/ash/components/telemetry_extension/diagnostics" ]
  }

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

source_set("unit_tests") {
  testonly = true
  sources = [
    "diagnostics_api_converters_unittest.cc",
    "diagnostics_api_metrics_unittest.cc",
  ]

  deps = [
    ":diagnostics",
    "//base/test:test_support",
    "//chrome/common/chromeos/extensions/api",
    "//chromeos/crosapi/mojom",
    "//testing/gtest",
  ]
}