1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
|