chromium/ios/chrome/test/xcuitest/ios_chrome_xcuitest_app_host.gni

# Copyright 2021 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/apple/tweak_info_plist.gni")
import("//build/config/ios/ios_sdk.gni")
import("//build/config/ios/rules.gni")
import("//ios/build/chrome_build.gni")
import("//ios/chrome/app/chrome_app.gni")
import("//ios/public/provider/chrome/browser/build_config.gni")

# Template to build a simple Chrome host app for XCUITests.
#
# Arguments
#
#   use_default_test_hooks:
#       (optional) boolean, whether to use the default test hooks. If false or
#       not set, must include a custom implementation in deps.
template("ios_chrome_xcuitest_app_host") {
  _tweak_info_plist = target_name + "_tweak_info_plist"
  tweak_info_plist(_tweak_info_plist) {
    info_plists = [
      "//ios/chrome/app/resources/Info.plist",

      # Include tweaks required for UI testing host app.
      "//ios/chrome/app/resources/EarlGreyAddition+Info.plist",
    ]
  }

  chrome_app(target_name) {
    testonly = true
    forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)

    bundle_identifier = shared_bundle_id_for_test_apps

    if (!defined(deps)) {
      deps = []
    }
    deps += [ "//ios/chrome/app:main" ]
    if (defined(use_default_test_hooks) && use_default_test_hooks) {
      deps += [ "//ios/chrome/test/xcuitest:hooks" ]
    }

    if (!defined(bundle_deps)) {
      bundle_deps = []
    }
    bundle_deps += [
      "//ios/chrome/app/resources",
      ios_application_icons_target,
    ]
    bundle_deps += ios_providers_resources_targets

    info_plist_target = ":$_tweak_info_plist"
    extra_substitutions = [
      "CHROMIUM_BUNDLE_ID=$bundle_identifier",
      "CHROMIUM_HANDOFF_ID=$chromium_handoff_id",
      "CHROMIUM_SHORT_NAME=$target_name",
      "CHROMIUM_URL_CHANNEL_SCHEME=$url_channel_scheme",
      "CHROMIUM_URL_SCHEME_1=$url_unsecure_scheme",
      "CHROMIUM_URL_SCHEME_2=$url_secure_scheme",
      "CHROMIUM_URL_SCHEME_3=$url_x_callback_scheme",
      "CONTENT_WIDGET_EXTENSION_BUNDLE_ID=$bundle_identifier.ContentTodayExtension",
      "EG_MAIN_APPLICATION_DELEGATE=MainApplicationDelegate",
      "IOS_MOVE_TAB_ACTIVITY_TYPE=$ios_move_tab_activity_type",
      "SSOAUTH_URL_SCHEME=$url_ssoauth_scheme",
    ]
  }
}

set_defaults("ios_chrome_xcuitest_app_host") {
  configs = default_executable_configs
}