diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-09-05 00:21:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-05 00:21:58 -0400 |
commit | 96581fd3ff4e4239d5498d7fc3d3a490c800d2e0 (patch) | |
tree | 5facff1f15c18e9f4ae2745efe95999f88538694 /platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm | |
parent | fa3bf5855bb5ff6ea2daa2cc1e265f1c17ea81b2 (diff) | |
download | qtlocation-mapboxgl-96581fd3ff4e4239d5498d7fc3d3a490c800d2e0.tar.gz |
[core, ios] Call transitionFinishFn for jumpTo. (#15473)
Diffstat (limited to 'platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm')
-rw-r--r-- | platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm b/platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm new file mode 100644 index 0000000000..1527e8dbe5 --- /dev/null +++ b/platform/ios/Integration Tests/Camera Tests/MGLCameraTransitionFinishTests.mm @@ -0,0 +1,109 @@ +#import "MGLMapViewIntegrationTest.h" +#import "MGLTestUtility.h" +#import "../../darwin/src/MGLGeometry_Private.h" + +#include <mbgl/map/camera.hpp> + +@interface MGLCameraTransitionFinishTests : MGLMapViewIntegrationTest +@end + +@implementation MGLCameraTransitionFinishTests + +- (void)testEaseToCompletionHandler { + + MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0.0, 0.0), + CLLocationCoordinate2DMake(1.0, 1.0)); + MGLMapCamera *camera = [self.mapView cameraThatFitsCoordinateBounds:bounds]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should be called"]; + + [self.mapView setCamera:camera + withDuration:0.0 + animationTimingFunction:nil + completionHandler:^{ + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:0.5]; +} + +- (void)testEaseToCompletionHandlerAnimated { + + MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0.0, 0.0), + CLLocationCoordinate2DMake(1.0, 1.0)); + MGLMapCamera *camera = [self.mapView cameraThatFitsCoordinateBounds:bounds]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should be called"]; + + [self.mapView setCamera:camera + withDuration:0.3 + animationTimingFunction:nil + completionHandler:^{ + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:0.5]; +} + +- (void)testFlyToCompletionHandler { + + MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0.0, 0.0), + CLLocationCoordinate2DMake(1.0, 1.0)); + MGLMapCamera *camera = [self.mapView cameraThatFitsCoordinateBounds:bounds]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should be called"]; + + [self.mapView flyToCamera:camera + withDuration:0.0 + completionHandler:^{ + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:0.5]; +} + +- (void)testFlyToCompletionHandlerAnimated { + + MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0.0, 0.0), + CLLocationCoordinate2DMake(1.0, 1.0)); + MGLMapCamera *camera = [self.mapView cameraThatFitsCoordinateBounds:bounds]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should be called"]; + + [self.mapView flyToCamera:camera + withDuration:0.3 + completionHandler:^{ + [expectation fulfill]; + }]; + + [self waitForExpectations:@[expectation] timeout:0.5]; +} +@end + +#pragma mark - camera transitions with NaN values + +@interface MGLMapView (MGLCameraTransitionFinishNaNTests) +- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)insets; +@end + +@interface MGLCameraTransitionNaNZoomMapView: MGLMapView +@end + +@implementation MGLCameraTransitionNaNZoomMapView +- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)insets { + mbgl::CameraOptions options = [super cameraOptionsObjectForAnimatingToCamera:camera edgePadding:insets]; + options.zoom = NAN; + return options; +} +@end + +// Subclass the entire test suite, but with a different MGLMapView subclass +@interface MGLCameraTransitionFinishNaNTests : MGLCameraTransitionFinishTests +@end + +@implementation MGLCameraTransitionFinishNaNTests +- (MGLMapView *)mapViewForTestWithFrame:(CGRect)rect styleURL:(NSURL *)styleURL { + return [[MGLCameraTransitionNaNZoomMapView alloc] initWithFrame:rect styleURL:styleURL]; +} +@end + |