diff options
author | Jason Wray <jason@mapbox.com> | 2016-03-28 14:30:01 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2016-03-29 15:17:04 -0400 |
commit | d20795b891a6dfbde55333c95234c0a6d4e82131 (patch) | |
tree | 698004ada8b0e0bf549b45d9190fcb97af46aa71 /platform/ios/test | |
parent | 8262846294067aba4d9e5a4db4d1a280b181d95b (diff) | |
download | qtlocation-mapboxgl-d20795b891a6dfbde55333c95234c0a6d4e82131.tar.gz |
[ios] Don't use negative content insets
When a map view was smaller than the entire viewport, negative content insets would be applied. Negative content insets would only be valid if the map view extended outside of its frame, which cannot happen.
Fixes #4440.
Diffstat (limited to 'platform/ios/test')
-rw-r--r-- | platform/ios/test/MGLTViewController.h | 1 | ||||
-rw-r--r-- | platform/ios/test/MGLTViewController.m | 5 | ||||
-rw-r--r-- | platform/ios/test/MapViewTests.m | 23 |
3 files changed, 29 insertions, 0 deletions
diff --git a/platform/ios/test/MGLTViewController.h b/platform/ios/test/MGLTViewController.h index 0be0e1ff2c..349c216008 100644 --- a/platform/ios/test/MGLTViewController.h +++ b/platform/ios/test/MGLTViewController.h @@ -3,6 +3,7 @@ @interface MGLTViewController : UIViewController - (void)insetMapView; +- (void)tinyMapView; - (void)resetMapView; @end diff --git a/platform/ios/test/MGLTViewController.m b/platform/ios/test/MGLTViewController.m index 09c60bf614..451dea9292 100644 --- a/platform/ios/test/MGLTViewController.m +++ b/platform/ios/test/MGLTViewController.m @@ -21,6 +21,11 @@ _mapView.frame = CGRectInset(_mapView.frame, 50, 50); } +- (void)tinyMapView +{ + _mapView.frame = CGRectMake(20, self.topLayoutGuide.length, self.view.frame.size.width / 2, self.view.frame.size.height / 2); +} + - (void)resetMapView { _mapView.frame = self.view.bounds; diff --git a/platform/ios/test/MapViewTests.m b/platform/ios/test/MapViewTests.m index 40022a1ee5..c8fe862e0a 100644 --- a/platform/ios/test/MapViewTests.m +++ b/platform/ios/test/MapViewTests.m @@ -424,6 +424,29 @@ @"compass should lie inside shrunken map view"); } +- (void)testContentInsetsWithTinyMapView { + [tester.viewController tinyMapView]; + [self keyValueObservingExpectationForObject:tester.mapView keyPath:@"contentInset" handler:^BOOL(id observedObject, NSDictionary *change) { + XCTAssertEqual(tester.mapView.contentInset.top, + 0, + @"map should not have top content inset"); + XCTAssertEqual(tester.mapView.contentInset.bottom, + 0, + @"map should not have bottom content inset"); + return YES; + }]; + [self waitForExpectationsWithTimeout:2.0 handler:nil]; + + tester.mapView.frame = CGRectMake(0, 0, tester.mapView.frame.size.width, tester.mapView.frame.size.height); + [self keyValueObservingExpectationForObject:tester.mapView keyPath:@"contentInset" handler:^BOOL(id observedObject, NSDictionary *change) { + XCTAssertEqual(tester.mapView.contentInset.top, + tester.viewController.topLayoutGuide.length, + @"map should have top content inset equal to the top layout guide"); + return YES; + }]; + [self waitForExpectationsWithTimeout:2.0 handler:nil]; +} + - (void)testDelegateRegionWillChange { __block NSUInteger unanimatedCount; __block NSUInteger animatedCount; |