aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-05-24 12:23:48 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-06-03 11:21:00 -0700
commit347b7cc8182ad87178650bb127a19ad11d642639 (patch)
tree43298b5fcd76ed38011fb5fcf9ccfa33d89df47c
parent6aac864f26b4df3e9ac5915a9bc6efc3328d3e45 (diff)
[ios] added map view subclass, access token run script
-rw-r--r--platform/darwin/src/MGLMapSnapshotter.mm7
-rw-r--r--platform/ios/Integration Tests/MBXTestMapView.h17
-rw-r--r--platform/ios/Integration Tests/MBXTestMapView.m26
-rw-r--r--platform/ios/Integration Tests/MGLMapViewIntegrationTest.h3
-rw-r--r--platform/ios/Integration Tests/MGLMapViewIntegrationTest.m10
-rw-r--r--platform/ios/Integration Tests/MGLTabBarControllerTests.m27
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj28
-rw-r--r--platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme9
8 files changed, 104 insertions, 23 deletions
diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm
index 65bed2cf4..a89669292 100644
--- a/platform/darwin/src/MGLMapSnapshotter.mm
+++ b/platform/darwin/src/MGLMapSnapshotter.mm
@@ -161,6 +161,13 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
[MGLMapboxEvents pushTurnstileEvent];
#endif
+
+#ifndef swift(version:)
+ NSLog(@"HI I'M OBJECTIVE-C");
+#else
+ NSLog(@"HI I'M SWIFT");
+#endif
+
}
return self;
}
diff --git a/platform/ios/Integration Tests/MBXTestMapView.h b/platform/ios/Integration Tests/MBXTestMapView.h
new file mode 100644
index 000000000..565e4971a
--- /dev/null
+++ b/platform/ios/Integration Tests/MBXTestMapView.h
@@ -0,0 +1,17 @@
+//
+// MBXTestMapView.h
+// Integration Test Harness
+//
+// Created by Jordan on 5/23/19.
+// Copyright © 2019 Mapbox. All rights reserved.
+//
+
+#import <Mapbox/Mapbox.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MBXTestMapView : MGLMapView
+- (void)updateFromDisplayLink:(CADisplayLink *)displayLink;
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/ios/Integration Tests/MBXTestMapView.m b/platform/ios/Integration Tests/MBXTestMapView.m
new file mode 100644
index 000000000..6e50e1b08
--- /dev/null
+++ b/platform/ios/Integration Tests/MBXTestMapView.m
@@ -0,0 +1,26 @@
+
+#import "MBXTestMapView.h"
+
+@interface MGLMapView
+- (void)updateFromDisplayLink:(CADisplayLink*)displayLink;
+@end
+@implementation MBXTestMapView
+
+- (void)updateFromDisplayLink:(CADisplayLink*)displayLink {
+
+ dispatch_block_t update = ^{
+ [super updateFromDisplayLink:displayLink];
+ };
+
+ NSLog(@"UPDATING");
+ update();
+
+}
+
+- (void)didMoveToWindow {
+ [super didMoveToWindow];
+ NSLog(@"MOVING TO WINDOW");
+}
+
+
+@end
diff --git a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h
index 3b59cc590..b152be8ce 100644
--- a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h
+++ b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h
@@ -1,6 +1,7 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import "MGLTestUtility.h"
+#import "MBXTestMapView.h"
#define MGLTestFail(myself, ...) \
_XCTPrimitiveFail(myself, __VA_ARGS__)
@@ -26,7 +27,7 @@
@interface MGLMapViewIntegrationTest : XCTestCase <MGLMapViewDelegate>
@property (nonatomic) UIWindow *window;
-@property (nonatomic) MGLMapView *mapView;
+@property (nonatomic) MBXTestMapView *mapView;
@property (nonatomic) MGLStyle *style;
@property (nonatomic) XCTestExpectation *styleLoadingExpectation;
@property (nonatomic) XCTestExpectation *renderFinishedExpectation;
diff --git a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
index be1579032..d5d4d8839 100644
--- a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
+++ b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
@@ -1,9 +1,5 @@
#import "MGLMapViewIntegrationTest.h"
-@interface MGLMapView (MGLMapViewIntegrationTest)
-- (void)updateFromDisplayLink:(CADisplayLink *)displayLink;
-@end
-
@implementation MGLMapViewIntegrationTest
- (void)invokeTest {
@@ -27,7 +23,7 @@
printf("warning: MAPBOX_ACCESS_TOKEN env var is required for this test - skipping.\n");
return nil;
}
-
+ NSLog(@"%@", accessToken);
[MGLAccountManager setAccessToken:accessToken];
return accessToken;
}
@@ -35,10 +31,10 @@
- (void)setUp {
[super setUp];
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
+// [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
- self.mapView = [[MGLMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL];
+ self.mapView = [[MBXTestMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL];
self.mapView.delegate = self;
UIView *superView = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];
diff --git a/platform/ios/Integration Tests/MGLTabBarControllerTests.m b/platform/ios/Integration Tests/MGLTabBarControllerTests.m
index 14b15230b..a277c6e92 100644
--- a/platform/ios/Integration Tests/MGLTabBarControllerTests.m
+++ b/platform/ios/Integration Tests/MGLTabBarControllerTests.m
@@ -3,12 +3,11 @@
// Will lack of access token impact CADisplayLink being called?
@implementation MGLTabBarControllerTests
-@synthesize mapView;
- (void)setUp {
[super setUp];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"IntegrationTest" bundle:[NSBundle mainBundle]];
-
+// [MGLAccountManager setAccessToken:@"pk.eyJ1Ijoiam9yZGFua2lsZXkiLCJhIjoiY2o1c3V0dG53MWJqczJxcGxmcXF5bGpmZyJ9.jgslVC7xNSQ2Rxayio_9Iw"];
// Keep an eye on how well this plays with other tests that use other root view controllers.
[self.window setRootViewController:(UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"TabController"]];
@@ -21,7 +20,7 @@
annot.coordinate = self.mapView.centerCoordinate;
[self.mapView addAnnotation:annot];
}
-
+
- (void)testViewControllerNil {
XCTAssertNotNil(self.viewController);
}
@@ -30,31 +29,30 @@
XCTestExpectation *expectation = [self expectationWithDescription:@"Able to switch the tabs repeatedly without lag"];
// TODO: Add animated map transition, or call setNeedGLDisplay if animation
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
__block NSInteger counter = 0;
+
NSTimer *repeatingTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) {
+
counter++;
NSLog(@"%li", counter);
- // TODO
self.tabController.selectedIndex = counter % 2;
if (counter > 30) {
// time call to updateDisplayLink to see if it takes longer that
// subclass MGLMapView
[repeatingTimer invalidate];
- [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(2, 2) zoomLevel:4 direction:0 animated:NO completionHandler:^{
- NSLog(@"DONE");
+ MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:CLLocationCoordinate2DMake(20, 20) altitude:100 pitch:0 heading:0];
+ [self.mapView flyToCamera:camera withDuration:5 completionHandler:^{
+ NSLog(@"all done");
[expectation fulfill];
+ [self.mapView updateFromDisplayLink:nil];
}];
}
}];
- });
-
- [self waitForExpectationsWithTimeout:10 handler:^(NSError * _Nullable error) {
- if (error) {
- XCTFail(@"Failed with error: %@", error);
- }
- }];
+
+
+ [self waitForExpectations:@[expectation] timeout:10];
+
}
- (void)switchTabsRepeatedly {
@@ -71,5 +69,6 @@
return annotView;
}
+
@end
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 067072868..03224040f 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -439,6 +439,7 @@
A46E4C9E228CE392009CAD5B /* MGLTabBarControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A46E4C9C228CB74B009CAD5B /* MGLTabBarControllerTests.m */; };
A46E4C9F228CE5FD009CAD5B /* IntegrationTest.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A46E4C99228CB731009CAD5B /* IntegrationTest.storyboard */; };
A46E4CA2228F4D6B009CAD5B /* IntegrationTest.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A46E4C99228CB731009CAD5B /* IntegrationTest.storyboard */; };
+ A4EE317022973F2E006A8F2F /* MBXTestMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = A4EE316F22973F2E006A8F2F /* MBXTestMapView.m */; };
A4F3FB1D2254865900A30170 /* missing_icon.json in Resources */ = {isa = PBXBuildFile; fileRef = A4F3FB1C2254865900A30170 /* missing_icon.json */; };
AC1B0916221CA14D00DB56C8 /* CLLocationManager+MMEMobileEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */; };
AC1B0917221CA14D00DB56C8 /* CLLocationManager+MMEMobileEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */; };
@@ -1108,6 +1109,8 @@
A46E4C99228CB731009CAD5B /* IntegrationTest.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = IntegrationTest.storyboard; sourceTree = "<group>"; };
A46E4C9B228CB74B009CAD5B /* MGLTabBarControllerTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTabBarControllerTests.h; sourceTree = "<group>"; };
A46E4C9C228CB74B009CAD5B /* MGLTabBarControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLTabBarControllerTests.m; sourceTree = "<group>"; };
+ A4EE316E22973F2E006A8F2F /* MBXTestMapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXTestMapView.h; sourceTree = "<group>"; };
+ A4EE316F22973F2E006A8F2F /* MBXTestMapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBXTestMapView.m; sourceTree = "<group>"; };
A4F3FB1C2254865900A30170 /* missing_icon.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = missing_icon.json; sourceTree = "<group>"; };
AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CLLocationManager+MMEMobileEvents.h"; path = "../vendor/mapbox-events-ios/MapboxMobileEvents/CLLocationManager+MMEMobileEvents.h"; sourceTree = "<group>"; };
AC1B0915221CA14C00DB56C8 /* CLLocationManager+MMEMobileEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CLLocationManager+MMEMobileEvents.m"; path = "../vendor/mapbox-events-ios/MapboxMobileEvents/CLLocationManager+MMEMobileEvents.m"; sourceTree = "<group>"; };
@@ -1482,12 +1485,14 @@
CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */,
A46E4C9B228CB74B009CAD5B /* MGLTabBarControllerTests.h */,
A46E4C9C228CB74B009CAD5B /* MGLTabBarControllerTests.m */,
- CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */,
CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */,
+ CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */,
CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */,
CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */,
077061DB215DA11F000FEF62 /* MGLTestLocationManager.h */,
077061D9215DA00E000FEF62 /* MGLTestLocationManager.m */,
+ A4EE316E22973F2E006A8F2F /* MBXTestMapView.h */,
+ A4EE316F22973F2E006A8F2F /* MBXTestMapView.m */,
);
path = "Integration Tests";
sourceTree = "<group>";
@@ -2691,6 +2696,7 @@
16376B2C1FFDB4B40000563E /* Frameworks */,
16376B2D1FFDB4B40000563E /* Resources */,
CAA69DA6206DCD0E007279CD /* Embed Frameworks */,
+ A4EE316D2294B528006A8F2F /* Insert Mapbox access token */,
);
buildRules = (
);
@@ -3042,6 +3048,25 @@
shellPath = /bin/sh;
shellScript = "$SRCROOT/app/insert_access_token.sh\n";
};
+ A4EE316D2294B528006A8F2F /* Insert Mapbox access token */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)",
+ );
+ name = "Insert Mapbox access token";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "$SRCROOT/app/insert_access_token.sh\n";
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -3069,6 +3094,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ A4EE317022973F2E006A8F2F /* MBXTestMapView.m in Sources */,
16376B411FFDB4B40000563E /* main.m in Sources */,
16376B331FFDB4B40000563E /* AppDelegate.m in Sources */,
);
diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme
index ce264aa19..dd0cdfe21 100644
--- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme
+++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/Integration Test Harness.xcscheme
@@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "NO">
+ <PreActions>
+ <ExecutionAction
+ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
+ <ActionContent
+ title = "Run Script"
+ scriptText = "$SRCROOT/app/insert_access_token.sh&#10;">
+ </ActionContent>
+ </ExecutionAction>
+ </PreActions>
<Testables>
<TestableReference
skipped = "NO">