chromium/third_party/blink/renderer/controller/BUILD.gn

# Copyright 2017 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")
import("//third_party/blink/renderer/bindings/bindings.gni")
import("//third_party/blink/renderer/config.gni")
import("//third_party/blink/renderer/core/core.gni")
import("//third_party/blink/renderer/modules/modules.gni")

if (is_ios) {
  import("//build/config/ios/bundle_data_from_filelist.gni")
}

visibility = [
  "//:gn_all",
  "//third_party/blink/*",
]

component("controller") {
  output_name = "blink_controller"

  deps = [
    "//components/performance_manager/public/mojom:mojom_blink",
    "//skia",
    "//third_party/blink/renderer/core",
    "//third_party/blink/renderer/modules",
    "//third_party/blink/renderer/platform",
    "//v8",
  ]

  if (use_blink_extensions_chromeos) {
    deps += [ "//third_party/blink/renderer/extensions/chromeos" ]
  }
  if (use_blink_extensions_webview) {
    deps += [ "//third_party/blink/renderer/extensions/webview" ]
  }

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer:non_test_config",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]

  defines = [ "BLINK_CONTROLLER_IMPLEMENTATION=1" ]

  sources = [
    "blink_initializer.cc",
    "blink_initializer.h",
    "blink_leak_detector.cc",
    "blink_leak_detector.h",
    "blink_shutdown.cc",
    "controller_export.h",
    "dev_tools_frontend_impl.cc",
    "dev_tools_frontend_impl.h",
    "javascript_call_stack_collector.cc",
    "javascript_call_stack_collector.h",
    "javascript_call_stack_generator.cc",
    "javascript_call_stack_generator.h",
    "memory_usage_monitor.cc",
    "memory_usage_monitor.h",
    "performance_manager/renderer_resource_coordinator_impl.cc",
    "performance_manager/renderer_resource_coordinator_impl.h",
    "performance_manager/v8_detailed_memory_reporter_impl.cc",
    "performance_manager/v8_detailed_memory_reporter_impl.h",
    "performance_manager/v8_worker_memory_reporter.cc",
    "performance_manager/v8_worker_memory_reporter.h",
  ]

  if (is_linux || is_chromeos) {
    sources += [
      "memory_usage_monitor_posix.cc",
      "memory_usage_monitor_posix.h",
    ]
    deps += [ "//third_party/blink/public/mojom:memory_usage_monitor_linux_mojo_bindings_blink" ]
  }
  if (is_android) {
    sources += [
      "crash_memory_metrics_reporter_impl.cc",
      "crash_memory_metrics_reporter_impl.h",
      "memory_usage_monitor_posix.cc",
      "memory_usage_monitor_posix.h",
      "oom_intervention_impl.cc",
      "oom_intervention_impl.h",
      "private_memory_footprint_provider.cc",
      "private_memory_footprint_provider.h",
    ]
    public_deps = [ "//third_party/blink/public/mojom:memory_usage_monitor_linux_mojo_bindings_blink" ]
  }
  if (is_win) {
    sources += [
      "memory_usage_monitor_win.cc",
      "memory_usage_monitor_win.h",
    ]
  }
  if (is_apple) {
    sources += [
      "memory_usage_monitor_mac.cc",
      "memory_usage_monitor_mac.h",
    ]
    frameworks = [ "Foundation.framework" ]
  }

  # HighestPmfReporter depends on MemoryUsageMonitor and MemoryUsageMonitor
  # depends on platform specific code. Explicitly specify supported platforms.
  if (is_linux || is_chromeos || is_win || is_android || is_apple) {
    sources += [
      "highest_pmf_reporter.cc",
      "highest_pmf_reporter.h",
    ]
  }
  if (is_android) {
    sources += [
      "user_level_memory_pressure_signal_generator.cc",
      "user_level_memory_pressure_signal_generator.h",
    ]
  }

  configs -= [ "//build/config/compiler:default_symbols" ]
  configs += blink_symbols_config

  # These targets are not necessary to build the Blink renderer, however, these
  # targets are quite useful for Blink developers to get error if any when
  # adding/editing *.idl files, especially because it's very easy to forget to
  # add generated bindings files to the lists defined in
  # generated_in_{core,modules}.gni. Hence, run the check scripts here.
  deps += [
    "//third_party/blink/renderer/bindings:check_generated_file_list",
    "//third_party/blink/renderer/bindings:validate_web_idl",
  ]
}

group("blink_unittests_data") {
  data = [
    "../core/testing/data/",
    "../core/paint/test_data/",
    "../core/animation/test_data/",
  ]
}

# Old name of blink_unittests.
# TODO(tkent): Remove this after removing external dependency.
group("webkit_unit_tests") {
  visibility = []  # Allow re-assignment of list.
  visibility = [ "*" ]
  testonly = true
  deps = [ ":blink_unittests" ]
}

