[ios] Fix for integration tests not running on iOS 9. (#12145)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#import "MGLMapViewIntegrationTest.h"
|
||||
|
||||
@interface MGLMapView (MGLMapViewIntegrationTest)
|
||||
- (void)updateFromDisplayLink;
|
||||
@end
|
||||
|
||||
@implementation MGLMapViewIntegrationTest
|
||||
|
||||
- (void)setUp {
|
||||
@@ -78,6 +82,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:@selector(updateFromDisplayLink)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
[super waitForExpectations:expectations timeout:seconds];
|
||||
[timer invalidate];
|
||||
}
|
||||
|
||||
- (MGLStyle *)style {
|
||||
return self.mapView.style;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user