summaryrefslogtreecommitdiff
path: root/test
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 /test
parenta551f70c6da8973f23e10cf19b630376553ab699 (diff)
downloadqtlocation-mapboxgl-a5ec862a2a241885918d4d843bbc93c3804a57e6.tar.gz
[test-runner] Share common code between test runners
Also remove some unnecessary files.
Diffstat (limited to 'test')
-rw-r--r--test/ios/iosTestRunner.h3
-rw-r--r--test/ios/iosTestRunner.mm82
2 files changed, 3 insertions, 82 deletions
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
diff --git a/test/ios/iosTestRunner.mm b/test/ios/iosTestRunner.mm
deleted file mode 100644
index d3f6113a05..0000000000
--- a/test/ios/iosTestRunner.mm
+++ /dev/null
@@ -1,82 +0,0 @@
-#import "iosTestRunner.h"
-
-#include <ios_test_runner.hpp>
-
-#include <string>
-
-@interface IosTestRunner ()
-
-@property (nullable) TestRunner* runner;
-
-@property (copy, nullable) NSString *resultPath;
-
-@property BOOL testStatus;
-
-@end
-
-@implementation IosTestRunner
-
--(instancetype)init
-{
- self = [super init];
- if (self) {
- self.testStatus = NO;
- self.runner = new TestRunner();
- NSError *error;
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
- NSArray *bundleContents = [fileManager contentsOfDirectoryAtPath: bundleRoot error: &error];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDir = [paths objectAtIndex: 0];
-
- for (uint32_t i = 0; i < bundleContents.count; i++) {
- NSString *dirName = [bundleContents objectAtIndex: i];
- if ([dirName isEqualToString:@"test-data"]) {
- NSString *destinationPath = [documentsDir stringByAppendingPathComponent: dirName];
- BOOL success = [fileManager fileExistsAtPath: destinationPath];
- if (success) {
- [fileManager removeItemAtPath:destinationPath error:NULL];
- }
-
- success = [fileManager fileExistsAtPath: destinationPath];
- if (!success) {
- NSString *copyDirPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: dirName];
- success = [fileManager copyItemAtPath: copyDirPath toPath: destinationPath error: &error];
-
- if (!success) {
- NSLog(@"Failed to copy file '%@'", dirName);
- NSAssert1(0, @"Failed to copy file, error '%@'", [error localizedDescription]);
- } else {
- NSLog(@"File '%@' copied OK", dirName);
- }
- } else {
- NSLog(@"Failed to remove file '%@'", dirName);
- NSAssert1(0, @"Failed to remove file, error '%@'", [error localizedDescription]);
- }
- break;
- }
- }
- std::string basePath = std::string([documentsDir UTF8String]) + std::string("/test-data");
- self.testStatus = self.runner->startTest(basePath) ? YES : NO;
- self.resultPath = [documentsDir stringByAppendingPathComponent:@"/test-data/test/results.xml"];
-
- BOOL fileFound = [fileManager fileExistsAtPath: self.resultPath];
- if (fileFound == NO) {
- NSLog(@"Test result file '%@' does not exist", self.resultPath);
- self.testStatus = NO;
- }
-
- delete self.runner;
- self.runner = nullptr;
- }
- return self;
-}
-
-- (NSString*) getResultPath {
- return self.resultPath;
-}
-
-- (BOOL) getTestStatus {
- return self.testStatus;
-}
-@end