diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-08-01 12:59:39 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:40:43 +0000 |
commit | 28b1110370900897ab652cb420c371fab8857ad4 (patch) | |
tree | 41b32127d23b0df4f2add2a27e12dc87bddb260e /chromium/testing/iossim | |
parent | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (diff) | |
download | qtwebengine-chromium-28b1110370900897ab652cb420c371fab8857ad4.tar.gz |
BASELINE: Update Chromium to 53.0.2785.41
Also adds a few extra files for extensions.
Change-Id: Iccdd55d98660903331cf8b7b29188da781830af4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/testing/iossim')
-rw-r--r-- | chromium/testing/iossim/BUILD.gn | 15 | ||||
-rw-r--r-- | chromium/testing/iossim/iossim.gyp | 204 | ||||
-rw-r--r-- | chromium/testing/iossim/iossim.mm | 367 |
3 files changed, 461 insertions, 125 deletions
diff --git a/chromium/testing/iossim/BUILD.gn b/chromium/testing/iossim/BUILD.gn index 25c5f6498d2..97fa2c8797b 100644 --- a/chromium/testing/iossim/BUILD.gn +++ b/chromium/testing/iossim/BUILD.gn @@ -3,7 +3,6 @@ # found in the LICENSE file. import("//build/config/mac/mac_sdk.gni") -import("//build/symlink.gni") import("//third_party/class-dump/class-dump.gni") if (current_toolchain == host_toolchain) { @@ -57,9 +56,15 @@ if (current_toolchain == host_toolchain) { class_dump_filter = "iPhoneSimulator" } } else if (current_toolchain == default_toolchain) { - binary_symlink("iossim") { - # This creates an 'iossim' target in root_build_dir for compatibility - # with GYP and the test scripts. - binary_label = ":iossim($host_toolchain)" + copy("iossim") { + deps = [ + ":iossim($host_toolchain)", + ] + outputs = [ + "$root_out_dir/iossim", + ] + sources = [ + get_label_info(":iossim($host_toolchain)", "root_out_dir") + "/iossim", + ] } } diff --git a/chromium/testing/iossim/iossim.gyp b/chromium/testing/iossim/iossim.gyp index 88069b6d0de..2b30b18106e 100644 --- a/chromium/testing/iossim/iossim.gyp +++ b/chromium/testing/iossim/iossim.gyp @@ -9,134 +9,98 @@ 'class_dump_bin': '<(PRODUCT_DIR)/class-dump', 'class_dump_py': '<(DEPTH)/third_party/class-dump/class-dump.py', }, - 'conditions': [ - ['OS!="ios" or "<(GENERATOR)"!="xcode" or "<(GENERATOR_FLAVOR)"=="ninja"', { - 'targets': [ + 'targets': [ + { + # GN version //testing/iossim(//build/toolchain/mac:clang_x64) + 'target_name': 'iossim', + 'toolsets': ['host'], + 'type': 'executable', + 'variables': { + 'developer_dir': '<!(xcode-select -print-path)', + 'iphone_sim_path': '<(developer_dir)/../SharedFrameworks', + }, + 'dependencies': [ + '<(DEPTH)/third_party/class-dump/class-dump.gyp:class-dump#host', + ], + 'include_dirs': [ + '<(INTERMEDIATE_DIR)/iossim', + ], + 'sources': [ + 'iossim.mm', + '<(INTERMEDIATE_DIR)/iossim/iPhoneSimulatorRemoteClient.h', + ], + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/Foundation.framework', + ], + 'actions': [ { - # GN version //testing/iossim(//build/toolchain/mac:clang_x64) - 'target_name': 'iossim', - 'toolsets': ['host'], - 'type': 'executable', - 'variables': { - 'developer_dir': '<!(xcode-select -print-path)', - 'iphone_sim_path': '<(developer_dir)/../SharedFrameworks', - }, - 'dependencies': [ - '<(DEPTH)/third_party/class-dump/class-dump.gyp:class-dump#host', + 'action_name': 'generate_dvt_core_simulator', + 'inputs': [ + '<(class_dump_bin)', + '<(class_dump_py)', + '<(developer_dir)/Library/PrivateFrameworks/CoreSimulator.framework/Versions/Current/CoreSimulator', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/iossim/CoreSimulator.h' ], - 'include_dirs': [ - '<(INTERMEDIATE_DIR)/iossim', + 'action': [ + 'python', + '<(class_dump_py)', + '-t', '<(class_dump_bin)', + '-o', '<(INTERMEDIATE_DIR)/iossim/CoreSimulator.h', + '--', + '-CSim', + '<(developer_dir)/Library/PrivateFrameworks/CoreSimulator.framework', ], - 'sources': [ - 'iossim.mm', - '<(INTERMEDIATE_DIR)/iossim/iPhoneSimulatorRemoteClient.h', + 'message': 'Generating CoreSimulator.h', + }, + { + 'action_name': 'generate_dvt_foundation_header', + 'inputs': [ + '<(class_dump_bin)', + '<(class_dump_py)', + '<(iphone_sim_path)/DVTFoundation.framework/Versions/Current/DVTFoundation', ], - 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/Foundation.framework', + 'outputs': [ + '<(INTERMEDIATE_DIR)/iossim/DVTFoundation.h' ], - 'actions': [ - { - 'action_name': 'generate_dvt_core_simulator', - 'inputs': [ - '<(class_dump_bin)', - '<(class_dump_py)', - '<(developer_dir)/Library/PrivateFrameworks/CoreSimulator.framework/Versions/Current/CoreSimulator', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/iossim/CoreSimulator.h' - ], - 'action': [ - 'python', - '<(class_dump_py)', - '-t', '<(class_dump_bin)', - '-o', '<(INTERMEDIATE_DIR)/iossim/CoreSimulator.h', - '--', - '-CSim', - '<(developer_dir)/Library/PrivateFrameworks/CoreSimulator.framework', - ], - 'message': 'Generating CoreSimulator.h', - }, - { - 'action_name': 'generate_dvt_foundation_header', - 'inputs': [ - '<(class_dump_bin)', - '<(class_dump_py)', - '<(iphone_sim_path)/DVTFoundation.framework/Versions/Current/DVTFoundation', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/iossim/DVTFoundation.h' - ], - 'action': [ - 'python', - '<(class_dump_py)', - '-t', '<(class_dump_bin)', - '-o', '<(INTERMEDIATE_DIR)/iossim/DVTFoundation.h', - '--', - '-CDVTStackBacktrace|DVTInvalidation|DVTMixIn', - '<(iphone_sim_path)/DVTFoundation.framework', - ], - 'message': 'Generating DVTFoundation.h', - }, - { - 'action_name': 'generate_dvt_iphone_sim_header', - 'inputs': [ - '<(class_dump_bin)', - '<(class_dump_py)', - '<(iphone_sim_path)/DVTiPhoneSimulatorRemoteClient.framework/Versions/Current/DVTiPhoneSimulatorRemoteClient', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/iossim/DVTiPhoneSimulatorRemoteClient.h' - ], - 'action': [ - 'python', - '<(class_dump_py)', - '-t', '<(class_dump_bin)', - '-o', '<(INTERMEDIATE_DIR)/iossim/DVTiPhoneSimulatorRemoteClient.h', - '--', - '-I', - '-CiPhoneSimulator', - '<(iphone_sim_path)/DVTiPhoneSimulatorRemoteClient.framework', - ], - 'message': 'Generating DVTiPhoneSimulatorRemoteClient.h', - }, - ], # actions - 'xcode_settings': { - 'ARCHS': ['x86_64'], - }, + 'action': [ + 'python', + '<(class_dump_py)', + '-t', '<(class_dump_bin)', + '-o', '<(INTERMEDIATE_DIR)/iossim/DVTFoundation.h', + '--', + '-CDVTStackBacktrace|DVTInvalidation|DVTMixIn', + '<(iphone_sim_path)/DVTFoundation.framework', + ], + 'message': 'Generating DVTFoundation.h', }, - ], - }, { # else, OS=="ios" and "<(GENERATOR)"=="xcode" and "<(GENERATOR_FLAVOR)"!="ninja" - 'variables': { - 'ninja_output_dir': 'ninja-iossim', - 'ninja_product_dir': - '$(SYMROOT)/<(ninja_output_dir)/<(CONFIGURATION_NAME)', - }, - 'targets': [ { - 'target_name': 'iossim', - 'type': 'none', - 'toolsets': ['host'], - 'variables': { - # Gyp to rerun - 're_run_targets': [ - 'testing/iossim/iossim.gyp', - ], - }, - 'includes': ['../../build/ios/mac_build.gypi'], - 'actions': [ - { - 'action_name': 'compile iossim', - 'inputs': [], - 'outputs': [], - 'action': [ - '<@(ninja_cmd)', - 'iossim', - ], - 'message': 'Generating the iossim executable', - }, + 'action_name': 'generate_dvt_iphone_sim_header', + 'inputs': [ + '<(class_dump_bin)', + '<(class_dump_py)', + '<(iphone_sim_path)/DVTiPhoneSimulatorRemoteClient.framework/Versions/Current/DVTiPhoneSimulatorRemoteClient', ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/iossim/DVTiPhoneSimulatorRemoteClient.h' + ], + 'action': [ + 'python', + '<(class_dump_py)', + '-t', '<(class_dump_bin)', + '-o', '<(INTERMEDIATE_DIR)/iossim/DVTiPhoneSimulatorRemoteClient.h', + '--', + '-I', + '-CiPhoneSimulator', + '<(iphone_sim_path)/DVTiPhoneSimulatorRemoteClient.framework', + ], + 'message': 'Generating DVTiPhoneSimulatorRemoteClient.h', }, - ], - }], + ], # actions + 'xcode_settings': { + 'ARCHS': ['x86_64'], + }, + }, ], } diff --git a/chromium/testing/iossim/iossim.mm b/chromium/testing/iossim/iossim.mm index b0d691632c8..a9ff47da8b7 100644 --- a/chromium/testing/iossim/iossim.mm +++ b/chromium/testing/iossim/iossim.mm @@ -1,7 +1,371 @@ // Copyright (c) 2012 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 <Foundation/Foundation.h> +#if defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 +#include <getopt.h> +#include <string> + +namespace { + +void PrintUsage() { + fprintf( + stderr, + "Usage: iossim [-d device] [-s sdk_version] <app_path> <xctest_path>\n" + " where <app_path> is the path to the .app directory and <xctest_path> " + "is the path to an optional xctest bundle.\n" + "Options:\n" + " -d Specifies the device (must be one of the values from the iOS " + "Simulator's Hardware -> Device menu. Defaults to 'iPhone 6s'.\n" + " -e Erase the device's contents and settings before running the " + "test.\n" + " -p Print the device's home directory, does not run a test.\n" + " -s Specifies the SDK version to use (e.g '9.3'). Will use system " + "default if not specified.\n"); +} + +// Exit status codes. +const int kExitSuccess = EXIT_SUCCESS; +const int kExitInvalidArguments = 2; + +void LogError(NSString* format, ...) { + va_list list; + va_start(list, format); + + NSString* message = + [[[NSString alloc] initWithFormat:format arguments:list] autorelease]; + + fprintf(stderr, "iossim: ERROR: %s\n", [message UTF8String]); + fflush(stderr); + + va_end(list); +} + +} + +// Wrap boiler plate calls to xcrun NSTasks. +@interface XCRunTask : NSObject { + NSTask* _task; +} +- (instancetype)initWithArguments:(NSArray*)arguments; +- (void)run; +- (void)setStandardOutput:(id)output; +- (void)setStandardError:(id)error; +@end + +@implementation XCRunTask + +- (instancetype)initWithArguments:(NSArray*)arguments { + self = [super init]; + if (self) { + _task = [[NSTask alloc] init]; + SEL selector = @selector(setStartsNewProcessGroup:); + if ([_task respondsToSelector:selector]) + [_task performSelector:selector withObject:nil]; + [_task setLaunchPath:@"/usr/bin/xcrun"]; + [_task setArguments:arguments]; + } + return self; +} + +- (void)dealloc { + [_task release]; + [super dealloc]; +} + +- (void)setStandardOutput:(id)output { + [_task setStandardOutput:output]; +} + +- (void)setStandardError:(id)error { + [_task setStandardError:error]; +} + +- (void)run { + [_task launch]; + [_task waitUntilExit]; +} + +@end + +// Return array of available iOS runtime dictionaries. Unavailable (old Xcode +// versions) or other runtimes (tvOS, watchOS) are removed. +NSArray* Runtimes(NSDictionary* simctl_list) { + NSMutableArray* runtimes = + [[simctl_list[@"runtimes"] mutableCopy] autorelease]; + for (NSDictionary* runtime in simctl_list[@"runtimes"]) { + if (![runtime[@"identifier"] + hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] || + ![runtime[@"availability"] isEqualToString:@"(available)"]) { + [runtimes removeObject:runtime]; + } + } + return runtimes; +} + +// Return array of device dictionaries. +NSArray* Devices(NSDictionary* simctl_list) { + NSMutableArray* devicetypes = + [[simctl_list[@"devicetypes"] mutableCopy] autorelease]; + for (NSDictionary* devicetype in simctl_list[@"devicetypes"]) { + if (![devicetype[@"identifier"] + hasPrefix:@"com.apple.CoreSimulator.SimDeviceType.iPad"] && + ![devicetype[@"identifier"] + hasPrefix:@"com.apple.CoreSimulator.SimDeviceType.iPhone"]) { + [devicetypes removeObject:devicetype]; + } + } + return devicetypes; +} + +// Get list of devices, runtimes, etc from sim_ctl. +NSDictionary* GetSimulatorList() { + XCRunTask* task = [[[XCRunTask alloc] + initWithArguments:@[ @"simctl", @"list", @"-j" ]] autorelease]; + NSPipe* out = [NSPipe pipe]; + [task setStandardOutput:out]; + [task run]; + + NSData* data = [[out fileHandleForReading] readDataToEndOfFile]; + NSError* error = nil; + return [NSJSONSerialization JSONObjectWithData:data + options:kNilOptions + error:&error]; +} + +// List supported runtimes and devices. +void PrintSupportedDevices(NSDictionary* simctl_list) { + printf("\niOS devices:\n"); + for (NSDictionary* type in Devices(simctl_list)) { + printf("%s\n", [type[@"name"] UTF8String]); + } + printf("\nruntimes:\n"); + for (NSDictionary* runtime in Runtimes(simctl_list)) { + printf("%s\n", [runtime[@"version"] UTF8String]); + } +} + +// Expand path to absolute path. +NSString* ResolvePath(NSString* path) { + path = [path stringByExpandingTildeInPath]; + path = [path stringByStandardizingPath]; + const char* cpath = [path cStringUsingEncoding:NSUTF8StringEncoding]; + char* resolved_name = NULL; + char* abs_path = realpath(cpath, resolved_name); + if (abs_path == NULL) { + return nil; + } + return [NSString stringWithCString:abs_path encoding:NSUTF8StringEncoding]; +} +// Search |simctl_list| for a udid matching |device_name| and |sdk_version|. +NSString* GetDeviceBySDKAndName(NSDictionary* simctl_list, + NSString* device_name, + NSString* sdk_version) { + NSString* sdk = [@"iOS " stringByAppendingString:sdk_version]; + NSArray* devices = [simctl_list[@"devices"] objectForKey:sdk]; + for (NSDictionary* device in devices) { + if ([device[@"name"] isEqualToString:device_name]) { + return device[@"udid"]; + } + } + return nil; +} + +// Prints the HOME environment variable for a device. Used by the bots to +// package up all the test data. +void PrintDeviceHome(NSString* udid) { + XCRunTask* task = [[[XCRunTask alloc] + initWithArguments:@[ @"simctl", @"getenv", udid, @"HOME" ]] autorelease]; + [task run]; +} + +// Erase a device, used by the bots before a clean test run. +void EraseDevice(NSString* udid) { + XCRunTask* shutdown = [[[XCRunTask alloc] + initWithArguments:@[ @"simctl", @"shutdown", udid ]] autorelease]; + [shutdown setStandardOutput:nil]; + [shutdown setStandardError:nil]; + [shutdown run]; + + XCRunTask* erase = [[[XCRunTask alloc] + initWithArguments:@[ @"simctl", @"erase", udid ]] autorelease]; + [erase run]; +} + +void KillSimulator() { + XCRunTask* task = [[[XCRunTask alloc] + initWithArguments:@[ @"killall", @"Simulator" ]] autorelease]; + [task setStandardOutput:nil]; + [task setStandardError:nil]; + [task run]; +} + +void RunApplication(NSString* app_path, NSString* xctest_path, NSString* udid) { + NSString* tempFilePath = [NSTemporaryDirectory() + stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]]; + [[NSFileManager defaultManager] createFileAtPath:tempFilePath + contents:nil + attributes:nil]; + + NSString* file_string = + @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" " + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + "<plist version=\"1.0\">\n" + "<dict>\n" + " <key>TestTargetName</key>\n" + " <dict>\n" + " <key>TestBundlePath</key>\n" + " <string>{0}</string>\n" + " <key>TestHostPath</key>\n" + " <string>{1}</string>\n" + " <key>TestingEnvironmentVariables</key>\n" + " <dict>\n" + " <key>IDEiPhoneInternalTestBundleName</key>\n" + " <string>{2}</string>\n" + "{3}" + " </dict>\n" + " </dict>\n" + "</dict>\n" + "</plist>\n"; + + NSString* xctest_inject = + @" <key>DYLD_INSERT_LIBRARIES</key>\n" + " " + "<string>__PLATFORMS__/iPhoneSimulator.platform/Developer/Library/" + "PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection</" + "string>\n"; + + if (xctest_path) { + file_string = + [file_string stringByReplacingOccurrencesOfString:@"{0}" + withString:xctest_path]; + file_string = + [file_string stringByReplacingOccurrencesOfString:@"{3}" + withString:xctest_inject]; + + } else { + file_string = [file_string stringByReplacingOccurrencesOfString:@"{0}" + withString:app_path]; + file_string = [file_string stringByReplacingOccurrencesOfString:@"{3}" + withString:@""]; + } + file_string = [file_string stringByReplacingOccurrencesOfString:@"{1}" + withString:app_path]; + file_string = [file_string + stringByReplacingOccurrencesOfString:@"{2}" + withString:[app_path lastPathComponent]]; + + [file_string writeToFile:tempFilePath + atomically:YES + encoding:NSUTF8StringEncoding + error:nil]; + + XCRunTask* task = [[[XCRunTask alloc] initWithArguments:@[ + @"xcodebuild", @"-xctestrun", tempFilePath, @"-destination", + [@"platform=iOS Simulator,id=" stringByAppendingString:udid], + @"test-without-building" + ]] autorelease]; + [task run]; +} + +int main(int argc, char* const argv[]) { + NSString* app_path = nil; + NSString* xctest_path = nil; + NSString* device_name = @"iPhone 6s"; + bool wants_erase = false; + bool wants_print_home = false; + NSDictionary* simctl_list = GetSimulatorList(); + float sdk = 0; + for (NSDictionary* runtime in Runtimes(simctl_list)) { + sdk = fmax(sdk, [runtime[@"version"] floatValue]); + } + NSString* sdk_version = [NSString stringWithFormat:@"%0.1f", sdk]; + + int c; + while ((c = getopt(argc, argv, "hs:d:u:t:pel")) != -1) { + switch (c) { + case 's': + sdk_version = [NSString stringWithUTF8String:optarg]; + break; + case 'd': + device_name = [NSString stringWithUTF8String:optarg]; + break; + case 'e': + wants_erase = true; + break; + case 'p': + wants_print_home = true; + break; + case 'l': + PrintSupportedDevices(simctl_list); + exit(kExitSuccess); + break; + case 'h': + PrintUsage(); + exit(kExitSuccess); + case 'u': + case 't': + // Ignore 'u' and 't', used by old version of iossim. + break; + default: + PrintUsage(); + exit(kExitInvalidArguments); + } + } + + NSString* 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); + } + + if (wants_print_home) { + PrintDeviceHome(udid); + exit(kExitSuccess); + } + + // There should be at least one arg left, specifying the app path. Any + // additional args are passed as arguments to the app. + if (optind < argc) { + NSString* unresolved_path = [[NSFileManager defaultManager] + stringWithFileSystemRepresentation:argv[optind] + length:strlen(argv[optind])]; + app_path = ResolvePath(unresolved_path); + if (!app_path) { + LogError(@"Unable to resolve app_path %@", unresolved_path); + exit(kExitInvalidArguments); + } + + if (++optind < argc) { + NSString* unresolved_path = [[NSFileManager defaultManager] + stringWithFileSystemRepresentation:argv[optind] + length:strlen(argv[optind])]; + xctest_path = ResolvePath(unresolved_path); + if (!xctest_path) { + LogError(@"Unable to resolve xctest_path %@", unresolved_path); + exit(kExitInvalidArguments); + } + } + } else { + LogError(@"Unable to parse command line arguments."); + PrintUsage(); + exit(kExitInvalidArguments); + } + + KillSimulator(); + if (wants_erase) { + EraseDevice(udid); + } + + RunApplication(app_path, xctest_path, udid); + return kExitSuccess; +} +#else +#import <Appkit/Appkit.h> #include <asl.h> #import <Foundation/Foundation.h> #include <libgen.h> @@ -56,6 +420,7 @@ didStart:(BOOL)started withError:(NSError*)error; @end + #import "DVTiPhoneSimulatorRemoteClient.h" // An undocumented system log key included in messages from launchd. The value @@ -865,3 +1230,5 @@ int main(int argc, char* const argv[]) { [pool drain]; return kExitFailure; } + +#endif |