test("blink_unittests") {
  deps = [ ":blink_unittests_sources" ]

  if (is_ios) {
    bundle_deps = [
      ":blink_unittests_pak_bundle_data",
      "//components/shared_highlighting/core/common:data_driven_testing_data",
      "//media/test:media_bundle_data",
      "//third_party/blink/renderer/core:animation_test_bundle_data",
      "//third_party/blink/renderer/core:core_test_bundle_data",
      "//third_party/blink/renderer/core:paint_test_bundle_data",
      "//third_party/blink/renderer/modules:accessibility_selection_test_bundle_data",
      "//third_party/blink/renderer/platform:blink_platform_unittests_bundle_data",
      "//third_party/text-fragments-polyfill:test_bundle_data",
    ]
  } else {
    data_deps = [
      ":blink_unittests_data",
      "//content/shell:pak",
    ]
  }

  if (is_android) {
    deps += [
      "//content/public/android:content_java",
      "//content/shell/android:content_shell_assets",
      "//net/android:net_java",
    ]

    if (enable_chrome_android_internal) {
      data_deps += [ "//clank/build/bot/filters:blink_unittests_filters" ]
    }
  }

  if (is_fuchsia) {
    additional_manifest_fragments = [
      "//build/config/fuchsia/test/fonts.shard.test-cml",
      "//build/config/fuchsia/test/network.shard.test-cml",

      # TODO(https://crbug.com/1185811): Investigate removing the requirement
      # for VmexResource.
      "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
    ]
  }
}

test("blink_perf_tests") {
  deps = [ ":blink_perf_tests_sources" ]
}

source_set("blink_perf_tests_sources") {
  visibility = []  # Allow re-assignment of list.
  visibility = [ "*" ]
  testonly = true

  sources = [
    "tests/run_all_perftests.cc",
    "tests/thread_state_test_environment.h",
  ]

  deps = [
    ":controller",
    "//base",
    "//base/test:test_support",
    "//content/test:test_support",
    "//third_party/blink/renderer/core:core",
    "//third_party/blink/renderer/core:perf_tests",
  ]

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]
}

source_set("blink_bindings_test_sources") {
  testonly = true
  sources = bindings_unittest_files
  deps = [
    "//base/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/blink/public:test_headers",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/core:unit_test_support",
    "//third_party/blink/renderer/modules:modules",
    "//third_party/blink/renderer/modules:modules_testing",
    "//third_party/blink/renderer/modules/mediastream:test_support",
    "//third_party/blink/renderer/platform:platform",
    "//third_party/blink/renderer/platform:test_support",
  ]
  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]
}

source_set("blink_unittests_sources") {
  visibility = []  # Allow re-assignment of list.
  visibility = [ "*" ]
  testonly = true

  sources = [
    "//third_party/blink/renderer/platform/testing/main_thread_isolate_unittest.cc",
    "//third_party/blink/renderer/platform/testing/task_environment_unittest.cc",
    "performance_manager/renderer_resource_coordinator_impl_test.cc",
    "performance_manager/v8_detailed_memory_reporter_impl_test.cc",
    "performance_manager/v8_worker_memory_reporter_test.cc",
    "tests/run_all_tests.cc",
    "tests/thread_state_test_environment.h",
  ]
  if (is_linux || is_chromeos) {
    sources += [ "memory_usage_monitor_posix_test.cc" ]
  }
  if (is_android) {
    sources += [
      "memory_usage_monitor_posix_test.cc",
      "oom_intervention_impl_test.cc",
      "user_level_memory_pressure_signal_generator_test.cc",
    ]
  }

  if (is_linux || is_chromeos || is_android || is_apple || is_win) {
    sources += [
      "highest_pmf_reporter_test.cc",
      "memory_usage_monitor_test.cc",
    ]
  }

  deps = [
    ":blink_bindings_test_sources",
    ":controller",
    "//base",
    "//base:i18n",
    "//base/test:test_support",
    "//components/payments/mojom:mojom_blink",
    "//components/performance_manager/public/mojom:mojom_blink",
    "//content/test:test_support",
    "//gpu:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/core:unit_test_support",
    "//third_party/blink/renderer/core:unit_tests",
    "//third_party/blink/renderer/modules:modules",
    "//third_party/blink/renderer/modules:unit_tests",
    "//third_party/blink/renderer/modules/exported:test_support",
    "//third_party/blink/renderer/platform",
    "//third_party/blink/renderer/platform:test_support",
    "//third_party/blink/renderer/platform:unit_tests",
    "//third_party/blink/renderer/platform/wtf",
    "//third_party/libwebp",
    "//third_party/zlib",
    "//url",
    "//v8",
  ]

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]
}

if (is_ios) {
  bundle_data("blink_unittests_pak_bundle_data") {
    testonly = true
    public_deps = [ "//content/shell:pak" ]
    sources = [ "$root_out_dir/content_shell.pak" ]
    outputs = [ "{{bundle_resources_dir}}/content_shell.pak" ]
  }
}