Commit 4ee4c0fb authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Adds an NSPrincipalClass entry to the XCTest Info.plist.

This defaults to NSObject, but can be set to a class that implements the
XCTestObservation protocol to perform one-time setup in XCTest bundles.

BUG=None

Change-Id: I3ff7abbf928a16ce6626fc99ed8fd747902cc791
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617623Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660845}
parent 9111095f
...@@ -20,5 +20,7 @@ ...@@ -20,5 +20,7 @@
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>NSPrincipalClass</key>
<string>${XCTEST_BUNDLE_PRINCIPAL_CLASS}</string>
</dict> </dict>
</plist> </plist>
...@@ -1660,14 +1660,23 @@ template("ios_xctest_bundle") { ...@@ -1660,14 +1660,23 @@ template("ios_xctest_bundle") {
info_plist = "//build/config/ios/Module-Info.plist" info_plist = "//build/config/ios/Module-Info.plist"
executable_name = _output_name executable_name = _output_name
if (defined(invoker.xctest_bundle_principal_class)) {
_principal_class = invoker.xctest_bundle_principal_class
} else {
# Fall back to a reasonable default value.
_principal_class = "NSObject"
}
extra_substitutions =
[ "XCTEST_BUNDLE_PRINCIPAL_CLASS=${_principal_class}" ]
if (ios_automatically_manage_certs) { if (ios_automatically_manage_certs) {
# Use a fixed bundle identifier for EarlGrey tests when using Xcode to # Use a fixed bundle identifier for EarlGrey tests when using Xcode to
# manage the certificates as the number of free certs is limited. # manage the certificates as the number of free certs is limited.
extra_substitutions = [ extra_substitutions += [
"MODULE_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}-module", "MODULE_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}-module",
] ]
} else { } else {
extra_substitutions = [ "MODULE_BUNDLE_ID=gtest.$_output_name" ] extra_substitutions += [ "MODULE_BUNDLE_ID=gtest.$_output_name" ]
} }
} }
...@@ -2027,7 +2036,11 @@ template("ios_xcuitest_test") { ...@@ -2027,7 +2036,11 @@ template("ios_xcuitest_test") {
_xcuitest_module_output = _xcuitest_target _xcuitest_module_output = _xcuitest_target
ios_xctest_bundle(_xcuitest_module_target) { ios_xctest_bundle(_xcuitest_module_target) {
forward_variables_from(invoker, [ "xcode_test_application_name" ]) forward_variables_from(invoker,
[
"xcode_test_application_name",
"xctest_bundle_principal_class",
])
product_type = _ios_xcode_xcuitest_bundle_id product_type = _ios_xcode_xcuitest_bundle_id
host_target = _xcuitest_runner_target host_target = _xcuitest_runner_target
......
...@@ -69,6 +69,7 @@ template("ios_eg2_test") { ...@@ -69,6 +69,7 @@ template("ios_eg2_test") {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"xcode_test_application_name", "xcode_test_application_name",
"xctest_bundle_principal_class",
"bundle_deps", "bundle_deps",
"deps", "deps",
]) ])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment