summaryrefslogtreecommitdiff
path: root/platform/ios/test/common
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/test/common')
-rw-r--r--platform/ios/test/common/AppDelegate.h7
-rw-r--r--platform/ios/test/common/AppDelegate.m38
-rw-r--r--platform/ios/test/common/LaunchScreen.storyboard27
-rw-r--r--platform/ios/test/common/Main.storyboard27
-rw-r--r--platform/ios/test/common/Tests.m37
-rw-r--r--platform/ios/test/common/ViewController.h6
-rw-r--r--platform/ios/test/common/ViewController.m22
-rw-r--r--platform/ios/test/common/ios_test_runner.hpp14
-rw-r--r--platform/ios/test/common/main.m9
9 files changed, 187 insertions, 0 deletions
diff --git a/platform/ios/test/common/AppDelegate.h b/platform/ios/test/common/AppDelegate.h
new file mode 100644
index 0000000000..134c8063dc
--- /dev/null
+++ b/platform/ios/test/common/AppDelegate.h
@@ -0,0 +1,7 @@
+#import <UIKit/UIApplication.h> // UIApplicationDelegate
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end \ No newline at end of file
diff --git a/platform/ios/test/common/AppDelegate.m b/platform/ios/test/common/AppDelegate.m
new file mode 100644
index 0000000000..874d18de2a
--- /dev/null
+++ b/platform/ios/test/common/AppDelegate.m
@@ -0,0 +1,38 @@
+#import "AppDelegate.h"
+
+@interface AppDelegate()
+
+@end
+
+@implementation AppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Insert code here to initialize your application
+ NSLog(@"didFinishLaunchingWithOptions");
+ 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 throttle down OpenGL ES frame rates. 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 inactive 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/platform/ios/test/common/LaunchScreen.storyboard b/platform/ios/test/common/LaunchScreen.storyboard
new file mode 100644
index 0000000000..c9b7564332
--- /dev/null
+++ b/platform/ios/test/common/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="9531" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
+ </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="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </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/platform/ios/test/common/Main.storyboard b/platform/ios/test/common/Main.storyboard
new file mode 100644
index 0000000000..34d4c7e2ec
--- /dev/null
+++ b/platform/ios/test/common/Main.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="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
+ </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="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <animations/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/platform/ios/test/common/Tests.m b/platform/ios/test/common/Tests.m
new file mode 100644
index 0000000000..8d0719705a
--- /dev/null
+++ b/platform/ios/test/common/Tests.m
@@ -0,0 +1,37 @@
+#import <XCTest/XCTest.h>
+#import "iosTestRunner.h"
+@interface Tests : XCTestCase
+
+@end
+
+@implementation Tests
+
+- (void)setUp {
+ [super setUp];
+}
+
+- (void)tearDown {
+ [super tearDown];
+}
+
+- (void)testStartTestRunner {
+ IosTestRunner* runner = [[IosTestRunner alloc] init];
+ XCTAssert(runner, @"IOSTestRunner is not initialized correctly");
+
+ NSString* testResult = [runner getResultPath];
+ XCTAssert(testResult, @"IOSTestRunner did not produce a test result file");
+
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ BOOL fileFound = [fileManager fileExistsAtPath: testResult];
+ XCTAssert(fileFound, @"Test result file '%@' does not exit", testResult);
+ NSURL *resultURL = [NSURL fileURLWithPath:testResult];
+ XCTAttachment *attachment1URL = [XCTAttachment attachmentWithContentsOfFileAtURL: resultURL];
+ XCTAssert(attachment1URL, @"Failed to attach test result '%@'", testResult);
+ attachment1URL.lifetime = XCTAttachmentLifetimeKeepAlways;
+ [self addAttachment:attachment1URL];
+
+ BOOL success = [runner getTestStatus];
+ XCTAssert(success, @"IOSTestRunner reports error because some of the tests are not passed, please check the test report");
+}
+
+@end
diff --git a/platform/ios/test/common/ViewController.h b/platform/ios/test/common/ViewController.h
new file mode 100644
index 0000000000..9c7dfc57ec
--- /dev/null
+++ b/platform/ios/test/common/ViewController.h
@@ -0,0 +1,6 @@
+#import <UIKit/UIKit.h>
+
+@interface ViewController : UIViewController
+
+@end
+
diff --git a/platform/ios/test/common/ViewController.m b/platform/ios/test/common/ViewController.m
new file mode 100644
index 0000000000..e9c526122a
--- /dev/null
+++ b/platform/ios/test/common/ViewController.m
@@ -0,0 +1,22 @@
+#import "ViewController.h"
+#import "iosTestRunner.h"
+
+@interface ViewController ()
+{
+ IosTestRunner* i;
+}
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+// In order to run test runner with app itself instead of with unit test, comment out the following line.
+// i = [[IosTestRunner alloc]init];
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+}
+
+@end
diff --git a/platform/ios/test/common/ios_test_runner.hpp b/platform/ios/test/common/ios_test_runner.hpp
new file mode 100644
index 0000000000..db263dc73c
--- /dev/null
+++ b/platform/ios/test/common/ios_test_runner.hpp
@@ -0,0 +1,14 @@
+#ifndef ios_test_runner_hpp
+#define ios_test_runner_hpp
+
+#include <string>
+
+class TestRunner {
+public:
+ TestRunner() = default;
+ ~TestRunner() = default;
+
+ bool startTest(const std::string& path);
+};
+
+#endif /* ios_test_runner_hpp */
diff --git a/platform/ios/test/common/main.m b/platform/ios/test/common/main.m
new file mode 100644
index 0000000000..f813c8fea9
--- /dev/null
+++ b/platform/ios/test/common/main.m
@@ -0,0 +1,9 @@
+#import <UIKit/UIKit.h>
+#import "AppDelegate.h"
+
+int main(int argc, char * argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}