summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kitchen <andrew.kitchen@mapbox.com>2018-01-05 14:00:57 -0800
committerAndrew Kitchen <andrew.kitchen@mapbox.com>2018-01-05 14:00:57 -0800
commitc71c7f187533900f1a1fea1eba8e36721f64f270 (patch)
tree657b12fcc8c1464564d6ac34cfcc3f8cb82a855d
parentdd9b856a31d8adca6e52fed144ba1248b590346b (diff)
downloadqtlocation-mapboxgl-upstream/akitchen-test-attribution-layout.tar.gz
Additional code changes from call with Fabian and Jasonupstream/akitchen-test-attribution-layout
-rw-r--r--platform/ios/test/MGLMapViewLayoutTests.m20
1 files changed, 18 insertions, 2 deletions
diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m
index 932dc0b8a9..6671d795ef 100644
--- a/platform/ios/test/MGLMapViewLayoutTests.m
+++ b/platform/ios/test/MGLMapViewLayoutTests.m
@@ -6,6 +6,7 @@
@interface MGLMapViewLayoutTests : XCTestCase<MGLMapViewDelegate>
+@property (nonatomic) UIView *superView;
@property (nonatomic) MGLMapView *mapView;
@property (nonatomic) XCTestExpectation *styleLoadingExpectation;
@@ -18,9 +19,22 @@
[MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
+ NSLog(@"================> Screen size: %@", NSStringFromCGRect(UIScreen.mainScreen.bounds));
+
+ self.superView = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];
+
self.mapView = [[MGLMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL];
self.mapView.delegate = self;
+ [self.superView addSubview:self.mapView];
+
+ UIView *mapView = self.mapView;
+ NSDictionary *bindings = NSDictionaryOfVariableBindings(mapView);
+ NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[mapView]-0-|" options:0 metrics:nil views:bindings];
+ NSArray *horizonatalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[mapView]-0-|" options:0 metrics:nil views:bindings];
+
+ [self.superView addConstraints:[verticalConstraints arrayByAddingObjectsFromArray:horizonatalConstraints]];
+
self.styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
[self waitForExpectationsWithTimeout:1 handler:nil];
@@ -29,8 +43,10 @@
[self.mapView.camera setHeading:12.0];
//invoke layout
- [self.mapView setNeedsLayout];
- [self.mapView layoutIfNeeded];
+ [self.superView setNeedsLayout];
+ [self.superView layoutIfNeeded];
+ NSLog(@"================> self.mapView.frame: %@", NSStringFromCGRect(self.mapView.frame));
+ NSLog(@"================> self.mapView.safeAreaInsets: %@", NSStringFromUIEdgeInsets(self.mapView.safeAreaInsets));
}
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {