diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 2718cca5880..0817bbdd6c7 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -24,9 +24,9 @@ load( "testing_objc_grpc_library" ) load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") -load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test") -load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_unit_test") +load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_test") exports_files(["LICENSE"]) @@ -59,12 +59,42 @@ grpc_objc_testing_library( hdrs = ["version.h"], data = [":TestCertificates"], defines = [ + "DEBUG=1", + "PB_FIELD_32BIT=1", + "PB_NO_PACKED_STRUCTS=1", + "PB_ENABLE_MALLOC=1", "HOST_PORT_LOCALSSL=localhost:5051", "HOST_PORT_LOCAL=localhost:5050", "HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com", ], ) +objc_library( + name = "host-lib", + srcs = glob(["Hosts/ios-host/*.m"]), + hdrs = glob(["Hosts/ios-host/*.h"]), +) + +ios_application( + name = "ios-host", + bundle_id = "grpc.objc.tests.ios-host", + infoplists = ["Hosts/ios-host/Info.plist"], + minimum_os_version = "9.0", + families = [ + "iphone", + "ipad", + ], + deps = ["host-lib"], +) + +tvos_application( + name = "tvos-host", + bundle_id = "grpc.objc.tests.tvos-host", + infoplists = ["Hosts/ios-host/Info.plist"], + minimum_os_version = "10.0", + deps = ["host-lib"], +) + grpc_objc_testing_library( name = "CronetConfig", srcs = ["ConfigureCronet.m"], @@ -159,7 +189,8 @@ ios_unit_test( ":ChannelPoolTest-lib", ":ChannelTests-lib", ":NSErrorUnitTests-lib", - ] + ], + test_host = ":ios-host", ) ios_unit_test( @@ -169,8 +200,9 @@ ios_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - # ":InteropTestsMultipleChannels-lib", #??????? Cronet must be used? + # ":InteropTestsMulitpleChannels-lib", # needs Cronet ], + test_host = ":ios-host", ) macos_unit_test( @@ -187,7 +219,7 @@ macos_unit_test( ] ) -# cares does not support tvOS CPU architecture with Bazel yet +# c-ares does not support tvOS CPU architecture with Bazel yet tvos_unit_test( name = "TvTests", minimum_os_version = "10.0", @@ -198,5 +230,6 @@ tvos_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - ] + ], + test_host = ":tvos-host", ) \ No newline at end of file diff --git a/src/objective-c/tests/Hosts/ios-host/AppDelegate.h b/src/objective-c/tests/Hosts/ios-host/AppDelegate.h new file mode 100644 index 00000000000..183abcf4ec8 --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/AppDelegate.h @@ -0,0 +1,25 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +@interface AppDelegate : UIResponder + +@property(strong, nonatomic) UIWindow* window; + +@end diff --git a/src/objective-c/tests/Hosts/ios-host/AppDelegate.m b/src/objective-c/tests/Hosts/ios-host/AppDelegate.m new file mode 100644 index 00000000000..4a76f4c488c --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/AppDelegate.m @@ -0,0 +1,27 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +@end diff --git a/src/objective-c/tests/Hosts/ios-host/Info.plist b/src/objective-c/tests/Hosts/ios-host/Info.plist new file mode 100644 index 00000000000..e5baf19b85c --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/objective-c/tests/Hosts/ios-host/main.m b/src/objective-c/tests/Hosts/ios-host/main.m new file mode 100644 index 00000000000..2797c6f17f2 --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/main.m @@ -0,0 +1,26 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}