Commit acd3f7ca authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Get things compiling on Xcode 11.

Updates various files with to conform to iOS13 SDK headers changes:
  Nullability and availability changes
  Updates security types
  Updated default values (modalPresentationStyle)
  Updates objc_zombie with IMP changes (as well as adding the accidentally-omitted tests)

TBR=rohitrao

Change-Id: I7d88a8c0fbb764484050be67dd33adcd11d343dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642508
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666142}
parent 46f2422a
......@@ -5,6 +5,7 @@
#ifndef BASE_MAC_FOUNDATION_UTIL_H_
#define BASE_MAC_FOUNDATION_UTIL_H_
#include <AvailabilityMacros.h>
#include <CoreFoundation/CoreFoundation.h>
#include <string>
......@@ -52,7 +53,7 @@ typedef CR_FORWARD_ENUM(unsigned int, NSSearchPathDirectory);
typedef unsigned int NSSearchPathDomainMask;
#endif
#if defined(OS_IOS)
#if defined(OS_IOS) || defined(MAC_OS_X_VERSION_10_15)
typedef struct CF_BRIDGED_TYPE(id) __SecCertificate* SecCertificateRef;
typedef struct CF_BRIDGED_TYPE(id) __SecKey* SecKeyRef;
typedef struct CF_BRIDGED_TYPE(id) __SecPolicy* SecPolicyRef;
......
......@@ -198,6 +198,7 @@ test("components_unittests") {
deps += [
"//components/autofill/ios/browser:unit_tests",
"//components/autofill/ios/form_util:unit_tests",
"//components/crash/core/common:unit_tests",
"//components/image_fetcher/ios:unit_tests",
"//components/language/ios/browser:unit_tests",
"//components/password_manager/ios:unit_tests",
......
......@@ -153,7 +153,15 @@ source_set("unit_tests") {
sources += [ "objc_zombie_unittest.mm" ]
}
if (!is_mac && !is_win && !is_fuchsia && !is_android) {
# TODO(crbug.com/970280): crash_key* is failing on iOS.
if (is_ios) {
sources -= [
"crash_key_unittest.cc",
"crash_keys_unittest.cc",
]
}
if (!is_mac && !is_ios && !is_win && !is_fuchsia && !is_android) {
include_dirs = [ "//third_party/breakpad/breakpad/src/" ]
sources += [ "crash_key_breakpad_unittest.cc" ]
}
......
......@@ -56,7 +56,17 @@ namespace {
const size_t kBacktraceDepth = 20;
// The original implementation for |-[NSObject dealloc]|.
IMP g_originalDeallocIMP = NULL;
#if OBJC_OLD_DISPATCH_PROTOTYPES
using RealIMP = IMP;
#else
// With !OBJC_OLD_DISPATCH_PROTOTYPES the runtime hasn't changed and IMP is
// still what it always was, but the SDK is hiding the details now outside the
// objc runtime. It is safe to define |RealIMP| to match the older definition of
// |IMP|.
using RealIMP = id (*)(id, SEL, ...);
#endif
RealIMP g_originalDeallocIMP = NULL;
// Classes which freed objects become. |g_fatZombieSize| is the
// minimum object size which can be made into a fat zombie (which can
......@@ -252,8 +262,8 @@ BOOL ZombieInit() {
return YES;
Class rootClass = [NSObject class];
g_originalDeallocIMP =
class_getMethodImplementation(rootClass, @selector(dealloc));
g_originalDeallocIMP = reinterpret_cast<RealIMP>(
class_getMethodImplementation(rootClass, @selector(dealloc)));
// objc_getClass() so CrZombie doesn't need +class.
g_zombieClass = objc_getClass("CrZombie");
g_fatZombieClass = objc_getClass("CrFatZombie");
......@@ -346,9 +356,10 @@ bool ZombieEnable(bool zombieAllObjects,
if (!m)
return false;
const IMP prevDeallocIMP = method_setImplementation(m, (IMP)ZombieDealloc);
const RealIMP prevDeallocIMP = reinterpret_cast<RealIMP>(
method_setImplementation(m, reinterpret_cast<IMP>(ZombieDealloc)));
DCHECK(prevDeallocIMP == g_originalDeallocIMP ||
prevDeallocIMP == (IMP)ZombieDealloc);
prevDeallocIMP == reinterpret_cast<RealIMP>(ZombieDealloc));
// Grab the current set of zombies. This is thread-safe because
// only the main thread can change these.
......@@ -420,7 +431,7 @@ void ZombieDisable() {
// Put back the original implementation of -[NSObject dealloc].
Method m = class_getInstanceMethod([NSObject class], @selector(dealloc));
DCHECK(m);
method_setImplementation(m, g_originalDeallocIMP);
method_setImplementation(m, reinterpret_cast<IMP>(g_originalDeallocIMP));
// Can safely grab this because it only happens on the main thread.
const size_t oldCount = g_zombieCount;
......
......@@ -2,7 +2,7 @@
"comments": [
"Runs tests on 64-bit iOS 11.4 and 12.1 and 13.0 tests"
],
"xcode build version": "10e125",
"xcode build version": "11m336w",
"gn_args": [
"goma_dir=\"$(goma_dir)\"",
"is_component_build=false",
......@@ -22,7 +22,7 @@
"xcode parallelization": true,
"include": "eg2_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -35,7 +35,7 @@
{
"include": "screen_size_dependent_tests.json",
"device type": "iPhone 6s Plus",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -48,7 +48,7 @@
{
"include": "screen_size_dependent_tests.json",
"device type": "iPhone 6s",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -61,7 +61,7 @@
{
"include": "common_tests.json",
"device type": "iPhone 6s",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -74,7 +74,7 @@
{
"include": "eg_tests.json",
"device type": "iPhone 7",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -87,7 +87,7 @@
{
"include": "eg_tests.json",
"device type": "iPad Air 2",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -100,7 +100,7 @@
{
"include": "eg_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -113,7 +113,7 @@
{
"include": "eg_cq_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -126,7 +126,7 @@
{
"include": "eg_cq_tests.json",
"device type": "iPad Air 2",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......
......@@ -2,7 +2,7 @@
"comments": [
"Runs tests on 64-bit iOS 11.4 and 12.1 and 13.0 tests"
],
"xcode build version": "10e125",
"xcode build version": "11m336w",
"gn_args": [
"goma_dir=\"$(goma_dir)\"",
"is_component_build=false",
......@@ -22,7 +22,7 @@
"xcode parallelization": true,
"include": "eg2_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -35,7 +35,7 @@
{
"include": "screen_size_dependent_tests.json",
"device type": "iPhone 6s Plus",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -48,7 +48,7 @@
{
"include": "screen_size_dependent_tests.json",
"device type": "iPhone 6s",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -61,7 +61,7 @@
{
"include": "common_tests.json",
"device type": "iPhone 6s",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -74,7 +74,7 @@
{
"include": "eg_tests.json",
"device type": "iPhone 7",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -87,7 +87,7 @@
{
"include": "eg_tests.json",
"device type": "iPad Air 2",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -100,7 +100,7 @@
{
"include": "eg_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -113,7 +113,7 @@
{
"include": "eg_cq_tests.json",
"device type": "iPhone X",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......@@ -126,7 +126,7 @@
{
"include": "eg_cq_tests.json",
"device type": "iPad Air 2",
"os": "12.2",
"os": "13.0",
"pool":"Chrome",
"host os": "Mac-10.14.3",
"optional_dimensions": {
......
......@@ -210,7 +210,6 @@ void UndockKeyboard() {
CGRect keyboardContainerFrame = KeyboardContainerForLayout(layout).frame;
CGPoint pointToKey = {keyFrame.origin.x - keyboardContainerFrame.origin.x,
keyFrame.origin.y - keyboardContainerFrame.origin.y};
CGRectIntersection(keyFrame, keyboardContainerFrame);
CGPoint startPoint = CGPointMake((pointToKey.x + keyFrame.size.width / 2.0) /
keyboardContainerFrame.size.width,
(pointToKey.y + keyFrame.size.height / 2.0) /
......
......@@ -143,6 +143,11 @@ initWithRootViewController:(UIViewController*)rootViewController
- (instancetype)initWithRootViewController:(UIViewController*)rootViewController
NS_UNAVAILABLE;
- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass
toolbarClass:(Class)toolbarClass NS_UNAVAILABLE;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
// Returns a new Done button for a UINavigationItem which will call
// closeSettings when it is pressed. Should only be called by view controllers
......
......@@ -249,9 +249,13 @@ initWithRootViewController:(UIViewController*)rootViewController
delegate:(id<SettingsNavigationControllerDelegate>)delegate {
DCHECK(browserState);
DCHECK(!browserState->IsOffTheRecord());
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
self = [super initWithRootViewController:rootViewController];
#else
self = rootViewController
? [super initWithRootViewController:rootViewController]
: [super init];
#endif
if (self) {
mainBrowserState_ = browserState;
delegate_ = delegate;
......
......@@ -302,6 +302,7 @@
}
self.bvcContainer = [[BVCContainerViewController alloc] init];
self.bvcContainer.modalPresentationStyle = UIModalPresentationFullScreen;
self.bvcContainer.currentBVC = viewController;
self.bvcContainer.transitioningDelegate = self.transitionHandler;
BOOL animated = !self.animationsDisabledForTesting;
......
......@@ -15,6 +15,10 @@
- (instancetype)initWithTable:(ChromeTableViewController*)table
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithRootViewController:(UIViewController*)rootViewController
NS_UNAVAILABLE;
- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass
toolbarClass:(Class)toolbarClass NS_UNAVAILABLE;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
......
......@@ -21,7 +21,7 @@
// Fake implementations of UIDocumentInteractionController properties:
@property(nonatomic, copy) NSString* UTI;
@property(nonatomic, weak) id<UIDocumentInteractionControllerDelegate> delegate;
@property(nonatomic, weak) id delegate;
// Whether or not this controller can present Open In... menu. Defaults to YES.
@property(nonatomic) BOOL presentsOpenInMenu;
......
......@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, nullable, copy) NSURLResponse* response;
- (nullable instancetype)initWithURL:(NSURL*)URL NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)init NS_UNAVAILABLE;
- (nonnull instancetype)init NS_UNAVAILABLE;
@end
......
......@@ -113,9 +113,13 @@ NSArray* Runtimes(NSDictionary* simctl_list) {
NSMutableArray* runtimes =
[[simctl_list[@"runtimes"] mutableCopy] autorelease];
for (NSDictionary* runtime in simctl_list[@"runtimes"]) {
BOOL available =
[runtime[@"availability"] isEqualToString:@"(available)"] ||
runtime[@"isAvailable"];
if (![runtime[@"identifier"]
hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] ||
![runtime[@"availability"] isEqualToString:@"(available)"]) {
!available) {
[runtimes removeObject:runtime];
}
}
......@@ -209,6 +213,18 @@ NSString* GetDeviceBySDKAndName(NSDictionary* simctl_list,
return nil;
}
// Create and a redturn a device udid of |device| and |sdk_version|.
NSString* CreateDeviceBySDKAndName(NSString* device, NSString* sdk_version) {
NSString* sdk = [@"iOS" stringByAppendingString:sdk_version];
XCRunTask* create = [[[XCRunTask alloc]
initWithArguments:@[ @"simctl", @"create", device, device, sdk ]]
autorelease];
[create run];
NSDictionary* simctl_list = GetSimulatorList();
return GetDeviceBySDKAndName(simctl_list, device, sdk_version);
}
bool FindDeviceByUDID(NSDictionary* simctl_list, NSString* udid) {
NSDictionary* devices_table = simctl_list[@"devices"];
for (id runtimes in devices_table) {
......@@ -433,10 +449,13 @@ int main(int argc, char* const argv[]) {
if (udid == nil) {
udid = GetDeviceBySDKAndName(simctl_list, device_name, sdk_version);
if (udid == nil) {
LogError(@"Unable to find a device %@ with SDK %@.", device_name,
sdk_version);
PrintSupportedDevices(simctl_list);
exit(kExitInvalidArguments);
udid = CreateDeviceBySDKAndName(device_name, sdk_version);
if (udid == nil) {
LogError(@"Unable to find a device %@ with SDK %@.", device_name,
sdk_version);
PrintSupportedDevices(simctl_list);
exit(kExitInvalidArguments);
}
}
} else {
if (!FindDeviceByUDID(simctl_list, udid)) {
......
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