diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-12-13 17:40:25 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-12-13 17:40:25 +0100 |
commit | be3f1d1fc29f0b13c26149a5e654e335eda75450 (patch) | |
tree | 3a41e2a92b3dfd6606ee212e1a2e476db4c321d3 /cpp/test/ios/controller/Classes | |
parent | Another fix for Windows bin PATH (diff) | |
download | ice-be3f1d1fc29f0b13c26149a5e654e335eda75450.tar.bz2 ice-be3f1d1fc29f0b13c26149a5e654e335eda75450.tar.xz ice-be3f1d1fc29f0b13c26149a5e654e335eda75450.zip |
Support for C++ iOS Simulator controller
Diffstat (limited to 'cpp/test/ios/controller/Classes')
28 files changed, 777 insertions, 0 deletions
diff --git a/cpp/test/ios/controller/Classes/AppDelegate.h b/cpp/test/ios/controller/Classes/AppDelegate.h new file mode 100644 index 00000000000..d5adf138722 --- /dev/null +++ b/cpp/test/ios/controller/Classes/AppDelegate.h @@ -0,0 +1,18 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#import <UIKit/UIKit.h> + +@interface AppDelegate : UIResponder <UIApplicationDelegate> + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/cpp/test/ios/controller/Classes/AppDelegate.m b/cpp/test/ios/controller/Classes/AppDelegate.m new file mode 100644 index 00000000000..6e3bd3ce574 --- /dev/null +++ b/cpp/test/ios/controller/Classes/AppDelegate.m @@ -0,0 +1,52 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/Contents.json b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..ef0fccfaf08 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,110 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "test_suite-Small-20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "test_suite-Small-20@3x-1.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "test_suite-Small@2x-1.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "test_suite-Small@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "test_suite-Small-40@2x-1.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "test_suite-Small-40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "test_suite-Small-40@3x-1.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "test_suite-Small-60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "test_suite-Small-20.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "test_suite-Small-41.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "test_suite-Small.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "test_suite-Small@2x-2.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "test_suite-Small-40.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "test_suite-Small-40@2x-2.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "test_suite-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "test_suite-76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "test_suite-Small-83,5@2x-1.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +}
\ No newline at end of file diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76.png Binary files differnew file mode 100644 index 00000000000..2855a8b674b --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76@2x.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76@2x.png Binary files differnew file mode 100644 index 00000000000..29047dc5a52 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-76@2x.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20.png Binary files differnew file mode 100644 index 00000000000..caacf7e7f46 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@2x.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@2x.png Binary files differnew file mode 100644 index 00000000000..e76086fb3d6 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@2x.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@3x-1.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@3x-1.png Binary files differnew file mode 100644 index 00000000000..7018d04d7a9 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-20@3x-1.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40.png Binary files differnew file mode 100644 index 00000000000..e76086fb3d6 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-1.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-1.png Binary files differnew file mode 100644 index 00000000000..7615d3255bc --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-1.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-2.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-2.png Binary files differnew file mode 100644 index 00000000000..7615d3255bc --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@2x-2.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x-1.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x-1.png Binary files differnew file mode 100644 index 00000000000..f04f442176a --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x-1.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x.png Binary files differnew file mode 100644 index 00000000000..f04f442176a --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-40@3x.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-41.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-41.png Binary files differnew file mode 100644 index 00000000000..e76086fb3d6 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-41.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-60@3x.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-60@3x.png Binary files differnew file mode 100644 index 00000000000..a37f851e642 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-60@3x.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-83,5@2x-1.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-83,5@2x-1.png Binary files differnew file mode 100644 index 00000000000..70fa6059084 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small-83,5@2x-1.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small.png Binary files differnew file mode 100644 index 00000000000..d57695edc28 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-1.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-1.png Binary files differnew file mode 100644 index 00000000000..79edc547e2c --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-1.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-2.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-2.png Binary files differnew file mode 100644 index 00000000000..79edc547e2c --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@2x-2.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@3x.png b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@3x.png Binary files differnew file mode 100644 index 00000000000..49cdc033096 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/AppIcon.appiconset/test_suite-Small@3x.png diff --git a/cpp/test/ios/controller/Classes/Assets.xcassets/Contents.json b/cpp/test/ios/controller/Classes/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +}
\ No newline at end of file diff --git a/cpp/test/ios/controller/Classes/Base.lproj/LaunchScreen.storyboard b/cpp/test/ios/controller/Classes/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000000..fdf3f97d1b6 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="EHf-IW-A2E"> + <objects> + <viewController id="01J-lp-oVM" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/> + <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="53" y="375"/> + </scene> + </scenes> +</document> diff --git a/cpp/test/ios/controller/Classes/Base.lproj/Main.storyboard b/cpp/test/ios/controller/Classes/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..9550d1821c9 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Base.lproj/Main.storyboard @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> + <device id="retina4_7" orientation="portrait"> + <adaptation id="fullscreen"/> + </device> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="tne-QT-ifu"> + <objects> + <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> + <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="nZ9-dY-qBC" userLabel="Output"> + <rect key="frame" x="16" y="20" width="343" height="627"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> + </textView> + </subviews> + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + </view> + <connections> + <outlet property="output" destination="nZ9-dY-qBC" id="drk-4a-vAK"/> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="136.80000000000001" y="138.98050974512745"/> + </scene> + </scenes> +</document> diff --git a/cpp/test/ios/controller/Classes/C++11-Info.plist b/cpp/test/ios/controller/Classes/C++11-Info.plist new file mode 100644 index 00000000000..d0524738680 --- /dev/null +++ b/cpp/test/ios/controller/Classes/C++11-Info.plist @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UIMainStoryboardFile</key> + <string>Main</string> + <key>UIRequiredDeviceCapabilities</key> + <array> + <string>armv7</string> + </array> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>UISupportedInterfaceOrientations~ipad</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> +</dict> +</plist> diff --git a/cpp/test/ios/controller/Classes/Info.plist b/cpp/test/ios/controller/Classes/Info.plist new file mode 100644 index 00000000000..d0524738680 --- /dev/null +++ b/cpp/test/ios/controller/Classes/Info.plist @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UIMainStoryboardFile</key> + <string>Main</string> + <key>UIRequiredDeviceCapabilities</key> + <array> + <string>armv7</string> + </array> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>UISupportedInterfaceOrientations~ipad</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> +</dict> +</plist> diff --git a/cpp/test/ios/controller/Classes/ViewController.h b/cpp/test/ios/controller/Classes/ViewController.h new file mode 100644 index 00000000000..82e72ca876a --- /dev/null +++ b/cpp/test/ios/controller/Classes/ViewController.h @@ -0,0 +1,18 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#import <UIKit/UIKit.h> + +@interface ViewController : UIViewController +{ +@private + IBOutlet UITextView* output; +} +@end + diff --git a/cpp/test/ios/controller/Classes/ViewController.mm b/cpp/test/ios/controller/Classes/ViewController.mm new file mode 100644 index 00000000000..e1d2e95fa32 --- /dev/null +++ b/cpp/test/ios/controller/Classes/ViewController.mm @@ -0,0 +1,397 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#import "ViewController.h" + +#include <Ice/Ice.h> +#include <Controller.h> +#include <TestHelper.h> + +#include <dlfcn.h> + +using namespace std; +using namespace Test::Common; + +@interface ViewController() +-(void) print:(NSString*)msg; +-(void) println:(NSString*)msg; +@end + + +namespace +{ + +typedef int (*MAIN_ENTRY_POINT)(int argc, char** argv, Test::MainHelper* helper); +typedef int (*SHUTDOWN_ENTRY_POINT)(); + +class MainHelperI : public Test::MainHelper, private IceUtil::Monitor<IceUtil::Mutex>, public IceUtil::Thread +{ +public: + + MainHelperI(ViewController*, const string&, const StringSeq&); + virtual ~MainHelperI(); + + virtual void serverReady(); + virtual void shutdown(); + virtual void waitForCompleted() {} + virtual bool redirect(); + virtual void print(const std::string&); + + virtual void run(); + + void completed(int); + void waitReady(int) const; + int waitSuccess(int) const; + string getOutput() const; + +private: + + ViewController* _controller; + std::string _dll; + StringSeq _args; + CFBundleRef _handle; + SHUTDOWN_ENTRY_POINT _dllTestShutdown; + bool _ready; + bool _completed; + int _status; + std::ostringstream _out; +}; + +class ProcessI : public Process +{ +public: + + ProcessI(ViewController*, MainHelperI*); + virtual ~ProcessI(); + + void waitReady(int, const Ice::Current&); + int waitSuccess(int, const Ice::Current&); + string terminate(const Ice::Current&); + +private: + + ViewController* _controller; + IceUtil::Handle<MainHelperI> _helper; +}; + +class ProcessControllerI : public ProcessController +{ +public: + + ProcessControllerI(ViewController*); + +#ifdef ICE_CPP11_MAPPING + virtual shared_ptr<ProcessPrx> + start(string, string, StringSeq, const Ice::Current&); +#else + virtual ProcessPrx + start(const string&, const string&, const StringSeq&, const Ice::Current&); +#endif + +private: + + ViewController* _controller; +}; + +class ControllerHelper +{ +public: + + ControllerHelper(ViewController*); + virtual ~ControllerHelper(); + +private: + + Ice::CommunicatorPtr _communicator; +}; + +} + +MainHelperI::MainHelperI(ViewController* controller, const string& dll, const StringSeq& args) : + _controller(controller), + _dll(dll), + _args(args), + _ready(false), + _completed(false), + _status(0) +{ +} + +MainHelperI::~MainHelperI() +{ + if(_handle) + { + CFBundleUnloadExecutable(_handle); + } +} + +void +MainHelperI::serverReady() +{ + Lock sync(*this); + _ready = true; + notifyAll(); +} + +void +MainHelperI::shutdown() +{ + Lock sync(*this); + if(_completed) + { + return; + } + + if(_dllTestShutdown) + { + _dllTestShutdown(); + } +} + +bool +MainHelperI::redirect() +{ + return _dll.find("client") != string::npos || _dll.find("collocated") != string::npos; +} + +void + +MainHelperI::print(const std::string& msg) +{ + _out << msg; +} + +void +MainHelperI::run() +{ + NSString* bundlePath = [[NSBundle mainBundle] privateFrameworksPath]; + + bundlePath = [bundlePath stringByAppendingPathComponent:[NSString stringWithUTF8String:_dll.c_str()]]; + + NSURL* bundleURL = [NSURL fileURLWithPath:bundlePath]; + _handle = CFBundleCreate(NULL, (CFURLRef)bundleURL); + if(!_handle) + { + print([[NSString stringWithFormat:@"Could not find bundle %@", bundlePath] UTF8String]); + completed(EXIT_FAILURE); + return; + } + + CFErrorRef error = nil; + Boolean loaded = CFBundleLoadExecutableAndReturnError(_handle, &error); + if(error != nil || !loaded) + { + print([[(__bridge NSError *)error description] UTF8String]); + completed(EXIT_FAILURE); + return; + } + + void* sym = dlsym(_handle, "dllTestShutdown"); + sym = CFBundleGetFunctionPointerForName(_handle, CFSTR("dllTestShutdown")); + if(sym == 0) + { + NSString* err = [NSString stringWithFormat:@"Could not get function pointer dllTestShutdown from bundle %@", + bundlePath]; + print([err UTF8String]); + completed(EXIT_FAILURE); + return; + } + _dllTestShutdown = (SHUTDOWN_ENTRY_POINT)sym; + + sym = CFBundleGetFunctionPointerForName(_handle, CFSTR("dllMain")); + if(sym == 0) + { + NSString* err = [NSString stringWithFormat:@"Could not get function pointer dllMain from bundle %@", + bundlePath]; + print([err UTF8String]); + completed(EXIT_FAILURE); + return; + } + + MAIN_ENTRY_POINT dllMain = (MAIN_ENTRY_POINT)sym; + char** argv = new char*[_args.size() + 1]; + for(unsigned int i = 0; i < _args.size(); ++i) + { + argv[i] = const_cast<char*>(_args[i].c_str()); + } + argv[_args.size()] = 0; + try + { + completed(dllMain(static_cast<int>(_args.size()), argv, this)); + } + catch(const std::exception& ex) + { + print("unexpected exception while running `" + _args[0] + "':\n" + ex.what()); + } + catch(...) + { + print("unexpected unknown exception while running `" + _args[0] + "'"); + } + delete[] argv; +} + +void +MainHelperI::completed(int status) +{ + Lock sync(*this); + _completed = true; + _status = status; + notifyAll(); +} + +void +MainHelperI::waitReady(int timeout) const +{ + Lock sync(*this); + while(!_ready && !_completed) + { + if(!timedWait(IceUtil::Time::seconds(timeout))) + { + throw ProcessFailedException("timed out waiting for the process to be ready"); + } + } + if(_completed && _status == EXIT_FAILURE) + { + throw ProcessFailedException(_out.str()); + } +} + +int +MainHelperI::waitSuccess(int timeout) const +{ + Lock sync(*this); + while(!_completed) + { + if(!timedWait(IceUtil::Time::seconds(timeout))) + { + throw ProcessFailedException("timed out waiting for the process to succeed"); + } + } + return _status; +} + +string +MainHelperI::getOutput() const +{ + assert(_completed); + return _out.str(); +} + +ProcessI::ProcessI(ViewController* controller, MainHelperI* helper) : _controller(controller), _helper(helper) +{ +} + +ProcessI::~ProcessI() +{ +} + +void +ProcessI::waitReady(int timeout, const Ice::Current&) +{ + _helper->waitReady(timeout); +} + +int +ProcessI::waitSuccess(int timeout, const Ice::Current&) +{ + return _helper->waitSuccess(timeout); +} + +string +ProcessI::terminate(const Ice::Current& current) +{ + _helper->shutdown(); + current.adapter->remove(current.id); + _helper->getThreadControl().join(); + return _helper->getOutput(); +} + +ProcessControllerI::ProcessControllerI(ViewController* controller) : _controller(controller) +{ +} + +#ifdef ICE_CPP11_MAPPING +shared_ptr<ProcessPrx> +ProcessControllerI::start(string testSuite, string exe, StringSeq args, const Ice::Current& c) +#else +ProcessPrx +ProcessControllerI::start(const string& testSuite, const string& exe, const StringSeq& args, const Ice::Current& c) +#endif +{ + std::string prefix = std::string("test/") + testSuite; + replace(prefix.begin(), prefix.end(), '/', '_'); + [_controller println:[NSString stringWithFormat:@"starting %s %s... ", testSuite.c_str(), exe.c_str()]]; + IceUtil::Handle<MainHelperI> helper = new MainHelperI(_controller, prefix + '/' + exe + ".bundle", args); + helper->start(); + return ICE_UNCHECKED_CAST(ProcessPrx, c.adapter->addWithUUID(ICE_MAKE_SHARED(ProcessI, _controller, helper.get()))); +} + +ControllerHelper::ControllerHelper(ViewController* controller) +{ + Ice::registerIceDiscovery(); + + Ice::InitializationData initData = Ice::InitializationData(); + initData.properties = Ice::createProperties(); + initData.properties->setProperty("Ice.ThreadPool.Server.SizeMax", "10"); + initData.properties->setProperty("IceDiscovery.DomainId", "TestController"); + initData.properties->setProperty("IceDiscovery.Interface", "127.0.0.1"); + initData.properties->setProperty("Ice.Default.Host", "127.0.0.1"); + initData.properties->setProperty("ControllerAdapter.Endpoints", "tcp"); + //initData.properties->setProperty("Ice.Trace.Network", "2"); + //initData.properties->setProperty("Ice.Trace.Protocol", "2"); + initData.properties->setProperty("ControllerAdapter.AdapterId", Ice::generateUUID()); + + _communicator = Ice::initialize(initData); + + Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapter("ControllerAdapter"); + Ice::Identity ident; +#if TARGET_IPHONE_SIMULATOR != 0 + ident.category = "iPhoneSimulator"; +#else + ident.category = "iPhoneOS"; +#endif + ident.name = [[[NSBundle mainBundle] bundleIdentifier] UTF8String]; + adapter->add(ICE_MAKE_SHARED(ProcessControllerI, controller), ident); + adapter->activate(); +} + +ControllerHelper::~ControllerHelper() +{ + _communicator->destroy(); + _communicator = 0; +} + +static ControllerHelper* controllerHelper = 0; + +@implementation ViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + controllerHelper = new ControllerHelper(self); +} +- (void) dealloc +{ + delete controllerHelper; +} +-(void) write:(NSString*)msg +{ + [output insertText:msg]; + [output layoutIfNeeded]; + [output scrollRangeToVisible:NSMakeRange([output.text length] - 1, 1)]; +} +-(void) print:(NSString*)msg +{ + [self performSelectorOnMainThread:@selector(write:) withObject:msg waitUntilDone:NO]; +} +-(void) println:(NSString*)msg +{ + [self print:[msg stringByAppendingString:@"\n"]]; +} +@end diff --git a/cpp/test/ios/controller/Classes/main.m b/cpp/test/ios/controller/Classes/main.m new file mode 100644 index 00000000000..bd3a0a0c555 --- /dev/null +++ b/cpp/test/ios/controller/Classes/main.m @@ -0,0 +1,16 @@ +// +// main.m +// C++ Test Controller +// +// Created by Benoit Foucher on 08/12/2016. +// Copyright © 2016 ZeroC, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} |