From 1d11624efdf2d73a8adb43310c481969ead18d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 25 Jun 2015 11:58:23 -0700 Subject: 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. --- test/ios/MapViewTests.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/ios') 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; -- cgit v1.2.1