blob: 7edc61efcd3a1a284fc5993a1d2d85b986757d7f [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/mac/tweak_info_plist.gni")
import("//build/config/ios/ios_sdk.gni")
import("//ios/build/chrome_build.gni")
import("//ios/public/provider/chrome/browser/build_config.gni")
import("//ios/third_party/earl_grey/ios_eg_test.gni")
import("//ios/third_party/firebase/firebase.gni")
# Template wrapping ios_eg_test, setting default values for EarlGrey test
# based on //ios/chrome/app:chrome.
#
# Arguments:
#
# info_plist:
# (optional) string, path to the Info.plist file that will be used for
# the bundle.
#
# info_plist_target:
# (optional) string, if the info_plist is generated from an action,
# rather than a regular source file, specify the target name in lieu
# of info_plist. The two arguments are mutually exclusive.
#
# extra_info_plists:
# (optional) string array, extra list of plist files that will be merged
# and tweaked; ignored if either info_plist or info_plist_target is set.
#
# entitlements_path:
# (optional) path to the template to use to generate the application
# entitlements by performing variable substitutions, defaults to
# //build/config/ios/entitlements.plist.
#
# entitlements_target:
# (optional) label of the target generating the application
# entitlements (must generate a single file as output); cannot be
# defined if entitlements_path is set.
#
# deps
# list of labels to depends on.
#
# hooks_target
# (optional) label of the target defining the hooks used in tests.
# Defaults to //ios/chrome/test/earl_grey:hooks if undefined.
#
# This template defines two targets, one named "${target_name}" is the EarlGrey
# test application, and the other named "${target_name}_deps_group" is a group
# target that depends on the template "deps" property (used to implement the
# test suite running the FLAKY_ tests).
#
template("chrome_ios_eg_test") {
if (!defined(entitlements_path) && !defined(entitlements_target)) {
_target_name = target_name
_tweak_entitlements = target_name + "_tweak_entitlements"
compile_entitlements(_tweak_entitlements) {
substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
output_name = "$target_gen_dir/$_target_name.entitlements"
entitlements_templates =
[ "//ios/chrome/test/earl_grey/resources/Chrome.entitlements" ]
if (ios_egtests_entitlements_additions != []) {
entitlements_templates += ios_egtests_entitlements_additions
}
}
}
if (!defined(info_plist) && !defined(info_plist_target)) {
_tweak_info_plist = target_name + "_tweak_info_plist"
tweak_info_plist(_tweak_info_plist) {
info_plists = [
"//ios/chrome/app/resources/Info.plist",
"//ios/chrome/app/resources/EarlGreyAddition+Info.plist",
]
if (ios_chrome_info_plist_additions != []) {
info_plists += ios_chrome_info_plist_additions
}
if (defined(invoker.extra_info_plists)) {
info_plists += invoker.extra_info_plists
}
args = [
"--breakpad=$breakpad_enabled_as_int",
"--branding=$chromium_short_name",
"--version-overrides=MINOR=9999",
]
}
}
_deps_group_name = target_name + "_deps_group"
group(_deps_group_name) {
testonly = true
public_deps = invoker.deps
if (defined(invoker.public_deps)) {
public_deps += invoker.public_deps
}
}
ios_eg_test(target_name) {
forward_variables_from(invoker,
"*",
[
"deps",
"entitlements_path",
"entitlements_target",
"eg_main_application_delegate",
"hooks_target",
"info_plist",
"info_plist_target",
"public_deps",
])
if (!defined(entitlements_path) && !defined(entitlements_target)) {
entitlements_target = ":$_tweak_entitlements"
}
if (!defined(info_plist) && !defined(info_plist_target)) {
info_plist_target = ":$_tweak_info_plist"
}
_eg_main_application_delegate = "MainApplicationDelegate"
if (defined(invoker.eg_main_application_delegate)) {
_eg_main_application_delegate = invoker.eg_main_application_delegate
}
deps = [
":$_deps_group_name",
"//ios/chrome/app:main",
"//ios/testing:http_server_bundle_data",
]
if (ios_enable_firebase_sdk) {
# This is required here so Firebase SDK can supply ldflags to app bundle.
deps += [ "//ios/third_party/firebase" ]
}
if (defined(invoker.hooks_target)) {
assert(invoker.hooks_target != "",
"hooks_target must be non-empty if defined")
deps += [ invoker.hooks_target ]
} else {
deps += [ "//ios/chrome/test/earl_grey:hooks" ]
}
if (!defined(bundle_deps)) {
bundle_deps = []
}
bundle_deps += [
"//ios/chrome/app/resources",
ios_application_icons_target,
]
if (!defined(extra_substitutions)) {
extra_substitutions = []
}
extra_substitutions += [
"CHROMIUM_HANDOFF_ID=$chromium_handoff_id",
"CHROMIUM_SHORT_NAME=$target_name",
"CHROMIUM_URL_SCHEME_1=$url_unsecure_scheme",
"CHROMIUM_URL_SCHEME_2=$url_secure_scheme",
"CHROMIUM_URL_SCHEME_3=$url_x_callback_scheme",
"CHROMIUM_URL_CHANNEL_SCHEME=$url_channel_scheme",
"EG_MAIN_APPLICATION_DELEGATE=$_eg_main_application_delegate",
"SSOAUTH_URL_SCHEME=$url_ssoauth_scheme",
"CONTENT_WIDGET_EXTENSION_BUNDLE_ID=$chromium_bundle_id.ContentTodayExtension",
]
if (ios_automatically_manage_certs) {
# Use the same bundle identifier for EarlGrey tests as for unit tests
# when managing certificates as the number of free certs is limited.
extra_substitutions +=
[ "CHROMIUM_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}" ]
} else {
extra_substitutions += [ "CHROMIUM_BUNDLE_ID=gtest.$target_name" ]
}
}
}
set_defaults("chrome_ios_eg_test") {
configs = default_executable_configs
}