summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuha Alanen <juha.alanen@mapbox.com>2020-02-12 15:50:39 +0200
committerJuha Alanen <juha.alanen@mapbox.com>2020-02-18 16:10:23 +0200
commita5ec862a2a241885918d4d843bbc93c3804a57e6 (patch)
tree14f3e91140b0a29a687d2932911060aba41aca0f
parenta551f70c6da8973f23e10cf19b630376553ab699 (diff)
downloadqtlocation-mapboxgl-a5ec862a2a241885918d4d843bbc93c3804a57e6.tar.gz
[test-runner] Share common code between test runners
Also remove some unnecessary files.
-rw-r--r--platform/ios/ios.cmake6
-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/iosTestRunner.mm (renamed from test/ios/iosTestRunner.mm)9
-rw-r--r--render-test/ios/main.m9
-rw-r--r--test/ios/iosTestRunner.h3
6 files changed, 9 insertions, 46 deletions
diff --git a/platform/ios/ios.cmake b/platform/ios/ios.cmake
index 18b2b2aad0..f9f6f540ce 100644
--- a/platform/ios/ios.cmake
+++ b/platform/ios/ios.cmake
@@ -108,8 +108,6 @@ if(MBGL_IOS_RENDER_TEST)
${PROJECT_SOURCE_DIR}/platform/ios/test/common/ios_test_runner.hpp
${PROJECT_SOURCE_DIR}/platform/ios/test/common/AppDelegate.h
${PROJECT_SOURCE_DIR}/platform/ios/test/common/AppDelegate.m
- ${PROJECT_SOURCE_DIR}/platform/ios/test/common/ViewController.h
- ${PROJECT_SOURCE_DIR}/platform/ios/test/common/ViewController.m
${PROJECT_SOURCE_DIR}/platform/ios/test/common/main.m
${PROJECT_SOURCE_DIR}/render-test/ios/ios_test_runner.cpp
${PROJECT_SOURCE_DIR}/render-test/ios/iosTestRunner.h
@@ -202,12 +200,10 @@ if(MBGL_IOS_UNIT_TEST)
${PROJECT_SOURCE_DIR}/platform/ios/test/common/ios_test_runner.hpp
${PROJECT_SOURCE_DIR}/platform/ios/test/common/AppDelegate.h
${PROJECT_SOURCE_DIR}/platform/ios/test/common/AppDelegate.m
- ${PROJECT_SOURCE_DIR}/platform/ios/test/common/ViewController.h
- ${PROJECT_SOURCE_DIR}/platform/ios/test/common/ViewController.m
+ ${PROJECT_SOURCE_DIR}/platform/ios/test/common/iosTestRunner.mm
${PROJECT_SOURCE_DIR}/platform/ios/test/common/main.m
${PROJECT_SOURCE_DIR}/test/ios/ios_test_runner.cpp
${PROJECT_SOURCE_DIR}/test/ios/iosTestRunner.h
- ${PROJECT_SOURCE_DIR}/test/ios/iosTestRunner.mm
${RESOURCES}
)
initialize_ios_target(UnitTestsApp)
diff --git a/platform/ios/test/common/ViewController.h b/platform/ios/test/common/ViewController.h
deleted file mode 100644
index 9c7dfc57ec..0000000000
--- a/platform/ios/test/common/ViewController.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface ViewController : UIViewController
-
-@end
-
diff --git a/platform/ios/test/common/ViewController.m b/platform/ios/test/common/ViewController.m
deleted file mode 100644
index e9c526122a..0000000000
--- a/platform/ios/test/common/ViewController.m
+++ /dev/null
@@ -1,22 +0,0 @@
-#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/test/ios/iosTestRunner.mm b/platform/ios/test/common/iosTestRunner.mm
index d3f6113a05..b1efa74e6a 100644
--- a/test/ios/iosTestRunner.mm
+++ b/platform/ios/test/common/iosTestRunner.mm
@@ -6,7 +6,7 @@
@interface IosTestRunner ()
-@property (nullable) TestRunner* runner;
+@property (nullable) TestRunner *runner;
@property (copy, nullable) NSString *resultPath;
@@ -31,7 +31,7 @@
for (uint32_t i = 0; i < bundleContents.count; i++) {
NSString *dirName = [bundleContents objectAtIndex: i];
- if ([dirName isEqualToString:@"test-data"]) {
+ if ([dirName isEqualToString: dataDir]) {
NSString *destinationPath = [documentsDir stringByAppendingPathComponent: dirName];
BOOL success = [fileManager fileExistsAtPath: destinationPath];
if (success) {
@@ -56,9 +56,10 @@
break;
}
}
- std::string basePath = std::string([documentsDir UTF8String]) + std::string("/test-data");
+ NSString *baseDir = [documentsDir stringByAppendingPathComponent: dataDir];
+ std::string basePath = std::string([baseDir UTF8String]);
self.testStatus = self.runner->startTest(basePath) ? YES : NO;
- self.resultPath = [documentsDir stringByAppendingPathComponent:@"/test-data/test/results.xml"];
+ self.resultPath = [baseDir stringByAppendingPathComponent: resultFilePath];
BOOL fileFound = [fileManager fileExistsAtPath: self.resultPath];
if (fileFound == NO) {
diff --git a/render-test/ios/main.m b/render-test/ios/main.m
deleted file mode 100644
index f813c8fea9..0000000000
--- a/render-test/ios/main.m
+++ /dev/null
@@ -1,9 +0,0 @@
-#import <UIKit/UIKit.h>
-#import "AppDelegate.h"
-
-int main(int argc, char * argv[])
-{
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
- }
-}
diff --git a/test/ios/iosTestRunner.h b/test/ios/iosTestRunner.h
index dcbb77e9d4..eefe2da3db 100644
--- a/test/ios/iosTestRunner.h
+++ b/test/ios/iosTestRunner.h
@@ -1,5 +1,8 @@
#import <Foundation/Foundation.h>
+NSString *dataDir = @"test-data";
+NSString *resultFilePath = @"test/results.xml";
+
__attribute__((visibility ("default")))
@interface IosTestRunner : NSObject