chromium/ui/snapshot/BUILD.gn

# 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/ui.gni")
import("//testing/test.gni")

component("snapshot") {
  sources = [
    "screenshot_grabber.cc",
    "screenshot_grabber.h",
    "snapshot.cc",
    "snapshot.h",
  ]

  if (is_android) {
    sources += [ "snapshot_android.cc" ]
  }

  if (is_mac) {
    sources += [
      "snapshot_mac.h",
      "snapshot_mac.mm",
    ]
  }

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

  if (is_ios) {
    sources += [ "snapshot_ios.mm" ]
  }

  defines = [ "SNAPSHOT_IMPLEMENTATION" ]

  deps = [
    ":snapshot_export",
    "//base",
    "//components/viz/common",
    "//skia",
    "//ui/base",
    "//ui/display",
    "//ui/gfx",
    "//ui/gfx/geometry",
  ]

  if (is_android) {
    deps += [ "//ui/android" ]
  }

  if (use_aura || is_android) {
    sources += [
      "snapshot_async.cc",
      "snapshot_async.h",
    ]
    deps += [
      "//cc",
      "//gpu/command_buffer/common",
    ]
  }

  if (use_aura) {
    sources += [
      "snapshot_aura.cc",
      "snapshot_aura.h",
    ]
    deps += [
      "//ui/aura",
      "//ui/compositor",
    ]
  }

  if (is_mac) {
    frameworks = [
      "AppKit.framework",
      "CoreGraphics.framework",
    ]
    weak_frameworks = [ "ScreenCaptureKit.framework" ]  # macOS 14.4
  }
}

source_set("snapshot_export") {
  sources = [ "snapshot_export.h" ]
  visibility = [ ":*" ]
}

test("snapshot_unittests") {
  use_xvfb = use_xvfb_in_this_config

  sources = [ "test/run_all_unittests.cc" ]

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

  deps = [
    ":snapshot",
    "//base",
    "//base/test:test_support",
    "//mojo/core/embedder",
    "//skia",
    "//testing/gtest",
    "//ui/base",
    "//ui/base:test_support",
    "//ui/compositor:test_support",
    "//ui/gfx",
    "//ui/gfx:test_support",
    "//ui/gfx/geometry",
    "//ui/gl",
  ]

  data_deps = [ "//testing/buildbot/filters:snapshot_unittests_filters" ]

  if (use_aura) {
    sources += [ "snapshot_aura_unittest.cc" ]
    deps += [
      "//ui/aura:test_support",
      "//ui/compositor",
      "//ui/compositor:test_support",
      "//ui/wm",
    ]
  }

  if (is_fuchsia) {
    # TODO(crbug.com/42050042): Some of these tests use SwiftShader,
    # which requires ambient VMEX.
    test_runner_shard = "//build/config/fuchsia/test/elf_test_ambient_exec_runner.shard.test-cml"

    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/present_view.shard.test-cml",
      "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
    ]
  }
}