diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-06-25 11:58:23 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-06-25 21:54:57 -0700 |
commit | 1d11624efdf2d73a8adb43310c481969ead18d46 (patch) | |
tree | c362981a8e2ff82e0cb00285de39565bae49588d /test | |
parent | 68e404c522d318ca87e5435a997a21a9604ad0e8 (diff) | |
download | qtlocation-mapboxgl-1d11624efdf2d73a8adb43310c481969ead18d46.tar.gz |
Test fit to bounds; added MGLCoordinateBounds functions
Added a bunch of functions to work with MGLCoordinateBounds in a separate header analogous to MKGeometry.h. Added resolution-independent tests for common fit to bounds scenarios.
Diffstat (limited to 'test')
-rw-r--r-- | test/ios/MapViewTests.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 90447680ae..de4095497a 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -150,6 +150,41 @@ @"disabling zoom gesture should disallow pinching"); } +- (void)testFitToBounds { + // No-op + MGLCoordinateBounds initialBounds = tester.mapView.visibleCoordinateBounds; + [tester.mapView setVisibleCoordinateBounds:initialBounds animated:NO]; + XCTAssertEqualObjects(MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds), + @"setting visible coordinate bounds to currently visible coordinate bounds should be a no-op"); + + // Roundtrip after zooming + tester.mapView.zoomLevel -= 3; + [tester.mapView setVisibleCoordinateBounds:initialBounds animated:NO]; + XCTAssertEqualObjects(MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds), + @"after zooming out, setting visible coordinate bounds back to %@ should not leave them at %@", + MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds)); + tester.mapView.zoomLevel += 3; + [tester.mapView setVisibleCoordinateBounds:initialBounds animated:NO]; + XCTAssertEqualObjects(MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds), + @"after zooming in, setting visible coordinate bounds back to %@ should not leave them at %@", + MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds)); + + // Roundtrip after panning + MGLCoordinateBounds offsetBounds = MGLCoordinateBoundsOffset(initialBounds, MGLCoordinateSpanMake(0, 30)); + [tester.mapView setVisibleCoordinateBounds:offsetBounds animated:NO]; + [tester.mapView setVisibleCoordinateBounds:initialBounds animated:NO]; + XCTAssertEqualObjects(MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds), + @"after panning 30° to the east, setting visible coordinate bounds back to %@ should not leave them at %@", + MGLStringFromCoordinateBounds(initialBounds), + MGLStringFromCoordinateBounds(tester.mapView.visibleCoordinateBounds)); +} + - (void)testPan { CLLocationCoordinate2D centerCoordinate = tester.mapView.centerCoordinate; |