summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@gmail.com>2018-04-26 12:40:26 -0400
committerGitHub <noreply@github.com>2018-04-26 12:40:26 -0400
commit1f4e3e0f6e1a568007f647102459e50cb98b63ca (patch)
treeb4e35b1d68d45e2a1de59ecf457fbf4d07347da7 /platform/ios
parente4f46dafe71e968402de344d4ba0065cae6d2434 (diff)
downloadqtlocation-mapboxgl-1f4e3e0f6e1a568007f647102459e50cb98b63ca.tar.gz
[ios, macos] Raise exceptions for empty expression stops dictionaries (#9539)
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m61
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj4
2 files changed, 65 insertions, 0 deletions
diff --git a/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m b/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m
new file mode 100644
index 0000000000..015a58d2d2
--- /dev/null
+++ b/platform/ios/Integration Tests/MGLStyleLayerIntegrationTests.m
@@ -0,0 +1,61 @@
+#import "MGLMapViewIntegrationTest.h"
+
+@interface MGLStyleLayerIntegrationTests : MGLMapViewIntegrationTest
+@end
+
+@implementation MGLStyleLayerIntegrationTests
+
+- (MGLCircleStyleLayer*)setupCircleStyleLayer {
+ // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/
+
+ // "mapbox://examples.2uf7qges" is a map ID referencing a tileset. For more
+ // more information, see mapbox.com/help/define-map-id/
+ MGLSource *source = [[MGLVectorTileSource alloc] initWithIdentifier:@"trees" configurationURL:[NSURL URLWithString:@"mapbox://examples.2uf7qges"]];
+ [self.mapView.style addSource:source];
+
+ MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier: @"tree-style" source:source];
+
+ // The source name from the source's TileJSON metadata: mapbox.com/api-documentation/#retrieve-tilejson-metadata
+ layer.sourceLayerIdentifier = @"yoshino-trees-a0puw5";
+
+ return layer;
+}
+
+- (void)testForInterpolatingExpressionRenderCrashWithEmptyStops {
+ // Tests: https://github.com/mapbox/mapbox-gl-native/issues/9539
+ // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/
+ self.mapView.centerCoordinate = CLLocationCoordinate2DMake(38.897,-77.039);
+ self.mapView.zoomLevel = 10.5;
+
+ MGLCircleStyleLayer *layer = [self setupCircleStyleLayer];
+
+ NSExpression *interpExpression = [NSExpression mgl_expressionForInterpolatingExpression:NSExpression.zoomLevelVariableExpression
+ withCurveType:MGLExpressionInterpolationModeLinear
+ parameters:nil
+ stops:[NSExpression expressionForConstantValue:@{}]];
+
+ XCTAssertThrowsSpecificNamed((layer.circleColor = interpExpression), NSException, NSInvalidArgumentException);
+
+ [self.mapView.style addLayer:layer];
+ [self waitForMapViewToBeRenderedWithTimeout:1.0];
+}
+
+- (void)testForSteppingExpressionRenderCrashWithEmptyStops {
+ // Tests: https://github.com/mapbox/mapbox-gl-native/issues/9539
+ // Adapted from https://www.mapbox.com/ios-sdk/examples/dds-circle-layer/
+ self.mapView.centerCoordinate = CLLocationCoordinate2DMake(38.897,-77.039);
+ self.mapView.zoomLevel = 10.5;
+
+ MGLCircleStyleLayer *layer = [self setupCircleStyleLayer];
+
+ NSExpression *steppingExpression = [NSExpression mgl_expressionForSteppingExpression:NSExpression.zoomLevelVariableExpression
+ fromExpression:[NSExpression expressionForConstantValue:[UIColor greenColor]]
+ stops:[NSExpression expressionForConstantValue:@{}]];
+
+ XCTAssertThrowsSpecificNamed((layer.circleColor = steppingExpression), NSException, NSInvalidArgumentException);
+
+ [self.mapView.style addLayer:layer];
+ [self waitForMapViewToBeRenderedWithTimeout:1.0];
+}
+
+@end
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index a9413accf2..6892760f59 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -362,6 +362,7 @@
AC518E03201BB56000EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; };
AC518E04201BB56100EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; };
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; };
+ CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; };
CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; };
@@ -993,6 +994,7 @@
AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLTelemetryConfig.m; sourceTree = "<group>"; };
CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewIntegrationTest.m; sourceTree = "<group>"; };
CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = "<group>"; };
+ CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = "<group>"; };
CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = "<group>"; };
DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; };
DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; };
@@ -1345,6 +1347,7 @@
16376B0B1FFD9DAF0000563E /* Info.plist */,
CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */,
CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */,
+ CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */,
);
path = "Integration Tests";
sourceTree = "<group>";
@@ -2793,6 +2796,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */,
16376B0A1FFD9DAF0000563E /* MBGLIntegrationTests.m in Sources */,
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */,
);