summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-01-09 13:05:56 -0600
committerFabian Guerra <fabian.guerra@mapbox.com>2018-01-09 13:05:56 -0600
commit48db3410b9c0294eb546c992a78ac9d92ac45cac (patch)
tree45947fd2f3ff2821a991e2bb969832a90dc06e0e
parent24e3c0408c9a0192d4fc456892ca8e8c8c67d88f (diff)
downloadqtlocation-mapboxgl-48db3410b9c0294eb546c992a78ac9d92ac45cac.tar.gz
[ios] Fix map view layout test for pre iOS 11.
-rw-r--r--platform/ios/test/MGLMapViewLayoutTests.m13
1 files changed, 10 insertions, 3 deletions
diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m
index 6671d795ef..cde50e480f 100644
--- a/platform/ios/test/MGLMapViewLayoutTests.m
+++ b/platform/ios/test/MGLMapViewLayoutTests.m
@@ -46,7 +46,9 @@
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
NSLog(@"================> self.mapView.frame: %@", NSStringFromCGRect(self.mapView.frame));
- NSLog(@"================> self.mapView.safeAreaInsets: %@", NSStringFromUIEdgeInsets(self.mapView.safeAreaInsets));
+ if ( [self.mapView respondsToSelector:@selector(safeAreaInsets)] ) {
+ NSLog(@"================> self.mapView.safeAreaInsets: %@", NSStringFromUIEdgeInsets(self.mapView.safeAreaInsets));
+ }
}
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
@@ -68,8 +70,13 @@
- (void)testOrnamentPlacement {
CGFloat margin = 8.0;
+ CGFloat bottomSafeAreaInset = 0.0;
double accuracy = 0.01;
+ if ( [self.mapView respondsToSelector:@selector(safeAreaInsets)] ) {
+ bottomSafeAreaInset = self.mapView.safeAreaInsets.bottom;
+ }
+
//compass
UIImageView *compassView = self.mapView.compassView;
NSLog(@"================> %@", compassView);
@@ -93,7 +100,7 @@
NSLog(@"================> %@", attributionButton);
CGFloat expectedButtonOriginX = CGRectGetMaxX(self.mapView.bounds) - margin - CGRectGetWidth(attributionButton.frame);
- CGFloat expectedButtonOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - CGRectGetHeight(attributionButton.frame);
+ CGFloat expectedButtonOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - bottomSafeAreaInset - CGRectGetHeight(attributionButton.frame);
XCTAssertEqualWithAccuracy(CGRectGetMinX(attributionButton.frame), expectedButtonOriginX, accuracy);
XCTAssertEqualWithAccuracy(CGRectGetMinY(attributionButton.frame), expectedButtonOriginY, accuracy);
@@ -103,7 +110,7 @@
NSLog(@"================> %@", logoView);
CGFloat expectedLogoOriginX = margin;
- CGFloat expectedLogoOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - CGRectGetHeight(logoView.frame);
+ CGFloat expectedLogoOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - bottomSafeAreaInset - CGRectGetHeight(logoView.frame);
XCTAssertEqualWithAccuracy(CGRectGetMinX(logoView.frame), expectedLogoOriginX, accuracy);
XCTAssertEqualWithAccuracy(CGRectGetMinY(logoView.frame), expectedLogoOriginY, accuracy);