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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user