summaryrefslogtreecommitdiff
path: root/platform/ios/Integration Tests
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-06-27 10:08:16 -0400
committerTobrun <tobrun@mapbox.com>2018-07-05 18:50:21 +0200
commit56ab3318a300b3675e902fd13690252d87739a27 (patch)
treef3717f3272ac1e5c93a390135df8c7c8715daa00 /platform/ios/Integration Tests
parent99f9787cc4099b76401ab5b9a9ef7d2f894f9ab6 (diff)
downloadqtlocation-mapboxgl-56ab3318a300b3675e902fd13690252d87739a27.tar.gz
[ios] [macos] Added `-[MGLSnapshot coordinateForPoint:]` and associated test.
Diffstat (limited to 'platform/ios/Integration Tests')
-rw-r--r--platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m90
1 files changed, 90 insertions, 0 deletions
diff --git a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m
index 6a698121c9..22f7fc5911 100644
--- a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m
+++ b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m
@@ -234,4 +234,94 @@ NSString* validAccessToken() {
[self waitForExpectations:@[expectation] timeout:60.0];
}
+- (void)testSnapshotPointConversion {
+ if (!validAccessToken()) {
+ return;
+ }
+
+ CGSize size = self.mapView.bounds.size;
+
+ XCTestExpectation *expectation = [self expectationWithDescription:@"snapshot"];
+ expectation.expectedFulfillmentCount = 1;
+ expectation.assertForOverFulfill = YES;
+
+ CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(30.0, 30.0);
+
+ MGLMapSnapshotter *snapshotter = snapshotterWithCoordinates(coord, size);
+ XCTAssertNotNil(snapshotter);
+
+ __weak __typeof__(self) weakself = self;
+
+ [snapshotter startWithCompletionHandler:^(MGLMapSnapshot * _Nullable snapshot, NSError * _Nullable error) {
+
+ __typeof__(self) myself = weakself;
+
+ MGLTestAssertNotNil(myself, snapshot);
+
+ CGPoint point = [snapshot pointForCoordinate:coord];
+
+ CGFloat epsilon = 0.000001;
+
+ MGLTestAssertEqualWithAccuracy(myself, point.x, size.width/2.0, epsilon);
+ MGLTestAssertEqualWithAccuracy(myself, point.y, size.height/2.0, epsilon);
+
+ CLLocationCoordinate2D coord2 = [snapshot coordinateForPoint:point];
+
+ MGLTestAssertEqualWithAccuracy(myself, coord.latitude, coord2.latitude, epsilon);
+ MGLTestAssertEqualWithAccuracy(myself, coord.longitude, coord2.longitude, epsilon);
+
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectations:@[expectation] timeout:5.0];
+}
+
+- (void)testSnapshotPointConversionCoordinateOrdering {
+ if (!validAccessToken()) {
+ return;
+ }
+
+ CGSize size = self.mapView.bounds.size;
+
+ XCTestExpectation *expectation = [self expectationWithDescription:@"snapshot"];
+ expectation.expectedFulfillmentCount = 1;
+ expectation.assertForOverFulfill = YES;
+
+ CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(30.0, 30.0);
+
+ MGLMapSnapshotter *snapshotter = snapshotterWithCoordinates(coord, size);
+ XCTAssertNotNil(snapshotter);
+
+ __weak __typeof__(self) weakself = self;
+
+ [snapshotter startWithCompletionHandler:^(MGLMapSnapshot * _Nullable snapshot, NSError * _Nullable error) {
+
+ __typeof__(self) myself = weakself;
+
+ CGFloat epsilon = 0.000001;
+
+ MGLTestAssertNotNil(myself, snapshot);
+
+ CLLocationCoordinate2D coordTL = [snapshot coordinateForPoint:CGPointZero];
+
+ MGLTestAssert(myself, coordTL.longitude < coord.longitude);
+ MGLTestAssert(myself, coordTL.latitude > coord.latitude);
+
+ // And check point
+ CGPoint tl = [snapshot pointForCoordinate:coordTL];
+ MGLTestAssertEqualWithAccuracy(myself, tl.x, 0.0, epsilon);
+ MGLTestAssertEqualWithAccuracy(myself, tl.y, 0.0, epsilon);
+
+ CLLocationCoordinate2D coordBR = [snapshot coordinateForPoint:CGPointMake(size.width, size.height)];
+
+ MGLTestAssert(myself, coordBR.longitude > coord.longitude);
+ MGLTestAssert(myself, coordBR.latitude < coord.latitude);
+
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectations:@[expectation] timeout:5.0];
+}
+
+
@end