diff options
author | Nadia Barbosa <nadiabarbosa@me.com> | 2018-08-28 08:52:27 -0700 |
---|---|---|
committer | Nadia Barbosa <nadiabarbosa@me.com> | 2018-09-04 15:10:03 -0700 |
commit | cd4611dfefccbcc102f1ce0848a40e85d4c1ce60 (patch) | |
tree | 388a850a95a783deab602d0903788a5de267ca6d /platform/darwin/test/MGLMapViewTests.m | |
parent | 260f96c2535672cba6ebe36d380c82f43fde492c (diff) | |
download | qtlocation-mapboxgl-upstream/nb-fix-antimeridian-bounds.tar.gz |
[ios, macos] Allow -convertCoordinateBounds to span antimeridianupstream/nb-fix-antimeridian-bounds
Diffstat (limited to 'platform/darwin/test/MGLMapViewTests.m')
-rw-r--r-- | platform/darwin/test/MGLMapViewTests.m | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLMapViewTests.m b/platform/darwin/test/MGLMapViewTests.m new file mode 100644 index 0000000000..6ac8e1fe81 --- /dev/null +++ b/platform/darwin/test/MGLMapViewTests.m @@ -0,0 +1,42 @@ +#import <Mapbox/Mapbox.h> +#import <XCTest/XCTest.h> + +static MGLMapView *mapView; + +@interface MGLMapViewTests : XCTestCase + +@end + +@implementation MGLMapViewTests + ++ (void)setUp { + [super setUp]; + + [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"]; + mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 64, 64) styleURL:MGLStyle.streetsStyleURL]; + [mapView setCenterCoordinate:CLLocationCoordinate2DMake(33, 179)]; +} + +- (void)testCoordinateBoundsConversion { + MGLCoordinateBounds leftAntimeridianBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(-75, 175), CLLocationCoordinate2DMake(75, 180)); + CGRect leftAntimeridianBoundsRect = [mapView convertCoordinateBounds:leftAntimeridianBounds toRectToView:mapView]; + + MGLCoordinateBounds rightAntimeridianBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(-75, -180), CLLocationCoordinate2DMake(75, -175)); + CGRect rightAntimeridianBoundsRect = [mapView convertCoordinateBounds:rightAntimeridianBounds toRectToView:mapView]; + + MGLCoordinateBounds spanningBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(24, 140), CLLocationCoordinate2DMake(44, 240)); + CGRect spanningBoundsRect = [mapView convertCoordinateBounds:spanningBounds toRectToView:mapView]; + + // If the resulting CGRect from -convertCoordinateBounds:toRectToView: + // intersects the set of bounds to the left and right of the + // antimeridian, then we know that the CGRect spans across the antimeridian + XCTAssertTrue(CGRectIntersectsRect(spanningBoundsRect, leftAntimeridianBoundsRect), @"Resulting "); + XCTAssertTrue(CGRectIntersectsRect(spanningBoundsRect, rightAntimeridianBoundsRect), @"Something"); +} + ++ (void)tearDown { + mapView = nil; + [super tearDown]; +} + +@end |