|
| 1 | +# Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | +# Use of this source code is governed by a BSD-style license that can be |
| 3 | +# found in the LICENSE file. |
| 4 | + |
| 5 | +import("//build/config/ios/rules.gni") |
| 6 | +import("//build/mac/tweak_info_plist.gni") |
| 7 | +import("//ios/build/chrome_build.gni") |
| 8 | +import("//ios/public/provider/chrome/browser/build_config.gni") |
| 9 | +import("//ios/third_party/earl_grey2/ios_eg2_test.gni") |
| 10 | + |
| 11 | +template("chrome_ios_eg2_test_app_host") { |
| 12 | + if (!defined(entitlements_path) && !defined(entitlements_target)) { |
| 13 | + _target_name = target_name |
| 14 | + _tweak_entitlements = target_name + "_tweak_entitlements" |
| 15 | + compile_entitlements(_tweak_entitlements) { |
| 16 | + substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ] |
| 17 | + output_name = "$target_gen_dir/$_target_name.entitlements" |
| 18 | + entitlements_templates = |
| 19 | + [ "//ios/chrome/test/earl_grey/resources/Chrome.entitlements" ] |
| 20 | + if (ios_egtests_entitlements_additions != []) { |
| 21 | + entitlements_templates += ios_egtests_entitlements_additions |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + if (!defined(info_plist) && !defined(info_plist_target)) { |
| 27 | + _tweak_info_plist = target_name + "_tweak_info_plist" |
| 28 | + tweak_info_plist(_tweak_info_plist) { |
| 29 | + info_plists = [ |
| 30 | + "//ios/chrome/app/resources/Info.plist", |
| 31 | + "//ios/chrome/app/resources/EarlGreyAddition+Info.plist", |
| 32 | + ] |
| 33 | + if (ios_chrome_info_plist_additions != []) { |
| 34 | + info_plists += ios_chrome_info_plist_additions |
| 35 | + } |
| 36 | + if (defined(invoker.extra_info_plists)) { |
| 37 | + info_plists += invoker.extra_info_plists |
| 38 | + } |
| 39 | + args = [ |
| 40 | + "--breakpad=$breakpad_enabled_as_int", |
| 41 | + "--branding=$chromium_short_name", |
| 42 | + "--version-overrides=MINOR=9999", |
| 43 | + ] |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + _deps_group_name = target_name + "_deps_group" |
| 48 | + group(_deps_group_name) { |
| 49 | + testonly = true |
| 50 | + |
| 51 | + public_deps = [] |
| 52 | + if (defined(invoker.deps)) { |
| 53 | + public_deps += invoker.deps |
| 54 | + } |
| 55 | + |
| 56 | + if (defined(invoker.public_deps)) { |
| 57 | + public_deps += invoker.public_deps |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + ios_eg2_test_app_host(target_name) { |
| 62 | + forward_variables_from(invoker, |
| 63 | + [ |
| 64 | + "entitlements_path", |
| 65 | + "entitlements_target", |
| 66 | + "eg_main_application_delegate", |
| 67 | + "info_plist", |
| 68 | + "info_plist_target", |
| 69 | + ], |
| 70 | + [ |
| 71 | + "deps", |
| 72 | + "public_deps", |
| 73 | + ]) |
| 74 | + testonly = true |
| 75 | + |
| 76 | + if (!defined(entitlements_path) && !defined(entitlements_target)) { |
| 77 | + entitlements_target = ":$_tweak_entitlements" |
| 78 | + } |
| 79 | + |
| 80 | + if (!defined(info_plist) && !defined(info_plist_target)) { |
| 81 | + info_plist_target = ":$_tweak_info_plist" |
| 82 | + } |
| 83 | + |
| 84 | + _eg_main_application_delegate = "MainApplicationDelegate" |
| 85 | + if (defined(eg_main_application_delegate)) { |
| 86 | + _eg_main_application_delegate = eg_main_application_delegate |
| 87 | + } |
| 88 | + |
| 89 | + deps = [ |
| 90 | + ":$_deps_group_name", |
| 91 | + "//ios/chrome/app:main", |
| 92 | + "//ios/chrome/test/earl_grey:hooks", |
| 93 | + "//ios/testing:http_server_bundle_data", |
| 94 | + "//ios/third_party/earl_grey2:app_framework+link", |
| 95 | + ] |
| 96 | + |
| 97 | + if (!defined(bundle_deps)) { |
| 98 | + bundle_deps = [] |
| 99 | + } |
| 100 | + bundle_deps += [ |
| 101 | + "//ios/chrome/app/resources", |
| 102 | + "//ios/third_party/earl_grey2:app_framework+bundle", |
| 103 | + ios_application_icons_target, |
| 104 | + ] |
| 105 | + |
| 106 | + if (!defined(extra_substitutions)) { |
| 107 | + extra_substitutions = [] |
| 108 | + } |
| 109 | + extra_substitutions += [ |
| 110 | + "CHROMIUM_HANDOFF_ID=$chromium_handoff_id", |
| 111 | + "CHROMIUM_SHORT_NAME=$target_name", |
| 112 | + "CHROMIUM_URL_SCHEME_1=$url_unsecure_scheme", |
| 113 | + "CHROMIUM_URL_SCHEME_2=$url_secure_scheme", |
| 114 | + "CHROMIUM_URL_SCHEME_3=$url_x_callback_scheme", |
| 115 | + "CHROMIUM_URL_CHANNEL_SCHEME=$url_channel_scheme", |
| 116 | + "EG_MAIN_APPLICATION_DELEGATE=$_eg_main_application_delegate", |
| 117 | + "SSOAUTH_URL_SCHEME=$url_ssoauth_scheme", |
| 118 | + "CONTENT_WIDGET_EXTENSION_BUNDLE_ID=$chromium_bundle_id.ContentTodayExtension", |
| 119 | + ] |
| 120 | + if (ios_automatically_manage_certs) { |
| 121 | + # Use the same bundle identifier for EarlGrey tests as for unit tests |
| 122 | + # when managing certificates as the number of free certs is limited. |
| 123 | + extra_substitutions += |
| 124 | + [ "CHROMIUM_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}" ] |
| 125 | + } else { |
| 126 | + extra_substitutions += [ "CHROMIUM_BUNDLE_ID=gtest.$target_name" ] |
| 127 | + } |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +set_defaults("chrome_ios_eg_v2_test_app_host") { |
| 132 | + configs = default_executable_configs |
| 133 | +} |
| 134 | + |
| 135 | +template("chrome_ios_eg2_test") { |
| 136 | + assert(defined(invoker.xcode_test_application_name), |
| 137 | + "xcode_test_application_name must be defined for $target_name") |
| 138 | + assert( |
| 139 | + defined(invoker.deps), |
| 140 | + "deps must be defined for $target_name to include at least one earl grey test file.") |
| 141 | + |
| 142 | + ios_eg2_test(target_name) { |
| 143 | + forward_variables_from(invoker, |
| 144 | + [ |
| 145 | + "xcode_test_application_name", |
| 146 | + "deps", |
| 147 | + ]) |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +set_defaults("chrome_ios_eg2_test") { |
| 152 | + configs = default_shared_library_configs |
| 153 | +} |
0 commit comments