chromium/chrome/browser/headless/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/chrome_build.gni")
import("//build/config/ozone.gni")
import("//testing/test.gni")

source_set("headless") {
  sources = [
    "headless_mode_switches.h",
    "headless_mode_util.cc",
    "headless_mode_util.h",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    "//base",
    "//chrome/common:non_code_constants",
    "//content/public/common",
    "//ui/gfx",
  ]

  if (is_linux) {
    deps += [
      "//ui/gl",
      "//ui/ozone",
    ]
  }
}

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

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    ":headless",
    "//base",
    "//components/headless/command_handler:switches",
    "//content/public/browser",
  ]
}

if (!is_android) {
  source_set("command_processor") {
    sources = [
      "headless_command_processor.cc",
      "headless_command_processor.h",
    ]

    configs += [ "//build/config/compiler:wexit_time_destructors" ]

    deps = [
      ":headless",
      "//base",
      "//chrome/common:non_code_constants",
      "//components/headless/command_handler",
      "//components/keep_alive_registry",
      "//content/public/browser",
    ]
  }

  source_set("browser_tests") {
    testonly = true
    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

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

    if (is_linux || is_win || is_mac) {
      sources += [
        "headless_mode_browsertest_utils.h",
        "headless_mode_command_browsertest.cc",
        "headless_mode_devtooled_browsertest.cc",
        "headless_mode_devtooled_browsertest.h",
        "headless_mode_protocol_browsertest.cc",
        "headless_mode_protocol_browsertest.h",
        "test/headless_browser_test_utils.cc",
        "test/headless_browser_test_utils.h",
      ]
    }

    if (is_linux) {
      sources += [ "headless_mode_browsertest_linux.cc" ]
    }

    if (is_win) {
      sources += [ "headless_mode_browsertest_win.cc" ]
    }

    if (is_mac) {
      sources += [ "headless_mode_browsertest_mac.mm" ]
    }

    deps = [
      ":headless",
      "//base",
      "//chrome/browser",
      "//chrome/test:test_support",
      "//content/test:test_support",
      "//pdf",
      "//testing/gtest",
    ]

    if (is_linux || is_win || is_mac) {
      deps += [
        "//chrome/browser/profiles",
        "//chrome/browser/ui",
        "//components/devtools/simple_devtools_protocol_client",
        "//components/headless/clipboard",
        "//components/headless/command_handler",
        "//components/headless/command_handler:switches",
        "//components/headless/select_file_dialog",
        "//components/headless/test",
        "//components/infobars/content",
        "//content/public/browser",
        "//ui/display",
        "//ui/gfx",
        "//ui/views",
      ]
    }

    if (use_ozone && is_linux) {
      deps += [ "//ui/ozone" ]
    }

    data = [
      "test/data/",
      "//third_party/blink/web_tests/http/tests/inspector-protocol/resources/inspector-protocol-test.js",
    ]
  }
}