summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-06-13 16:48:27 -0400
committerJulian Rex <julian.rex@mapbox.com>2018-06-13 16:48:27 -0400
commit00cd950995970dbbe6bedeeb931e452dbd2e67ac (patch)
treebfa63a613669dc6c5c15e001477186859ea91b25
parentcaecdc8482fee16694b3b7d5ba5cd963c07fceb0 (diff)
downloadqtlocation-mapboxgl-00cd950995970dbbe6bedeeb931e452dbd2e67ac.tar.gz
Fix for integration tests not running on iOS 9.
-rw-r--r--platform/ios/Integration Tests/MGLCameraTransitionTests.mm6
-rw-r--r--platform/ios/Integration Tests/MGLMapViewIntegrationTest.m21
2 files changed, 22 insertions, 5 deletions
diff --git a/platform/ios/Integration Tests/MGLCameraTransitionTests.mm b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm
index 4a9db60982..0b28104c96 100644
--- a/platform/ios/Integration Tests/MGLCameraTransitionTests.mm
+++ b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm
@@ -323,11 +323,7 @@
// Should take MGLAnimationDuration
[self.mapView setCenterCoordinate:target zoomLevel:zoomLevel animated:YES];
- // Run the loop, so the camera can fly to the new camera
- while (runloop) {
- [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
- }
- [self waitForExpectations:@[expectation] timeout:0.5];
+ [self waitForExpectations:@[expectation] timeout:2.0];
NSLog(@"setCenterCoordinate: %0.4fs", stop1 - stop0);
NSLog(@"flyToCamera: %0.4fs", stop2 - stop1);
diff --git a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
index c42b8eef89..3240ffa2a8 100644
--- a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
+++ b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.m
@@ -78,6 +78,27 @@
[self waitForExpectations:@[self.renderFinishedExpectation] timeout:timeout];
}
+- (void)waitForExpectations:(NSArray<XCTestExpectation *> *)expectations timeout:(NSTimeInterval)seconds {
+
+ NSTimer *timer;
+
+ if (@available(iOS 10.0, *)) {
+ // We're good.
+ }
+ else if (self.mapView) {
+ // Before iOS 10 it seems that the display link is not called during the
+ // waitForExpectations below
+ timer = [NSTimer scheduledTimerWithTimeInterval:1.0/30.0
+ target:self.mapView
+ selector:NSSelectorFromString(@"updateFromDisplayLink")
+ userInfo:nil
+ repeats:YES];
+ }
+
+ [super waitForExpectations:expectations timeout:seconds];
+ [timer invalidate];
+}
+
- (MGLStyle *)style {
return self.mapView.style;
}