chromium/chrome/updater/BUILD.gn

# Copyright 2019 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/python.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/util/process_version.gni")
import("//chrome/updater/branding.gni")
import("//components/crx_file/crx3.gni")
import("//testing/test.gni")

# Run 'gn check out\Default --check-generated //chrome/updater/*' every time
# dependencies are modified until a presubmit is written to automatically
# check that the C++ includes match the build dependency graph.

group("updater") {
  if (is_win) {
    deps = [ "//chrome/updater/win" ]
  }
  if (is_mac) {
    deps = [ "//chrome/updater/mac" ]
  }
  if (is_linux) {
    deps = [ "//chrome/updater/linux" ]
  }

  if (is_win || is_mac || is_linux) {
    deps += [
      "//chrome/updater/test/qualification_app",
      "//chrome/updater/tools",
    ]
  }
}

group("all") {
  testonly = true

  if (is_win || is_mac || is_linux) {
    deps = [
      ":updater",
      ":updater_tests",
      ":updater_tests_system",
    ]
    if (is_win) {
      deps += [ "win/installer:msi_custom_action" ]
    }
  }
}

if (is_win || is_mac || is_linux) {
  source_set("base") {
    sources = [
      "action_handler.h",
      "activity.cc",
      "activity.h",
      "activity_impl.h",
      "app/app_install.cc",
      "app/app_install.h",
      "app/app_install_progress.cc",
      "app/app_install_progress.h",
      "app/app_recover.cc",
      "app/app_recover.h",
      "app/app_server.cc",
      "app/app_server.h",
      "app/app_uninstall.cc",
      "app/app_uninstall.h",
      "app/app_uninstall_self.cc",
      "app/app_uninstall_self.h",
      "app/app_update.cc",
      "app/app_update.h",
      "app/app_utils.cc",
      "app/app_utils.h",
      "app/app_wake.cc",
      "app/app_wake.h",
      "app/app_wakeall.cc",
      "app/app_wakeall.h",
      "auto_run_on_os_upgrade_task.cc",
      "auto_run_on_os_upgrade_task.h",
      "change_owners_task.h",
      "check_for_updates_task.cc",
      "check_for_updates_task.h",
      "cleanup_task.cc",
      "cleanup_task.h",
      "configurator.cc",
      "configurator.h",
      "crash_client.cc",
      "crash_client.h",
      "crash_reporter.cc",
      "crash_reporter.h",
      "crx_downloader_factory.h",
      "device_management/dm_client.cc",
      "device_management/dm_client.h",
      "device_management/dm_message.cc",
      "device_management/dm_message.h",
      "device_management/dm_response_validator.cc",
      "device_management/dm_response_validator.h",
      "find_unregistered_apps_task.cc",
      "find_unregistered_apps_task.h",
      "installer.cc",
      "installer.h",
      "ipc/update_service_internal_proxy.cc",
      "ipc/update_service_internal_proxy.h",
      "lock.cc",
      "lock.h",
      "net/fallback_net_fetcher.cc",
      "net/fallback_net_fetcher.h",
      "net/network.h",
      "persisted_data.cc",
      "persisted_data.h",
      "policy/dm_policy_manager.cc",
      "policy/dm_policy_manager.h",
      "policy/manager.cc",
      "policy/manager.h",
      "policy/policy_fetcher.cc",
      "policy/policy_fetcher.h",
      "policy/policy_manager.cc",
      "policy/policy_manager.h",
      "policy/service.cc",
      "policy/service.h",
      "prefs.cc",
      "prefs.h",
      "prefs_impl.h",
      "remove_uninstalled_apps_task.cc",
      "remove_uninstalled_apps_task.h",
      "setup.h",
      "update_block_check.cc",
      "update_block_check.h",
      "update_service_impl.cc",
      "update_service_impl.h",
      "update_service_impl_impl.cc",
      "update_service_impl_impl.h",
      "update_service_impl_inactive.cc",
      "update_service_impl_inactive.h",
      "update_service_internal.h",
      "update_service_internal_impl.cc",
      "update_service_internal_impl.h",
      "update_service_internal_impl_inactive.cc",
      "update_service_internal_impl_inactive.h",
      "update_service_internal_impl_qualifying.cc",
      "update_service_internal_impl_qualifying.h",
      "update_usage_stats_task.cc",
      "update_usage_stats_task.h",
      "updater.cc",
      "updater.h",
    ]

    deps = [
      ":branding_header",
      ":constants_header",
      ":tagging",
      ":version_header",
      "//base",
      "//base:i18n",
      "//build:chromeos_buildflags",
      "//chrome/enterprise_companion:client",
      "//chrome/enterprise_companion/device_management_storage",
      "//chrome/enterprise_companion/mojom",
      "//chrome/updater/protos:omaha_proto",
      "//components/crash/core/common",
      "//components/crx_file",
      "//components/named_system_lock",
      "//components/policy/core/common:common_constants",
      "//components/policy/proto",
      "//components/prefs",
      "//components/update_client",
      "//components/update_client:in_process_patcher",
      "//components/update_client:in_process_unzipper",
      "//components/version_info",
      "//crypto",
      "//third_party/abseil-cpp:absl",
      "//third_party/boringssl",
      "//third_party/crashpad/crashpad/client",
      "//third_party/crashpad/crashpad/handler",
      "//url",
    ]

    if (is_component_build) {
      deps += [ "//components/policy/core/common" ]
    } else {
      deps += [
        "//components/policy/core/common:common_constants",
        "//components/policy/core/common:util",
      ]
    }

    public_deps = [
      ":base_app",
      ":external_constants",
    ]

    if (is_mac) {
      sources += [
        "activity_impl_util_mac.cc",
        "app/app_net_worker.cc",
        "app/app_net_worker.h",
        "app/app_server_posix_mac.cc",
        "installer_mac.cc",
        "ipc/ipc_security_mac.cc",
        "mac/install_from_archive.h",
        "mac/install_from_archive.mm",
        "mac/setup/setup.mm",
        "mac/setup/wake_task.h",
        "mac/setup/wake_task.mm",
        "net/fetcher_callback_adapter.cc",
        "net/fetcher_callback_adapter.h",
        "net/network_fetcher_mac.mm",
        "net/network_file_fetcher.h",
        "policy/mac/managed_preference_policy_manager.h",
        "policy/mac/managed_preference_policy_manager.mm",
        "policy/mac/managed_preference_policy_manager_impl.h",
        "policy/mac/managed_preference_policy_manager_impl.mm",
        "setup_mac.mm",
        "update_service_internal_impl_qualifying_mac.cc",
        "update_usage_stats_task_mac.mm",
      ]

      deps += [
        ":ks_ticket",
        "//chrome/updater/net/mac/mojom",
        "//mojo/public/cpp/platform",
        "//net",
      ]

      frameworks = [
        "AppKit.framework",
        "CoreServices.framework",
        "Foundation.framework",
        "ServiceManagement.framework",
        "SystemConfiguration.framework",
      ]
    }

    if (is_win) {
      sources += [
        "activity_impl_win.cc",
        "app/app_install_util_win.cc",
        "app/app_install_util_win.h",
        "app/app_install_win.cc",
        "app/app_install_win_internal.h",
        "app/app_server_win.cc",
        "app/app_server_win.h",
        "app/server/win/com_classes.cc",
        "app/server/win/com_classes.h",
        "app/server/win/com_classes_legacy.cc",
        "app/server/win/com_classes_legacy.h",
        "app/server/win/service_main.cc",
        "app/server/win/service_main.h",
        "app/server/win/update_service_internal_stub_win.cc",
        "app/server/win/update_service_internal_stub_win.h",
        "app/server/win/update_service_stub_win.cc",
        "app/server/win/update_service_stub_win.h",
        "app/server/win/wrl_classes.cc",
        "change_owners_task_win.cc",
        "ipc/update_service_internal_proxy_win.cc",
        "ipc/update_service_internal_proxy_win.h",
        "net/network_fetcher_win.cc",
        "policy/win/group_policy_manager.cc",
        "policy/win/group_policy_manager.h",
        "remove_uninstalled_apps_task_win.cc",
        "setup_win.cc",
        "update_block_check_win.cc",
        "update_service_internal_impl_qualifying_win.cc",
        "update_usage_stats_task_win.cc",
        "util/progress_sampler.cc",
        "util/progress_sampler.h",
        "win/action_handler.cc",
        "win/app_command_runner.cc",
        "win/app_command_runner.h",
        "win/installer/exit_code.h",
        "win/installer_api.cc",
        "win/installer_api.h",
        "win/manifest_util.cc",
        "win/manifest_util.h",
        "win/protocol_parser_xml.cc",
        "win/protocol_parser_xml.h",
        "win/scoped_impersonation.cc",
        "win/scoped_impersonation.h",
        "win/setup/setup.cc",
        "win/setup/setup.h",
        "win/setup/setup_util.cc",
        "win/setup/setup_util.h",
        "win/setup/uninstall.cc",
        "win/setup/uninstall.h",
        "win/task_scheduler.cc",
        "win/task_scheduler.h",
        "win/ui/complete_wnd.cc",
        "win/ui/complete_wnd.h",
        "win/ui/l10n_util.cc",
        "win/ui/l10n_util.h",
        "win/ui/owner_draw_controls.cc",
        "win/ui/owner_draw_controls.h",
        "win/ui/progress_wnd.cc",
        "win/ui/progress_wnd.h",
        "win/ui/ui.cc",
        "win/ui/ui.h",
        "win/ui/ui_constants.cc",
        "win/ui/ui_constants.h",
        "win/ui/ui_ctls.h",
        "win/ui/ui_util.cc",
        "win/ui/ui_util.h",
      ]
      deps += [
        "//build:branding_buildflags",
        "//chrome/installer/util:constants",
        "//chrome/installer/util:metainstaller_utils",
        "//chrome/installer/util:work_item",
        "//chrome/updater/app/server/win:updater_idl",
        "//chrome/updater/app/server/win:updater_idl_system",
        "//chrome/updater/app/server/win:updater_idl_user",
        "//chrome/updater/app/server/win:updater_internal_idl",
        "//chrome/updater/app/server/win:updater_internal_idl_system",
        "//chrome/updater/app/server/win:updater_internal_idl_user",
        "//chrome/updater/app/server/win:updater_legacy_idl",
        "//chrome/updater/app/server/win:updater_legacy_idl_system",
        "//chrome/updater/app/server/win:updater_legacy_idl_user",
        "//chrome/updater/win/ui/resources",
        "//chrome/updater/win/ui/resources:strings",
        "//components/winhttp",
        "//third_party/wtl",
      ]

      configs -= [ "//build/config/win:winver" ]
      configs += [
        "//chrome/updater/app/server/win:winver",
        "//chrome/updater/win:wrl_strict",
      ]

      defines = [ "SECURITY_WIN32" ]

      libs = [
        "msxml2.lib",
        "secur32.lib",
        "taskschd.lib",
        "wtsapi32.lib",
      ]
    }

    if (is_posix) {
      sources += [
        "activity_impl_posix.cc",
        "activity_impl_util_posix.h",
        "app/app_server_posix.cc",
        "app/app_server_posix.h",
        "app/server/posix/update_service_internal_stub.cc",
        "app/server/posix/update_service_internal_stub.h",
        "app/server/posix/update_service_stub.cc",
        "app/server/posix/update_service_stub.h",
        "change_owners_task_posix.cc",
        "ipc/ipc_security.h",
        "ipc/update_service_internal_proxy_posix.cc",
        "ipc/update_service_internal_proxy_posix.h",
        "remove_uninstalled_apps_task_posix.cc",
      ]

      deps += [
        "//chrome/updater/app/server/posix/mojom",
        "//components/named_mojo_ipc_server",
      ]
    }

    if (is_linux) {
      sources += [
        "activity_impl_util_linux.cc",
        "app/app_server_posix_linux.cc",
        "installer_linux.cc",
        "ipc/ipc_security_linux.cc",
        "linux/setup/setup.cc",
        "linux/systemd_util.cc",
        "linux/systemd_util.h",
        "net/network_fetcher_linux.cc",
        "setup_linux.cc",
        "update_service_internal_impl_qualifying_linux.cc",
        "update_usage_stats_task_linux.cc",
      ]

      libs = [
        "curl",
        "systemd",
      ]
    }
  }

  if (is_mac) {
    source_set("ks_ticket") {
      sources = [
        "mac/setup/ks_tickets.h",
        "mac/setup/ks_tickets.mm",
      ]

      deps = [ "//base" ]
    }
  }

  # Set of sources that are required to create an executable based on `App`.
  source_set("base_app") {
    sources = [
      "app/app.cc",
      "app/app.h",
    ]

    deps = [ ":constants_header" ]

    public_deps = [
      ":public_sources",
      "//base",
    ]
  }

  source_set("constants_header") {
    sources = [ "constants.h" ]

    public_deps = [ "//base" ]
    deps = [ "//components/update_client" ]
  }

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

    deps = [
      ":branding_header",
      ":constants_header",
      "//base",
      "//components/crx_file",
      "//url",
    ]
  }

  source_set("constants_prod") {
    sources = [
      "constants_prod.cc",
      "external_constants_prod.cc",
    ]

    deps = [
      ":constants_header",
      ":external_constants",
      "//base",
    ]
  }

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

    deps = [
      ":branding_header",
      ":constants_header",
      ":external_constants",
      ":public_sources",
      ":version_header",
      "//base",
      "//components/crx_file",
      "//url",
    ]
  }

  process_version("version_header") {
    sources = [ "//chrome/VERSION" ]
    template_file = "updater_version.h.in"
    output = "$target_gen_dir/updater_version.h"
  }

  process_version("branding_header") {
    sources = [ "//chrome/VERSION" ]
    extra_args = [
      "-e",
      "BROWSER_NAME=\"$browser_name\"",
      "-e",
      "BROWSER_PRODUCT_NAME=\"$browser_product_name\"",
      "-e",
      "COMPANY_FULLNAME=\"$updater_company_full_name\"",
      "-e",
      "COMPANY_SHORTNAME=\"$updater_company_short_name\"",
      "-e",
      "COMPANY_SHORTNAME_LOWERCASE=\"$updater_company_short_name_lowercase\"",
      "-e",
      "COMPANY_SHORTNAME_UPPERCASE=\"$updater_company_short_name_uppercase\"",
      "-e",
      "COPYRIGHT=\"updater_copyright\"",
      "-e",
      "CRASH_PRODUCT_NAME=\"$crash_product_name\"",
      "-e",
      "CRASH_UPLOAD_URL=\"$crash_upload_url\"",
      "-e",
      "DEVICE_MANAGEMENT_SERVER_URL=\"$device_management_server_url\"",
      "-e",
      "HELP_CENTER_URL=\"$help_center_url\"",
      "-e",
      "APP_LOGO_URL=\"$app_logo_url\"",
      "-e",
      "KEYSTONE_NAME=\"$keystone_app_name\"",
      "-e",
      "PRIVILEGED_HELPER_NAME=\"$privileged_helper_name\"",
      "-e",
      "PRODUCT_FULLNAME=\"$updater_product_full_name\"",
      "-e",
      "PRODUCT_FULLNAME_DASHED_LOWERCASE=\"$updater_product_full_name_dashed_lowercase\"",
      "-e",
      "MAC_BROWSER_BUNDLE_IDENTIFIER=\"$mac_browser_bundle_identifier\"",
      "-e",
      "MAC_BUNDLE_IDENTIFIER=\"$mac_updater_bundle_identifier\"",
      "-e",
      "MAC_TEAM_IDENTIFIER=\"$mac_team_identifier\"",
      "-e",
      "UPDATE_CHECK_URL=\"$update_check_url\"",
      "-e",
      "UPDATER_APPID=\"$updater_appid\"",
      "-e",
      "QUALIFICATION_APPID=\"$qualification_appid\"",
      "-e",
      "LEGACY_GOOGLE_UPDATE_APPID=\"$legacy_google_update_appid\"",
      "-e",
      "LEGACY_SERVICE_NAME_PREFIX=\"$legacy_service_name_prefix\"",
      "-e",
      "PREFS_ACCESS_MUTEX=\"$prefs_access_mutex\"",
      "-e",
      "SETUP_MUTEX=\"$setup_mutex_prefix.%s.%s.%s.%s\"%(MAJOR,MINOR,BUILD,PATCH)",
    ]

    template_file = "updater_branding.h.in"
    output = "$target_gen_dir/updater_branding.h"
  }

  source_set("browser_sources") {
    sources = [
      # Ideally we would have :constants_prod as a public_dep. However, this
      # pulls in a static initializer, which is not allowed in Chromium.
      "constants_prod.cc",
    ]

    public_deps = [ ":public_sources" ]
    deps = [ ":constants_header" ]

    visibility = [
      "//chrome/browser",
      "//chrome/browser/ui",
      "//chrome/browser/updater:*",
      "//chrome/enterprise_companion:*",
      "//chrome/enterprise_companion/device_management_storage:*",
      "//chrome/test:*",
      "//chrome/test:unit_tests",
    ]
  }

  source_set("tagging") {
    sources = [
      "certificate_tag.cc",
      "certificate_tag.h",
      "certificate_tag_internal.h",
      "tag.cc",
      "tag.h",
    ]

    deps = [ "//base" ]
  }

  source_set("public_sources") {
    sources = [
      "constants.cc",
      "constants.h",
      "enum_traits.h",
      "ipc/ipc_support.cc",
      "ipc/ipc_support.h",
      "ipc/update_service_proxy.cc",
      "ipc/update_service_proxy.h",
      "registration_data.cc",
      "registration_data.h",
      "service_proxy_factory.h",
      "update_service.cc",
      "update_service.h",
      "updater_scope.cc",
      "updater_scope.h",
      "util/util.cc",
      "util/util.h",
    ]

    deps = [
      ":branding_header",
      ":tagging",
      ":version_header",
      "//base",
      "//components/update_client",
      "//mojo/core/embedder",
      "//url",
    ]

    if (is_win) {
      sources += [
        "ipc/proxy_impl_base_win.h",
        "ipc/update_service_proxy_win.cc",
        "ipc/update_service_proxy_win.h",
        "util/win_util.cc",
        "util/win_util.h",
        "win/scoped_handle.h",
        "win/user_info.cc",
        "win/user_info.h",
        "win/win_constants.cc",
        "win/win_constants.h",
      ]

      deps += [ "//chrome/updater/app/server/win:updater_idl" ]

      configs -= [ "//build/config/win:winver" ]
      configs += [
        "//chrome/updater/app/server/win:winver",
        "//chrome/updater/win:wrl_strict",
      ]

      libs = [ "wtsapi32.lib" ]
    }

    if (is_linux) {
      sources += [
        "ipc/ipc_names_linux.cc",
        "ipc/update_service_dialer_linux.cc",
        "linux/ipc_constants.cc",
        "linux/ipc_constants.h",
        "util/linux_util.cc",
        "util/linux_util.h",
      ]
    }

    if (is_mac) {
      sources += [
        "ipc/ipc_names_mac.mm",
        "ipc/update_service_dialer_mac.cc",
        "mac/privileged_helper/service_protocol.h",
        "mac/setup/keystone.h",
        "mac/setup/keystone.mm",
        "util/mac_util.h",
        "util/mac_util.mm",
      ]

      deps += [ ":ks_ticket" ]

      frameworks = [ "Foundation.framework" ]
    }

    if (is_posix) {
      sources += [
        "ipc/ipc_names.h",
        "ipc/update_service_dialer.h",
        "ipc/update_service_proxy_posix.cc",
        "ipc/update_service_proxy_posix.h",
        "posix/setup.h",
        "util/posix_util.cc",
        "util/posix_util.h",
      ]

      deps += [
        "//chrome/updater/app/server/posix/mojom",
        "//components/named_mojo_ipc_server",
      ]
    }
  }

  if (is_linux || is_mac || is_win) {
    crx3("updater_selfupdate_test_crx") {
      base_dir = "$root_build_dir"
      key = "test/data/selfupdate_test_key.der"
      output = "$root_build_dir/updater_selfupdate.crx3"
      testonly = true

      if (is_linux) {
        inputs = [ "$root_build_dir/updater_test" ]
        deps = [ "//chrome/updater/linux:updater_test" ]
      }

      if (is_mac) {
        inputs = [
          "$root_build_dir/.install",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Info.plist",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/MacOS/${updater_product_full_name}_test",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/MacOS/$keystone_app_name",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/Helpers/ksinstall",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/Helpers/ksadmin",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/Resources/${keystone_app_name}Agent.app/Contents/MacOS/${keystone_app_name}Agent",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/Resources/${keystone_app_name}Agent.app/Contents/Info.plist",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/Info.plist",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/launcher",
          "$root_build_dir/${updater_product_full_name}_test.app/Contents/PkgInfo",
        ]
        deps = [
          "//chrome/updater/mac:updater_bundle_test",
          "//chrome/updater/mac:updater_test_install_script",
        ]

        # Mac ASAN builds have an extra dylib that must be packaged in the CRX.
        if (is_asan) {
          inputs += [
            "$root_build_dir/${updater_product_full_name}_test.app/Contents/Helpers/$keystone_app_name.bundle/Contents/MacOS/libclang_rt.asan_osx_dynamic.dylib",
            "$root_build_dir/${updater_product_full_name}_test.app/Contents/MacOS/libclang_rt.asan_osx_dynamic.dylib",
          ]
        }
      }

      if (is_win) {
        inputs = [ "$root_build_dir/UpdaterSetup_test.exe" ]
        deps = [ "//chrome/updater/win/installer:installer_test" ]

        if (is_component_build) {
          inputs += [
            "$root_build_dir/base.dll",
            "$root_build_dir/ui_base.dll",
          ]

          if (is_debug) {
            data = [ "$root_build_dir/ucrtbased.dll" ]
          }

          deps += [ "//ui/base" ]
        }
      }
    }
  }

  source_set("unit_test_util_sources") {
    testonly = true
    sources = [
      "test/test_scope.h",
      "test/unit_test_util.cc",
      "test/unit_test_util.h",
    ]
    if (is_win) {
      sources += [
        "//chrome/test/base/process_inspector_win.cc",
        "//chrome/test/base/process_inspector_win.h",
      ]
    }
    deps = [
      ":base",
      ":public_sources",
      ":tagging",
      "//base",
      "//base/test:test_support",
      "//testing/gtest",
      "//third_party/abseil-cpp:absl",
    ]
    if (is_win) {
      deps += [ "//chrome/updater/win/test:test_executables" ]
    }
  }

  source_set("updater_test_sources") {
    testonly = true
    sources = [
      "app/app_server_unittest.cc",
      "app/app_uninstall_unittest.cc",
      "app/app_utils_unittest.cc",
      "certificate_tag_unittest.cc",
      "cleanup_task_unittest.cc",
      "constants_unittest.cc",
      "device_management/dm_client_unittest.cc",
      "device_management/dm_message_unittest.cc",
      "device_management/dm_policy_builder_for_testing.cc",
      "device_management/dm_policy_builder_for_testing.h",
      "device_management/dm_response_validator_unittest.cc",
      "enum_traits_unittest.cc",
      "external_constants_builder.cc",
      "external_constants_builder.h",
      "external_constants_builder_unittest.cc",
      "external_constants_override_unittest.cc",
      "installer_unittest.cc",
      "net/fallback_net_fetcher_unittest.cc",
      "net/network_unittest.cc",
      "persisted_data_unittest.cc",
      "policy/dm_policy_manager_unittest.cc",
      "policy/manager_unittest.cc",
      "policy/policy_manager_unittest.cc",
      "policy/service_unittest.cc",
      "prefs_unittest.cc",
      "tag_unittest.cc",
      "test/http_request.cc",
      "test/http_request.h",
      "test/integration_test_commands.h",
      "test/integration_test_commands_system.cc",
      "test/integration_test_commands_user.cc",
      "test/integration_tests_impl.cc",
      "test/integration_tests_impl.h",
      "test/request_matcher.cc",
      "test/request_matcher.h",
      "test/server.cc",
      "test/server.h",
      "test/unit_test_util_unittest.cc",
      "update_service_impl_impl_unittest.cc",
      "update_service_impl_inactive_unittest.cc",
      "update_service_unittest.cc",
      "update_usage_stats_task_unittest.cc",
      "updater_scope_unittest.cc",
      "updater_unittest.cc",
      "util/util_unittest.cc",
    ]
    if (!is_component_build) {
      sources += [ "test/integration_tests.cc" ]
    }

    deps = [
      ":base",
      ":branding_header",
      ":constants_test",
      ":public_sources",
      ":tagging",
      ":unit_test_util_sources",
      ":version_header",
      "//base",
      "//base/test:test_support",
      "//chrome/common:constants",
      "//chrome/enterprise_companion/device_management_storage",
      "//chrome/updater/protos:omaha_proto",
      "//components/crx_file",
      "//components/policy/proto",
      "//components/prefs:test_support",
      "//components/update_client",
      "//net:test_support",
      "//testing/gmock",
      "//testing/gtest",
      "//third_party/abseil-cpp:absl",
      "//third_party/crashpad/crashpad/client",
      "//third_party/re2",
      "//third_party/zlib/google:compression_utils",
      "//url",
    ]

    data = [
      "test/data/app_logos/googletest.bmp",
      "test/data/signed.exe",  # Payload used by network tests.
      "test/data/signed.exe.gz",
      "test/data/tagged_encode_utf8.exe",
      "test/data/tagged_msi/GUH-ampersand-ending.msi",
      "test/data/tagged_msi/GUH-bad-format.msi",
      "test/data/tagged_msi/GUH-bad-format2.msi",
      "test/data/tagged_msi/GUH-brand-only.msi",
      "test/data/tagged_msi/GUH-empty-key.msi",
      "test/data/tagged_msi/GUH-empty-tag.msi",
      "test/data/tagged_msi/GUH-empty-value.msi",
      "test/data/tagged_msi/GUH-invalid-key.msi",
      "test/data/tagged_msi/GUH-invalid-length.msi",
      "test/data/tagged_msi/GUH-invalid-marker.msi",
      "test/data/tagged_msi/GUH-multiple.msi",
      "test/data/tagged_msi/GUH-size-greater-than-max.msi",
      "test/data/tagged_msi/GUH-special-value.msi",
      "test/data/tagged_msi/GUH-untagged.msi",
    ]

    data_deps = [
      ":updater_selfupdate_test_crx",
      "//chrome/updater/test/test_installer:app_installers",
    ]

    if (is_win) {
      sources += [
        "activity_impl_win_unittest.cc",
        "app/app_install_win_unittest.cc",
        "app/server/win/com_classes_legacy_unittest.cc",
        "auto_run_on_os_upgrade_task_unittest.cc",
        "policy/win/group_policy_manager_unittest.cc",
        "test/integration_tests_win.cc",
        "test/integration_tests_win.h",
        "test/unit_test_util_win.cc",
        "test/unit_test_util_win.h",
        "util/progress_sampler_unittest.cc",
        "util/util_win_unittest.cc",
        "util/win_util_unittest.cc",
        "win/app_command_runner_unittest.cc",
        "win/installer/configuration_unittest.cc",
        "win/installer/installer_win_unittest.cc",
        "win/installer/msi_custom_action_unittest.cc",
        "win/installer/string_unittest.cc",
        "win/installer_api_unittest.cc",
        "win/manifest_util_unittest.cc",
        "win/protocol_parser_xml_unittest.cc",
        "win/setup/setup_util_unittest.cc",
        "win/task_scheduler_unittest.cc",
        "win/ui/l10n_util_unittest.cc",
        "win/ui/progress_wnd_unittest.cc",
        "win/updater_tests.rc",
      ]

      deps += [
        "app/server/win:updater_idl",
        "app/server/win:updater_internal_idl",
        "app/server/win:updater_legacy_idl",
        "win/installer:lib",
        "win/installer:msi_custom_action_sources",
        "win/test:test_executables",
        "win/test:test_strings",
        "win/ui/resources",
        "//third_party/wtl",
      ]

      data_deps += [
        "//chrome/updater/win:updater",
        "//chrome/updater/win:updater_test",
        "//chrome/updater/win/installer:installer_test",
        "//chrome/updater/win/test:updater_test_process",
      ]

      data += [
        "test/data/ProcmonConfiguration.pmc",
        "//chrome/test/data/updater/OfflineManifest.gup",
        "//chrome/test/data/updater/updater_qualification_app_exe.crx",
      ]

      if (target_cpu == "arm64") {
        data += [
          "//third_party/updater/chrome_win_arm64/cipd/UpdaterSetup_test.exe",
          "//third_party/updater/chromium_win_arm64/cipd/UpdaterSetup_test.exe",
        ]
      }

      if (target_cpu == "x64") {
        data += [
          "//third_party/updater/chrome_win_x86_64/cipd/UpdaterSetup_test.exe",
          "//third_party/updater/chromium_win_x86_64/cipd/UpdaterSetup_test.exe",
        ]
      }

      if (target_cpu == "x86") {
        data += [
          "//third_party/updater/chrome_win_x86/cipd/UpdaterSetup_test.exe",
          "//third_party/updater/chromium_win_x86/cipd/UpdaterSetup_test.exe",
        ]
      }

      if (is_chrome_branded) {
        sources +=
            [ "enterprise/win/google/build_group_policy_template_unittest.cc" ]
        data += [
          "enterprise/win/google/build_group_policy_template_unittest.py",
          "enterprise/win/google/generate_group_policy_template_admx.py",
          "test/data/enterprise/win/google/test_gold.admx",
          "test/data/enterprise/win/google/test_gold.adml",
        ]
      }

      defines = [ "SECURITY_WIN32" ]

      libs = [
        "secur32.lib",
        "taskschd.lib",
        "urlmon.lib",
      ]
    }

    if (is_mac) {
      sources += [
        "app/app_net_worker_unittest.cc",
        "mac/keystone/ksadmin_unittest.cc",
        "mac/privileged_helper/privileged_helper_unittests.mm",
        "mac/setup/keystone_unittest.mm",
        "mac/setup/ks_tickets_unittest.mm",
        "mac/setup/setup_unittest.mm",
        "mac/setup/wake_task_unittest.mm",
        "policy/mac/managed_preference_policy_manager_impl_unittest.mm",
        "policy/mac/managed_preference_policy_manager_unittest.cc",
        "test/integration_tests_mac.h",
        "test/integration_tests_mac.mm",
        "util/util_mac_unittest.mm",
      ]

      deps += [
        ":ks_ticket",
        "//chrome/updater/mac:ksadmin_lib",
        "//chrome/updater/mac:privileged_helper_sources",
        "//chrome/updater/mac/client_lib:public_sources",
        "//chrome/updater/mac/client_lib:test_sources",
        "//chrome/updater/net/mac/mojom",
        "//third_party/ocmock",
      ]

      frameworks = [
        "Foundation.framework",
        "Security.framework",
      ]

      data += [
        "//chrome/test/data/updater/CountingMetrics.plist",
        "//chrome/test/data/updater/Keystone.ticketstore",
        "//chrome/test/data/updater/Keystone.withlaunchservicechecker.ticketstore",
        "//chrome/test/data/updater/Keystone.legacy.ticketstore",
        "//chrome/test/data/updater/updater_setup_test_dmg.dmg",
        "//chrome/test/data/updater/setup_test_preinstallfailure/.preinstall",
        "//chrome/test/data/updater/setup_test_preinstallfailure/.install",
        "//chrome/test/data/updater/setup_test_preinstallfailure/.postinstall",
        "//chrome/test/data/updater/setup_test_preinstallfailure/marker.app",
        "//chrome/test/data/updater/setup_test_postinstallfailure/.preinstall",
        "//chrome/test/data/updater/setup_test_postinstallfailure/.install",
        "//chrome/test/data/updater/setup_test_postinstallfailure/.postinstall",
        "//chrome/test/data/updater/setup_test_postinstallfailure/marker.app",
        "//chrome/test/data/updater/setup_test_installfailure/.preinstall",
        "//chrome/test/data/updater/setup_test_installfailure/.install",
        "//chrome/test/data/updater/setup_test_installfailure/.postinstall",
        "//chrome/test/data/updater/setup_test_installfailure/marker.app",
        "//chrome/test/data/updater/setup_test_envcheck/.install",
        "//chrome/test/data/updater/setup_test_envcheck/marker.app",
        "//chrome/test/data/updater/updater_qualification_app_dmg.crx",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/MacOS/GoogleUpdater_test",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/MacOS/GoogleSoftwareUpdate",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/MacOS/GoogleSoftwareUpdateAgent",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Helpers/ksinstall",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Helpers/ksadmin",
        "//third_party/updater/chrome_mac_universal/cipd/GoogleUpdater_test.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/CodeResources",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Helpers/ksadmin",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Helpers/ksinstall",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/MacOS/GoogleSoftwareUpdate",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/MacOS/ksadmin",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/MacOS/GoogleSoftwareUpdateAgent",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/_CodeSignature",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/GoogleSoftwareUpdate.bundle/Contents/_CodeSignature",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Helpers/launcher",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/Info.plist",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/MacOS/GoogleUpdater",
        "//third_party/updater/chrome_mac_universal_prod/cipd/GoogleUpdater.app/Contents/_CodeSignature",
      ]

      data_deps += [
        "//chrome/updater/mac:ksadmin_test",
        "//chrome/updater/mac:updater_bundle_test",
        "//chrome/updater/mac/client_lib/test_helpers/app_bundle:registration_test_app_bundle",
      ]

      if (target_cpu == "arm64") {
        data += [
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/MacOS/ChromiumUpdater_test",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Info.plist",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/MacOS/ChromiumSoftwareUpdate",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Resources/ChromiumSoftwareUpdateAgent.app/Contents/MacOS/ChromiumSoftwareUpdateAgent",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Resources/ChromiumSoftwareUpdateAgent.app/Contents/Info.plist",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Helpers/ksinstall",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Helpers/ksadmin",
          "//third_party/updater/chromium_mac_arm64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Info.plist",
        ]
      }

      if (target_cpu == "x64") {
        data += [
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/MacOS/ChromiumUpdater_test",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Info.plist",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/MacOS/ChromiumSoftwareUpdate",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Resources/ChromiumSoftwareUpdateAgent.app/Contents/MacOS/ChromiumSoftwareUpdateAgent",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Resources/ChromiumSoftwareUpdateAgent.app/Contents/Info.plist",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Helpers/ksinstall",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Helpers/ksadmin",
          "//third_party/updater/chromium_mac_amd64/cipd/ChromiumUpdater_test.app/Contents/Helpers/ChromiumSoftwareUpdate.bundle/Contents/Info.plist",
        ]
      }
    }

    if (is_linux) {
      sources += [ "test/integration_tests_linux.cc" ]

      data += [ "//chrome/test/data/updater/updater_qualification_app.crx" ]
      data_deps += [ "//chrome/updater/linux:updater_test" ]
      libs = [ "systemd" ]
    }

    if (is_posix) {
      sources += [
        "app/server/posix/ipc_unittests.cc",
        "util/posix_util_unittest.cc",
      ]

      deps += [ "//chrome/updater/app/server/posix/mojom" ]
    }
  }

  if (is_win) {
    copy("test_service_files") {
      testonly = true
      sources = [
        "test/service/win/answer_uac.py",
        "test/service/win/impersonate.py",
        "test/service/win/proc_util.py",
        "test/service/win/rpc_client.py",
        "test/service/win/rpc_handler.py",
        "test/service/win/run_command_as_standard_user.py",
        "test/service/win/service_client.py",
        "test/service/win/uac.py",
        "test/service/win/ui.py",
        "test/service/win/updater_test_service.py",
        "test/service/win/updater_test_service_control.py",
      ]
      outputs = [ "$root_build_dir/test_service/{{source_file_part}}" ]
    }
  }

  # These tests are run serially since they mutate system state.
  test("updater_tests") {
    testonly = true

    sources = [
      "test/integration_test_commands_factory_user.cc",
      "test/run_all_unittests.cc",
      "test/test_scope_user.cc",
    ]

    deps = [
      ":base",
      ":branding_header",
      ":unit_test_util_sources",
      ":updater_test_sources",
      "//base/test:test_support",
      "//chrome/common:constants",
      "//testing/gtest",
    ]

    if (is_mac) {
      data_deps = [
        "//chrome/updater/mac:updater_bundle_test",
        "//chrome/updater/mac/client_lib/test_helpers/app_bundle:registration_test_app_bundle",
        "//third_party/updater:old_updater",
      ]
    }
    if (is_win) {
      deps += [ "//chrome/installer/util:with_no_strings" ]
      data_deps = [
        ":test_service_files",
        "//chrome/updater/win:updater_test",
        "//third_party/updater:old_updater",
      ]
    }
    if (is_linux) {
      data_deps = [ "//chrome/updater/linux:updater_test" ]
      data_deps += [ "//third_party/updater:old_updater" ]
    }
  }

  test("updater_tests_system") {
    testonly = true

    sources = [
      "test/integration_test_commands_factory_system.cc",
      "test/run_all_unittests.cc",
      "test/test_scope_system.cc",
    ]

    deps = [
      ":base",
      ":branding_header",
      ":unit_test_util_sources",
      ":updater_test_sources",
      "//base/test:test_support",
      "//chrome/common:constants",
      "//testing/gtest",
    ]

    data_deps = [ ":updater_integration_tests_helper" ]
    if (is_mac) {
      data_deps += [
        "//chrome/updater/mac:updater_bundle_test",
        "//chrome/updater/mac/client_lib/test_helpers/app_bundle:registration_test_app_bundle",
        "//third_party/updater:old_updater",
      ]
    }
    if (is_win) {
      deps += [ "//chrome/installer/util:with_no_strings" ]
      data_deps += [
        ":test_service_files",
        "//chrome/updater/win:updater_test",
        "//third_party/updater:old_updater",
      ]
    }
    if (is_linux) {
      data_deps += [ "//chrome/updater/linux:updater_test" ]
    }
  }

  if (is_win) {
    group("updater_tests_win_uac") {
      testonly = true
      data = [ "//testing/scripts/run_telemetry_as_googletest.py" ]
      data_deps = [
        ":test_service_files",
        ":updater_tests",
        "//testing:test_scripts_shared",
      ]
    }
  }

  executable("updater_integration_tests_helper") {
    testonly = true

    sources = [
      "test/integration_test_commands_factory_system.cc",
      "test/integration_tests_helper.cc",
      "test/test_scope_system.cc",
    ]

    deps = [
      ":base",
      ":unit_test_util_sources",
      ":updater_test_sources",
      "//base",
      "//base/test:test_support",
      "//chrome/common:constants",
      "//testing/gtest",
      "//url",
    ]
  }
}