summaryrefslogtreecommitdiff
path: root/platform/darwin/test
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/test')
-rw-r--r--platform/darwin/test/MGLAttributionInfoTests.m137
-rw-r--r--platform/darwin/test/MGLBackgroundStyleLayerTests.mm197
-rw-r--r--platform/darwin/test/MGLCircleStyleLayerTests.mm804
-rw-r--r--platform/darwin/test/MGLClockDirectionFormatterTests.m72
-rw-r--r--platform/darwin/test/MGLCodingTests.mm615
-rw-r--r--platform/darwin/test/MGLCompassDirectionFormatterTests.m88
-rw-r--r--platform/darwin/test/MGLComputedShapeSourceTests.m24
-rw-r--r--platform/darwin/test/MGLCoordinateFormatterTests.m48
-rw-r--r--platform/darwin/test/MGLDistanceFormatterTests.m30
-rw-r--r--platform/darwin/test/MGLDocumentationExampleTests.swift592
-rw-r--r--platform/darwin/test/MGLDocumentationGuideTests.swift270
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm1408
-rw-r--r--platform/darwin/test/MGLFeatureTests.mm364
-rw-r--r--platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm541
-rw-r--r--platform/darwin/test/MGLFillStyleLayerTests.mm487
-rw-r--r--platform/darwin/test/MGLGeometryTests.mm211
-rw-r--r--platform/darwin/test/MGLHeatmapColorTests.mm62
-rw-r--r--platform/darwin/test/MGLHeatmapStyleLayerTests.mm313
-rw-r--r--platform/darwin/test/MGLHillshadeStyleLayerTests.mm349
-rw-r--r--platform/darwin/test/MGLImageSourceTests.m42
-rw-r--r--platform/darwin/test/MGLLightTest.mm133
-rw-r--r--platform/darwin/test/MGLLightTest.mm.ejs91
-rw-r--r--platform/darwin/test/MGLLineStyleLayerTests.mm904
-rw-r--r--platform/darwin/test/MGLMapCameraTests.m106
-rw-r--r--platform/darwin/test/MGLMapViewTests.m155
-rw-r--r--platform/darwin/test/MGLNSDateAdditionsTests.mm40
-rw-r--r--platform/darwin/test/MGLNSStringAdditionsTests.m89
-rw-r--r--platform/darwin/test/MGLOfflinePackTests.mm58
-rw-r--r--platform/darwin/test/MGLOfflineRegionTests.m71
-rw-r--r--platform/darwin/test/MGLOfflineStorageTests.mm671
-rw-r--r--platform/darwin/test/MGLPredicateTests.mm426
-rw-r--r--platform/darwin/test/MGLRasterStyleLayerTests.mm430
-rw-r--r--platform/darwin/test/MGLRendererConfigurationTests.mm197
-rw-r--r--platform/darwin/test/MGLResourceTests.mm85
-rw-r--r--platform/darwin/test/MGLSDKTestHelpers.swift48
-rw-r--r--platform/darwin/test/MGLShapeSourceTests.mm330
-rw-r--r--platform/darwin/test/MGLSourceQueryTests.m25
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.h28
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.m125
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.mm.ejs232
-rw-r--r--platform/darwin/test/MGLStyleTests.mm500
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.mm3204
-rw-r--r--platform/darwin/test/MGLTestAssertionHandler.h18
-rw-r--r--platform/darwin/test/MGLTestAssertionHandler.m77
-rw-r--r--platform/darwin/test/MGLTestUtility.h27
-rw-r--r--platform/darwin/test/MGLTileSetTests.mm149
-rw-r--r--platform/darwin/test/MGLVersionNumber.m15
-rw-r--r--platform/darwin/test/Media.xcassets/Contents.json6
-rw-r--r--platform/darwin/test/Media.xcassets/RadarImage.imageset/Contents.json21
-rw-r--r--platform/darwin/test/Media.xcassets/RadarImage.imageset/radar.pngbin44094 -> 0 bytes
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json26
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.pngbin407 -> 0 bytes
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.pngbin680 -> 0 bytes
-rw-r--r--platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.pngbin903 -> 0 bytes
-rw-r--r--platform/darwin/test/amsterdam.geojson2283
-rw-r--r--platform/darwin/test/one-liner.json1
-rw-r--r--platform/darwin/test/test-Bridging-Header.h4
57 files changed, 0 insertions, 17229 deletions
diff --git a/platform/darwin/test/MGLAttributionInfoTests.m b/platform/darwin/test/MGLAttributionInfoTests.m
deleted file mode 100644
index b6f053a8af..0000000000
--- a/platform/darwin/test/MGLAttributionInfoTests.m
+++ /dev/null
@@ -1,137 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import "MGLAttributionInfo_Private.h"
-
-@interface MGLAttributionInfoTests : XCTestCase
-
-@end
-
-@implementation MGLAttributionInfoTests
-
-- (void)setUp {
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
-}
-
-- (void)tearDown {
- [MGLAccountManager setAccessToken:nil];
-}
-
-- (void)testParsing {
- static NSString * const htmlStrings[] = {
- @"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> "
- @"<a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">©️ OpenStreetMap</a> "
- @"CC&nbsp;BY-SA "
- @"<a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a>",
- };
-
- NSMutableArray<MGLAttributionInfo *> *infos = [NSMutableArray array];
- for (NSUInteger i = 0; i < sizeof(htmlStrings) / sizeof(htmlStrings[0]); i++) {
- NSArray *subinfos = [MGLAttributionInfo attributionInfosFromHTMLString:htmlStrings[i]
- fontSize:0
- linkColor:nil];
- [infos growArrayByAddingAttributionInfosFromArray:subinfos];
- }
-
- XCTAssertEqual(infos.count, 4);
-
- CLLocationCoordinate2D mapbox = CLLocationCoordinate2DMake(12.9810816, 77.6368034);
- XCTAssertEqualObjects(infos[0].title.string, @"© Mapbox");
- XCTAssertEqualObjects(infos[0].URL, [NSURL URLWithString:@"https://www.mapbox.com/about/maps/"]);
- XCTAssertFalse(infos[0].feedbackLink);
- XCTAssertNil([infos[0] feedbackURLAtCenterCoordinate:mapbox zoomLevel:14]);
-
- XCTAssertEqualObjects(infos[1].title.string, @"©️ OpenStreetMap");
- XCTAssertEqualObjects(infos[1].URL, [NSURL URLWithString:@"http://www.openstreetmap.org/about/"]);
- XCTAssertFalse(infos[1].feedbackLink);
- XCTAssertNil([infos[1] feedbackURLAtCenterCoordinate:mapbox zoomLevel:14]);
-
- XCTAssertEqualObjects(infos[2].title.string, @"CC\u00a0BY-SA");
- XCTAssertNil(infos[2].URL);
- XCTAssertFalse(infos[2].feedbackLink);
- XCTAssertNil([infos[2] feedbackURLAtCenterCoordinate:mapbox zoomLevel:14]);
-
- XCTAssertEqualObjects(infos[3].title.string, @"Improve this map");
- XCTAssertEqualObjects(infos[3].URL, [NSURL URLWithString:@"https://apps.mapbox.com/feedback/"]);
- XCTAssertTrue(infos[3].feedbackLink);
- NSURL *styleURL = [MGLStyle satelliteStreetsStyleURLWithVersion:99];
-
-#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 120200) || \
- (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101404)
- NSString *bundleId = @"com.apple.dt.xctest.tool";
-#else
- NSString *bundleId = @"com.mapbox.Mapbox";
-#endif
-
- NSString *urlString = [NSString stringWithFormat:@"https://apps.mapbox.com/feedback/?referrer=%@#/77.63680/12.98108/14.00/0.0/0", bundleId];
- XCTAssertEqualObjects([infos[3] feedbackURLAtCenterCoordinate:mapbox zoomLevel:14],
- [NSURL URLWithString:urlString]);
-
- urlString = [NSString stringWithFormat:@"https://apps.mapbox.com/feedback/?referrer=%@&owner=mapbox&id=satellite-streets-v99&access_token=pk.feedcafedeadbeefbadebede&map_sdk_version=1.0.0#/77.63680/12.98108/3.14/90.9/13", bundleId];
- XCTAssertEqualObjects([infos[3] feedbackURLForStyleURL:styleURL atCenterCoordinate:mapbox zoomLevel:3.14159 direction:90.9 pitch:12.5],
- [NSURL URLWithString:urlString]);
-}
-
-- (void)testStyle {
- static NSString * const htmlStrings[] = {
- @"<a href=\"https://www.mapbox.com/\">Mapbox</a>",
- };
-
- CGFloat fontSize = 72;
- MGLColor *color = [MGLColor redColor];
- NSMutableArray<MGLAttributionInfo *> *infos = [NSMutableArray array];
- for (NSUInteger i = 0; i < sizeof(htmlStrings) / sizeof(htmlStrings[0]); i++) {
- NSArray *subinfos = [MGLAttributionInfo attributionInfosFromHTMLString:htmlStrings[i]
- fontSize:72
- linkColor:color];
- [infos growArrayByAddingAttributionInfosFromArray:subinfos];
- }
-
- XCTAssertEqual(infos.count, 1);
-
- XCTAssertEqualObjects(infos[0].title.string, @"Mapbox");
- XCTAssertNil([infos[0].title attribute:NSLinkAttributeName atIndex:0 effectiveRange:nil]);
- XCTAssertEqualObjects([infos[0].title attribute:NSUnderlineStyleAttributeName atIndex:0 effectiveRange:nil], @(NSUnderlineStyleSingle));
-
-#if TARGET_OS_IPHONE
- UIFont *font;
-#else
- NSFont *font;
-#endif
- font = [infos[0].title attribute:NSFontAttributeName atIndex:0 effectiveRange:nil];
- XCTAssertEqual(font.pointSize, fontSize);
-
- CGFloat r, g, b, a;
- [color getRed:&r green:&g blue:&b alpha:&a];
- MGLColor *linkColor = [infos[0].title attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:nil];
- CGFloat linkR, linkG, linkB, linkA;
- [linkColor getRed:&linkR green:&linkG blue:&linkB alpha:&linkA];
- XCTAssertEqual(r, linkR);
- XCTAssertEqual(g, linkG);
- XCTAssertEqual(b, linkB);
- XCTAssertEqual(a, linkA);
-}
-
-- (void)testDedupe {
- static NSString * const htmlStrings[] = {
- @"World",
- @"Hello World",
- @"Another Source",
- @"Hello",
- @"Hello World",
- };
-
- NSMutableArray<MGLAttributionInfo *> *infos = [NSMutableArray array];
- for (NSUInteger i = 0; i < sizeof(htmlStrings) / sizeof(htmlStrings[0]); i++) {
- NSArray *subinfos = [MGLAttributionInfo attributionInfosFromHTMLString:htmlStrings[i]
- fontSize:0
- linkColor:nil];
- [infos growArrayByAddingAttributionInfosFromArray:subinfos];
- }
-
- XCTAssertEqual(infos.count, 2);
- XCTAssertEqualObjects(infos[0].title.string, @"Hello World");
- XCTAssertEqualObjects(infos[1].title.string, @"Another Source");
-}
-
-@end
diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
deleted file mode 100644
index 4617cff598..0000000000
--- a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
+++ /dev/null
@@ -1,197 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/background_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLBackgroundLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLBackgroundLayerTests
-
-+ (NSString *)layerType {
- return @"background";
-}
-
-- (void)testProperties {
- MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"layerID"];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"background");
- auto rawLayer = static_cast<mbgl::style::BackgroundLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // background-color
- {
- XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(),
- @"background-color should be unset initially.");
- NSExpression *defaultExpression = layer.backgroundColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.backgroundColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
- @"Setting backgroundColor to a constant value expression should update background-color.");
- XCTAssertEqualObjects(layer.backgroundColor, constantExpression,
- @"backgroundColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.backgroundColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
- @"Setting backgroundColor to a camera expression should update background-color.");
- XCTAssertEqualObjects(layer.backgroundColor, functionExpression,
- @"backgroundColor should round-trip camera expressions.");
-
-
- layer.backgroundColor = nil;
- XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(),
- @"Unsetting backgroundColor should return background-color to the default value.");
- XCTAssertEqualObjects(layer.backgroundColor, defaultExpression,
- @"backgroundColor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.backgroundColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.backgroundColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.backgroundColorTransition = transitionTest;
- auto toptions = rawLayer->getBackgroundColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition backgroundColorTransition = layer.backgroundColorTransition;
- XCTAssertEqual(backgroundColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(backgroundColorTransition.duration, transitionTest.duration);
- }
-
- // background-opacity
- {
- XCTAssertTrue(rawLayer->getBackgroundOpacity().isUndefined(),
- @"background-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.backgroundOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.backgroundOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
- @"Setting backgroundOpacity to a constant value expression should update background-opacity.");
- XCTAssertEqualObjects(layer.backgroundOpacity, constantExpression,
- @"backgroundOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.backgroundOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
- @"Setting backgroundOpacity to a camera expression should update background-opacity.");
- XCTAssertEqualObjects(layer.backgroundOpacity, functionExpression,
- @"backgroundOpacity should round-trip camera expressions.");
-
-
- layer.backgroundOpacity = nil;
- XCTAssertTrue(rawLayer->getBackgroundOpacity().isUndefined(),
- @"Unsetting backgroundOpacity should return background-opacity to the default value.");
- XCTAssertEqualObjects(layer.backgroundOpacity, defaultExpression,
- @"backgroundOpacity should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.backgroundOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.backgroundOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.backgroundOpacityTransition = transitionTest;
- auto toptions = rawLayer->getBackgroundOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition backgroundOpacityTransition = layer.backgroundOpacityTransition;
- XCTAssertEqual(backgroundOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(backgroundOpacityTransition.duration, transitionTest.duration);
- }
-
- // background-pattern
- {
- XCTAssertTrue(rawLayer->getBackgroundPattern().isUndefined(),
- @"background-pattern should be unset initially.");
- NSExpression *defaultExpression = layer.backgroundPattern;
-
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Background Pattern"];
- layer.backgroundPattern = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Image> propertyValue = { "Background Pattern" };
- XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
- @"Setting backgroundPattern to a constant value expression should update background-pattern.");
- XCTAssertEqualObjects(layer.backgroundPattern, constantExpression,
- @"backgroundPattern should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Background Pattern')"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.backgroundPattern = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- step(zoom(), image(literal("Background Pattern")), 18.0, image(literal("Background Pattern")))
- );
- }
-
- XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
- @"Setting backgroundPattern to a camera expression should update background-pattern.");
- XCTAssertEqualObjects(layer.backgroundPattern, functionExpression,
- @"backgroundPattern should round-trip camera expressions.");
-
-
- layer.backgroundPattern = nil;
- XCTAssertTrue(rawLayer->getBackgroundPattern().isUndefined(),
- @"Unsetting backgroundPattern should return background-pattern to the default value.");
- XCTAssertEqualObjects(layer.backgroundPattern, defaultExpression,
- @"backgroundPattern should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.backgroundPatternTransition = transitionTest;
- auto toptions = rawLayer->getBackgroundPatternTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition backgroundPatternTransition = layer.backgroundPatternTransition;
- XCTAssertEqual(backgroundPatternTransition.delay, transitionTest.delay);
- XCTAssertEqual(backgroundPatternTransition.duration, transitionTest.duration);
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"background-color" isBoolean:NO];
- [self testPropertyName:@"background-opacity" isBoolean:NO];
- [self testPropertyName:@"background-pattern" isBoolean:NO];
-}
-
-@end
diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/darwin/test/MGLCircleStyleLayerTests.mm
deleted file mode 100644
index 5f789f4faf..0000000000
--- a/platform/darwin/test/MGLCircleStyleLayerTests.mm
+++ /dev/null
@@ -1,804 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/circle_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLCircleLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLCircleLayerTests
-
-+ (NSString *)layerType {
- return @"circle";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"circle");
- auto rawLayer = static_cast<mbgl::style::CircleLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // circle-blur
- {
- XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(),
- @"circle-blur should be unset initially.");
- NSExpression *defaultExpression = layer.circleBlur;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.circleBlur = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
- @"Setting circleBlur to a constant value expression should update circle-blur.");
- XCTAssertEqualObjects(layer.circleBlur, constantExpression,
- @"circleBlur should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
- @"Setting circleBlur to a camera expression should update circle-blur.");
- XCTAssertEqualObjects(layer.circleBlur, functionExpression,
- @"circleBlur should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
- @"Setting circleBlur to a data expression should update circle-blur.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleBlur, pedanticFunctionExpression,
- @"circleBlur should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
- @"Setting circleBlur to a camera-data expression should update circle-blur.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleBlur, pedanticFunctionExpression,
- @"circleBlur should round-trip camera-data expressions.");
-
- layer.circleBlur = nil;
- XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(),
- @"Unsetting circleBlur should return circle-blur to the default value.");
- XCTAssertEqualObjects(layer.circleBlur, defaultExpression,
- @"circleBlur should return the default value after being unset.");
- // Transition property test
- layer.circleBlurTransition = transitionTest;
- auto toptions = rawLayer->getCircleBlurTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleBlurTransition = layer.circleBlurTransition;
- XCTAssertEqual(circleBlurTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleBlurTransition.duration, transitionTest.duration);
- }
-
- // circle-color
- {
- XCTAssertTrue(rawLayer->getCircleColor().isUndefined(),
- @"circle-color should be unset initially.");
- NSExpression *defaultExpression = layer.circleColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.circleColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
- @"Setting circleColor to a constant value expression should update circle-color.");
- XCTAssertEqualObjects(layer.circleColor, constantExpression,
- @"circleColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
- @"Setting circleColor to a camera expression should update circle-color.");
- XCTAssertEqualObjects(layer.circleColor, functionExpression,
- @"circleColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
- @"Setting circleColor to a data expression should update circle-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleColor, pedanticFunctionExpression,
- @"circleColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
- @"Setting circleColor to a camera-data expression should update circle-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleColor, pedanticFunctionExpression,
- @"circleColor should round-trip camera-data expressions.");
-
- layer.circleColor = nil;
- XCTAssertTrue(rawLayer->getCircleColor().isUndefined(),
- @"Unsetting circleColor should return circle-color to the default value.");
- XCTAssertEqualObjects(layer.circleColor, defaultExpression,
- @"circleColor should return the default value after being unset.");
- // Transition property test
- layer.circleColorTransition = transitionTest;
- auto toptions = rawLayer->getCircleColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleColorTransition = layer.circleColorTransition;
- XCTAssertEqual(circleColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleColorTransition.duration, transitionTest.duration);
- }
-
- // circle-opacity
- {
- XCTAssertTrue(rawLayer->getCircleOpacity().isUndefined(),
- @"circle-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.circleOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.circleOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
- @"Setting circleOpacity to a constant value expression should update circle-opacity.");
- XCTAssertEqualObjects(layer.circleOpacity, constantExpression,
- @"circleOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
- @"Setting circleOpacity to a camera expression should update circle-opacity.");
- XCTAssertEqualObjects(layer.circleOpacity, functionExpression,
- @"circleOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
- @"Setting circleOpacity to a data expression should update circle-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleOpacity, pedanticFunctionExpression,
- @"circleOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
- @"Setting circleOpacity to a camera-data expression should update circle-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleOpacity, pedanticFunctionExpression,
- @"circleOpacity should round-trip camera-data expressions.");
-
- layer.circleOpacity = nil;
- XCTAssertTrue(rawLayer->getCircleOpacity().isUndefined(),
- @"Unsetting circleOpacity should return circle-opacity to the default value.");
- XCTAssertEqualObjects(layer.circleOpacity, defaultExpression,
- @"circleOpacity should return the default value after being unset.");
- // Transition property test
- layer.circleOpacityTransition = transitionTest;
- auto toptions = rawLayer->getCircleOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleOpacityTransition = layer.circleOpacityTransition;
- XCTAssertEqual(circleOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleOpacityTransition.duration, transitionTest.duration);
- }
-
- // circle-pitch-alignment
- {
- XCTAssertTrue(rawLayer->getCirclePitchAlignment().isUndefined(),
- @"circle-pitch-alignment should be unset initially.");
- NSExpression *defaultExpression = layer.circlePitchAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.circlePitchAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Viewport };
- XCTAssertEqual(rawLayer->getCirclePitchAlignment(), propertyValue,
- @"Setting circlePitchAlignment to a constant value expression should update circle-pitch-alignment.");
- XCTAssertEqualObjects(layer.circlePitchAlignment, constantExpression,
- @"circlePitchAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circlePitchAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::AlignmentType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getCirclePitchAlignment(), propertyValue,
- @"Setting circlePitchAlignment to a camera expression should update circle-pitch-alignment.");
- XCTAssertEqualObjects(layer.circlePitchAlignment, functionExpression,
- @"circlePitchAlignment should round-trip camera expressions.");
-
-
- layer.circlePitchAlignment = nil;
- XCTAssertTrue(rawLayer->getCirclePitchAlignment().isUndefined(),
- @"Unsetting circlePitchAlignment should return circle-pitch-alignment to the default value.");
- XCTAssertEqualObjects(layer.circlePitchAlignment, defaultExpression,
- @"circlePitchAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.circlePitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.circlePitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // circle-radius
- {
- XCTAssertTrue(rawLayer->getCircleRadius().isUndefined(),
- @"circle-radius should be unset initially.");
- NSExpression *defaultExpression = layer.circleRadius;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.circleRadius = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
- @"Setting circleRadius to a constant value expression should update circle-radius.");
- XCTAssertEqualObjects(layer.circleRadius, constantExpression,
- @"circleRadius should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
- @"Setting circleRadius to a camera expression should update circle-radius.");
- XCTAssertEqualObjects(layer.circleRadius, functionExpression,
- @"circleRadius should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
- @"Setting circleRadius to a data expression should update circle-radius.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleRadius, pedanticFunctionExpression,
- @"circleRadius should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
- @"Setting circleRadius to a camera-data expression should update circle-radius.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleRadius, pedanticFunctionExpression,
- @"circleRadius should round-trip camera-data expressions.");
-
- layer.circleRadius = nil;
- XCTAssertTrue(rawLayer->getCircleRadius().isUndefined(),
- @"Unsetting circleRadius should return circle-radius to the default value.");
- XCTAssertEqualObjects(layer.circleRadius, defaultExpression,
- @"circleRadius should return the default value after being unset.");
- // Transition property test
- layer.circleRadiusTransition = transitionTest;
- auto toptions = rawLayer->getCircleRadiusTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleRadiusTransition = layer.circleRadiusTransition;
- XCTAssertEqual(circleRadiusTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleRadiusTransition.duration, transitionTest.duration);
- }
-
- // circle-pitch-scale
- {
- XCTAssertTrue(rawLayer->getCirclePitchScale().isUndefined(),
- @"circle-pitch-scale should be unset initially.");
- NSExpression *defaultExpression = layer.circleScaleAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.circleScaleAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::CirclePitchScaleType> propertyValue = { mbgl::style::CirclePitchScaleType::Viewport };
- XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue,
- @"Setting circleScaleAlignment to a constant value expression should update circle-pitch-scale.");
- XCTAssertEqualObjects(layer.circleScaleAlignment, constantExpression,
- @"circleScaleAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleScaleAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::CirclePitchScaleType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue,
- @"Setting circleScaleAlignment to a camera expression should update circle-pitch-scale.");
- XCTAssertEqualObjects(layer.circleScaleAlignment, functionExpression,
- @"circleScaleAlignment should round-trip camera expressions.");
-
-
- layer.circleScaleAlignment = nil;
- XCTAssertTrue(rawLayer->getCirclePitchScale().isUndefined(),
- @"Unsetting circleScaleAlignment should return circle-pitch-scale to the default value.");
- XCTAssertEqualObjects(layer.circleScaleAlignment, defaultExpression,
- @"circleScaleAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // circle-stroke-color
- {
- XCTAssertTrue(rawLayer->getCircleStrokeColor().isUndefined(),
- @"circle-stroke-color should be unset initially.");
- NSExpression *defaultExpression = layer.circleStrokeColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.circleStrokeColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
- @"Setting circleStrokeColor to a constant value expression should update circle-stroke-color.");
- XCTAssertEqualObjects(layer.circleStrokeColor, constantExpression,
- @"circleStrokeColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleStrokeColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
- @"Setting circleStrokeColor to a camera expression should update circle-stroke-color.");
- XCTAssertEqualObjects(layer.circleStrokeColor, functionExpression,
- @"circleStrokeColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleStrokeColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
- @"Setting circleStrokeColor to a data expression should update circle-stroke-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleStrokeColor, pedanticFunctionExpression,
- @"circleStrokeColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleStrokeColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
- @"Setting circleStrokeColor to a camera-data expression should update circle-stroke-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleStrokeColor, pedanticFunctionExpression,
- @"circleStrokeColor should round-trip camera-data expressions.");
-
- layer.circleStrokeColor = nil;
- XCTAssertTrue(rawLayer->getCircleStrokeColor().isUndefined(),
- @"Unsetting circleStrokeColor should return circle-stroke-color to the default value.");
- XCTAssertEqualObjects(layer.circleStrokeColor, defaultExpression,
- @"circleStrokeColor should return the default value after being unset.");
- // Transition property test
- layer.circleStrokeColorTransition = transitionTest;
- auto toptions = rawLayer->getCircleStrokeColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleStrokeColorTransition = layer.circleStrokeColorTransition;
- XCTAssertEqual(circleStrokeColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleStrokeColorTransition.duration, transitionTest.duration);
- }
-
- // circle-stroke-opacity
- {
- XCTAssertTrue(rawLayer->getCircleStrokeOpacity().isUndefined(),
- @"circle-stroke-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.circleStrokeOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.circleStrokeOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
- @"Setting circleStrokeOpacity to a constant value expression should update circle-stroke-opacity.");
- XCTAssertEqualObjects(layer.circleStrokeOpacity, constantExpression,
- @"circleStrokeOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleStrokeOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
- @"Setting circleStrokeOpacity to a camera expression should update circle-stroke-opacity.");
- XCTAssertEqualObjects(layer.circleStrokeOpacity, functionExpression,
- @"circleStrokeOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleStrokeOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
- @"Setting circleStrokeOpacity to a data expression should update circle-stroke-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleStrokeOpacity, pedanticFunctionExpression,
- @"circleStrokeOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleStrokeOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
- @"Setting circleStrokeOpacity to a camera-data expression should update circle-stroke-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleStrokeOpacity, pedanticFunctionExpression,
- @"circleStrokeOpacity should round-trip camera-data expressions.");
-
- layer.circleStrokeOpacity = nil;
- XCTAssertTrue(rawLayer->getCircleStrokeOpacity().isUndefined(),
- @"Unsetting circleStrokeOpacity should return circle-stroke-opacity to the default value.");
- XCTAssertEqualObjects(layer.circleStrokeOpacity, defaultExpression,
- @"circleStrokeOpacity should return the default value after being unset.");
- // Transition property test
- layer.circleStrokeOpacityTransition = transitionTest;
- auto toptions = rawLayer->getCircleStrokeOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleStrokeOpacityTransition = layer.circleStrokeOpacityTransition;
- XCTAssertEqual(circleStrokeOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleStrokeOpacityTransition.duration, transitionTest.duration);
- }
-
- // circle-stroke-width
- {
- XCTAssertTrue(rawLayer->getCircleStrokeWidth().isUndefined(),
- @"circle-stroke-width should be unset initially.");
- NSExpression *defaultExpression = layer.circleStrokeWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.circleStrokeWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
- @"Setting circleStrokeWidth to a constant value expression should update circle-stroke-width.");
- XCTAssertEqualObjects(layer.circleStrokeWidth, constantExpression,
- @"circleStrokeWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleStrokeWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
- @"Setting circleStrokeWidth to a camera expression should update circle-stroke-width.");
- XCTAssertEqualObjects(layer.circleStrokeWidth, functionExpression,
- @"circleStrokeWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.circleStrokeWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
- @"Setting circleStrokeWidth to a data expression should update circle-stroke-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.circleStrokeWidth, pedanticFunctionExpression,
- @"circleStrokeWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.circleStrokeWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
- @"Setting circleStrokeWidth to a camera-data expression should update circle-stroke-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.circleStrokeWidth, pedanticFunctionExpression,
- @"circleStrokeWidth should round-trip camera-data expressions.");
-
- layer.circleStrokeWidth = nil;
- XCTAssertTrue(rawLayer->getCircleStrokeWidth().isUndefined(),
- @"Unsetting circleStrokeWidth should return circle-stroke-width to the default value.");
- XCTAssertEqualObjects(layer.circleStrokeWidth, defaultExpression,
- @"circleStrokeWidth should return the default value after being unset.");
- // Transition property test
- layer.circleStrokeWidthTransition = transitionTest;
- auto toptions = rawLayer->getCircleStrokeWidthTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition circleStrokeWidthTransition = layer.circleStrokeWidthTransition;
- XCTAssertEqual(circleStrokeWidthTransition.delay, transitionTest.delay);
- XCTAssertEqual(circleStrokeWidthTransition.duration, transitionTest.duration);
- }
-
- // circle-translate
- {
- XCTAssertTrue(rawLayer->getCircleTranslate().isUndefined(),
- @"circle-translate should be unset initially.");
- NSExpression *defaultExpression = layer.circleTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.circleTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue,
- @"Setting circleTranslation to a constant value expression should update circle-translate.");
- XCTAssertEqualObjects(layer.circleTranslation, constantExpression,
- @"circleTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue,
- @"Setting circleTranslation to a camera expression should update circle-translate.");
- XCTAssertEqualObjects(layer.circleTranslation, functionExpression,
- @"circleTranslation should round-trip camera expressions.");
-
-
- layer.circleTranslation = nil;
- XCTAssertTrue(rawLayer->getCircleTranslate().isUndefined(),
- @"Unsetting circleTranslation should return circle-translate to the default value.");
- XCTAssertEqualObjects(layer.circleTranslation, defaultExpression,
- @"circleTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.circleTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.circleTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // circle-translate-anchor
- {
- XCTAssertTrue(rawLayer->getCircleTranslateAnchor().isUndefined(),
- @"circle-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.circleTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.circleTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue,
- @"Setting circleTranslationAnchor to a constant value expression should update circle-translate-anchor.");
- XCTAssertEqualObjects(layer.circleTranslationAnchor, constantExpression,
- @"circleTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.circleTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue,
- @"Setting circleTranslationAnchor to a camera expression should update circle-translate-anchor.");
- XCTAssertEqualObjects(layer.circleTranslationAnchor, functionExpression,
- @"circleTranslationAnchor should round-trip camera expressions.");
-
-
- layer.circleTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getCircleTranslateAnchor().isUndefined(),
- @"Unsetting circleTranslationAnchor should return circle-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.circleTranslationAnchor, defaultExpression,
- @"circleTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"circle-blur" isBoolean:NO];
- [self testPropertyName:@"circle-color" isBoolean:NO];
- [self testPropertyName:@"circle-opacity" isBoolean:NO];
- [self testPropertyName:@"circle-pitch-alignment" isBoolean:NO];
- [self testPropertyName:@"circle-radius" isBoolean:NO];
- [self testPropertyName:@"circle-scale-alignment" isBoolean:NO];
- [self testPropertyName:@"circle-stroke-color" isBoolean:NO];
- [self testPropertyName:@"circle-stroke-opacity" isBoolean:NO];
- [self testPropertyName:@"circle-stroke-width" isBoolean:NO];
- [self testPropertyName:@"circle-translation" isBoolean:NO];
- [self testPropertyName:@"circle-translation-anchor" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLCirclePitchAlignment:MGLCirclePitchAlignmentMap].MGLCirclePitchAlignmentValue, MGLCirclePitchAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLCirclePitchAlignment:MGLCirclePitchAlignmentViewport].MGLCirclePitchAlignmentValue, MGLCirclePitchAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentMap].MGLCircleScaleAlignmentValue, MGLCircleScaleAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentViewport].MGLCircleScaleAlignmentValue, MGLCircleScaleAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorMap].MGLCircleTranslationAnchorValue, MGLCircleTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorViewport].MGLCircleTranslationAnchorValue, MGLCircleTranslationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLClockDirectionFormatterTests.m b/platform/darwin/test/MGLClockDirectionFormatterTests.m
deleted file mode 100644
index 05ebc3af2d..0000000000
--- a/platform/darwin/test/MGLClockDirectionFormatterTests.m
+++ /dev/null
@@ -1,72 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-@interface MGLClockDirectionFormatterTests : XCTestCase
-
-@end
-
-@implementation MGLClockDirectionFormatterTests
-
-- (void)testClockDirections {
- MGLClockDirectionFormatter *shortFormatter = [[MGLClockDirectionFormatter alloc] init];
- shortFormatter.unitStyle = NSFormattingUnitStyleShort;
-
- MGLClockDirectionFormatter *mediumFormatter = [[MGLClockDirectionFormatter alloc] init];
-
- MGLClockDirectionFormatter *longFormatter = [[MGLClockDirectionFormatter alloc] init];
- longFormatter.unitStyle = NSFormattingUnitStyleLong;
-
- CLLocationDirection direction;
-
- direction = -90;
- XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"9 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 0;
- XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 45;
- XCTAssertEqualObjects(@"2:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"2 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"2 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 90;
- XCTAssertEqualObjects(@"3:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"3 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"3 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 180;
- XCTAssertEqualObjects(@"6:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"6 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"6 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 270;
- XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"9 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 359.34951805867024;
- XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 360;
- XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 360.1;
- XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
-
- direction = 720;
- XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
-}
-
-@end
diff --git a/platform/darwin/test/MGLCodingTests.mm b/platform/darwin/test/MGLCodingTests.mm
deleted file mode 100644
index e6417c99f5..0000000000
--- a/platform/darwin/test/MGLCodingTests.mm
+++ /dev/null
@@ -1,615 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import "MGLFoundation_Private.h"
-#import "MGLCluster.h"
-
-#if TARGET_OS_IPHONE
-#import "MGLUserLocation_Private.h"
-#endif
-
-@interface MGLCodingTests : XCTestCase
-@end
-
-@implementation MGLCodingTests
-
-- (NSString *)temporaryFilePathForClass:(Class)clazz {
- return [NSTemporaryDirectory() stringByAppendingPathComponent:NSStringFromClass(clazz)];
-}
-
-- (void)testPointAnnotation {
- MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
- annotation.coordinate = CLLocationCoordinate2DMake(0.5, 0.5);
- annotation.title = @"title";
- annotation.subtitle = @"subtitle";
-
- NSString *filePath = [self temporaryFilePathForClass:MGLPointAnnotation.class];
- [NSKeyedArchiver archiveRootObject:annotation toFile:filePath];
- MGLPointAnnotation *unarchivedAnnotation = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(annotation, unarchivedAnnotation);
-}
-
-- (void)testPointFeature {
- MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init];
- pointFeature.title = @"title";
- pointFeature.subtitle = @"subtitle";
- pointFeature.identifier = @(123);
- pointFeature.attributes = @{@"bbox": @[@1, @2, @3, @4]};
-
- NSString *filePath = [self temporaryFilePathForClass:MGLPointFeature.class];
- [NSKeyedArchiver archiveRootObject:pointFeature toFile:filePath];
- MGLPointFeature *unarchivedPointFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(pointFeature, unarchivedPointFeature);
-}
-
-- (void)testPointFeatureCluster {
- MGLPointFeature *pointFeature = [[MGLPointFeatureCluster alloc] init];
- pointFeature.title = @"title";
- pointFeature.subtitle = @"subtitle";
- pointFeature.identifier = @(123);
- pointFeature.attributes = @{
- @"cluster" : @(YES),
- @"cluster_id" : @(456),
- @"point_count" : @(2),
- };
-
- XCTAssert([pointFeature isKindOfClass:[MGLPointFeature class]], @"");
-
- NSString *filePath = [self temporaryFilePathForClass:MGLPointFeature.class];
- [NSKeyedArchiver archiveRootObject:pointFeature toFile:filePath];
- MGLPointFeature *unarchivedPointFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(pointFeature, unarchivedPointFeature);
-
- // Unarchive process should ensure we still have a cluster
- XCTAssert([unarchivedPointFeature isMemberOfClass:[MGLPointFeatureCluster class]]);
-
- id<MGLCluster> cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(unarchivedPointFeature, MGLCluster);
-
- XCTAssert(cluster);
- XCTAssert(cluster.clusterIdentifier == 456);
- XCTAssert(cluster.clusterPointCount == 2);
-}
-
-
-- (void)testPolyline {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.129631234123, 1.7812739312551),
- CLLocationCoordinate2DMake(2.532083092342, 3.5216418292392)
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPolyline *polyline = [MGLPolyline polylineWithCoordinates:coordinates count:numberOfCoordinates];
- polyline.title = @"title";
- polyline.subtitle = @"subtitle";
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPolyline class]];
- [NSKeyedArchiver archiveRootObject:polyline toFile:filePath];
- MGLPolyline *unarchivedPolyline = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(polyline, unarchivedPolyline);
-
- CLLocationCoordinate2D otherCoordinates[] = {
- CLLocationCoordinate2DMake(-1, -2)
- };
-
- [unarchivedPolyline replaceCoordinatesInRange:NSMakeRange(0, 1) withCoordinates:otherCoordinates];
-
- XCTAssertNotEqualObjects(polyline, unarchivedPolyline);
-
- CLLocationCoordinate2D multiLineCoordinates[] = {
- CLLocationCoordinate2DMake(51.000000, 0.000000),
- CLLocationCoordinate2DMake(51.000000, 1.000000),
- CLLocationCoordinate2DMake(51.000000, 2.000000),
- };
-
- NSUInteger multiLineCoordinatesCount = sizeof(multiLineCoordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolyline *multiLine = [MGLPolyline polylineWithCoordinates:multiLineCoordinates count:multiLineCoordinatesCount];
- CLLocationCoordinate2D multiLineCenter = CLLocationCoordinate2DMake(51.000000, 1.000000);
-
- XCTAssertEqual([multiLine coordinate].latitude, multiLineCenter.latitude);
- XCTAssertEqual([multiLine coordinate].longitude, multiLineCenter.longitude);
-
- CLLocationCoordinate2D segmentCoordinates[] = {
- CLLocationCoordinate2DMake(35.040390, -85.311477),
- CLLocationCoordinate2DMake(35.040390, -85.209510),
- };
-
- NSUInteger segmentCoordinatesCount = sizeof(segmentCoordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolyline *segmentLine = [MGLPolyline polylineWithCoordinates:segmentCoordinates count:segmentCoordinatesCount];
- CLLocationCoordinate2D segmentCenter = CLLocationCoordinate2DMake(35.0404006631, -85.2604935);
-
- XCTAssertEqualWithAccuracy([segmentLine coordinate].latitude, segmentCenter.latitude, 0.0001);
- XCTAssertEqualWithAccuracy([segmentLine coordinate].longitude, segmentCenter.longitude, 0.0001);
-
- CLLocationCoordinate2D sfToBerkeleyCoordinates[] = {
- CLLocationCoordinate2DMake(37.782440, -122.397111),
- CLLocationCoordinate2DMake(37.818384, -122.352994),
- CLLocationCoordinate2DMake(37.831401, -122.274545),
- CLLocationCoordinate2DMake(37.862172, -122.262700),
- };
-
- NSUInteger sfToBerkeleyCoordinatesCount = sizeof(sfToBerkeleyCoordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolyline *sfToBerkeleyLine = [MGLPolyline polylineWithCoordinates:sfToBerkeleyCoordinates count:sfToBerkeleyCoordinatesCount];
- CLLocationCoordinate2D sfToBerkeleyCenter = CLLocationCoordinate2DMake(37.8230575118,-122.324867587);
-
- XCTAssertEqualWithAccuracy([sfToBerkeleyLine coordinate].latitude, sfToBerkeleyCenter.latitude, 0.0001);
- XCTAssertEqualWithAccuracy([sfToBerkeleyLine coordinate].longitude, sfToBerkeleyCenter.longitude, 0.0001);
-
-}
-
-- (void)testPolygon {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(35.090745, -85.300259),
- CLLocationCoordinate2DMake(35.092035, -85.298885),
- CLLocationCoordinate2DMake(35.090639, -85.297416),
- CLLocationCoordinate2DMake(35.089112, -85.298928)
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:numberOfCoordinates];
- polygon.title = nil;
- polygon.subtitle = @"subtitle";
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPolygon class]];
- [NSKeyedArchiver archiveRootObject:polygon toFile:filePath];
-
- MGLPolygon *unarchivedPolygon = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- [unarchivedPolygon coordinate];
-
- XCTAssertEqualObjects(polygon, unarchivedPolygon);
-
- CLLocationCoordinate2D squareCoordinates[] = {
- CLLocationCoordinate2DMake(100.0, 0.0),
- CLLocationCoordinate2DMake(101.0, 0.0),
- CLLocationCoordinate2DMake(101.0, 1.0),
- CLLocationCoordinate2DMake(100.0, 1.0),
- };
-
- NSUInteger squareCoordinatesCount = sizeof(squareCoordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolygon *squarePolygon = [MGLPolygon polygonWithCoordinates:squareCoordinates count:squareCoordinatesCount];
- CLLocationCoordinate2D squareCenter = CLLocationCoordinate2DMake(100.5, 0.5);
-
- XCTAssertEqual([squarePolygon coordinate].latitude, squareCenter.latitude);
- XCTAssertEqual([squarePolygon coordinate].longitude, squareCenter.longitude);
-
-}
-
-- (void)testPolygonWithInteriorPolygons {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 20)
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- CLLocationCoordinate2D interiorCoordinates[] = {
- CLLocationCoordinate2DMake(4, 4),
- CLLocationCoordinate2DMake(6, 6)
- };
-
- NSUInteger numberOfInteriorCoordinates = sizeof(interiorCoordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPolygon *interiorPolygon = [MGLPolygon polygonWithCoordinates:interiorCoordinates count:numberOfInteriorCoordinates];
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:numberOfCoordinates interiorPolygons:@[interiorPolygon]];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPolygon class]];
- [NSKeyedArchiver archiveRootObject:polygon toFile:filePath];
-
- MGLPolygon *unarchivedPolygon = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(polygon, unarchivedPolygon);
-}
-
-- (void)testPolylineFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 20)
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:coordinates count:numberOfCoordinates];
- polylineFeature.attributes = @{@"bbox": @[@0, @1, @2, @3]};
- polylineFeature.identifier = @"identifier";
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPolylineFeature class]];
- [NSKeyedArchiver archiveRootObject:polylineFeature toFile:filePath];
-
- MGLPolylineFeature *unarchivedPolylineFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(polylineFeature, unarchivedPolylineFeature);
-
- unarchivedPolylineFeature.attributes = @{@"bbox": @[@4, @3, @2, @1]};
-
- XCTAssertNotEqualObjects(polylineFeature, unarchivedPolylineFeature);
-}
-
-- (void)testPolygonFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 20)
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:numberOfCoordinates];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPolygonFeature class]];
- [NSKeyedArchiver archiveRootObject:polygonFeature toFile:filePath];
-
- MGLPolygonFeature *unarchivedPolygonFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(polygonFeature, unarchivedPolygonFeature);
-
- unarchivedPolygonFeature.identifier = @"test";
-
- XCTAssertNotEqualObjects(polygonFeature, unarchivedPolygonFeature);
-}
-
-- (void)testPointCollection {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 11),
- CLLocationCoordinate2DMake(20, 21),
- CLLocationCoordinate2DMake(30, 31),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPointCollection *pointCollection = [MGLPointCollection pointCollectionWithCoordinates:coordinates count:numberOfCoordinates];
- CLLocationCoordinate2D pointsCenter = CLLocationCoordinate2DMake(0, 1);
-
- XCTAssertEqual([pointCollection coordinate].latitude, pointsCenter.latitude);
- XCTAssertEqual([pointCollection coordinate].longitude, pointsCenter.longitude);
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPointCollection class]];
- [NSKeyedArchiver archiveRootObject:pointCollection toFile:filePath];
-
- MGLPointCollection *unarchivedPointCollection = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(pointCollection, unarchivedPointCollection);
-}
-
-- (void)testPointCollectionFeature {
- NSMutableArray *features = [NSMutableArray array];
- for (NSUInteger i = 0; i < 100; i++) {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- feature.coordinate = CLLocationCoordinate2DMake(arc4random() % 90, arc4random() % 180);
- [features addObject:feature];
- }
-
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 11),
- CLLocationCoordinate2DMake(20, 21),
- CLLocationCoordinate2DMake(30, 31),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPointCollectionFeature *collection = [MGLPointCollectionFeature pointCollectionWithCoordinates:coordinates count:numberOfCoordinates];
- collection.identifier = @"identifier";
- collection.attributes = @{@"bbox": @[@1, @2, @3, @4]};
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLPointCollectionFeature class]];
- [NSKeyedArchiver archiveRootObject:collection toFile:filePath];
-
- MGLPointCollectionFeature *unarchivedCollection = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(collection, unarchivedCollection);
-
- unarchivedCollection.identifier = @"newIdentifier";
-
- XCTAssertNotEqualObjects(collection, unarchivedCollection);
-}
-
-- (void)testMultiPolyline {
-
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 11),
- CLLocationCoordinate2DMake(20, 21),
- CLLocationCoordinate2DMake(30, 31),
- };
-
- CLLocationCoordinate2D line1[] = {
- CLLocationCoordinate2DMake(100, 40),
- CLLocationCoordinate2DMake(105, 45),
- CLLocationCoordinate2DMake(110, 55)
- };
-
- CLLocationCoordinate2D line2[] = {
- CLLocationCoordinate2DMake(105, 40),
- CLLocationCoordinate2DMake(110, 45),
- CLLocationCoordinate2DMake(115, 55)
- };
-
- NSUInteger road1CoordinatesCount = sizeof(line1) / sizeof(CLLocationCoordinate2D);
- NSUInteger road2CoordinatesCount = sizeof(line2) / sizeof(CLLocationCoordinate2D);
-
- MGLPolyline *road1Polyline = [MGLPolyline polylineWithCoordinates:line1 count:road1CoordinatesCount];
- MGLPolyline *road2Polyline = [MGLPolyline polylineWithCoordinates:line1 count:road2CoordinatesCount];
-
- MGLMultiPolyline *roads = [MGLMultiPolyline multiPolylineWithPolylines:@[road1Polyline, road2Polyline]];
- CLLocationCoordinate2D roadCenter = CLLocationCoordinate2DMake(100, 40);
-
- XCTAssertEqual([roads coordinate].latitude, roadCenter.latitude);
- XCTAssertEqual([roads coordinate].longitude, roadCenter.longitude);
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- NSMutableArray *polylines = [NSMutableArray array];
-
- for (NSUInteger i = 0; i < 100; i++) {
- MGLPolyline *polyline = [MGLPolyline polylineWithCoordinates:coordinates count:numberOfCoordinates];
- [polylines addObject:polyline];
- }
-
- MGLMultiPolyline *multiPolyline = [MGLMultiPolyline multiPolylineWithPolylines:polylines];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLMultiPolyline class]];
- [NSKeyedArchiver archiveRootObject:multiPolyline toFile:filePath];
-
- MGLMultiPolyline *unarchivedMultiPolyline = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- MGLMultiPolyline *anotherMultipolyline = [MGLMultiPolyline multiPolylineWithPolylines:[polylines subarrayWithRange:NSMakeRange(0, polylines.count/2)]];
-
- XCTAssertEqualObjects(multiPolyline, unarchivedMultiPolyline);
- XCTAssertNotEqualObjects(unarchivedMultiPolyline, anotherMultipolyline);
-}
-
-- (void)testMultiPolygon {
-
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0, 1),
- CLLocationCoordinate2DMake(10, 11),
- CLLocationCoordinate2DMake(20, 21),
- CLLocationCoordinate2DMake(30, 31),
- };
-
- CLLocationCoordinate2D outerSquare[] = {
- CLLocationCoordinate2DMake(100.0, 0.0),
- CLLocationCoordinate2DMake(101.0, 0.0),
- CLLocationCoordinate2DMake(101.0, 1.0),
- CLLocationCoordinate2DMake(100.0, 1.0),
- };
-
- CLLocationCoordinate2D innerSquare[] = {
- CLLocationCoordinate2DMake(100.35, 0.35),
- CLLocationCoordinate2DMake(100.65, 0.35),
- CLLocationCoordinate2DMake(100.65, 0.65),
- CLLocationCoordinate2DMake(100.35, 0.65),
- };
-
- NSUInteger outerCoordinatesCount = sizeof(outerSquare) / sizeof(CLLocationCoordinate2D);
- NSUInteger innerCoordinatesCount = sizeof(innerSquare) / sizeof(CLLocationCoordinate2D);
-
- MGLPolygon *innerPolygonSquare = [MGLPolygon polygonWithCoordinates:innerSquare count:innerCoordinatesCount];
- MGLPolygon *outerPolygonSquare = [MGLPolygon polygonWithCoordinates:outerSquare count:outerCoordinatesCount interiorPolygons:@[innerPolygonSquare]];
- MGLMultiPolygon *squares = [MGLMultiPolygon multiPolygonWithPolygons:@[outerPolygonSquare, innerPolygonSquare]];
- CLLocationCoordinate2D squareCenter = CLLocationCoordinate2DMake(100.5, 0.5);
-
- XCTAssertEqual([squares coordinate].latitude, squareCenter.latitude);
- XCTAssertEqual([squares coordinate].longitude, squareCenter.longitude);
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- NSMutableArray *polygons = [NSMutableArray array];
-
- for (NSUInteger i = 0; i < 100; i++) {
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:numberOfCoordinates];
- [polygons addObject:polygon];
- }
-
- MGLMultiPolygon *multiPolygon = [MGLMultiPolygon multiPolygonWithPolygons:polygons];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLMultiPolygon class]];
- [NSKeyedArchiver archiveRootObject:multiPolygon toFile:filePath];
-
- MGLMultiPolygon *unarchivedMultiPolygon = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- MGLMultiPolygon *anotherMultiPolygon = [MGLMultiPolygon multiPolygonWithPolygons:[polygons subarrayWithRange:NSMakeRange(0, polygons.count/2)]];
-
- XCTAssertEqualObjects(multiPolygon, unarchivedMultiPolygon);
- XCTAssertNotEqualObjects(anotherMultiPolygon, unarchivedMultiPolygon);
-
-}
-
-- (void)testShapeCollection {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(10.12315786, 11.23451186),
- CLLocationCoordinate2DMake(20.91836515, 21.93689215),
- CLLocationCoordinate2DMake(30.55697246, 31.33988123),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPolyline *polyline = [MGLPolyline polylineWithCoordinates:coordinates count:numberOfCoordinates];
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:numberOfCoordinates];
-
- MGLShapeCollection *shapeCollection = [MGLShapeCollection shapeCollectionWithShapes:@[polyline, polygon]];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLShapeCollection class]];
- [NSKeyedArchiver archiveRootObject:shapeCollection toFile:filePath];
-
- MGLShapeCollection *unarchivedShapeCollection = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- MGLShapeCollection *anotherShapeCollection = [MGLShapeCollection shapeCollectionWithShapes:@[polygon]];
-
- XCTAssertEqualObjects(shapeCollection, unarchivedShapeCollection);
- XCTAssertNotEqualObjects(shapeCollection, anotherShapeCollection);
-}
-
-- (void)testMultiPolylineFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(10.12315786, 11.23451186),
- CLLocationCoordinate2DMake(20.91836515, 21.93689215),
- CLLocationCoordinate2DMake(30.55697246, 31.33988123),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- NSMutableArray *polylines = [NSMutableArray array];
- for (NSUInteger i = 0; i < 100; i++) {
- MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:coordinates count:numberOfCoordinates];
- polylineFeature.identifier = @(arc4random() % 100).stringValue;
- [polylines addObject:polylineFeature];
- }
-
- MGLMultiPolylineFeature *multiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:polylines];
- multiPolylineFeature.attributes = @{@"bbox": @[@4, @3, @2, @1]};
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLMultiPolylineFeature class]];
- [NSKeyedArchiver archiveRootObject:multiPolylineFeature toFile:filePath];
-
- MGLMultiPolylineFeature *unarchivedMultiPolylineFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- MGLMultiPolylineFeature *anotherMultiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:[polylines subarrayWithRange:NSMakeRange(0, polylines.count/2)]];
-
- XCTAssertEqualObjects(multiPolylineFeature, unarchivedMultiPolylineFeature);
- XCTAssertNotEqualObjects(unarchivedMultiPolylineFeature, anotherMultiPolylineFeature);
-}
-
-- (void)testMultiPolygonFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(10.12315786, 11.23451185),
- CLLocationCoordinate2DMake(20.88471238, 21.93684215),
- CLLocationCoordinate2DMake(30.15697236, 31.32988123),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- NSMutableArray *polygons = [NSMutableArray array];
- for (NSUInteger i = 0; i < 100; i++ ) {
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:numberOfCoordinates];
- polygonFeature.identifier = @(arc4random_uniform(100)).stringValue;
- [polygons addObject:polygonFeature];
- }
-
- MGLMultiPolygonFeature *multiPolygonFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:polygons];
- multiPolygonFeature.attributes = @{@"bbox": @[@(arc4random_uniform(100)),
- @(arc4random_uniform(100)),
- @(arc4random_uniform(100)),
- @(arc4random_uniform(100))]};
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLMultiPolylineFeature class]];
- [NSKeyedArchiver archiveRootObject:multiPolygonFeature toFile:filePath];
-
- MGLMultiPolygonFeature *unarchivedMultiPolygonFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
- MGLMultiPolygonFeature *anotherMultiPolygonFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:[polygons subarrayWithRange:NSMakeRange(0, polygons.count/2)]];
-
- XCTAssertEqualObjects(multiPolygonFeature, unarchivedMultiPolygonFeature);
- XCTAssertNotEqualObjects(anotherMultiPolygonFeature, unarchivedMultiPolygonFeature);
-}
-
-- (void)testShapeCollectionFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(10.12315786, 11.23451186),
- CLLocationCoordinate2DMake(20.91836515, 21.93689215),
- CLLocationCoordinate2DMake(30.55697246, 31.33988123),
- };
-
- NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D);
-
- MGLPolylineFeature *polyline = [MGLPolylineFeature polylineWithCoordinates:coordinates count:numberOfCoordinates];
- MGLPolygonFeature *polygon = [MGLPolygonFeature polygonWithCoordinates:coordinates count:numberOfCoordinates];
-
- MGLShapeCollectionFeature *shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[polyline, polygon]];
- shapeCollectionFeature.identifier = @(arc4random_uniform(100)).stringValue;
- shapeCollectionFeature.attributes = @{@"bbox":@[@(arc4random_uniform(100)),
- @(arc4random_uniform(100)),
- @(arc4random_uniform(100)),
- @(arc4random_uniform(100))]};
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLShapeCollectionFeature class]];
- [NSKeyedArchiver archiveRootObject:shapeCollectionFeature toFile:filePath];
-
- MGLShapeCollectionFeature *unarchivedShapeCollectionFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(shapeCollectionFeature, unarchivedShapeCollectionFeature);
-}
-
-- (void)testAnnotationImage {
-#if TARGET_OS_IPHONE
- UIGraphicsBeginImageContext(CGSizeMake(10, 10));
- [[UIColor redColor] setFill];
- UIRectFill(CGRectMake(0, 0, 10, 10));
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-#else
- NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(10, 10)];
- [image lockFocus];
- [[NSColor redColor] drawSwatchInRect:CGRectMake(0, 0, 10, 10)];
- [image unlockFocus];
-#endif
-
- MGLAnnotationImage *annotationImage = [MGLAnnotationImage annotationImageWithImage:image reuseIdentifier:@(arc4random_uniform(100)).stringValue];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLAnnotationImage class]];
- [NSKeyedArchiver archiveRootObject:annotationImage toFile:filePath];
-
- MGLAnnotationImage *unarchivedAnnotationImage = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(annotationImage, unarchivedAnnotationImage);
-}
-
-#if TARGET_OS_IPHONE
-- (void)testAnnotationView {
- MGLAnnotationView *annotationView = [[MGLAnnotationView alloc] initWithReuseIdentifier:@"id"];
- annotationView.enabled = NO;
- annotationView.selected = YES;
- annotationView.draggable = YES;
- annotationView.centerOffset = CGVectorMake(10, 10);
- annotationView.scalesWithViewingDistance = NO;
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLAnnotationView class]];
- [NSKeyedArchiver archiveRootObject:annotationView toFile:filePath];
-
- MGLAnnotationView *unarchivedAnnotationView = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqual(annotationView.enabled, unarchivedAnnotationView.enabled);
- XCTAssertEqual(annotationView.selected, unarchivedAnnotationView.selected);
- XCTAssertEqual(annotationView.draggable, unarchivedAnnotationView.draggable);
- XCTAssertEqualObjects(NSStringFromCGVector(annotationView.centerOffset), NSStringFromCGVector(unarchivedAnnotationView.centerOffset));
- XCTAssertEqual(annotationView.scalesWithViewingDistance, unarchivedAnnotationView.scalesWithViewingDistance);
-}
-#endif
-
-#if TARGET_OS_IPHONE
-- (void)testUserLocation {
- MGLUserLocation *userLocation = [[MGLUserLocation alloc] init];
- userLocation.location = [[CLLocation alloc] initWithLatitude:1 longitude:1];
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLUserLocation class]];
- [NSKeyedArchiver archiveRootObject:userLocation toFile:filePath];
-
- MGLUserLocation *unarchivedUserLocation = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqualObjects(userLocation, unarchivedUserLocation);
- unarchivedUserLocation.location = [[CLLocation alloc] initWithLatitude:10 longitude:10];
- XCTAssertNotEqualObjects(userLocation, unarchivedUserLocation);
-}
-#endif
-
-#if TARGET_OS_IPHONE
-- (void)testUserLocationAnnotationView {
- MGLUserLocationAnnotationView *annotationView = [[MGLUserLocationAnnotationView alloc] init];
- annotationView.enabled = NO;
- annotationView.selected = YES;
- annotationView.draggable = YES;
- annotationView.centerOffset = CGVectorMake(10, 10);
- annotationView.scalesWithViewingDistance = NO;
-
- NSString *filePath = [self temporaryFilePathForClass:[MGLUserLocationAnnotationView class]];
- [NSKeyedArchiver archiveRootObject:annotationView toFile:filePath];
-
- MGLUserLocationAnnotationView *unarchivedAnnotationView = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
-
- XCTAssertEqual(annotationView.enabled, unarchivedAnnotationView.enabled);
- XCTAssertEqual(annotationView.selected, unarchivedAnnotationView.selected);
- XCTAssertEqual(annotationView.draggable, unarchivedAnnotationView.draggable);
- XCTAssertEqualObjects(NSStringFromCGVector(annotationView.centerOffset), NSStringFromCGVector(unarchivedAnnotationView.centerOffset));
- XCTAssertEqual(annotationView.scalesWithViewingDistance, unarchivedAnnotationView.scalesWithViewingDistance);
-}
-#endif
-
-@end
diff --git a/platform/darwin/test/MGLCompassDirectionFormatterTests.m b/platform/darwin/test/MGLCompassDirectionFormatterTests.m
deleted file mode 100644
index c4ccc6ac4f..0000000000
--- a/platform/darwin/test/MGLCompassDirectionFormatterTests.m
+++ /dev/null
@@ -1,88 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-@interface MGLCompassDirectionFormatterTests : XCTestCase
-
-@end
-
-@implementation MGLCompassDirectionFormatterTests
-
-- (void)testCompassDirections {
- MGLCompassDirectionFormatter *shortFormatter = [[MGLCompassDirectionFormatter alloc] init];
- shortFormatter.unitStyle = NSFormattingUnitStyleShort;
-
- MGLCompassDirectionFormatter *mediumFormatter = [[MGLCompassDirectionFormatter alloc] init];
- XCTAssertEqual(mediumFormatter.unitStyle, NSFormattingUnitStyleMedium, @"Unit style should be medium by default.");
-
- MGLCompassDirectionFormatter *longFormatter = [[MGLCompassDirectionFormatter alloc] init];
- longFormatter.unitStyle = NSFormattingUnitStyleLong;
-
- CLLocationDirection direction;
-
- direction = -45;
- XCTAssertEqualObjects(@"NW", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"northwest", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"northwest", [longFormatter stringFromDirection:direction]);
-
- direction = 0;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-
- direction = 1;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-
- direction = 10;
- XCTAssertEqualObjects(@"NbE", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north by east", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north by east", [longFormatter stringFromDirection:direction]);
-
- direction = 20;
- XCTAssertEqualObjects(@"NNE", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north-northeast", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north-northeast", [longFormatter stringFromDirection:direction]);
-
- direction = 45;
- XCTAssertEqualObjects(@"NE", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"northeast", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"northeast", [longFormatter stringFromDirection:direction]);
-
- direction = 90;
- XCTAssertEqualObjects(@"E", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"east", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"east", [longFormatter stringFromDirection:direction]);
-
- direction = 180;
- XCTAssertEqualObjects(@"S", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"south", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"south", [longFormatter stringFromDirection:direction]);
-
- direction = 270;
- XCTAssertEqualObjects(@"W", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"west", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"west", [longFormatter stringFromDirection:direction]);
-
- direction = 359.34951805867024;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-
- direction = 360;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-
- direction = 360.1;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-
- direction = 720;
- XCTAssertEqualObjects(@"N", [shortFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [mediumFormatter stringFromDirection:direction]);
- XCTAssertEqualObjects(@"north", [longFormatter stringFromDirection:direction]);
-}
-
-@end
diff --git a/platform/darwin/test/MGLComputedShapeSourceTests.m b/platform/darwin/test/MGLComputedShapeSourceTests.m
deleted file mode 100644
index 6eb45913d6..0000000000
--- a/platform/darwin/test/MGLComputedShapeSourceTests.m
+++ /dev/null
@@ -1,24 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import <Mapbox/Mapbox.h>
-
-
-@interface MGLComputedShapeSourceTests : XCTestCase
-@end
-
-@implementation MGLComputedShapeSourceTests
-
-- (void)testInitializer {
- MGLComputedShapeSource *source = [[MGLComputedShapeSource alloc] initWithIdentifier:@"id" options:@{}];
- XCTAssertNotNil(source);
- XCTAssertNotNil(source.requestQueue);
- XCTAssertNil(source.dataSource);
-}
-
-- (void)testNilOptions {
- MGLComputedShapeSource *source = [[MGLComputedShapeSource alloc] initWithIdentifier:@"id" options:nil];
- XCTAssertNotNil(source);
-}
-
-
-@end
diff --git a/platform/darwin/test/MGLCoordinateFormatterTests.m b/platform/darwin/test/MGLCoordinateFormatterTests.m
deleted file mode 100644
index ac083fa103..0000000000
--- a/platform/darwin/test/MGLCoordinateFormatterTests.m
+++ /dev/null
@@ -1,48 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-@interface MGLCoordinateFormatterTests : XCTestCase
-
-@end
-
-@implementation MGLCoordinateFormatterTests
-
-- (void)testStrings {
- MGLCoordinateFormatter *shortFormatter = [[MGLCoordinateFormatter alloc] init];
- shortFormatter.unitStyle = NSFormattingUnitStyleShort;
- XCTAssertTrue(shortFormatter.allowsSeconds, @"Arcseconds should be allowed by default.");
- XCTAssertTrue(shortFormatter.allowsMinutes, @"Arcminutes should be allowed by default.");
-
- MGLCoordinateFormatter *mediumFormatter = [[MGLCoordinateFormatter alloc] init];
- XCTAssertEqual(mediumFormatter.unitStyle, NSFormattingUnitStyleMedium, @"Unit style should be medium by default.");
-
- MGLCoordinateFormatter *longFormatter = [[MGLCoordinateFormatter alloc] init];
- longFormatter.unitStyle = NSFormattingUnitStyleLong;
-
- CLLocationCoordinate2D coordinate;
-
- coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
- XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"38°54′48″N, 77°1′57″W");
- XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"38°54′48″ north, 77°1′57″ west");
- XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"38 degrees, 54 minutes, and 48 seconds north by 77 degrees, 1 minute, and 57 seconds west");
-
- shortFormatter.allowsSeconds = NO;
- mediumFormatter.allowsSeconds = NO;
- longFormatter.allowsSeconds = NO;
-
- coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
- XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"38°55′N, 77°2′W");
- XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"38°55′ north, 77°2′ west");
- XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"38 degrees and 55 minutes north by 77 degrees and 2 minutes west");
-
- shortFormatter.allowsMinutes = NO;
- mediumFormatter.allowsMinutes = NO;
- longFormatter.allowsMinutes = NO;
-
- coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
- XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"39°N, 77°W");
- XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"39° north, 77° west");
- XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"39 degrees north by 77 degrees west");
-}
-
-@end
diff --git a/platform/darwin/test/MGLDistanceFormatterTests.m b/platform/darwin/test/MGLDistanceFormatterTests.m
deleted file mode 100644
index f15ad9d313..0000000000
--- a/platform/darwin/test/MGLDistanceFormatterTests.m
+++ /dev/null
@@ -1,30 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-@interface MGLDistanceFormatterTests : XCTestCase
-
-@end
-
-@implementation MGLDistanceFormatterTests
-
-- (void)testAbbreviatedMetricUnits {
- MGLDistanceFormatter *formatter = [[MGLDistanceFormatter alloc] init];
- formatter.numberFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_CA"];
- for (CLLocationDistance distance=0; distance <= 10000; distance+=5) {
- NSString *unit = [[formatter stringFromDistance:distance] componentsSeparatedByString:@" "][1];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF IN %@", @[@"mm", @"cm", @"m", @"km"]];
- XCTAssert([predicate evaluateWithObject:unit], @"Should only contain metric units");
- }
-}
-
-- (void)testAbbreviatedImperialUnits {
- MGLDistanceFormatter *formatter = [[MGLDistanceFormatter alloc] init];
- formatter.numberFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
- for (CLLocationDistance distance=0; distance <= 10000; distance+=5) {
- NSString *unit = [[formatter stringFromDistance:distance] componentsSeparatedByString:@" "][1];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF IN %@", @[@"ft", @"mi"]];
- XCTAssert([predicate evaluateWithObject:unit], @"Should only contain imperial units");
- }
-}
-
-@end
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift
deleted file mode 100644
index 7d6bdbed54..0000000000
--- a/platform/darwin/test/MGLDocumentationExampleTests.swift
+++ /dev/null
@@ -1,592 +0,0 @@
-import XCTest
-import Mapbox
-
-/**
- Test cases that ensure the inline examples in the project documentation
- compile.
-
- To add an example:
- 1. Add a test case named in the form testMGLClass or testMGLClass$method.
- 2. Wrap the code you'd like to appear in the documentation within the
- following comment blocks:
- ```
- //#-example-code
- ...
- //#-end-example-code
- ```
- 3. Insert an empty Swift code block inside the header file where you'd like the
- example code to be inserted.
- 4. Run `make darwin-update-examples` to extract example code from the test
- method below and insert it into the header.
- */
-class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
- var mapView: MGLMapView!
- var styleLoadingExpectation: XCTestExpectation!
- static let styleURL = Bundle(for: MGLDocumentationExampleTests.self).url(forResource: "one-liner", withExtension: "json")!
-
- // Mock MGLOfflineStorage singleton so that it doesn't start long-running tasks that could interfere with other tests.
- fileprivate class MGLOfflineStorageMock {
- static let shared = MGLOfflineStorageMock()
- func addPack(for: MGLOfflineRegion, withContext: Data, completionHandler: MGLOfflinePackAdditionCompletionHandler? = nil) {
- XCTAssert(MGLOfflineStorage.shared.responds(to: #selector(MGLOfflineStorage.shared.addPack(for:withContext:completionHandler:))))
- if let completionHandler = completionHandler {
- completionHandler(nil, NSError(domain: "MGLDocumentationExampleError", code: 0, userInfo: [NSLocalizedDescriptionKey: "\(#function) is mocked and not functional."]))
- }
- }
- }
-
- override func setUp() {
- super.setUp()
- mapView = MGLMapView(frame: CGRect(x: 0, y: 0, width: 256, height: 256), styleURL: MGLDocumentationExampleTests.styleURL)
- mapView.delegate = self
- styleLoadingExpectation = expectation(description: "Map view should finish loading style")
- waitForExpectations(timeout: 10, handler: nil)
- }
-
- override func tearDown() {
- mapView = nil
- styleLoadingExpectation = nil
- super.tearDown()
- }
-
- func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
- styleLoadingExpectation.fulfill()
- }
-
- func testMGLLight() {
- //#-example-code
- let light = MGLLight()
- let position = MGLSphericalPosition(radial: 5, azimuthal: 180, polar: 80)
- light.position = NSExpression(forConstantValue: NSValue(mglSphericalPosition: position))
- light.anchor = NSExpression(forConstantValue: "map")
- mapView.style?.light = light
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.light)
- }
-
- func testMGLTilePyramidOfflineRegion() {
- class MGLStyle {
- static var lightStyleURL: URL {
- return MGLDocumentationExampleTests.styleURL
- }
- }
-
- typealias MGLOfflineStorage = MGLOfflineStorageMock
-
- //#-example-code
- let northeast = CLLocationCoordinate2D(latitude: 40.989329, longitude: -102.062592)
- let southwest = CLLocationCoordinate2D(latitude: 36.986207, longitude: -109.049896)
- let bbox = MGLCoordinateBounds(sw: southwest, ne: northeast)
-
- let region = MGLTilePyramidOfflineRegion(styleURL: MGLStyle.lightStyleURL, bounds: bbox, fromZoomLevel: 11, toZoomLevel: 14)
- let context = "Tile Pyramid Region".data(using: .utf8)
- MGLOfflineStorage.shared.addPack(for: region, withContext: context!)
- //#-end-example-code
-
- XCTAssertNotNil(region)
- }
-
- func testMGLShapeOfflineRegion() {
- class MGLStyle {
- static var lightStyleURL: URL {
- return MGLDocumentationExampleTests.styleURL
- }
- }
-
- typealias MGLOfflineStorage = MGLOfflineStorageMock
-
- //#-example-code
- var coordinates = [
- CLLocationCoordinate2D(latitude: 45.522585, longitude: -122.685699),
- CLLocationCoordinate2D(latitude: 45.534611, longitude: -122.708873),
- CLLocationCoordinate2D(latitude: 45.530883, longitude: -122.678833)
- ]
-
- let triangle = MGLPolygon(coordinates: &coordinates, count: UInt(coordinates.count))
- let region = MGLShapeOfflineRegion(styleURL: MGLStyle.lightStyleURL, shape: triangle, fromZoomLevel: 11, toZoomLevel: 14)
- let context = "Triangle Region".data(using: .utf8)
- MGLOfflineStorage.shared.addPack(for: region, withContext: context!)
- //#-end-example-code
-
- XCTAssertNotNil(region)
- }
-
- func testMGLOfflinePack() {
- typealias MGLOfflineStorage = MGLOfflineStorageMock
-
- let northeast = CLLocationCoordinate2D(latitude: 40.989329, longitude: -102.062592)
- let southwest = CLLocationCoordinate2D(latitude: 36.986207, longitude: -109.049896)
- let bbox = MGLCoordinateBounds(sw: southwest, ne: northeast)
- let region = MGLTilePyramidOfflineRegion(styleURL: MGLDocumentationExampleTests.styleURL, bounds: bbox, fromZoomLevel: 11, toZoomLevel: 14)
- let context = "Tile Pyramid Region".data(using: .utf8)!
-
- //#-example-code
- MGLOfflineStorage.shared.addPack(for: region, withContext: context) { (pack, error) in
- guard let pack = pack else {
- // If adding the pack fails, log an error to console.
- print("Error:", error?.localizedDescription ?? "unknown error adding pack at \(#file)(\(#line)) in \(#function)")
- return
- }
-
- // Start an MGLOfflinePack download
- pack.resume()
- }
- //#-end-example-code
- }
-
- func testMGLShape$shapeWithData_encoding_error_() {
- let mainBundle = Bundle(for: MGLDocumentationExampleTests.self)
-
- //#-example-code
- let url = mainBundle.url(forResource: "amsterdam", withExtension: "geojson")!
- let data = try! Data(contentsOf: url)
- let feature = try! MGLShape(data: data, encoding: String.Encoding.utf8.rawValue) as! MGLShapeCollectionFeature
- //#-end-example-code
-
- XCTAssertNotNil(feature.shapes.first as? MGLPolygonFeature)
- }
-
- func testMGLShapeSource() {
- //#-example-code
- var coordinates: [CLLocationCoordinate2D] = [
- CLLocationCoordinate2D(latitude: 37.77, longitude: -122.42),
- CLLocationCoordinate2D(latitude: 38.91, longitude: -77.04),
- ]
- let polyline = MGLPolylineFeature(coordinates: &coordinates, count: UInt(coordinates.count))
- let source = MGLShapeSource(identifier: "lines", features: [polyline], options: nil)
- mapView.style?.addSource(source)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.source(withIdentifier: "lines"))
- }
-
- func testMGLRasterTileSource() {
- //#-example-code
- let source = MGLRasterTileSource(identifier: "clouds", tileURLTemplates: ["https://example.com/raster-tiles/{z}/{x}/{y}.png"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .tileSize: 512,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
- ]
- ])
- mapView.style?.addSource(source)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.source(withIdentifier: "clouds"))
- }
-
- func testMGLRasterDEMSource() {
- // We want to use mapbox.terrain-rgb in the example, but using a mapbox:
- // URL requires setting an access token. So this identically named
- // subclass of MGLRasterDEMSource swaps in a nonexistent URL.
- class MGLRasterDEMSource: Mapbox.MGLRasterDEMSource {
- override init(identifier: String, configurationURL: URL, tileSize: CGFloat = 256) {
- let bogusURL = URL(string: "https://example.com/raster-rgb.json")!
- super.init(identifier: identifier, configurationURL: bogusURL, tileSize: tileSize)
- }
- }
-
- //#-example-code
- let terrainRGBURL = URL(string: "mapbox://mapbox.terrain-rgb")!
- let source = MGLRasterDEMSource(identifier: "hills", configurationURL: terrainRGBURL)
- mapView.style?.addSource(source)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.source(withIdentifier: "hills"))
- }
-
- func testMGLVectorTileSource() {
- //#-example-code
- let source = MGLVectorTileSource(identifier: "pois", tileURLTemplates: ["https://example.com/vector-tiles/{z}/{x}/{y}.mvt"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
- ]
- ])
- mapView.style?.addSource(source)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.source(withIdentifier: "pois"))
- }
-
- func testMGLPolyline() {
- //#-example-code
- let coordinates = [
- CLLocationCoordinate2D(latitude: 35.68476, longitude: -220.24257),
- CLLocationCoordinate2D(latitude: 37.78428, longitude: -122.41310)
- ]
- let polyline = MGLPolyline(coordinates: coordinates, count: UInt(coordinates.count))
- //#-end-example-code
-
- XCTAssertNotNil(polyline)
- }
-
- func testMGLImageSource() {
- //#-example-code
- let coordinates = MGLCoordinateQuad(
- topLeft: CLLocationCoordinate2D(latitude: 46.437, longitude: -80.425),
- bottomLeft: CLLocationCoordinate2D(latitude: 37.936, longitude: -80.425),
- bottomRight: CLLocationCoordinate2D(latitude: 37.936, longitude: -71.516),
- topRight: CLLocationCoordinate2D(latitude: 46.437, longitude: -71.516))
- let source = MGLImageSource(identifier: "radar", coordinateQuad: coordinates, url: URL(string: "https://www.mapbox.com/mapbox-gl-js/assets/radar.gif")!)
- mapView.style?.addSource(source)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.source(withIdentifier: "radar"))
- }
-
- func testMGLCircleStyleLayer() {
- let population = MGLVectorTileSource(identifier: "population", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(population)
-
- //#-example-code
- let layer = MGLCircleStyleLayer(identifier: "circles", source: population)
- layer.sourceLayerIdentifier = "population"
- #if os(macOS)
- layer.circleColor = NSExpression(forConstantValue: NSColor.green)
- #else
- layer.circleColor = NSExpression(forConstantValue: UIColor.green)
- #endif
- layer.circleRadius = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.75, %@)",
- [12: 2,
- 22: 180])
- layer.circleOpacity = NSExpression(forConstantValue: 0.7)
- layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "circles"))
- }
-
- func testMGLLineStyleLayer() {
- let trails = MGLVectorTileSource(identifier: "trails", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(trails)
-
- //#-example-code
- let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails)
- layer.sourceLayerIdentifier = "trails"
- layer.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.5, %@)",
- [14: 2,
- 18: 20])
- #if os(macOS)
- layer.lineColor = NSExpression(forConstantValue: NSColor.brown)
- #else
- layer.lineColor = NSExpression(forConstantValue: UIColor.brown)
- #endif
- layer.lineCap = NSExpression(forConstantValue: "round")
- layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "trails-path"))
- }
-
- func testMGLFillStyleLayer() {
- let parks = MGLVectorTileSource(identifier: "parks", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(parks)
-
- //#-example-code
- let layer = MGLFillStyleLayer(identifier: "parks", source: parks)
- layer.sourceLayerIdentifier = "parks"
- #if os(macOS)
- layer.fillColor = NSExpression(forConstantValue: NSColor.green)
- #else
- layer.fillColor = NSExpression(forConstantValue: UIColor.green)
- #endif
- layer.predicate = NSPredicate(format: "type == %@", "national-park")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "parks"))
- }
-
- func testMGLFillExtrusionStyleLayer() {
- let buildings = MGLVectorTileSource(identifier: "buildings", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(buildings)
-
- //#-example-code
- let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings)
- layer.sourceLayerIdentifier = "building"
- layer.fillExtrusionHeight = NSExpression(forKeyPath: "height")
- layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height")
- layer.predicate = NSPredicate(format: "extrude == 'true'")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "buildings"))
- }
-
- func testMGLHeatmapStyleLayer() {
- let earthquakes = MGLShapeSource(identifier: "earthquakes", url: URL(string: "https://example.com/earthquakes.json")!, options: [:])
- mapView.style?.addSource(earthquakes)
-
- //#-example-code
- let layer = MGLHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes)
- layer.heatmapWeight = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:(magnitude, 'linear', nil, %@)",
- [0: 0,
- 6: 1])
- layer.heatmapIntensity = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)",
- [0: 1,
- 9: 3])
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "earthquake-heat"))
- }
-
- func testMGLSymbolStyleLayer() {
- let pois = MGLVectorTileSource(identifier: "pois", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(pois)
-
- //#-example-code
- let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois)
- layer.sourceLayerIdentifier = "pois"
- layer.iconImageName = NSExpression(forConstantValue: "coffee")
- layer.iconScale = NSExpression(forConstantValue: 0.5)
- layer.text = NSExpression(forKeyPath: "name")
- #if os(macOS)
- var vector = CGVector(dx: 10, dy: 0)
- layer.textTranslation = NSExpression(forConstantValue: NSValue(bytes: &vector, objCType: "{CGVector=dd}"))
- #else
- layer.textTranslation = NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: 10, dy: 0)))
- #endif
- layer.textJustification = NSExpression(forConstantValue: "left")
- layer.textAnchor = NSExpression(forConstantValue: "left")
- layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "coffeeshops"))
- }
-
- func testMGLRasterStyleLayer() {
- let source = MGLRasterTileSource(identifier: "clouds", tileURLTemplates: ["https://example.com/raster-tiles/{z}/{x}/{y}.png"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .tileSize: 512,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
- ]
- ])
- mapView.style?.addSource(source)
-
- //#-example-code
- let layer = MGLRasterStyleLayer(identifier: "clouds", source: source)
- layer.rasterOpacity = NSExpression(forConstantValue: 0.5)
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "clouds"))
- }
-
- func testMGLHillshadeStyleLayer() {
- let source = MGLRasterDEMSource(identifier: "dem", tileURLTemplates: ["https://example.com/raster-rgb/{z}/{x}/{y}.png"], options: [
- .minimumZoomLevel: 9,
- .maximumZoomLevel: 16,
- .tileSize: 256,
- .attributionInfos: [
- MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com"))
- ]
- ])
- mapView.style?.addSource(source)
-
- let canals = MGLVectorTileSource(identifier: "canals", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(canals)
- let canalShadowLayer = MGLLineStyleLayer(identifier: "waterway-river-canal-shadow", source: canals)
- mapView.style?.addLayer(canalShadowLayer)
-
- //#-example-code
- let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source)
- layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
- if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
- mapView.style?.insertLayer(layer, below: canalShadowLayer)
- }
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "hills"))
- }
-
- func testMGLVectorStyleLayer$predicate() {
- let terrain = MGLVectorTileSource(identifier: "terrain", configurationURL: URL(string: "https://example.com/style.json")!)
- mapView.style?.addSource(terrain)
-
- //#-example-code
- let layer = MGLLineStyleLayer(identifier: "contour", source: terrain)
- layer.sourceLayerIdentifier = "contours"
- layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= 1500.0")
- mapView.style?.addLayer(layer)
- //#-end-example-code
-
- XCTAssertNotNil(mapView.style?.layer(withIdentifier: "contour"))
- }
-
- func testMGLMapView() {
- //#-example-code
- #if os(macOS)
- class MapClickGestureRecognizer: NSClickGestureRecognizer {
- override func shouldRequireFailure(of otherGestureRecognizer: NSGestureRecognizer) -> Bool {
- return otherGestureRecognizer is NSClickGestureRecognizer
- }
- }
- #else
- let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(myCustomFunction))
- for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer {
- mapTapGestureRecognizer.require(toFail: recognizer)
- }
- mapView.addGestureRecognizer(mapTapGestureRecognizer)
- #endif
- //#-end-example-code
- }
-
- func testMGLMapSnapshotter() {
- let expectation = self.expectation(description: "MGLMapSnapshotter should produce a snapshot")
- #if os(macOS)
- var image: NSImage? {
- didSet {
- expectation.fulfill()
- }
- }
- #else
- var image: UIImage? {
- didSet {
- expectation.fulfill()
- }
- }
- #endif
-
- class MGLStyle {
- static var satelliteStreetsStyleURL: URL {
- return MGLDocumentationExampleTests.styleURL
- }
- }
-
- //#-example-code
- let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0)
-
- let options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480))
- options.zoomLevel = 10
-
- let snapshotter = MGLMapSnapshotter(options: options)
- snapshotter.start { (snapshot, error) in
- if let error = error {
- fatalError(error.localizedDescription)
- }
-
- image = snapshot?.image
- }
- //#-end-example-code
-
- wait(for: [expectation], timeout: 5)
- }
-
- func testMGLCluster() {
-
- enum ExampleError: Error {
- case unexpectedFeatureType
- case featureIsNotACluster
- }
-
- let geoJSON: [String: Any] = [
- "type" : "Feature",
- "geometry" : [
- "coordinates" : [
- -77.00896639534831,
- 38.87031006108791,
- 0.0
- ],
- "type" : "Point"
- ],
- "properties" : [
- "cluster" : true,
- "cluster_id" : 123,
- "point_count" : 4567,
- ]
- ]
-
- let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])
-
- do {
- //#-example-code
- let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue)
-
- guard let pointFeature = shape as? MGLPointFeature else {
- throw ExampleError.unexpectedFeatureType
- }
-
- // Check for cluster conformance
- guard let cluster = pointFeature as? MGLCluster else {
- throw ExampleError.featureIsNotACluster
- }
-
- // Currently the only supported class that conforms to `MGLCluster` is
- // `MGLPointFeatureCluster`
- guard cluster is MGLPointFeatureCluster else {
- throw ExampleError.unexpectedFeatureType
- }
-
- //#-end-example-code
-
- XCTAssert(cluster.clusterIdentifier == 123)
- XCTAssert(cluster.clusterPointCount == 4567)
- }
- catch let error {
- XCTFail("Example failed with thrown error: \(error)")
- }
- }
-
- func testMGLAttributedExpression() {
- //#-example-code
- #if os(macOS)
- let redColor = NSColor.red
- #else
- let redColor = UIColor.red
- #endif
- let expression = NSExpression(forConstantValue: "Foo")
- let attributes: [MGLAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic",
- "Arial Unicode MS Regular"]),
- .fontScaleAttribute: NSExpression(forConstantValue: 1.2),
- .fontColorAttribute: NSExpression(forConstantValue: redColor)]
- let attributedExpression = MGLAttributedExpression(expression, attributes:attributes)
- //#-end-example-code
-
- XCTAssertNotNil(attributedExpression)
- }
-
- func testMGLShapeSourceOptionClusterProperties() {
- //#-example-code
- let firstExpression = NSExpression(format: "sum:({$featureAccumulated, sumValue})")
- let secondExpression = NSExpression(forKeyPath: "magnitude")
- let clusterPropertiesDictionary = ["sumValue" : [firstExpression, secondExpression]]
-
- let options : [MGLShapeSourceOption : Any] = [.clustered : true,
- .clusterProperties: clusterPropertiesDictionary]
- //#-end-example-code
- let geoJSON: [String: Any] = [
- "type" : "Feature",
- "geometry" : [
- "coordinates" : [
- -77.00896639534831,
- 38.87031006108791,
- 0.0
- ],
- "type" : "Point"
- ],
- "properties" : [
- "cluster" : true,
- "cluster_id" : 123,
- "point_count" : 4567,
- ]
- ]
-
- let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])
- let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue)
- let source = MGLShapeSource(identifier: "source", shape: shape, options: options)
- mapView.style?.addSource(source)
-
- }
- // For testMGLMapView().
- func myCustomFunction() {}
-}
diff --git a/platform/darwin/test/MGLDocumentationGuideTests.swift b/platform/darwin/test/MGLDocumentationGuideTests.swift
deleted file mode 100644
index 30814c4156..0000000000
--- a/platform/darwin/test/MGLDocumentationGuideTests.swift
+++ /dev/null
@@ -1,270 +0,0 @@
-import XCTest
-import Mapbox
-
-/**
- Test cases that ensure the inline examples in the jazzy guides compile.
-
- To add an example:
- 1. Add a test case named in the form `testGuideName$ExampleName`.
- 2. Wrap the code you’d like to appear in the documentation within the
- following comment blocks:
- ```
- //#-example-code
- ...
- //#-end-example-code
- ```
- 3. Insert a call to `guideExample()` where you’d like the example code to be
- inserted in the guide’s Markdown.
- ```
- <%- guideExample('GuideName', 'ExampleName', 'iOS') %>
- ```
- 4. Run `make darwin-style-code` to extract example code from the test method
- below and insert it into the guide.
- */
-class MGLDocumentationGuideTests: XCTestCase, MGLMapViewDelegate {
- var mapView: MGLMapView!
- var styleLoadingExpectation: XCTestExpectation!
-
- override func setUp() {
- super.setUp()
- let styleURL = Bundle(for: MGLDocumentationGuideTests.self).url(forResource: "one-liner", withExtension: "json")
- mapView = MGLMapView(frame: CGRect(x: 0, y: 0, width: 256, height: 256), styleURL: styleURL)
- mapView.delegate = self
- styleLoadingExpectation = expectation(description: "Map view should finish loading style")
- waitForExpectations(timeout: 10, handler: nil)
- }
-
- override func tearDown() {
- mapView = nil
- styleLoadingExpectation = nil
- super.tearDown()
- }
-
- func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
- styleLoadingExpectation.fulfill()
- }
-
- func testMigratingToExpressions$Stops() {
- //#-example-code
- #if os(macOS)
- let stops: [NSNumber: NSColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #else
- let stops: [NSNumber: UIColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #endif
- //#-end-example-code
-
- let _ = NSExpression(format: "mgl_step:from:stops:(mag, %@, %@)",
- stops[0]!, stops)
- }
-
- func testMigratingToExpressions$Linear() {
- //#-example-code
- let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")!
- let symbolSource = MGLSource(identifier: "source")
- let symbolLayer = MGLSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource)
-
- let source = MGLShapeSource(identifier: "earthquakes", url: url, options: nil)
- mapView.style?.addSource(source)
-
- #if os(macOS)
- let stops: [NSNumber: NSColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #else
- let stops: [NSNumber: UIColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #endif
-
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
- #if os(macOS)
- layer.circleColor = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:(mag, 'linear', nil, %@)",
- stops)
- #else
- layer.circleColor = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:(mag, 'linear', nil, %@)",
- stops)
- #endif
- layer.circleRadius = NSExpression(forConstantValue: 10)
- mapView.style?.insertLayer(layer, below: symbolLayer)
- //#-end-example-code
- }
-
- func testMigratingToExpressions$LinearConvenience() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- #if os(macOS)
- let stops: [NSNumber: NSColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #else
- let stops: [NSNumber: UIColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
- #endif
-
- //#-example-code
- layer.circleColor = NSExpression(forMGLInterpolating: NSExpression(forKeyPath: "mag"), curveType: .linear, parameters: nil, stops: NSExpression(forConstantValue: stops))
- //#-end-example-code
-
- layer.circleRadius = NSExpression(forConstantValue: 10)
- mapView.style?.addLayer(layer)
-
- }
- func testMigratingToExpressions$Exponential() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- let stops = [
- 12: 0.5,
- 14: 2,
- 18: 18,
- ]
-
- layer.circleRadius = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1.5, %@)",
- stops)
- //#-end-example-code
- }
-
- func testMigratingToExpressions$ExponentialConvenience() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- let stops = [
- 12: 0.5,
- 14: 2,
- 18: 18,
- ]
-
- layer.circleRadius = NSExpression(forMGLInterpolating: NSExpression.zoomLevelVariable, curveType: MGLExpressionInterpolationMode.exponential, parameters: NSExpression(forConstantValue: 1.5), stops: NSExpression(forConstantValue: stops))
- //#-end-example-code
- }
- func testMigratingToExpressions$Interval() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- #if os(macOS)
- let stops: [NSNumber: NSColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
-
- layer.circleColor = NSExpression(format: "mgl_step:from:stops:(mag, %@, %@)",
- NSColor.green, stops)
- #else
- let stops: [NSNumber: UIColor] = [
- 0: .yellow,
- 2.5: .orange,
- 5: .red,
- 7.5: .blue,
- 10: .white,
- ]
-
- layer.circleColor = NSExpression(format: "mgl_step:from:stops:(mag, %@, %@)",
- UIColor.green, stops)
- #endif
- //#-end-example-code
- }
-
- func testMigratingToExpressions$Categorical() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- #if os(macOS)
- let defaultColor = NSColor.blue
- layer.circleColor = NSExpression(
- format: "MGL_MATCH(type, 'earthquake', %@, 'explosion', %@, 'quarry blast', %@, %@)",
- NSColor.orange, NSColor.red, NSColor.yellow, defaultColor)
- #else
- let defaultColor = UIColor.blue
- layer.circleColor = NSExpression(format: "MGL_MATCH(type, 'earthquake', %@, 'explosion', %@, 'quarry blast', %@, %@)",
- UIColor.orange, UIColor.red, UIColor.yellow, defaultColor)
- #endif
- //#-end-example-code
- }
-
- func testMigratingToExpressions$CategoricalValue() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- #if os(macOS)
- let stops : [String : NSColor] = ["earthquake" : NSColor.orange,
- "explosion" : NSColor.red,
- "quarry blast" : NSColor.yellow]
- layer.circleColor = NSExpression(
- format: "FUNCTION(%@, 'valueForKeyPath:', type)",
- stops)
- #else
- let stops : [String : UIColor] = ["earthquake" : UIColor.orange,
- "explosion" : UIColor.red,
- "quarry blast" : UIColor.yellow]
- layer.circleColor = NSExpression(
- format: "FUNCTION(%@, 'valueForKeyPath:', type)",
- stops)
- #endif
- //#-end-example-code
- }
- func testMigratingToExpressions$Identity() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- layer.circleRadius = NSExpression(forKeyPath: "mag")
- //#-end-example-code
- }
-
- func testMigratingToExpressions$Multiply() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
- let layer = MGLCircleStyleLayer(identifier: "circles", source: source)
-
- //#-example-code
- layer.circleRadius = NSExpression(forFunction: "multiply:by:", arguments: [NSExpression(forKeyPath: "mag"), 3])
- //#-end-example-code
- }
-
- func testMigratingToExpressions$Cast() {
- let source = MGLShapeSource(identifier: "circles", shape: nil, options: nil)
-
- //#-example-code
- let magnitudeLayer = MGLSymbolStyleLayer(identifier: "mag-layer", source: source)
- magnitudeLayer.text = NSExpression(format: "CAST(mag, 'NSString')")
- mapView.style?.addLayer(magnitudeLayer)
- //#-end-example-code
- }
-}
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm
deleted file mode 100644
index 4ccd7adb6e..0000000000
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ /dev/null
@@ -1,1408 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import "MGLStyleLayerTests.h"
-
-#import <string>
-
-#import "MGLTypes.h"
-#import "NSExpression+MGLPrivateAdditions.h"
-#import "NSValue+MGLAdditions.h"
-#if TARGET_OS_IPHONE
-#import "UIColor+MGLAdditions.h"
-#else
-#import "NSColor+MGLAdditions.h"
-#endif
-#import "MGLAttributedExpression.h"
-
-#define MGLAssertEqualValues(actual, expected, ...) \
- XCTAssertTrue(actual.is<__typeof__(expected)>()); \
- if (actual.is<__typeof__(expected)>()) { \
- XCTAssertEqual(actual.get<__typeof__(expected)>(), expected, __VA_ARGS__); \
- }
-
-#define MGLAssertEqualValuesWithAccuracy(actual, expected, accuracy, ...) \
- XCTAssertTrue(actual.is<__typeof__(expected)>()); \
- if (actual.is<__typeof__(expected)>()) { \
- XCTAssertEqualWithAccuracy(actual.get<__typeof__(expected)>(), expected, accuracy, __VA_ARGS__); \
- }
-
-#define MGLConstantExpression(constant) \
- [NSExpression expressionForConstantValue:constant]
-
-#define MGLAssertConstantEqualsValue(constant, value, ...) \
- MGLAssertEqualValues(MGLConstantExpression(constant).mgl_constantMBGLValue, value, __VA_ARGS__);
-
-#define MGLAssertConstantEqualsValueWithAccuracy(constant, value, accuracy, ...) \
- MGLAssertEqualValuesWithAccuracy(MGLConstantExpression(constant).mgl_constantMBGLValue, value, accuracy, __VA_ARGS__);
-
-using namespace std::string_literals;
-
-@interface MGLExpressionTests : XCTestCase
-
-@end
-
-@implementation MGLExpressionTests
-
-#pragma mark - Utility
-
-- (NSComparisonPredicate *)equalityComparisonPredicateWithRightConstantValue:(id)rightConstantValue
-{
- NSComparisonPredicate *predicate = [NSComparisonPredicate
- predicateWithLeftExpression:[NSExpression expressionForKeyPath:@"foo"]
- rightExpression:[NSExpression expressionForConstantValue:rightConstantValue]
- modifier:NSDirectPredicateModifier
- type:NSEqualToPredicateOperatorType
- options:0];
- return predicate;
-}
-
-#pragma mark - Valuation tests
-
-- (void)testStringValuation {
- MGLAssertConstantEqualsValue(@"bar", "bar"s, @"NSString should convert to std::string.");
- MGLAssertConstantEqualsValue(@"🆔🆗🇦🇶", "🆔🆗🇦🇶"s, @"NSString with non-ASCII characters should convert losslessly to std::string.");
-}
-
-- (void)testColorValuation {
- MGLAssertConstantEqualsValue([MGLColor redColor], "rgba(255,0,0,1)"s, @"MGLColor should convert to std::string containing CSS color string.");
-}
-
-- (void)testBooleanValuation {
- MGLAssertConstantEqualsValue(@NO, false, @"Boolean NSNumber should convert to bool.");
- MGLAssertConstantEqualsValue(@YES, true, @"Boolean NSNumber should convert to bool.");
-}
-
-- (void)testDoubleValuation
-{
- MGLAssertConstantEqualsValue(@DBL_MIN, DBL_MIN, @"Double NSNumber should convert to double.");
- MGLAssertConstantEqualsValue(@DBL_MAX, DBL_MAX, @"Double NSNumber should convert to double.");
-}
-
-- (void)testFloatValuation {
- // Because we can't guarantee precision when using float, and because
- // we warn the user to this effect in -[NSExpression mgl_constantMBGLValue],
- // we just check that things are in the ballpark here with integer values
- // and some lower-precision checks.
-
- MGLAssertConstantEqualsValue(@-1.0f, -1.0, @"Float NSNumber should convert to double.");
- MGLAssertConstantEqualsValue(@1.0f, 1.0, @"Float NSNumber should convert to double.");
- MGLAssertConstantEqualsValueWithAccuracy(@-23.232342f, -23.232342, 0.000001, @"Float NSNumber should convert to double.");
- MGLAssertConstantEqualsValueWithAccuracy(@23.232342f, 23.232342, 0.000001, @"Float NSNumber should convert to double.");
- MGLAssertConstantEqualsValueWithAccuracy(@-FLT_MAX, static_cast<double>(-FLT_MAX), 0.000001, @"Float NSNumber should convert to double.");
- MGLAssertConstantEqualsValueWithAccuracy(@FLT_MAX, static_cast<double>(FLT_MAX), 0.000001, @"Float NSNumber should convert to double.");
-}
-
-- (void)testIntegerValuation {
- // Negative integers should always come back as int64_t per mbgl::Value definition.
- MGLAssertConstantEqualsValue(@SHRT_MIN, static_cast<int64_t>(SHRT_MIN), @"Negative short NSNumber should convert to int64_t.");
- MGLAssertConstantEqualsValue(@INT_MIN, static_cast<int64_t>(INT_MIN), @"Negative int NSNumber should convert to int64_t.");
- MGLAssertConstantEqualsValue(@LONG_MIN, static_cast<int64_t>(LONG_MIN), @"Negative long NSNumber should convert to int64_t.");
- MGLAssertConstantEqualsValue(@LLONG_MIN, static_cast<int64_t>(LLONG_MIN), @"Negative long long NSNumber should convert to int64_t.");
- MGLAssertConstantEqualsValue(@NSIntegerMin, static_cast<int64_t>(NSIntegerMin), @"Negative NSInteger NSNumber should convert to int64_t.");
-
- // Positive integers should always come back as uint64_t per mbgl::Value definition.
- MGLAssertConstantEqualsValue(@SHRT_MAX, static_cast<uint64_t>(SHRT_MAX), @"Positive short NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@INT_MAX, static_cast<uint64_t>(INT_MAX), @"Positive int NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@LONG_MAX, static_cast<uint64_t>(LONG_MAX), @"Positive long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@LLONG_MAX, static_cast<uint64_t>(LLONG_MAX), @"Positive long long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@NSIntegerMax, static_cast<uint64_t>(NSIntegerMax), @"Positive NSInteger NSNumber should convert to uint64_t.");
-}
-
-- (void)testUnsignedIntegerValuation {
- // Zero-value integers should always come back as uint64_t per mbgl::Value definition
- // (using the interpretation that zero is not negative). We use the unsigned long long
- // value just for parity with the positive integer test.
- MGLAssertConstantEqualsValue(@(static_cast<unsigned short>(0)), static_cast<uint64_t>(0), @"Unsigned short NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@0u, static_cast<uint64_t>(0), @"Unsigned int NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@0UL, static_cast<uint64_t>(0), @"Unsigned long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@0ULL, static_cast<uint64_t>(0), @"Unsigned long long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@(static_cast<NSUInteger>(0)), static_cast<uint64_t>(0), @"Unsigned NSUInteger NSNumber should convert to uint64_t.");
-
- // Positive integers should always come back as uint64_t per mbgl::Value definition.
- // We use the unsigned long long value because it can store the highest number on
- // both 32- and 64-bit and won't overflow.
- MGLAssertConstantEqualsValue(@USHRT_MAX, static_cast<uint64_t>(USHRT_MAX), @"Unsigned short NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@UINT_MAX, static_cast<uint64_t>(UINT_MAX), @"Unsigned int NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@ULONG_MAX, static_cast<uint64_t>(ULONG_MAX), @"Unsigned long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@ULLONG_MAX, static_cast<uint64_t>(ULLONG_MAX), @"Unsigned long long NSNumber should convert to uint64_t.");
- MGLAssertConstantEqualsValue(@NSUIntegerMax, static_cast<uint64_t>(NSUIntegerMax), @"Unsigned NSUInteger NSNumber should convert to uint64_t.");
-}
-
-- (void)testNullValuation {
- mbgl::NullValue nullValue;
- MGLAssertConstantEqualsValue([NSNull null], nullValue, @"NSNull should convert to mbgl::NullValue.");
-}
-
-#pragma mark - Feature type tests
-
-- (void)testFeatureType {
- XCTAssertEqual([NSExpression expressionForConstantValue:@"Point"].mgl_featureType, mbgl::FeatureType::Point);
- XCTAssertEqual([NSExpression expressionForConstantValue:@"LineString"].mgl_featureType, mbgl::FeatureType::LineString);
- XCTAssertEqual([NSExpression expressionForConstantValue:@"Polygon"].mgl_featureType, mbgl::FeatureType::Polygon);
- XCTAssertEqual([NSExpression expressionForConstantValue:@"Unknown"].mgl_featureType, mbgl::FeatureType::Unknown);
- XCTAssertEqual([NSExpression expressionForConstantValue:@""].mgl_featureType, mbgl::FeatureType::Unknown);
-
- XCTAssertEqual([NSExpression expressionForConstantValue:@1].mgl_featureType, mbgl::FeatureType::Point);
- XCTAssertEqual([NSExpression expressionForConstantValue:@2].mgl_featureType, mbgl::FeatureType::LineString);
- XCTAssertEqual([NSExpression expressionForConstantValue:@3].mgl_featureType, mbgl::FeatureType::Polygon);
- XCTAssertEqual([NSExpression expressionForConstantValue:@0].mgl_featureType, mbgl::FeatureType::Unknown);
- XCTAssertEqual([NSExpression expressionForConstantValue:@-1].mgl_featureType, mbgl::FeatureType::Unknown);
- XCTAssertEqual([NSExpression expressionForConstantValue:@4].mgl_featureType, mbgl::FeatureType::Unknown);
-
- XCTAssertEqual([NSExpression expressionForConstantValue:nil].mgl_featureType, mbgl::FeatureType::Unknown);
-}
-
-#pragma mark - JSON expression object tests
-
-- (void)testVariableExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"zoomLevel"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"zoom"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$zoomLevel"].mgl_jsonExpressionObject, @[@"zoom"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"zoom"]], expression);
- NSMutableDictionary *context = [@{@"zoomLevel": @16} mutableCopy];
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @16);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"heatmapDensity"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"heatmap-density"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$heatmapDensity"].mgl_jsonExpressionObject, @[@"heatmap-density"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"heatmap-density"]], expression);
- NSMutableDictionary *context = [@{@"heatmapDensity": @1} mutableCopy];
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @1);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"lineProgress"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"line-progress"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$lineProgress"].mgl_jsonExpressionObject, @[@"line-progress"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"line-progress"]], expression);
- NSMutableDictionary *context = [@{@"lineProgress": @1} mutableCopy];
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @1);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"featureAccumulated"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"accumulated"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$featureAccumulated"].mgl_jsonExpressionObject, @[@"accumulated"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"accumulated"]], expression);
- }
-
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"geometryType"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"geometry-type"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$geometryType"].mgl_jsonExpressionObject, @[@"geometry-type"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"geometry-type"]], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"featureIdentifier"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"id"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$featureIdentifier"].mgl_jsonExpressionObject, @[@"id"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"id"]], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"featureAttributes"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"properties"]);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$featureAttributes"].mgl_jsonExpressionObject, @[@"properties"]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"properties"]], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForVariable:@"loremIpsum"];
- NSArray *jsonExpression = @[@"var", @"loremIpsum"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$loremIpsum"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- NSMutableDictionary *context = [@{@"loremIpsum": @"Lorem ipsum dolor sit amet"} mutableCopy];
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @"Lorem ipsum dolor sit amet");
- }
- {
- NSDictionary *context = @{@"loremIpsum": MGLConstantExpression(@"Lorem ipsum dolor sit amet")};
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_LET('loremIpsum', 'Lorem ipsum dolor sit amet', uppercase($loremIpsum))", context];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(uppercase($loremIpsum), 'mgl_expressionWithContext:', %@)", context];
- NSArray *jsonExpression = @[@"let", @"loremIpsum", @"Lorem ipsum dolor sit amet", @[@"upcase", @[@"var", @"loremIpsum"]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testConstantValueExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:nil];
- XCTAssert(expression.mgl_jsonExpressionObject == [NSNull null]);
- XCTAssert([NSExpression expressionWithFormat:@"nil"].mgl_jsonExpressionObject == [NSNull null]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:[NSNull null]], expression);
- XCTAssertNil([expression expressionValueWithObject:nil context:nil]);
- }
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:@1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @1);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1"].mgl_jsonExpressionObject, @1);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@1], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- }
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:@YES];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @YES);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"TRUE"].mgl_jsonExpressionObject, @YES);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@YES], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @YES);
- }
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:nil];
- XCTAssert(expression.mgl_jsonExpressionObject == [NSNull null]);
- XCTAssert([NSExpression expressionWithFormat:@"nil"].mgl_jsonExpressionObject == [NSNull null]);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:[NSNull null]], expression);
- XCTAssertNil([expression expressionValueWithObject:nil context:nil]);
- }
- {
- CGVector vector = CGVectorMake(1, 2);
- NSExpression *expression = [NSExpression expressionForConstantValue:@(vector)];
-#if !TARGET_OS_IPHONE
- NSArray *jsonExpression = @[@"literal", @[@1, @-2]];
-#else
- NSArray *jsonExpression = @[@"literal", @[@1, @2]];
-#endif
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- // No way to distinguish offsets from ordinary arrays in expressions.
- XCTAssertEqualObjects([[NSExpression expressionWithMGLJSONObject:jsonExpression].collection valueForKeyPath:@"constantValue"], jsonExpression.lastObject);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @(vector));
- }
- {
-#if !TARGET_OS_IPHONE
- NSEdgeInsets padding = {1, 2, 3, 4};
- NSValue *value = [NSValue valueWithEdgeInsets:padding];
-#else
- UIEdgeInsets padding = {1, 2, 3, 4};
- NSValue *value = [NSValue valueWithUIEdgeInsets:padding];
-#endif
- NSExpression *expression = [NSExpression expressionForConstantValue:value];
- NSArray *jsonExpression = @[@"literal", @[@1, @4, @3, @2]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- // No way to distinguish offsets from ordinary arrays in expressions.
- XCTAssertEqualObjects([[NSExpression expressionWithMGLJSONObject:jsonExpression].collection valueForKeyPath:@"constantValue"], jsonExpression.lastObject);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], value);
- }
- {
- MGLColor *color = [MGLColor mgl_colorWithColor:{ 255.0/255, 239.0/255, 213.0/255, 1 }]; // papayawhip
- NSExpression *expression = [NSExpression expressionForConstantValue:color];
- NSArray *jsonExpression = @[@"rgb", @255, @239, @213];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], color);
- }
- {
- // Transform color components to non-premultiplied values
- float alpha = 0.5;
- float red = (255.0 * alpha) / 255;
- float green = (239.0 * alpha) / 255;
- float blue = (213.0 * alpha) / 255;
- MGLColor *color = [MGLColor mgl_colorWithColor:{ red, green, blue, alpha }]; // papayawhip
- NSExpression *expression = [NSExpression expressionForConstantValue:color];
- NSArray *jsonExpression = @[@"rgba", @127.5, @119.5, @106.5, @0.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], color);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"noindex(513)"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @513);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @513);
- }
-}
-
-- (void)testKeyPathExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionForKeyPath:@"highway"];
- NSArray *jsonExpression = @[@"get", @"highway"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"highway"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"%@.population", @{@"population": MGLConstantExpression(@12000)}];
- NSArray *jsonExpression = @[@"get", @"population", @[@"literal", @{@"population": @12000}]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"%@.uppercase('population')", @{@"POPULATION": MGLConstantExpression(@12000)}];
- NSArray *jsonExpression = @[@"get", @[@"upcase", @"population"], @[@"literal", @{@"POPULATION": @12000}]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForKeyPath:@"lineStyle.color"];
- NSArray *jsonExpression = @[@"get", @"color", @[@"get", @"lineStyle"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForKeyPath:@"map.box.gl"];
- NSArray *jsonExpression = @[@"get", @"gl", @[@"get", @"box", @[@"get", @"map"]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testStatisticalExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"average({1, 2, 2, 3, 4, 7, 9})"];
- NSArray *jsonExpression = @[@"/", @[@"+", @1, @2, @2, @3, @4, @7, @9], @[@"length", @[@"literal", @[@1, @2, @2, @3, @4, @7, @9]]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @4);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"sum({1, 2, 2, 3, 4, 7, 9})"];
- NSArray *jsonExpression = @[@"+", @1, @2, @2, @3, @4, @7, @9];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @28);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"count({1, 2, 2, 3, 4, 7, 9})"];
- NSArray *jsonExpression = @[@"length", @[@"literal", @[@1, @2, @2, @3, @4, @7, @9]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @7);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"min({1, 2, 2, 3, 4, 7, 9})"];
- NSArray *jsonExpression = @[@"min", @1, @2, @2, @3, @4, @7, @9];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"max({1, 2, 2, 3, 4, 7, 9})"];
- NSArray *jsonExpression = @[@"max", @1, @2, @2, @3, @4, @7, @9];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @9);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testArithmeticExpressionObject {
- NSArray *arguments = @[MGLConstantExpression(@1), MGLConstantExpression(@1)];
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"add:to:" arguments:arguments];
- NSArray *jsonExpression = @[@"+", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 + 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *testExpression = [NSExpression expressionWithFormat:@"sum:({1, 1, 2})"];
- NSExpression *expression = [NSExpression expressionForFunction:@"sum:" arguments:@[[NSExpression expressionForAggregate:@[MGLConstantExpression(@1), MGLConstantExpression(@1), MGLConstantExpression(@2)]]]];
-
- NSArray *jsonExpression = @[@"+", @1, @1, @2];
-
- XCTAssertEqualObjects(testExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(expression, testExpression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"sum:" arguments:@[MGLConstantExpression(@1), MGLConstantExpression(@1), MGLConstantExpression(@2)]];
- NSArray *jsonExpression = @[@"+", @1, @1, @2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
-
- // - [NSExpression expressionWithMGLJSONObject:] creates an expression with an aggregate expression as an argument. This is not equal to an expression with an array of expressions as an argument. For testing purposes, we will compare their operands and arrays of expressions.
- NSExpression *aggregateExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
- XCTAssertEqualObjects(aggregateExpression.operand, expression.operand);
- XCTAssertEqualObjects(aggregateExpression.arguments.firstObject.collection, expression.arguments);
- }
- {
- NSArray *threeArguments = @[MGLConstantExpression(@1), MGLConstantExpression(@1), MGLConstantExpression(@1)];
- NSExpression *expression = [NSExpression expressionForFunction:@"add:to:" arguments:threeArguments];
- NSArray *jsonExpression = @[@"+", @1, @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- jsonExpression = @[@"+", @[@"+", @1, @1], @1];
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 + 1 + 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], [NSExpression expressionWithFormat:@"1 + 1 + 1"]);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"from:subtract:" arguments:arguments];
- NSArray *jsonExpression = @[@"-", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 - 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"multiply:by:" arguments:arguments];
- NSArray *jsonExpression = @[@"*", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 * 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"divide:by:" arguments:arguments];
- NSArray *jsonExpression = @[@"/", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 / 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"modulus:by:" arguments:arguments];
- NSArray *jsonExpression = @[@"%", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- // NSExpression lacks a shorthand operator for modulus.
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"max:" arguments:arguments];
- NSArray *jsonExpression = @[@"max", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
-
- NSExpression *aggregateExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
- XCTAssertEqualObjects(aggregateExpression.operand, expression.operand);
- XCTAssertEqualObjects(aggregateExpression.arguments.firstObject.collection, expression.arguments);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"min:" arguments:arguments];
- NSArray *jsonExpression = @[@"min", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
-
- NSExpression *aggregateExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
- XCTAssertEqualObjects(aggregateExpression.operand, expression.operand);
- XCTAssertEqualObjects(aggregateExpression.arguments.firstObject.collection, expression.arguments);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"ceiling:" arguments:@[MGLConstantExpression(@1.5)]];
- NSArray *jsonExpression = @[@"ceil", @1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"ceiling:" arguments:@[MGLConstantExpression(@-1.5)]];
- NSArray *jsonExpression = @[@"ceil", @-1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-1);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"ceiling:" arguments:@[MGLConstantExpression(@2)]];
- NSArray *jsonExpression = @[@"ceil", @2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"ceiling:" arguments:@[MGLConstantExpression(@-2)]];
- NSArray *jsonExpression = @[@"ceil", @-2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"trunc:" arguments:@[MGLConstantExpression(@1.5)]];
- NSArray *jsonExpression = @[@"-", @1.5, @[@"%", @1.5, @1]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"trunc:" arguments:@[MGLConstantExpression(@-1.5)]];
- NSArray *jsonExpression = @[@"-", @-1.5, @[@"%", @-1.5, @1]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-1);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"abs:" arguments:@[MGLConstantExpression(@2)]];
- NSArray *jsonExpression = @[@"abs", @2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"abs:" arguments:@[MGLConstantExpression(@-2)]];
- NSArray *jsonExpression = @[@"abs", @-2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"floor:" arguments:@[MGLConstantExpression(@1.5)]];
- NSArray *jsonExpression = @[@"floor", @1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"floor:" arguments:@[MGLConstantExpression(@-1.5)]];
- NSArray *jsonExpression = @[@"floor", @-1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"floor:" arguments:@[MGLConstantExpression(@2)]];
- NSArray *jsonExpression = @[@"floor", @2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"floor:" arguments:@[MGLConstantExpression(@-2)]];
- NSArray *jsonExpression = @[@"floor", @-2];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_round:" arguments:@[MGLConstantExpression(@1.5)]];
- NSArray *jsonExpression = @[@"round", @1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_round:" arguments:@[MGLConstantExpression(@-1.5)]];
- NSArray *jsonExpression = @[@"round", @-1.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-2);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_round:" arguments:@[MGLConstantExpression(@2.5)]];
- NSArray *jsonExpression = @[@"round", @2.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @3);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_round:" arguments:@[MGLConstantExpression(@-2.5)]];
- NSArray *jsonExpression = @[@"round", @-2.5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @-3);
- }
-}
-
-- (void)testTrigonometricExpressionObject {
- NSArray *arguments = @[MGLConstantExpression(@1), MGLConstantExpression(@1)];
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"sqrt:" arguments:arguments];
- NSArray *jsonExpression = @[@"sqrt", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"ln:" arguments:arguments];
- NSArray *jsonExpression = @[@"ln", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_log2:" arguments:@[MGLConstantExpression(@1024)]];
- NSArray *jsonExpression = @[@"log2", @1024];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @10);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"raise:toPower:" arguments:arguments];
- NSArray *jsonExpression = @[@"^", @1, @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 ** 1"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"exp:" arguments:@[MGLConstantExpression(@0)]];
- NSArray *jsonExpression = @[@"^", @[@"e"], @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:@(M_E)];
- NSArray *jsonExpression = @[@"e"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @(M_E));
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForConstantValue:@(M_PI)];
- NSArray *jsonExpression = @[@"pi"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @(M_PI));
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_acos:" arguments:@[MGLConstantExpression(@1)]];
- NSArray *jsonExpression = @[@"acos", @1];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @0);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_cos:" arguments:@[MGLConstantExpression(@0)]];
- NSArray *jsonExpression = @[@"cos", @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @1);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_asin:" arguments:@[MGLConstantExpression(@0)]];
- NSArray *jsonExpression = @[@"asin", @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @0);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_sin:" arguments:@[MGLConstantExpression(@0)]];
- NSArray *jsonExpression = @[@"sin", @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @0);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_atan:" arguments:@[MGLConstantExpression(@20)]];
- NSArray *jsonExpression = @[@"atan", @20];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- NSNumber *value = [expression expressionValueWithObject:nil context:nil];
- XCTAssertEqualWithAccuracy(value.doubleValue, 1.52, 0.001);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_tan:" arguments:@[MGLConstantExpression(@0)]];
- NSArray *jsonExpression = @[@"tan", @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @0);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testStringFormattingExpressionObject {
- NSArray *arguments = @[MGLConstantExpression(@"MacDonald")];
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION('Old', 'stringByAppendingString:', 'MacDonald')"];
- NSExpression *aftermarketExpression = [NSExpression expressionWithFormat:@"mgl_join({'Old', 'MacDonald'})"];
- NSArray *jsonExpression = @[@"concat", @"Old", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(aftermarketExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @"OldMacDonald");
- XCTAssertEqualObjects([aftermarketExpression expressionValueWithObject:nil context:nil], @"OldMacDonald");
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], aftermarketExpression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_join:" arguments:@[@"Old", @"MacDonald"]];
- NSExpression *aftermarketExpression = [NSExpression expressionWithFormat:@"mgl_join({'Old', 'MacDonald'})"];
- NSArray *jsonExpression = @[@"concat", @"Old", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
-
- XCTAssertEqualObjects(aftermarketExpression.mgl_jsonExpressionObject, expression.mgl_jsonExpressionObject);
- NSExpression *aggregateExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
- XCTAssertEqualObjects(aggregateExpression.operand, expression.operand);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"uppercase:" arguments:arguments];
- NSArray *jsonExpression = @[@"upcase", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"lowercase:" arguments:arguments];
- NSArray *jsonExpression = @[@"downcase", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"length:" arguments:arguments];
- NSArray *jsonExpression = @[@"length", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testTypeConversionExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(number, 'boolValue')"];
- NSArray *jsonExpression = @[@"to-boolean", @[@"get", @"number"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- // NSExpression is unable to evaluate -[NSNumber boolValue] by itself
- // because it returns a primitive instead of an object.
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_number')"];
- NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'doubleValue')"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'floatValue')"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'decimalValue')"].mgl_jsonExpressionObject, jsonExpression);
- // NSExpression is unable to evaluate NSNumber’s -floatValue,
- // -doubleValue, or -decimalValue by themselves because they each return
- // a primitive instead of an object.
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression],
- [NSExpression expressionWithFormat:@"CAST(postalCode, 'NSNumber')"]);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_numberWithFallbackValues:', zipCode)"];
- NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"], @[@"get", @"zipCode"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'doubleValue', zipCode)"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'floatValue', zipCode)"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'decimalValue', zipCode)"].mgl_jsonExpressionObject, jsonExpression);
- // NSExpression is unable to evaluate NSNumber’s -floatValue,
- // -doubleValue, or -decimalValue by themselves because they each return
- // a primitive instead of an object.
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(postalCode, 'NSNumber')"];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_numberWithFallbackValues:')"];
- NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:@{@"postalCode": @"02134"} context:nil], @02134);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(number, 'NSString')"];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(number, 'stringValue')"];
- NSArray *jsonExpression = @[@"to-string", @[@"get", @"number"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:@{@"number": @1.5} context:nil], @"1.5");
- XCTAssertEqualObjects([compatibilityExpression expressionValueWithObject:@{@"number": @1.5} context:nil], @"1.5");
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
-#if TARGET_OS_IPHONE
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'UIColor')"];
-#else
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'NSColor')"];
-#endif
-
- NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('to-color', x, y, z)"];
- NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"], @[@"get", @"y"], @[@"get", @"z"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(x), 'NSArray')"];
- NSArray *jsonExpression = @[@"to-rgba", @[@"get", @"x"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(%@), 'NSArray')", MGLConstantExpression(MGLColor.blueColor)];
- NSArray *jsonExpression = @[@"to-rgba", @[@"rgb", @0, @0, @255]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex('x'), 'NSArray')"];
- XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException);
- }
-}
-
-- (void)testInterpolationExpressionObject {
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@100), @10: MGLConstantExpression(@200)};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(x, 'linear', nil, %@)", stops];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(x, 'mgl_interpolateWithCurveType:parameters:stops:', 'linear', nil, %@)", stops];
- NSArray *jsonExpression = @[@"interpolate", @[@"linear"], @[@"get", @"x"], @0, @100, @10, @200];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{@1: MGLConstantExpression(@2), @3: MGLConstantExpression(@6)};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(x, 'exponential', 2, %@)", stops];
- NSArray *jsonExpression = @[@"interpolate", @[@"exponential", @2], @[@"get", @"x"], @1, @2, @3, @6];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@0), @100: MGLConstantExpression(@100)};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(x, 'cubic-bezier', { 0.42, 0, 0.58, 1 }, %@)", stops];
- NSArray *jsonExpression = @[@"interpolate", @[@"cubic-bezier", @0.42, @0, @0.58, @1], @[@"get", @"x"], @0, @0, @100, @100];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@111), @1: MGLConstantExpression(@1111)};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(x, 11, %@)", stops];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(x, 'mgl_stepWithMinimum:stops:', 11, %@)", stops];
- NSArray *jsonExpression = @[@"step", @[@"get", @"x"], @11, @0, @111, @1, @1111];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@111), @1: MGLConstantExpression(@1111)};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, 11, %@)", stops];
- NSArray *jsonExpression = @[@"step", @[@"zoom"], @11, @0, @111, @1, @1111];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(x, 'cubic-bezier', { 0.42, 0, 0.58, 1 }, %@)", stops];
- XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException);
- }
- {
- NSDictionary *stops = @{};
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, 11, %@)", stops];
- XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException);
- }
-}
-
-- (void)testMatchExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_MATCH(2 - 1, %@, %@, %@, %@, 'default')", MGLConstantExpression(@1),
- MGLConstantExpression(@"one"),
- MGLConstantExpression(@0),
- MGLConstantExpression(@"zero")];
- NSExpression *predicate = [NSExpression expressionWithFormat:@"2 - 1"];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(%@, 'mgl_match:', %@)", predicate, @[MGLConstantExpression(@1),
- MGLConstantExpression(@"one"),
- MGLConstantExpression(@0),
- MGLConstantExpression(@"zero"),
- MGLConstantExpression(@"default")]];
- NSArray *jsonExpression = @[@"match", @[@"-", @2, @1], @1, @"one", @0, @"zero", @"default"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_MATCH(2 * 1, %@, %@, 'default')", MGLConstantExpression(@1), MGLConstantExpression(@"one")];
- NSArray *jsonExpression = @[@"match", @[@"*", @2, @1], @1, @"one", @"default"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_MATCH(x, {'a', 'A'}, 'Apple', {'b', 'B'}, 'Banana', 'Kumquat')"];
- NSArray *jsonExpression = @[@"match", @[@"get", @"x"], @[@"a", @"A"], @"Apple", @[@"b", @"B"], @"Banana", @"Kumquat"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_MATCH(x, %@, 'Apple', %@, 'Banana', 'Kumquat')",
- @[@"a", @"A"], @"Bb"];
- NSArray *jsonExpression = @[@"match", @[@"get", @"x"], @[@"a", @"A"], @"Apple", @"Bb", @"Banana", @"Kumquat"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression].description, expression.description);
- }
-}
-
-- (void)testCoalesceExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_coalesce(%@)",
- @[[NSExpression expressionForKeyPath:@"x"],
- [NSExpression expressionForKeyPath:@"y"],
- [NSExpression expressionForKeyPath:@"z"],
- [NSExpression expressionForConstantValue:@0]]];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(%@, 'mgl_coalesce')", @[[NSExpression expressionForKeyPath:@"x"],
- [NSExpression expressionForKeyPath:@"y"],
- [NSExpression expressionForKeyPath:@"z"],
- [NSExpression expressionForConstantValue:@0]]];
- NSArray *jsonExpression = @[@"coalesce", @[@"get", @"x"], @[@"get", @"y"], @[@"get", @"z"], @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-
-}
-
-- (void)testConditionalExpressionObject {
- {
- NSPredicate *conditional = [NSPredicate predicateWithFormat:@"1 = 2"];
- NSExpression *trueExpression = [NSExpression expressionForConstantValue:@YES];
- NSExpression *falseExpression = [NSExpression expressionForConstantValue:@NO];
- NSExpression *expression = [NSExpression expressionForConditional:conditional trueExpression:trueExpression falseExpression:falseExpression];
- NSArray *jsonExpression = @[@"case", @[@"==", @1, @2], @YES, @NO];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithFormat:@"TERNARY(1 = 2, TRUE, FALSE)"].mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @NO);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"TERNARY(0 = 1, TRUE, TERNARY(1 = 2, TRUE, FALSE))"];
- NSArray *jsonExpression = @[@"case", @[@"==", @0, @1], @YES, @[@"case", @[@"==", @1, @2], @YES, @NO]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @NO);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_IF(%@, %@, %@)",
- [NSExpression expressionWithFormat:@"%@", [NSPredicate predicateWithFormat:@"1 = 2"]],
- MGLConstantExpression(@YES),
- MGLConstantExpression(@NO)];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(%@, 'mgl_if:', %@)", [NSPredicate predicateWithFormat:@"1 = 2"], @[MGLConstantExpression(@YES), MGLConstantExpression(@NO)]];
- NSArray *jsonExpression = @[@"case", @[@"==", @1, @2], @YES, @NO];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- expression = [NSExpression expressionWithFormat:@"TERNARY(1 = 2, YES, NO)"];
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @NO);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_IF(%@, %@, %@, %@, %@)",
- [NSExpression expressionWithFormat:@"%@", [NSPredicate predicateWithFormat:@"1 = 2"]],
- MGLConstantExpression(@YES),
- [NSExpression expressionWithFormat:@"%@", [NSPredicate predicateWithFormat:@"1 = 1"]],
- MGLConstantExpression(@YES),
- MGLConstantExpression(@NO)];
- NSArray *jsonExpression = @[@"case", @[@"==", @1, @2], @YES, @[@"==", @1, @1], @YES, @NO];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @YES);
- }
- {
- NSArray *jsonExpression = @[
- @"case",
- @[
- @"<",
- @[@"get", @"area"],
- @80000
- ],
- @[@"get", @"abbr"],
- @[@"get", @"name_en"]
- ];
- NSExpression *expression = [NSExpression expressionWithFormat:@"TERNARY(area < 80000, abbr, name_en)"];
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- }
-}
-
-- (void)testLookupExpressionObject {
- {
- NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9),
- MGLConstantExpression(@8),
- MGLConstantExpression(@7)]];
- NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:"
- arguments:@[array, MGLConstantExpression(@"FIRST")]];
- NSArray *jsonExpression = @[@"at", @0, @[ @"literal", @[@9, @8, @7]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- }
- {
- NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9),
- MGLConstantExpression(@8),
- MGLConstantExpression(@7)]];
- NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:"
- arguments:@[array, MGLConstantExpression(@"LAST")]];
- NSArray *jsonExpression = @[@"at", @[@"-", @[@"length", @[ @"literal", @[@9, @8, @7]]], @1], @[ @"literal", @[@9, @8, @7]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- }
- {
- NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9),
- MGLConstantExpression(@8),
- MGLConstantExpression(@7)]];
- NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:"
- arguments:@[array, MGLConstantExpression(@"SIZE")]];
- NSArray *jsonExpression = @[@"length", @[ @"literal", @[@9, @8, @7]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- }
- {
- NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9),
- MGLConstantExpression(@8),
- MGLConstantExpression(@7)]];
- NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:"
- arguments:@[array, MGLConstantExpression(@1)]];
- NSArray *jsonExpression = @[@"at", @1, @[ @"literal", @[@9, @8, @7]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *array = [NSExpression expressionForAggregate:@[MGLConstantExpression(@9),
- MGLConstantExpression(@8),
- MGLConstantExpression(@7)]];
- NSExpression *expression = [NSExpression expressionForFunction:@"objectFrom:withIndex:"
- arguments:@[array, [NSExpression expressionForKeyPath:@"x"]]];
- NSArray *jsonExpression = @[@"at", @[@"get", @"x"], @[ @"literal", @[@9, @8, @7]]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_does:have:"
- arguments:@[[NSExpression expressionForEvaluatedObject],
- [NSExpression expressionForConstantValue:@"x"]]];
- NSExpression *compatibilityExpression = [NSExpression expressionWithFormat:@"FUNCTION(self, 'mgl_has:', 'x')"];
- NSArray *jsonExpression = @[@"has", @"x"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_does:have:"
- arguments:@[MGLConstantExpression(@{@"x": MGLConstantExpression(@0)}),
- MGLConstantExpression(@"x")]];
- NSArray *jsonExpression = @[@"has", @"x", @[@"literal", @{@"x": @0}]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionForFunction:@"mgl_does:have:"
- arguments:@[[NSExpression expressionForVariable:@"featureAttributes"],
- [NSExpression expressionForConstantValue:@"x"]]];
- NSArray *jsonExpression = @[@"has", @"x", @[@"properties"]];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression;
- expression = [NSExpression expressionWithFormat:@"TERNARY(key != nil, 1, 0)"];
- NSArray *jsonExpression = @[@"case", @[@"!=", @[@"get", @"key"], [NSNull null]], @1, @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:@{} context:nil], @NO);
- XCTAssertEqualObjects([expression expressionValueWithObject:@{@"key": @"🗝"} context:nil], @YES);
- }
- {
- NSDictionary *dictionary = @{@"key": @"🔑"};
- NSExpression *expression;
- expression = [NSExpression expressionWithFormat:@"TERNARY(%@.key != nil, 1, 0)", dictionary];
- NSArray *jsonExpression = @[@"case", @[@"!=", @[@"get", @"key", @[@"literal", dictionary]], [NSNull null]], @1, @0];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- // The dictionary isn’t equal enough.
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression].description, expression.description);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @YES);
- }
-}
-
-- (void)testFormatExpressionObject {
- {
- MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
- fontNames:nil
- fontScale:@(1.2)];
- MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
- fontNames:nil
- fontScale:@(1.0)];
- MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
- fontNames:nil
- fontScale:@(0.8)];
- MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\r"]
- fontNames:@[]
- fontScale:nil];
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@, %@, %@, %@)",
- MGLConstantExpression(attribute1),
- MGLConstantExpression(attribute4),
- MGLConstantExpression(attribute2),
- MGLConstantExpression(attribute3)];
- NSArray *jsonExpression = @[@"format", @"foo", @{@"font-scale": @1.2}, @"\r", @{}, @"biz", @{@"font-scale": @1.0}, @"bar", @{@"font-scale": @0.8}];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
- fontNames:nil
- fontScale:@(1.2)];
- MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
- fontNames:nil
- fontScale:@(1.0)];
- MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
- fontNames:nil
- fontScale:@(0.8)];
- MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\n"]
- fontNames:@[]
- fontScale:nil];
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@, %@, %@, %@)",
- MGLConstantExpression(attribute1),
- MGLConstantExpression(attribute4),
- MGLConstantExpression(attribute2),
- MGLConstantExpression(attribute3)];
- NSArray *jsonExpression = @[@"format", @"foo", @{@"font-scale": @1.2}, @"\n", @{}, @"biz", @{@"font-scale": @1.0}, @"bar", @{@"font-scale": @0.8}];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
- fontNames:nil
- fontScale:@(1.2)];
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSExpression *compatibilityExpression = [NSExpression expressionForFunction:@"mgl_attributed:" arguments:@[MGLConstantExpression(attribute1)]];
- NSArray *jsonExpression = @[@"format", @"foo", @{@"font-scale": @1.2}];
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, expression.mgl_jsonExpressionObject);
- XCTAssertEqualObjects(compatibilityExpression, expression);
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
- MGLFontColorAttribute: MGLConstantExpression(@"yellow") }] ;
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSExpression *compatibilityExpression = [NSExpression expressionForFunction:@"mgl_attributed:" arguments:@[MGLConstantExpression(attribute1)]];
- NSArray *jsonExpression = @[ @"format", @"foo", @{ @"font-scale": @1.2, @"text-color": @"yellow" } ];
- XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, expression.mgl_jsonExpressionObject);
- XCTAssertEqualObjects(compatibilityExpression, expression);
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]] ;
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSArray *jsonExpression = @[ @"format", @"foo", @{ } ];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
- MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
- MGLFontColorAttribute: MGLConstantExpression(@"yellow"),
- MGLFontNamesAttribute: fontNames
- }] ;
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSArray *jsonExpression = @[ @"format", @"foo", @{ @"font-scale": @1.2, @"text-color": @"yellow" , @"text-font" : @[ @"literal", @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]]} ];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
- MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
- MGLFontColorAttribute: MGLConstantExpression([MGLColor redColor]),
- MGLFontNamesAttribute: fontNames
- }] ;
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSArray *jsonExpression = @[ @"format", @"foo", @{ @"font-scale": @1.2, @"text-color": @[@"rgb", @255, @0, @0] , @"text-font" : @[ @"literal", @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]]} ];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
- MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"CAST(x, 'NSString')"]
- attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
- MGLFontColorAttribute: MGLConstantExpression([MGLColor redColor]),
- MGLFontNamesAttribute: fontNames
- }] ;
- NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
-
- NSArray *jsonExpression = @[ @"format", @[@"to-string", @[@"get", @"x"]], @{ @"font-scale": @1.2, @"text-color": @[@"rgb", @255, @0, @0] , @"text-font" : @[ @"literal", @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]]} ];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
- fontNames:nil
- fontScale:@(1.2)];
- MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
- fontNames:nil
- fontScale:@(1.0)];
- MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
- fontNames:nil
- fontScale:@(0.8)];
- MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\n"]
- fontNames:@[]
- fontScale:nil];
- NSExpression *expression = [NSExpression mgl_expressionForAttributedExpressions:@[MGLConstantExpression(attribute1),
- MGLConstantExpression(attribute4),
- MGLConstantExpression(attribute2),
- MGLConstantExpression(attribute3)]];
- NSArray *jsonExpression = @[@"format", @"foo", @{@"font-scale": @1.2}, @"\n", @{}, @"biz", @{@"font-scale": @1.0}, @"bar", @{@"font-scale": @0.8}];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-- (void)testGenericExpressionObject {
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('random', 1, 2, 3, 4, 5)"];
- NSArray *jsonExpression = @[@"random", @1, @2, @3, @4, @5];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('random', 1, 2, 3, 4)"];
- XCTAssertThrowsSpecificNamed([expression expressionValueWithObject:nil context:nil], NSException, NSInvalidArgumentException);
- }
- {
- NSArray *arguments = @[
- MGLConstantExpression(@"one"), MGLConstantExpression(@1),
- [NSExpression expressionForVariable:@"one"],
- ];
- NSExpression *nullaryExpression = [NSExpression expressionForFunction:@"MGL_LET" arguments:arguments];
- NSExpression *unaryExpression = [NSExpression expressionForFunction:@"MGL_LET:" arguments:arguments];
- XCTAssertEqualObjects(nullaryExpression.mgl_jsonExpressionObject, unaryExpression.mgl_jsonExpressionObject);
- }
- {
- NSArray *arguments = @[
- [NSExpression expressionForVariable:@"x"],
- MGLConstantExpression(@YES), MGLConstantExpression(@"yes"),
- MGLConstantExpression(@NO), MGLConstantExpression(@"no"),
- ];
- NSExpression *nullaryExpression = [NSExpression expressionForFunction:@"MGL_MATCH" arguments:arguments];
- NSExpression *unaryExpression = [NSExpression expressionForFunction:@"MGL_MATCH:" arguments:arguments];
- XCTAssertEqualObjects(nullaryExpression.mgl_jsonExpressionObject, unaryExpression.mgl_jsonExpressionObject);
- }
- {
- NSArray *arguments = @[
- [NSPredicate predicateWithValue:YES],
- MGLConstantExpression(@"yes"), MGLConstantExpression(@"no"),
- ];
- NSExpression *nullaryExpression = [NSExpression expressionForFunction:@"MGL_IF" arguments:arguments];
- NSExpression *unaryExpression = [NSExpression expressionForFunction:@"MGL_IF:" arguments:arguments];
- XCTAssertEqualObjects(nullaryExpression.mgl_jsonExpressionObject, unaryExpression.mgl_jsonExpressionObject);
- }
- {
- NSArray *arguments = @[MGLConstantExpression(@"zoom")];
- NSExpression *nullaryExpression = [NSExpression expressionForFunction:@"MGL_FUNCTION" arguments:arguments];
- NSExpression *unaryExpression = [NSExpression expressionForFunction:@"MGL_FUNCTION:" arguments:arguments];
- XCTAssertEqualObjects(nullaryExpression.mgl_jsonExpressionObject, unaryExpression.mgl_jsonExpressionObject);
- }
-}
-
-#pragma mark - Localization tests
-
-- (void)testLocalization {
- {
- NSExpression *original = MGLConstantExpression(@"");
- NSExpression *expected = original;
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *original = MGLConstantExpression(@"Old MacDonald");
- NSExpression *expected = original;
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *original = MGLConstantExpression(@"{name_en}");
- NSExpression *expected = original;
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *keyExpression = [NSExpression expressionForKeyPath:@"name_en"];
- MGLAttributedExpression *attributedExpression = [MGLAttributedExpression attributedExpression:keyExpression attributes:@{}];
- NSExpression *original = [NSExpression expressionForConstantValue:attributedExpression];
-
- NSExpression *coalesceExpression = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_en", @"name"];
- MGLAttributedExpression *expectedAttributedExpression = [MGLAttributedExpression attributedExpression:coalesceExpression attributes:@{}];
- NSExpression *expected = [NSExpression expressionForConstantValue:expectedAttributedExpression];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *original = [NSExpression expressionForKeyPath:@"name_en"];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_en", @"name"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *original = [NSExpression expressionForKeyPath:@"name_en"];
- NSExpression *expected = [NSExpression expressionForKeyPath:@"name"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"mul"]], expected);
- }
- {
- NSExpression *original = [NSExpression expressionForKeyPath:@"name_en"];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_fr", @"name"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"fr-CA"]], expected);
- }
- {
- NSExpression *original = [NSExpression expressionForKeyPath:@"name_en"];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K, %K, %K})", @"name_zh-Hans", @"name_zh-CN", @"name_zh", @"name"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"zh-Hans"]], expected);
- }
- {
- NSExpression *original = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_en", @"name"];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_coalesce:({mgl_coalesce:({name_en, name}), mgl_coalesce:({name_en, name})})"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:nil], expected);
- }
- {
- NSExpression *original = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_en", @"name"];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_coalesce:({mgl_coalesce:({name_ja, name}), mgl_coalesce:({name_ja, name})})"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"ja-JP"]], expected);
- }
- {
- NSExpression *original = [NSExpression expressionForKeyPath:@"name_en"];
- NSExpression *expected = [NSExpression expressionForKeyPath:@"name"];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"tlh"]], expected);
- }
- {
- NSExpression *original = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, short, %@)", @{
- @1: [NSExpression expressionForKeyPath:@"abbr"],
- @2: @"…",
- @3: [NSExpression expressionForKeyPath:@"name_fr"],
- }];
- NSExpression *expected = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, short, %@)", @{
- @1: [NSExpression expressionForKeyPath:@"abbr"],
- @2: @"…",
- @3: [NSExpression expressionWithFormat:@"mgl_coalesce({%K, %K})", @"name_es", @"name"]
- }];
- XCTAssertEqualObjects([original mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"es-PR"]], expected);
- }
- {
- NSArray *jsonExpression = @[
- @"step",
- @[@"zoom"],
- @[
- @"case",
- @[
- @"<",
- @[
- @"to-number",
- @[@"get", @"area"]
- ],
- @80000
- ],
- @[@"get", @"abbr"],
- @[@"get", @"name_en"]
- ],
- @5, @[@"get", @"name_en"]
- ];
- NSArray *localizedJSONExpression = @[
- @"step",
- @[@"zoom"],
- @[
- @"case",
- @[
- @"<",
- @[
- @"to-number",
- @[@"get", @"area"]
- ],
- @80000
- ],
- @[@"get", @"abbr"],
- @[@"get", @"name"]
- ],
- @5, @[@"get", @"name"]
- ];
- NSExpression *expression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
- NSExpression *localizedExpression = [expression mgl_expressionLocalizedIntoLocale:[NSLocale localeWithLocaleIdentifier:@"mul"]];
- XCTAssertEqualObjects(localizedExpression.mgl_jsonExpressionObject, localizedJSONExpression);
- }
-}
-
-- (void)testConvenienceInitializers {
- {
- NSExpression *expression = [NSExpression mgl_expressionForConditional:[NSPredicate predicateWithFormat:@"1 = 2"]
- trueExpression:MGLConstantExpression(@YES)
- falseExpresssion:MGLConstantExpression(@NO)];
-
- NSArray *jsonExpression = @[@"case", @[@"==", @1, @2], @YES, @NO];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @NO);
- }
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@111), @1: MGLConstantExpression(@1111)};
- NSExpression *expression = [NSExpression mgl_expressionForSteppingExpression:[NSExpression expressionForKeyPath:@"x"]
- fromExpression:[NSExpression expressionForConstantValue:@11]
- stops:[NSExpression expressionForConstantValue:stops]];
- NSArray *jsonExpression = @[@"step", @[@"get", @"x"], @11, @0, @111, @1, @1111];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *stops = @{@0: MGLConstantExpression(@100), @10: MGLConstantExpression(@200)};
- NSExpression *expression = [NSExpression mgl_expressionForInterpolatingExpression:[NSExpression expressionForKeyPath:@"x"]
- withCurveType:MGLExpressionInterpolationModeLinear
- parameters:nil
- stops:[NSExpression expressionForConstantValue:stops]];
- NSArray *jsonExpression = @[@"interpolate", @[@"linear"], @[@"get", @"x"], @0, @100, @10, @200];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSExpression *expression = [[NSExpression expressionForConstantValue:@"Old"] mgl_expressionByAppendingExpression:[NSExpression expressionForConstantValue:@"MacDonald"]];
-
- NSArray *jsonExpression = @[@"concat", @"Old", @"MacDonald"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @"OldMacDonald");
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
- {
- NSDictionary *values = @{ MGLConstantExpression(@1): MGLConstantExpression(@"one") };
- NSExpression *expression = [NSExpression mgl_expressionForMatchingExpression:[NSExpression expressionWithFormat:@"2 * 1"]
- inDictionary:values
- defaultExpression:[NSExpression expressionForConstantValue:@"default"]];
- NSArray *jsonExpression = @[@"match", @[@"*", @2, @1], @1, @"one", @"default"];
- XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
- }
-}
-
-
-@end
diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm
deleted file mode 100644
index edc105bca4..0000000000
--- a/platform/darwin/test/MGLFeatureTests.mm
+++ /dev/null
@@ -1,364 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import <mbgl/util/geometry.hpp>
-#import "MGLFoundation_Private.h"
-#import "../../darwin/src/MGLFeature_Private.h"
-
-@interface MGLFeatureTests : XCTestCase
-
-@end
-
-@implementation MGLFeatureTests
-
-- (void)testGeometryConversion {
- std::vector<mbgl::Feature> features;
-
- mbgl::Point<double> point = { -90.066667, 29.95 };
- features.push_back(mbgl::Feature { point });
-
- mbgl::LineString<double> lineString = {
- { -84.516667, 39.1 },
- { -90.066667, 29.95 },
- };
- features.push_back(mbgl::Feature { lineString });
-
- mbgl::Polygon<double> polygon = {
- {
- { 1, 1 },
- { 4, 1 },
- { 4, 4 },
- { 1, 4 },
- },
- {
- { 2, 2 },
- { 3, 2 },
- { 3, 3 },
- { 2, 3 },
- },
- };
- features.push_back(mbgl::Feature { polygon });
-
- NSArray<MGLShape <MGLFeature> *> *shapes = MGLFeaturesFromMBGLFeatures(features);
- XCTAssertEqual(shapes.count, 3UL, @"All features should be converted into shapes");
-
- MGLPointFeature *pointShape = (MGLPointFeature *)shapes[0];
- XCTAssertTrue([pointShape isKindOfClass:[MGLPointFeature class]]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:pointShape.coordinate],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(29.95, -90.066667)]);
-
- MGLPolylineFeature *polylineShape = (MGLPolylineFeature *)shapes[1];
- XCTAssertTrue([polylineShape isKindOfClass:[MGLPolylineFeature class]]);
- XCTAssertEqual(polylineShape.pointCount, 2UL);
- CLLocationCoordinate2D polylineCoordinates[2];
- [polylineShape getCoordinates:polylineCoordinates range:NSMakeRange(0, polylineShape.pointCount)];
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polylineCoordinates[0]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(39.1, -84.516667)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polylineCoordinates[1]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(29.95, -90.066667)]);
-
- MGLPolygonFeature *polygonShape = (MGLPolygonFeature *)shapes[2];
- XCTAssertTrue([polygonShape isKindOfClass:[MGLPolygonFeature class]]);
- XCTAssertEqual(polygonShape.pointCount, 4UL);
- CLLocationCoordinate2D *polygonCoordinates = polygonShape.coordinates;
- XCTAssertNotEqual(polygonCoordinates, nil);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[0]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(1, 1)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[1]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(1, 4)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[2]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(4, 4)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[3]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(4, 1)]);
- NSArray<MGLPolygon *> *interiorPolygons = polygonShape.interiorPolygons;
- XCTAssertEqual(interiorPolygons.count, 1UL);
- MGLPolygon *interiorPolygon = interiorPolygons.firstObject;
- XCTAssertEqual(interiorPolygon.pointCount, 4UL);
- CLLocationCoordinate2D interiorPolygonCoordinates[4];
- [interiorPolygon getCoordinates:interiorPolygonCoordinates range:NSMakeRange(0, interiorPolygon.pointCount)];
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[0]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(2, 2)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[1]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(2, 3)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[2]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(3, 3)]);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[3]],
- [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(3, 2)]);
-}
-
-- (void)testClusterGeometryConversion {
- mbgl::Point<double> point = { -90.066667, 29.95 };
- mbgl::Feature pointFeature { point };
- pointFeature.id = { UINT64_MAX };
- pointFeature.properties["cluster"] = true;
- pointFeature.properties["cluster_id"] = 1ULL;
- pointFeature.properties["point_count"] = 5ULL;
-
- id<MGLFeature> feature = MGLFeatureFromMBGLFeature(pointFeature);
-
- XCTAssert([feature conformsToProtocol:@protocol(MGLFeature)]);
-
- id<MGLCluster> cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(feature, MGLCluster);
- XCTAssert(cluster);
- XCTAssert(cluster.clusterIdentifier == 1);
- XCTAssert(cluster.clusterPointCount == 5);
-
- XCTAssert([cluster isMemberOfClass:[MGLPointFeatureCluster class]]);
-}
-
-- (void)testPropertyConversion {
- std::vector<mbgl::Feature> features;
-
- mbgl::Point<double> point = { -90.066667, 29.95 };
- mbgl::Feature pointFeature { point };
- pointFeature.id = { UINT64_MAX };
- pointFeature.properties["null"] = mapbox::feature::null_value;
- pointFeature.properties["bool"] = true;
- pointFeature.properties["unsigned int"] = UINT64_MAX;
- pointFeature.properties["int"] = INT64_MIN;
- pointFeature.properties["double"] = DBL_MAX;
- pointFeature.properties["string"] = std::string("🚏");
- std::vector<bool> vector;
- vector.push_back(true);
- vector.push_back(false);
- vector.push_back(true);
- features.push_back(pointFeature);
-
- NSArray<MGLShape <MGLFeature> *> *shapes = MGLFeaturesFromMBGLFeatures(features);
- XCTAssertEqual(shapes.count, 1UL, @"All features should be converted into shapes");
-
- MGLShape <MGLFeature> *shape = shapes.firstObject;
- XCTAssertTrue([shape conformsToProtocol:@protocol(MGLFeature)]);
- XCTAssertTrue([shape isKindOfClass:[MGLShape class]]);
-
- NSNumber *identifier = shape.identifier;
- XCTAssertTrue([identifier isKindOfClass:[NSNumber class]], @"Feature identifier should be NSNumber");
- XCTAssertEqual(strcmp(identifier.objCType, @encode(uint64_t)), 0, @"Feature identifier should be 64-bit unsigned integer");
-
- NSNull *null = [shape attributeForKey:@"null"];
- XCTAssertNotNil(null);
- XCTAssertTrue([null isKindOfClass:[NSNull class]]);
- XCTAssertEqual(null, shape.attributes[@"null"]);
-
- NSNumber *boolean = [shape attributeForKey:@"bool"];
- XCTAssertNotNil(boolean);
- XCTAssertTrue([boolean isKindOfClass:[NSNumber class]]);
-#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
- XCTAssertEqual(strcmp(boolean.objCType, @encode(char)), 0, @"Boolean property should be converted to bool NSNumber");
-#else
- XCTAssertEqual(strcmp(boolean.objCType, @encode(BOOL)), 0, @"Boolean property should be converted to bool NSNumber");
-#endif
- XCTAssertTrue(boolean.boolValue);
- XCTAssertEqual(boolean, shape.attributes[@"bool"]);
-
- NSNumber *unsignedInteger = [shape attributeForKey:@"unsigned int"];
- XCTAssertNotNil(unsignedInteger);
- XCTAssertTrue([unsignedInteger isKindOfClass:[NSNumber class]]);
- XCTAssertEqual(strcmp(unsignedInteger.objCType, @encode(uint64_t)), 0, @"Unsigned integer property should be converted to unsigned long long NSNumber");
- XCTAssertEqual(unsignedInteger.unsignedLongLongValue, UINT64_MAX);
- XCTAssertEqual(unsignedInteger, shape.attributes[@"unsigned int"]);
-
- NSNumber *integer = [shape attributeForKey:@"int"];
- XCTAssertNotNil(integer);
- XCTAssertTrue([integer isKindOfClass:[NSNumber class]]);
- XCTAssertEqual(strcmp(integer.objCType, @encode(int64_t)), 0, @"Integer property should be converted to long long NSNumber");
- XCTAssertEqual(integer.longLongValue, INT64_MIN);
- XCTAssertEqual(integer, shape.attributes[@"int"]);
-
- NSNumber *floatingPointNumber = [shape attributeForKey:@"double"];
- XCTAssertNotNil(floatingPointNumber);
- XCTAssertTrue([floatingPointNumber isKindOfClass:[NSNumber class]]);
- XCTAssertEqual(strcmp(floatingPointNumber.objCType, @encode(double)), 0, @"Floating-point number property should be converted to double NSNumber");
- XCTAssertEqual(floatingPointNumber.doubleValue, DBL_MAX);
- XCTAssertEqual(floatingPointNumber, shape.attributes[@"double"]);
-
- NSString *string = [shape attributeForKey:@"string"];
- XCTAssertNotNil(string);
- XCTAssertTrue([string isKindOfClass:[NSString class]]);
- XCTAssertEqualObjects(string, @"🚏");
- XCTAssertEqual(string, shape.attributes[@"string"]);
-}
-
-- (void)testPointFeatureGeoJSONDictionary {
- MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init];
- CLLocationCoordinate2D coordinate = { 10, 10 };
- pointFeature.coordinate = coordinate;
-
- // A GeoJSON feature
- // when there are no identifier or properties
- NSDictionary *geoJSONFeature = [pointFeature geoJSONDictionary];
-
- // it has the correct type
- XCTAssertEqualObjects(geoJSONFeature[@"type"], @"Feature");
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"Point",
- @"coordinates": @[@(coordinate.longitude), @(coordinate.latitude)]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
- // it has no "id" key (or value)
- XCTAssertNil(geoJSONFeature[@"id"]);
- // it has a null representation of the properties object
- XCTAssertEqualObjects(geoJSONFeature[@"properties"], @{});
-
- // when there is a string identifier
- pointFeature.identifier = @"string-id";
-
- // it has the identifier in the result
- geoJSONFeature = [pointFeature geoJSONDictionary];
- XCTAssertEqualObjects(geoJSONFeature[@"id"], pointFeature.identifier);
-
- // when there are properties
- pointFeature.attributes = @{@"name": @"name-value"};
-
- // it has the properties value in the result
- geoJSONFeature = [pointFeature geoJSONDictionary];
- XCTAssertEqualObjects(geoJSONFeature[@"properties"], pointFeature.attributes);
-}
-
-- (void)testPolylineFeatureGeoJSONDictionary {
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coords[] = { coord1, coord2 };
- MGLPolylineFeature *polyLineFeature = [MGLPolylineFeature polylineWithCoordinates:coords count:2];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [polyLineFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"LineString",
- @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)]]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-}
-
-- (void)testPolygonFeatureGeoJSONDictionary {
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coord3 = { 0, 0 };
- CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 };
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coords count:3];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [polygonFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"Polygon",
- @"coordinates": @[@[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]]]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-}
-
-- (void)testMultiPolylineFeatureGeoJSONDictionary {
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coord3 = { 0, 0 };
- CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 };
-
- MGLPolyline *polyLine1 = [MGLPolyline polylineWithCoordinates:coords count:3];
- MGLPolyline *polyLine2 = [MGLPolyline polylineWithCoordinates:coords count:3];
-
- MGLMultiPolylineFeature *multiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:@[polyLine1, polyLine2]];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [multiPolylineFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"MultiLineString",
- @"coordinates": @[@[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]],
- @[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]]]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-}
-
-- (void)testMultiPolygonFeatureGeoJSONDictionary {
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coord3 = { 0, 0 };
- CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 };
-
- MGLPolygon *polygon1 = [MGLPolygon polygonWithCoordinates:coords count:3];
- MGLPolygon *polygon2 = [MGLPolygon polygonWithCoordinates:coords count:3];
-
- MGLMultiPolygonFeature *multiPolylineFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:@[polygon1, polygon2]];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [multiPolylineFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"MultiPolygon",
- @"coordinates": @[
- @[@[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]]],
- @[@[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]]]]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-}
-
-- (void)testPointCollectionFeatureGeoJSONDictionary {
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coord3 = { 0, 0 };
- CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 };
- MGLPointCollectionFeature *pointCollectionFeature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coords count:3];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [pointCollectionFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"MultiPoint",
- @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)],
- @[@(coord3.longitude), @(coord3.latitude)]]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-
-}
-
-- (void)testShapeCollectionFeatureGeoJSONDictionary {
- MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init];
- CLLocationCoordinate2D pointCoordinate = { 10, 10 };
- pointFeature.coordinate = pointCoordinate;
-
- CLLocationCoordinate2D coord1 = { 0, 0 };
- CLLocationCoordinate2D coord2 = { 10, 10 };
- CLLocationCoordinate2D coords[] = { coord1, coord2 };
- MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:coords count:2];
-
- MGLShapeCollectionFeature *shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[pointFeature, polylineFeature]];
-
- // A GeoJSON feature
- NSDictionary *geoJSONFeature = [shapeCollectionFeature geoJSONDictionary];
-
- // it has the correct geometry
- NSDictionary *expectedGeometry = @{@"type": @"GeometryCollection",
- @"geometries": @[
- @{ @"geometry": @{@"type": @"Point",
- @"coordinates": @[@(pointCoordinate.longitude), @(pointCoordinate.latitude)]},
- @"properties": @{},
- @"type": @"Feature",
- },
- @{ @"geometry": @{@"type": @"LineString",
- @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)],
- @[@(coord2.longitude), @(coord2.latitude)]]},
- @"properties": @{},
- @"type": @"Feature",
- }
- ]
- };
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-
- // When the shape collection is created with an empty array of shapes
- shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[]];
-
- // it has the correct (empty) geometry
- geoJSONFeature = [shapeCollectionFeature geoJSONDictionary];
- expectedGeometry = @{@"type": @"GeometryCollection",
- @"geometries": @[]};
- XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry);
-}
-
-@end
diff --git a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm b/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm
deleted file mode 100644
index 8dfc077777..0000000000
--- a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm
+++ /dev/null
@@ -1,541 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/fill_extrusion_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLFillExtrusionLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLFillExtrusionLayerTests
-
-+ (NSString *)layerType {
- return @"fill-extrusion";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill-extrusion");
- auto rawLayer = static_cast<mbgl::style::FillExtrusionLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // fill-extrusion-base
- {
- XCTAssertTrue(rawLayer->getFillExtrusionBase().isUndefined(),
- @"fill-extrusion-base should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionBase;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.fillExtrusionBase = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
- @"Setting fillExtrusionBase to a constant value expression should update fill-extrusion-base.");
- XCTAssertEqualObjects(layer.fillExtrusionBase, constantExpression,
- @"fillExtrusionBase should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionBase = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
- @"Setting fillExtrusionBase to a camera expression should update fill-extrusion-base.");
- XCTAssertEqualObjects(layer.fillExtrusionBase, functionExpression,
- @"fillExtrusionBase should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillExtrusionBase = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
- @"Setting fillExtrusionBase to a data expression should update fill-extrusion-base.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionBase, pedanticFunctionExpression,
- @"fillExtrusionBase should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillExtrusionBase = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
- @"Setting fillExtrusionBase to a camera-data expression should update fill-extrusion-base.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionBase, pedanticFunctionExpression,
- @"fillExtrusionBase should round-trip camera-data expressions.");
-
- layer.fillExtrusionBase = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionBase().isUndefined(),
- @"Unsetting fillExtrusionBase should return fill-extrusion-base to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionBase, defaultExpression,
- @"fillExtrusionBase should return the default value after being unset.");
- // Transition property test
- layer.fillExtrusionBaseTransition = transitionTest;
- auto toptions = rawLayer->getFillExtrusionBaseTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillExtrusionBaseTransition = layer.fillExtrusionBaseTransition;
- XCTAssertEqual(fillExtrusionBaseTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillExtrusionBaseTransition.duration, transitionTest.duration);
- }
-
- // fill-extrusion-color
- {
- XCTAssertTrue(rawLayer->getFillExtrusionColor().isUndefined(),
- @"fill-extrusion-color should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.fillExtrusionColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
- @"Setting fillExtrusionColor to a constant value expression should update fill-extrusion-color.");
- XCTAssertEqualObjects(layer.fillExtrusionColor, constantExpression,
- @"fillExtrusionColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
- @"Setting fillExtrusionColor to a camera expression should update fill-extrusion-color.");
- XCTAssertEqualObjects(layer.fillExtrusionColor, functionExpression,
- @"fillExtrusionColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillExtrusionColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
- @"Setting fillExtrusionColor to a data expression should update fill-extrusion-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionColor, pedanticFunctionExpression,
- @"fillExtrusionColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillExtrusionColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
- @"Setting fillExtrusionColor to a camera-data expression should update fill-extrusion-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionColor, pedanticFunctionExpression,
- @"fillExtrusionColor should round-trip camera-data expressions.");
-
- layer.fillExtrusionColor = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionColor().isUndefined(),
- @"Unsetting fillExtrusionColor should return fill-extrusion-color to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionColor, defaultExpression,
- @"fillExtrusionColor should return the default value after being unset.");
- // Transition property test
- layer.fillExtrusionColorTransition = transitionTest;
- auto toptions = rawLayer->getFillExtrusionColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillExtrusionColorTransition = layer.fillExtrusionColorTransition;
- XCTAssertEqual(fillExtrusionColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillExtrusionColorTransition.duration, transitionTest.duration);
- }
-
- // fill-extrusion-vertical-gradient
- {
- XCTAssertTrue(rawLayer->getFillExtrusionVerticalGradient().isUndefined(),
- @"fill-extrusion-vertical-gradient should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionHasVerticalGradient;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"];
- layer.fillExtrusionHasVerticalGradient = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { false };
- XCTAssertEqual(rawLayer->getFillExtrusionVerticalGradient(), propertyValue,
- @"Setting fillExtrusionHasVerticalGradient to a constant value expression should update fill-extrusion-vertical-gradient.");
- XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, constantExpression,
- @"fillExtrusionHasVerticalGradient should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"false"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionHasVerticalGradient = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(false), 18.0, literal(false))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionVerticalGradient(), propertyValue,
- @"Setting fillExtrusionHasVerticalGradient to a camera expression should update fill-extrusion-vertical-gradient.");
- XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, functionExpression,
- @"fillExtrusionHasVerticalGradient should round-trip camera expressions.");
-
-
- layer.fillExtrusionHasVerticalGradient = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionVerticalGradient().isUndefined(),
- @"Unsetting fillExtrusionHasVerticalGradient should return fill-extrusion-vertical-gradient to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, defaultExpression,
- @"fillExtrusionHasVerticalGradient should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionHasVerticalGradient = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionHasVerticalGradient = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // fill-extrusion-height
- {
- XCTAssertTrue(rawLayer->getFillExtrusionHeight().isUndefined(),
- @"fill-extrusion-height should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionHeight;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.fillExtrusionHeight = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
- @"Setting fillExtrusionHeight to a constant value expression should update fill-extrusion-height.");
- XCTAssertEqualObjects(layer.fillExtrusionHeight, constantExpression,
- @"fillExtrusionHeight should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionHeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
- @"Setting fillExtrusionHeight to a camera expression should update fill-extrusion-height.");
- XCTAssertEqualObjects(layer.fillExtrusionHeight, functionExpression,
- @"fillExtrusionHeight should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillExtrusionHeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
- @"Setting fillExtrusionHeight to a data expression should update fill-extrusion-height.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionHeight, pedanticFunctionExpression,
- @"fillExtrusionHeight should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillExtrusionHeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
- @"Setting fillExtrusionHeight to a camera-data expression should update fill-extrusion-height.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillExtrusionHeight, pedanticFunctionExpression,
- @"fillExtrusionHeight should round-trip camera-data expressions.");
-
- layer.fillExtrusionHeight = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionHeight().isUndefined(),
- @"Unsetting fillExtrusionHeight should return fill-extrusion-height to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionHeight, defaultExpression,
- @"fillExtrusionHeight should return the default value after being unset.");
- // Transition property test
- layer.fillExtrusionHeightTransition = transitionTest;
- auto toptions = rawLayer->getFillExtrusionHeightTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillExtrusionHeightTransition = layer.fillExtrusionHeightTransition;
- XCTAssertEqual(fillExtrusionHeightTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillExtrusionHeightTransition.duration, transitionTest.duration);
- }
-
- // fill-extrusion-opacity
- {
- XCTAssertTrue(rawLayer->getFillExtrusionOpacity().isUndefined(),
- @"fill-extrusion-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.fillExtrusionOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue,
- @"Setting fillExtrusionOpacity to a constant value expression should update fill-extrusion-opacity.");
- XCTAssertEqualObjects(layer.fillExtrusionOpacity, constantExpression,
- @"fillExtrusionOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue,
- @"Setting fillExtrusionOpacity to a camera expression should update fill-extrusion-opacity.");
- XCTAssertEqualObjects(layer.fillExtrusionOpacity, functionExpression,
- @"fillExtrusionOpacity should round-trip camera expressions.");
-
-
- layer.fillExtrusionOpacity = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionOpacity().isUndefined(),
- @"Unsetting fillExtrusionOpacity should return fill-extrusion-opacity to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionOpacity, defaultExpression,
- @"fillExtrusionOpacity should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.fillExtrusionOpacityTransition = transitionTest;
- auto toptions = rawLayer->getFillExtrusionOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillExtrusionOpacityTransition = layer.fillExtrusionOpacityTransition;
- XCTAssertEqual(fillExtrusionOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillExtrusionOpacityTransition.duration, transitionTest.duration);
- }
-
- // fill-extrusion-pattern
- {
- XCTAssertTrue(rawLayer->getFillExtrusionPattern().isUndefined(),
- @"fill-extrusion-pattern should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionPattern;
-
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Fill Extrusion Pattern"];
- layer.fillExtrusionPattern = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Image> propertyValue = { "Fill Extrusion Pattern" };
- XCTAssertEqual(rawLayer->getFillExtrusionPattern(), propertyValue,
- @"Setting fillExtrusionPattern to a constant value expression should update fill-extrusion-pattern.");
- XCTAssertEqualObjects(layer.fillExtrusionPattern, constantExpression,
- @"fillExtrusionPattern should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Fill Extrusion Pattern')"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionPattern = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- step(zoom(), image(literal("Fill Extrusion Pattern")), 18.0, image(literal("Fill Extrusion Pattern")))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionPattern(), propertyValue,
- @"Setting fillExtrusionPattern to a camera expression should update fill-extrusion-pattern.");
- XCTAssertEqualObjects(layer.fillExtrusionPattern, functionExpression,
- @"fillExtrusionPattern should round-trip camera expressions.");
-
-
- layer.fillExtrusionPattern = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionPattern().isUndefined(),
- @"Unsetting fillExtrusionPattern should return fill-extrusion-pattern to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionPattern, defaultExpression,
- @"fillExtrusionPattern should return the default value after being unset.");
- // Transition property test
- layer.fillExtrusionPatternTransition = transitionTest;
- auto toptions = rawLayer->getFillExtrusionPatternTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillExtrusionPatternTransition = layer.fillExtrusionPatternTransition;
- XCTAssertEqual(fillExtrusionPatternTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillExtrusionPatternTransition.duration, transitionTest.duration);
- }
-
- // fill-extrusion-translate
- {
- XCTAssertTrue(rawLayer->getFillExtrusionTranslate().isUndefined(),
- @"fill-extrusion-translate should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.fillExtrusionTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getFillExtrusionTranslate(), propertyValue,
- @"Setting fillExtrusionTranslation to a constant value expression should update fill-extrusion-translate.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslation, constantExpression,
- @"fillExtrusionTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionTranslate(), propertyValue,
- @"Setting fillExtrusionTranslation to a camera expression should update fill-extrusion-translate.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslation, functionExpression,
- @"fillExtrusionTranslation should round-trip camera expressions.");
-
-
- layer.fillExtrusionTranslation = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionTranslate().isUndefined(),
- @"Unsetting fillExtrusionTranslation should return fill-extrusion-translate to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslation, defaultExpression,
- @"fillExtrusionTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // fill-extrusion-translate-anchor
- {
- XCTAssertTrue(rawLayer->getFillExtrusionTranslateAnchor().isUndefined(),
- @"fill-extrusion-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.fillExtrusionTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.fillExtrusionTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getFillExtrusionTranslateAnchor(), propertyValue,
- @"Setting fillExtrusionTranslationAnchor to a constant value expression should update fill-extrusion-translate-anchor.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, constantExpression,
- @"fillExtrusionTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillExtrusionTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillExtrusionTranslateAnchor(), propertyValue,
- @"Setting fillExtrusionTranslationAnchor to a camera expression should update fill-extrusion-translate-anchor.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, functionExpression,
- @"fillExtrusionTranslationAnchor should round-trip camera expressions.");
-
-
- layer.fillExtrusionTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getFillExtrusionTranslateAnchor().isUndefined(),
- @"Unsetting fillExtrusionTranslationAnchor should return fill-extrusion-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, defaultExpression,
- @"fillExtrusionTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"fill-extrusion-base" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-color" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-has-vertical-gradient" isBoolean:YES];
- [self testPropertyName:@"fill-extrusion-height" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-opacity" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-pattern" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-translation" isBoolean:NO];
- [self testPropertyName:@"fill-extrusion-translation-anchor" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLFillExtrusionTranslationAnchor:MGLFillExtrusionTranslationAnchorMap].MGLFillExtrusionTranslationAnchorValue, MGLFillExtrusionTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLFillExtrusionTranslationAnchor:MGLFillExtrusionTranslationAnchorViewport].MGLFillExtrusionTranslationAnchorValue, MGLFillExtrusionTranslationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLFillStyleLayerTests.mm b/platform/darwin/test/MGLFillStyleLayerTests.mm
deleted file mode 100644
index e37bd537a7..0000000000
--- a/platform/darwin/test/MGLFillStyleLayerTests.mm
+++ /dev/null
@@ -1,487 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/fill_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLFillLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLFillLayerTests
-
-+ (NSString *)layerType {
- return @"fill";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill");
- auto rawLayer = static_cast<mbgl::style::FillLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // fill-antialias
- {
- XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(),
- @"fill-antialias should be unset initially.");
- NSExpression *defaultExpression = layer.fillAntialiased;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"];
- layer.fillAntialiased = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { false };
- XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue,
- @"Setting fillAntialiased to a constant value expression should update fill-antialias.");
- XCTAssertEqualObjects(layer.fillAntialiased, constantExpression,
- @"fillAntialiased should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"false"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillAntialiased = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(false), 18.0, literal(false))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue,
- @"Setting fillAntialiased to a camera expression should update fill-antialias.");
- XCTAssertEqualObjects(layer.fillAntialiased, functionExpression,
- @"fillAntialiased should round-trip camera expressions.");
-
-
- layer.fillAntialiased = nil;
- XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(),
- @"Unsetting fillAntialiased should return fill-antialias to the default value.");
- XCTAssertEqualObjects(layer.fillAntialiased, defaultExpression,
- @"fillAntialiased should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // fill-color
- {
- XCTAssertTrue(rawLayer->getFillColor().isUndefined(),
- @"fill-color should be unset initially.");
- NSExpression *defaultExpression = layer.fillColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.fillColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
- @"Setting fillColor to a constant value expression should update fill-color.");
- XCTAssertEqualObjects(layer.fillColor, constantExpression,
- @"fillColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
- @"Setting fillColor to a camera expression should update fill-color.");
- XCTAssertEqualObjects(layer.fillColor, functionExpression,
- @"fillColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
- @"Setting fillColor to a data expression should update fill-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillColor, pedanticFunctionExpression,
- @"fillColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
- @"Setting fillColor to a camera-data expression should update fill-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillColor, pedanticFunctionExpression,
- @"fillColor should round-trip camera-data expressions.");
-
- layer.fillColor = nil;
- XCTAssertTrue(rawLayer->getFillColor().isUndefined(),
- @"Unsetting fillColor should return fill-color to the default value.");
- XCTAssertEqualObjects(layer.fillColor, defaultExpression,
- @"fillColor should return the default value after being unset.");
- // Transition property test
- layer.fillColorTransition = transitionTest;
- auto toptions = rawLayer->getFillColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillColorTransition = layer.fillColorTransition;
- XCTAssertEqual(fillColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillColorTransition.duration, transitionTest.duration);
- }
-
- // fill-opacity
- {
- XCTAssertTrue(rawLayer->getFillOpacity().isUndefined(),
- @"fill-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.fillOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.fillOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
- @"Setting fillOpacity to a constant value expression should update fill-opacity.");
- XCTAssertEqualObjects(layer.fillOpacity, constantExpression,
- @"fillOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
- @"Setting fillOpacity to a camera expression should update fill-opacity.");
- XCTAssertEqualObjects(layer.fillOpacity, functionExpression,
- @"fillOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
- @"Setting fillOpacity to a data expression should update fill-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillOpacity, pedanticFunctionExpression,
- @"fillOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
- @"Setting fillOpacity to a camera-data expression should update fill-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillOpacity, pedanticFunctionExpression,
- @"fillOpacity should round-trip camera-data expressions.");
-
- layer.fillOpacity = nil;
- XCTAssertTrue(rawLayer->getFillOpacity().isUndefined(),
- @"Unsetting fillOpacity should return fill-opacity to the default value.");
- XCTAssertEqualObjects(layer.fillOpacity, defaultExpression,
- @"fillOpacity should return the default value after being unset.");
- // Transition property test
- layer.fillOpacityTransition = transitionTest;
- auto toptions = rawLayer->getFillOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillOpacityTransition = layer.fillOpacityTransition;
- XCTAssertEqual(fillOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillOpacityTransition.duration, transitionTest.duration);
- }
-
- // fill-outline-color
- {
- XCTAssertTrue(rawLayer->getFillOutlineColor().isUndefined(),
- @"fill-outline-color should be unset initially.");
- NSExpression *defaultExpression = layer.fillOutlineColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.fillOutlineColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
- @"Setting fillOutlineColor to a constant value expression should update fill-outline-color.");
- XCTAssertEqualObjects(layer.fillOutlineColor, constantExpression,
- @"fillOutlineColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillOutlineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
- @"Setting fillOutlineColor to a camera expression should update fill-outline-color.");
- XCTAssertEqualObjects(layer.fillOutlineColor, functionExpression,
- @"fillOutlineColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.fillOutlineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
- @"Setting fillOutlineColor to a data expression should update fill-outline-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.fillOutlineColor, pedanticFunctionExpression,
- @"fillOutlineColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.fillOutlineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
- @"Setting fillOutlineColor to a camera-data expression should update fill-outline-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.fillOutlineColor, pedanticFunctionExpression,
- @"fillOutlineColor should round-trip camera-data expressions.");
-
- layer.fillOutlineColor = nil;
- XCTAssertTrue(rawLayer->getFillOutlineColor().isUndefined(),
- @"Unsetting fillOutlineColor should return fill-outline-color to the default value.");
- XCTAssertEqualObjects(layer.fillOutlineColor, defaultExpression,
- @"fillOutlineColor should return the default value after being unset.");
- // Transition property test
- layer.fillOutlineColorTransition = transitionTest;
- auto toptions = rawLayer->getFillOutlineColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillOutlineColorTransition = layer.fillOutlineColorTransition;
- XCTAssertEqual(fillOutlineColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillOutlineColorTransition.duration, transitionTest.duration);
- }
-
- // fill-pattern
- {
- XCTAssertTrue(rawLayer->getFillPattern().isUndefined(),
- @"fill-pattern should be unset initially.");
- NSExpression *defaultExpression = layer.fillPattern;
-
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Fill Pattern"];
- layer.fillPattern = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Image> propertyValue = { "Fill Pattern" };
- XCTAssertEqual(rawLayer->getFillPattern(), propertyValue,
- @"Setting fillPattern to a constant value expression should update fill-pattern.");
- XCTAssertEqualObjects(layer.fillPattern, constantExpression,
- @"fillPattern should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Fill Pattern')"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillPattern = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- step(zoom(), image(literal("Fill Pattern")), 18.0, image(literal("Fill Pattern")))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillPattern(), propertyValue,
- @"Setting fillPattern to a camera expression should update fill-pattern.");
- XCTAssertEqualObjects(layer.fillPattern, functionExpression,
- @"fillPattern should round-trip camera expressions.");
-
-
- layer.fillPattern = nil;
- XCTAssertTrue(rawLayer->getFillPattern().isUndefined(),
- @"Unsetting fillPattern should return fill-pattern to the default value.");
- XCTAssertEqualObjects(layer.fillPattern, defaultExpression,
- @"fillPattern should return the default value after being unset.");
- // Transition property test
- layer.fillPatternTransition = transitionTest;
- auto toptions = rawLayer->getFillPatternTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition fillPatternTransition = layer.fillPatternTransition;
- XCTAssertEqual(fillPatternTransition.delay, transitionTest.delay);
- XCTAssertEqual(fillPatternTransition.duration, transitionTest.duration);
- }
-
- // fill-translate
- {
- XCTAssertTrue(rawLayer->getFillTranslate().isUndefined(),
- @"fill-translate should be unset initially.");
- NSExpression *defaultExpression = layer.fillTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.fillTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue,
- @"Setting fillTranslation to a constant value expression should update fill-translate.");
- XCTAssertEqualObjects(layer.fillTranslation, constantExpression,
- @"fillTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue,
- @"Setting fillTranslation to a camera expression should update fill-translate.");
- XCTAssertEqualObjects(layer.fillTranslation, functionExpression,
- @"fillTranslation should round-trip camera expressions.");
-
-
- layer.fillTranslation = nil;
- XCTAssertTrue(rawLayer->getFillTranslate().isUndefined(),
- @"Unsetting fillTranslation should return fill-translate to the default value.");
- XCTAssertEqualObjects(layer.fillTranslation, defaultExpression,
- @"fillTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // fill-translate-anchor
- {
- XCTAssertTrue(rawLayer->getFillTranslateAnchor().isUndefined(),
- @"fill-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.fillTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.fillTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue,
- @"Setting fillTranslationAnchor to a constant value expression should update fill-translate-anchor.");
- XCTAssertEqualObjects(layer.fillTranslationAnchor, constantExpression,
- @"fillTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.fillTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue,
- @"Setting fillTranslationAnchor to a camera expression should update fill-translate-anchor.");
- XCTAssertEqualObjects(layer.fillTranslationAnchor, functionExpression,
- @"fillTranslationAnchor should round-trip camera expressions.");
-
-
- layer.fillTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getFillTranslateAnchor().isUndefined(),
- @"Unsetting fillTranslationAnchor should return fill-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.fillTranslationAnchor, defaultExpression,
- @"fillTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"is-fill-antialiased" isBoolean:YES];
- [self testPropertyName:@"fill-color" isBoolean:NO];
- [self testPropertyName:@"fill-opacity" isBoolean:NO];
- [self testPropertyName:@"fill-outline-color" isBoolean:NO];
- [self testPropertyName:@"fill-pattern" isBoolean:NO];
- [self testPropertyName:@"fill-translation" isBoolean:NO];
- [self testPropertyName:@"fill-translation-anchor" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorMap].MGLFillTranslationAnchorValue, MGLFillTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorViewport].MGLFillTranslationAnchorValue, MGLFillTranslationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm
deleted file mode 100644
index e3b1836e8d..0000000000
--- a/platform/darwin/test/MGLGeometryTests.mm
+++ /dev/null
@@ -1,211 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import "../../darwin/src/MGLGeometry_Private.h"
-
-@interface MGLGeometryTests : XCTestCase
-@end
-
-@implementation MGLGeometryTests
-
-- (void)testCoordinateBoundsIsEmpty {
- MGLCoordinateBounds emptyBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(10, 0));
- XCTAssertTrue(MGLCoordinateBoundsIsEmpty(emptyBounds));
- XCTAssertFalse(MGLCoordinateSpanEqualToCoordinateSpan(MGLCoordinateSpanZero, MGLCoordinateBoundsGetCoordinateSpan(emptyBounds)));
-}
-
-- (void)testAngleConversions {
- XCTAssertEqualWithAccuracy(-180, MGLDegreesFromRadians(-M_PI), 1e-5);
- XCTAssertEqual(0, MGLDegreesFromRadians(0));
- XCTAssertEqualWithAccuracy(45, MGLDegreesFromRadians(M_PI_4), 1e-5);
- XCTAssertEqualWithAccuracy(90, MGLDegreesFromRadians(M_PI_2), 1e-5);
- XCTAssertEqualWithAccuracy(180, MGLDegreesFromRadians(M_PI), 1e-5);
- XCTAssertEqualWithAccuracy(360, MGLDegreesFromRadians(2 * M_PI), 1e-5);
- XCTAssertEqualWithAccuracy(720, MGLDegreesFromRadians(4 * M_PI), 1e-5);
-
- XCTAssertEqualWithAccuracy(-360, MGLDegreesFromRadians(MGLRadiansFromDegrees(-360)), 1e-4);
- XCTAssertEqualWithAccuracy(-180, MGLDegreesFromRadians(MGLRadiansFromDegrees(-180)), 1e-5);
- XCTAssertEqualWithAccuracy(-90, MGLDegreesFromRadians(MGLRadiansFromDegrees(-90)), 1e-5);
- XCTAssertEqualWithAccuracy(-45, MGLDegreesFromRadians(MGLRadiansFromDegrees(-45)), 1e-5);
- XCTAssertEqualWithAccuracy(0, MGLDegreesFromRadians(MGLRadiansFromDegrees(0)), 1e-5);
- XCTAssertEqualWithAccuracy(45, MGLDegreesFromRadians(MGLRadiansFromDegrees(45)), 1e-5);
- XCTAssertEqualWithAccuracy(90, MGLDegreesFromRadians(MGLRadiansFromDegrees(90)), 1e-5);
- XCTAssertEqualWithAccuracy(180, MGLDegreesFromRadians(MGLRadiansFromDegrees(180)), 1e-5);
- XCTAssertEqualWithAccuracy(360, MGLDegreesFromRadians(MGLRadiansFromDegrees(360)), 1e-4);
-}
-
-- (void)testAltitudeConversions {
- CGSize tallSize = CGSizeMake(600, 1200);
- CGSize midSize = CGSizeMake(600, 800);
- CGSize shortSize = CGSizeMake(600, 400);
-
- XCTAssertEqualWithAccuracy(1800, MGLAltitudeForZoomLevel(MGLZoomLevelForAltitude(1800, 0, 0, midSize), 0, 0, midSize), 1e-8);
- XCTAssertLessThan(MGLZoomLevelForAltitude(1800, 0, 0, midSize), MGLZoomLevelForAltitude(1800, 0, 0, tallSize));
- XCTAssertGreaterThan(MGLZoomLevelForAltitude(1800, 0, 0, midSize), MGLZoomLevelForAltitude(1800, 0, 0, shortSize));
-
- XCTAssertEqualWithAccuracy(0, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(0, 0, 0, midSize), 0, 0, midSize), 1e-8);
- XCTAssertEqualWithAccuracy(18, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(18, 0, 0, midSize), 0, 0, midSize), 1e-8);
-
- XCTAssertEqualWithAccuracy(0, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(0, 0, 40, midSize), 0, 40, midSize), 1e-8);
- XCTAssertEqualWithAccuracy(18, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(18, 0, 40, midSize), 0, 40, midSize), 1e-8);
-
- XCTAssertEqualWithAccuracy(0, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(0, 60, 40, midSize), 60, 40, midSize), 1e-8);
- XCTAssertEqualWithAccuracy(18, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(18, 60, 40, midSize), 60, 40, midSize), 1e-8);
-}
-
-- (void)testGeometryBoxing {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
- CLLocationCoordinate2D roundTrippedCoordinate = [NSValue valueWithMGLCoordinate:coordinate].MGLCoordinateValue;
-
- XCTAssertEqual(coordinate.latitude, roundTrippedCoordinate.latitude, @"Latitude should round-trip.");
- XCTAssertEqual(coordinate.longitude, roundTrippedCoordinate.longitude, @"Longitude should round-trip.");
-
- MGLCoordinateSpan span = MGLCoordinateSpanMake(4.383333333333335, -4.299999999999997);
- MGLCoordinateSpan roundTrippedSpan = [NSValue valueWithMGLCoordinateSpan:span].MGLCoordinateSpanValue;
-
- XCTAssertEqual(span.latitudeDelta, roundTrippedSpan.latitudeDelta, @"Latitude delta should round-trip.");
- XCTAssertEqual(span.longitudeDelta, roundTrippedSpan.longitudeDelta, @"Longitude delta should round-trip.");
-
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(38.9131982, -77.0325453144239),
- CLLocationCoordinate2DMake(37.7757368, -122.4135302));
- MGLCoordinateBounds roundTrippedBounds = [NSValue valueWithMGLCoordinateBounds:bounds].MGLCoordinateBoundsValue;
-
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.sw],
- [NSValue valueWithMGLCoordinate:roundTrippedBounds.sw],
- @"Southwest should round-trip.");
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.ne],
- [NSValue valueWithMGLCoordinate:roundTrippedBounds.ne],
- @"Northeast should round-trip.");
-}
-
-- (void)testCoordinateInCoordinateBounds {
- CLLocationCoordinate2D ne = CLLocationCoordinate2DMake(45, -104);
- CLLocationCoordinate2D sw = CLLocationCoordinate2DMake(41, -111);
- MGLCoordinateBounds wyoming = MGLCoordinateBoundsMake(sw, ne);
-
- CLLocationCoordinate2D centerOfWyoming = CLLocationCoordinate2DMake(43, -107.5);
-
- XCTAssertTrue(MGLCoordinateInCoordinateBounds(ne, wyoming));
- XCTAssertTrue(MGLCoordinateInCoordinateBounds(sw, wyoming));
- XCTAssertTrue(MGLCoordinateInCoordinateBounds(centerOfWyoming, wyoming));
-
- CLLocationCoordinate2D australia = CLLocationCoordinate2DMake(-25, 135);
- CLLocationCoordinate2D brazil = CLLocationCoordinate2DMake(-12, -50);
- CLLocationCoordinate2D china = CLLocationCoordinate2DMake(35, 100);
-
- XCTAssertFalse(MGLCoordinateInCoordinateBounds(australia, wyoming));
- XCTAssertFalse(MGLCoordinateInCoordinateBounds(brazil, wyoming));
- XCTAssertFalse(MGLCoordinateInCoordinateBounds(china, wyoming));
- XCTAssertFalse(MGLCoordinateInCoordinateBounds(kCLLocationCoordinate2DInvalid, wyoming));
-}
-
-- (void)testGeoJSONDeserialization {
- NSData *data = [@"{\"type\": \"Feature\", \"geometry\": {\"type\": \"Point\", \"coordinates\": [0, 0]}, \"properties\": {}}" dataUsingEncoding:NSUTF8StringEncoding];
- NSError *error;
- MGLPointFeature *feature = (MGLPointFeature *)[MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
- XCTAssertNil(error, @"Valid GeoJSON data should produce no error on deserialization.");
- XCTAssertNotNil(feature, @"Valid GeoJSON data should produce an object on deserialization.");
- XCTAssertTrue([feature isKindOfClass:[MGLPointFeature class]], @"Valid GeoJSON point feature data should produce an MGLPointFeature.");
- XCTAssertEqual(feature.attributes.count, 0UL);
- XCTAssertEqual(feature.coordinate.latitude, 0);
- XCTAssertEqual(feature.coordinate.longitude, 0);
-
- data = [@"{\"type\": \"Feature\", \"feature\": {\"type\": \"Point\", \"coordinates\": [0, 0]}}" dataUsingEncoding:NSUTF8StringEncoding];
- error = nil;
- MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
- XCTAssertNotNil(error, @"Invalid GeoJSON data should produce an error on deserialization.");
- XCTAssertNil(shape, @"Invalid GeoJSON data should produce no object on deserialization.");
-}
-
-- (void)testGeoJSONSerialization {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- feature.identifier = @504;
- feature.coordinate = CLLocationCoordinate2DMake(29.95, -90.066667);
-
- NSData *data = [feature geoJSONDataUsingEncoding:NSUTF8StringEncoding];
- XCTAssertNotNil(data, @"MGLPointFeature should serialize as an UTF-8 string data object.");
- NSError *error;
- NSDictionary *serializedGeoJSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
- XCTAssertNil(error, @"Serialized GeoJSON data should be deserializable JSON.");
- XCTAssertNotNil(serializedGeoJSON, @"Serialized GeoJSON data should be valid JSON.");
- XCTAssertTrue([serializedGeoJSON isKindOfClass:[NSDictionary class]], @"Serialized GeoJSON data should be a JSON object.");
- NSDictionary *geoJSON = @{
- @"type": @"Feature",
- @"id": @504,
- @"geometry": @{
- @"type": @"Point",
- @"coordinates": @[
- @(-90.066667),
- @29.95,
- ],
- },
- @"properties": @{},
- };
- XCTAssertEqualObjects(serializedGeoJSON, geoJSON, @"MGLPointFeature should serialize as a GeoJSON point feature.");
-}
-
-- (void)testMGLCoordinateBoundsToMGLCoordinateQuad {
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(37.936, -80.425),
- CLLocationCoordinate2DMake(46.437, -71.516));
-
- MGLCoordinateQuad quad = MGLCoordinateQuadFromCoordinateBounds(bounds);
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.sw],
- [NSValue valueWithMGLCoordinate:quad.bottomLeft],
- @"Bounds southwest should be bottom left of quad.");
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.ne],
- [NSValue valueWithMGLCoordinate:quad.topRight],
- @"Bounds northeast should be top right of quad.");
-
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(46.437, -80.425)],
- [NSValue valueWithMGLCoordinate:quad.topLeft],
- @"Quad top left should be computed correctly.");
- XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(37.936, -71.516)],
- [NSValue valueWithMGLCoordinate:quad.bottomRight],
- @"Quad bottom right should be computed correctly.");
-}
-
-- (void)testMGLMapPoint {
- MGLMapPoint point = MGLMapPointForCoordinate(CLLocationCoordinate2DMake(37.936, -80.425), 0.0);
-
- MGLMapPoint roundTrippedPoint = [NSValue valueWithMGLMapPoint:point].MGLMapPointValue;
- XCTAssertEqual(point.x, roundTrippedPoint.x);
- XCTAssertEqual(point.y, roundTrippedPoint.y);
- XCTAssertEqual(point.zoomLevel, roundTrippedPoint.zoomLevel);
-}
-
-- (void)testMGLLocationCoordinate2DIsValid {
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(37.936, -71.516);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(46.816368, 5.844469);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-21.512680, 23.334703);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-44.947936, -73.081313);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(19.333630, 203.555405);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(23.254696, -240.795323);
- XCTAssertTrue(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(91, 361);
- XCTAssertFalse(MGLLocationCoordinate2DIsValid(coordinate));
- }
- {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(-91, -361);
- XCTAssertFalse(MGLLocationCoordinate2DIsValid(coordinate));
- }
-}
-
-@end
diff --git a/platform/darwin/test/MGLHeatmapColorTests.mm b/platform/darwin/test/MGLHeatmapColorTests.mm
deleted file mode 100644
index 19f9b4e86e..0000000000
--- a/platform/darwin/test/MGLHeatmapColorTests.mm
+++ /dev/null
@@ -1,62 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/heatmap_layer.hpp>
-
-@interface MGLHeatmapColorTests : XCTestCase <MGLMapViewDelegate>
-@end
-
-@implementation MGLHeatmapColorTests
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- auto rawLayer = static_cast<mbgl::style::HeatmapLayer*>(layer.rawLayer);
-
- XCTAssertTrue(rawLayer->getHeatmapColor().isUndefined(),
- @"heatmap-color should be unset initially.");
- NSExpression *defaultExpression = layer.heatmapColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.heatmapColor = constantExpression;
-
-
- mbgl::style::PropertyValue<float> propertyValue = { 0xff };
- XCTAssertEqual(rawLayer->getHeatmapColor().evaluate(0.0), mbgl::Color::red(),
- @"Setting heatmapColor to a constant value expression should update heatmap-color.");
- XCTAssertEqualObjects(layer.heatmapColor, constantExpression,
- @"heatmapColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *constantExpression2 = [NSExpression expressionWithFormat:@"%@", [MGLColor blueColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($heatmapDensity, %@, %@)", constantExpression, @{@12: constantExpression2}];
- layer.heatmapColor = functionExpression;
-
- XCTAssertEqual(rawLayer->getHeatmapColor().evaluate(11.0), mbgl::Color::red(),
- @"Setting heatmapColor to an expression depending on $heatmapDensity should update heatmap-color.");
- XCTAssertEqual(rawLayer->getHeatmapColor().evaluate(12.0), mbgl::Color::blue(),
- @"Setting heatmapColor to an expression depending on $heatmapDensity should update heatmap-color.");
- XCTAssertEqualObjects(layer.heatmapColor, functionExpression,
- @"heatmapColor should round-trip expressions depending on $heatmapDensity.");
-
- layer.heatmapColor = nil;
- XCTAssertTrue(rawLayer->getHeatmapColor().isUndefined(),
- @"Unsetting heatmapColor should return heatmap-color to the default value.");
- // The contained colors aren’t object equal, even though their descriptions are.
- XCTAssertEqualObjects(layer.heatmapColor.description, defaultExpression.description,
- @"heatmapColor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- XCTAssertThrowsSpecificNamed(layer.heatmapColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera expression is applied to heatmapColor.");
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.heatmapColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a data expression is applied to heatmapColor.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.heatmapColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
-}
-
-@end
diff --git a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
deleted file mode 100644
index 98d314cb9f..0000000000
--- a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
+++ /dev/null
@@ -1,313 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/heatmap_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLHeatmapLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLHeatmapLayerTests
-
-+ (NSString *)layerType {
- return @"heatmap";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"heatmap");
- auto rawLayer = static_cast<mbgl::style::HeatmapLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // heatmap-intensity
- {
- XCTAssertTrue(rawLayer->getHeatmapIntensity().isUndefined(),
- @"heatmap-intensity should be unset initially.");
- NSExpression *defaultExpression = layer.heatmapIntensity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.heatmapIntensity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue,
- @"Setting heatmapIntensity to a constant value expression should update heatmap-intensity.");
- XCTAssertEqualObjects(layer.heatmapIntensity, constantExpression,
- @"heatmapIntensity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.heatmapIntensity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue,
- @"Setting heatmapIntensity to a camera expression should update heatmap-intensity.");
- XCTAssertEqualObjects(layer.heatmapIntensity, functionExpression,
- @"heatmapIntensity should round-trip camera expressions.");
-
-
- layer.heatmapIntensity = nil;
- XCTAssertTrue(rawLayer->getHeatmapIntensity().isUndefined(),
- @"Unsetting heatmapIntensity should return heatmap-intensity to the default value.");
- XCTAssertEqualObjects(layer.heatmapIntensity, defaultExpression,
- @"heatmapIntensity should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.heatmapIntensity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.heatmapIntensity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.heatmapIntensityTransition = transitionTest;
- auto toptions = rawLayer->getHeatmapIntensityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition heatmapIntensityTransition = layer.heatmapIntensityTransition;
- XCTAssertEqual(heatmapIntensityTransition.delay, transitionTest.delay);
- XCTAssertEqual(heatmapIntensityTransition.duration, transitionTest.duration);
- }
-
- // heatmap-opacity
- {
- XCTAssertTrue(rawLayer->getHeatmapOpacity().isUndefined(),
- @"heatmap-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.heatmapOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.heatmapOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue,
- @"Setting heatmapOpacity to a constant value expression should update heatmap-opacity.");
- XCTAssertEqualObjects(layer.heatmapOpacity, constantExpression,
- @"heatmapOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.heatmapOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue,
- @"Setting heatmapOpacity to a camera expression should update heatmap-opacity.");
- XCTAssertEqualObjects(layer.heatmapOpacity, functionExpression,
- @"heatmapOpacity should round-trip camera expressions.");
-
-
- layer.heatmapOpacity = nil;
- XCTAssertTrue(rawLayer->getHeatmapOpacity().isUndefined(),
- @"Unsetting heatmapOpacity should return heatmap-opacity to the default value.");
- XCTAssertEqualObjects(layer.heatmapOpacity, defaultExpression,
- @"heatmapOpacity should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.heatmapOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.heatmapOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.heatmapOpacityTransition = transitionTest;
- auto toptions = rawLayer->getHeatmapOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition heatmapOpacityTransition = layer.heatmapOpacityTransition;
- XCTAssertEqual(heatmapOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(heatmapOpacityTransition.duration, transitionTest.duration);
- }
-
- // heatmap-radius
- {
- XCTAssertTrue(rawLayer->getHeatmapRadius().isUndefined(),
- @"heatmap-radius should be unset initially.");
- NSExpression *defaultExpression = layer.heatmapRadius;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.heatmapRadius = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
- @"Setting heatmapRadius to a constant value expression should update heatmap-radius.");
- XCTAssertEqualObjects(layer.heatmapRadius, constantExpression,
- @"heatmapRadius should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.heatmapRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
- @"Setting heatmapRadius to a camera expression should update heatmap-radius.");
- XCTAssertEqualObjects(layer.heatmapRadius, functionExpression,
- @"heatmapRadius should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.heatmapRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
- @"Setting heatmapRadius to a data expression should update heatmap-radius.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.heatmapRadius, pedanticFunctionExpression,
- @"heatmapRadius should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.heatmapRadius = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
- @"Setting heatmapRadius to a camera-data expression should update heatmap-radius.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.heatmapRadius, pedanticFunctionExpression,
- @"heatmapRadius should round-trip camera-data expressions.");
-
- layer.heatmapRadius = nil;
- XCTAssertTrue(rawLayer->getHeatmapRadius().isUndefined(),
- @"Unsetting heatmapRadius should return heatmap-radius to the default value.");
- XCTAssertEqualObjects(layer.heatmapRadius, defaultExpression,
- @"heatmapRadius should return the default value after being unset.");
- // Transition property test
- layer.heatmapRadiusTransition = transitionTest;
- auto toptions = rawLayer->getHeatmapRadiusTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition heatmapRadiusTransition = layer.heatmapRadiusTransition;
- XCTAssertEqual(heatmapRadiusTransition.delay, transitionTest.delay);
- XCTAssertEqual(heatmapRadiusTransition.duration, transitionTest.duration);
- }
-
- // heatmap-weight
- {
- XCTAssertTrue(rawLayer->getHeatmapWeight().isUndefined(),
- @"heatmap-weight should be unset initially.");
- NSExpression *defaultExpression = layer.heatmapWeight;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.heatmapWeight = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
- @"Setting heatmapWeight to a constant value expression should update heatmap-weight.");
- XCTAssertEqualObjects(layer.heatmapWeight, constantExpression,
- @"heatmapWeight should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.heatmapWeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
- @"Setting heatmapWeight to a camera expression should update heatmap-weight.");
- XCTAssertEqualObjects(layer.heatmapWeight, functionExpression,
- @"heatmapWeight should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.heatmapWeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
- @"Setting heatmapWeight to a data expression should update heatmap-weight.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.heatmapWeight, pedanticFunctionExpression,
- @"heatmapWeight should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.heatmapWeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
- @"Setting heatmapWeight to a camera-data expression should update heatmap-weight.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.heatmapWeight, pedanticFunctionExpression,
- @"heatmapWeight should round-trip camera-data expressions.");
-
- layer.heatmapWeight = nil;
- XCTAssertTrue(rawLayer->getHeatmapWeight().isUndefined(),
- @"Unsetting heatmapWeight should return heatmap-weight to the default value.");
- XCTAssertEqualObjects(layer.heatmapWeight, defaultExpression,
- @"heatmapWeight should return the default value after being unset.");
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"heatmap-intensity" isBoolean:NO];
- [self testPropertyName:@"heatmap-opacity" isBoolean:NO];
- [self testPropertyName:@"heatmap-radius" isBoolean:NO];
- [self testPropertyName:@"heatmap-weight" isBoolean:NO];
-}
-
-@end
diff --git a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm b/platform/darwin/test/MGLHillshadeStyleLayerTests.mm
deleted file mode 100644
index a52f36e8c6..0000000000
--- a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm
+++ /dev/null
@@ -1,349 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/hillshade_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLHillshadeLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLHillshadeLayerTests
-
-+ (NSString *)layerType {
- return @"hillshade";
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLHillshadeStyleLayer *layer = [[MGLHillshadeStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"hillshade");
- auto rawLayer = static_cast<mbgl::style::HillshadeLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // hillshade-accent-color
- {
- XCTAssertTrue(rawLayer->getHillshadeAccentColor().isUndefined(),
- @"hillshade-accent-color should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeAccentColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.hillshadeAccentColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getHillshadeAccentColor(), propertyValue,
- @"Setting hillshadeAccentColor to a constant value expression should update hillshade-accent-color.");
- XCTAssertEqualObjects(layer.hillshadeAccentColor, constantExpression,
- @"hillshadeAccentColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeAccentColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeAccentColor(), propertyValue,
- @"Setting hillshadeAccentColor to a camera expression should update hillshade-accent-color.");
- XCTAssertEqualObjects(layer.hillshadeAccentColor, functionExpression,
- @"hillshadeAccentColor should round-trip camera expressions.");
-
-
- layer.hillshadeAccentColor = nil;
- XCTAssertTrue(rawLayer->getHillshadeAccentColor().isUndefined(),
- @"Unsetting hillshadeAccentColor should return hillshade-accent-color to the default value.");
- XCTAssertEqualObjects(layer.hillshadeAccentColor, defaultExpression,
- @"hillshadeAccentColor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeAccentColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeAccentColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.hillshadeAccentColorTransition = transitionTest;
- auto toptions = rawLayer->getHillshadeAccentColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition hillshadeAccentColorTransition = layer.hillshadeAccentColorTransition;
- XCTAssertEqual(hillshadeAccentColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(hillshadeAccentColorTransition.duration, transitionTest.duration);
- }
-
- // hillshade-exaggeration
- {
- XCTAssertTrue(rawLayer->getHillshadeExaggeration().isUndefined(),
- @"hillshade-exaggeration should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeExaggeration;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.hillshadeExaggeration = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue,
- @"Setting hillshadeExaggeration to a constant value expression should update hillshade-exaggeration.");
- XCTAssertEqualObjects(layer.hillshadeExaggeration, constantExpression,
- @"hillshadeExaggeration should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeExaggeration = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue,
- @"Setting hillshadeExaggeration to a camera expression should update hillshade-exaggeration.");
- XCTAssertEqualObjects(layer.hillshadeExaggeration, functionExpression,
- @"hillshadeExaggeration should round-trip camera expressions.");
-
-
- layer.hillshadeExaggeration = nil;
- XCTAssertTrue(rawLayer->getHillshadeExaggeration().isUndefined(),
- @"Unsetting hillshadeExaggeration should return hillshade-exaggeration to the default value.");
- XCTAssertEqualObjects(layer.hillshadeExaggeration, defaultExpression,
- @"hillshadeExaggeration should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeExaggeration = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeExaggeration = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.hillshadeExaggerationTransition = transitionTest;
- auto toptions = rawLayer->getHillshadeExaggerationTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition hillshadeExaggerationTransition = layer.hillshadeExaggerationTransition;
- XCTAssertEqual(hillshadeExaggerationTransition.delay, transitionTest.delay);
- XCTAssertEqual(hillshadeExaggerationTransition.duration, transitionTest.duration);
- }
-
- // hillshade-highlight-color
- {
- XCTAssertTrue(rawLayer->getHillshadeHighlightColor().isUndefined(),
- @"hillshade-highlight-color should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeHighlightColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.hillshadeHighlightColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getHillshadeHighlightColor(), propertyValue,
- @"Setting hillshadeHighlightColor to a constant value expression should update hillshade-highlight-color.");
- XCTAssertEqualObjects(layer.hillshadeHighlightColor, constantExpression,
- @"hillshadeHighlightColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeHighlightColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeHighlightColor(), propertyValue,
- @"Setting hillshadeHighlightColor to a camera expression should update hillshade-highlight-color.");
- XCTAssertEqualObjects(layer.hillshadeHighlightColor, functionExpression,
- @"hillshadeHighlightColor should round-trip camera expressions.");
-
-
- layer.hillshadeHighlightColor = nil;
- XCTAssertTrue(rawLayer->getHillshadeHighlightColor().isUndefined(),
- @"Unsetting hillshadeHighlightColor should return hillshade-highlight-color to the default value.");
- XCTAssertEqualObjects(layer.hillshadeHighlightColor, defaultExpression,
- @"hillshadeHighlightColor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeHighlightColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeHighlightColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.hillshadeHighlightColorTransition = transitionTest;
- auto toptions = rawLayer->getHillshadeHighlightColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition hillshadeHighlightColorTransition = layer.hillshadeHighlightColorTransition;
- XCTAssertEqual(hillshadeHighlightColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(hillshadeHighlightColorTransition.duration, transitionTest.duration);
- }
-
- // hillshade-illumination-anchor
- {
- XCTAssertTrue(rawLayer->getHillshadeIlluminationAnchor().isUndefined(),
- @"hillshade-illumination-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeIlluminationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.hillshadeIlluminationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::HillshadeIlluminationAnchorType> propertyValue = { mbgl::style::HillshadeIlluminationAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getHillshadeIlluminationAnchor(), propertyValue,
- @"Setting hillshadeIlluminationAnchor to a constant value expression should update hillshade-illumination-anchor.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, constantExpression,
- @"hillshadeIlluminationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeIlluminationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::HillshadeIlluminationAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeIlluminationAnchor(), propertyValue,
- @"Setting hillshadeIlluminationAnchor to a camera expression should update hillshade-illumination-anchor.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, functionExpression,
- @"hillshadeIlluminationAnchor should round-trip camera expressions.");
-
-
- layer.hillshadeIlluminationAnchor = nil;
- XCTAssertTrue(rawLayer->getHillshadeIlluminationAnchor().isUndefined(),
- @"Unsetting hillshadeIlluminationAnchor should return hillshade-illumination-anchor to the default value.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, defaultExpression,
- @"hillshadeIlluminationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // hillshade-illumination-direction
- {
- XCTAssertTrue(rawLayer->getHillshadeIlluminationDirection().isUndefined(),
- @"hillshade-illumination-direction should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeIlluminationDirection;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.hillshadeIlluminationDirection = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue,
- @"Setting hillshadeIlluminationDirection to a constant value expression should update hillshade-illumination-direction.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, constantExpression,
- @"hillshadeIlluminationDirection should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeIlluminationDirection = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue,
- @"Setting hillshadeIlluminationDirection to a camera expression should update hillshade-illumination-direction.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, functionExpression,
- @"hillshadeIlluminationDirection should round-trip camera expressions.");
-
-
- layer.hillshadeIlluminationDirection = nil;
- XCTAssertTrue(rawLayer->getHillshadeIlluminationDirection().isUndefined(),
- @"Unsetting hillshadeIlluminationDirection should return hillshade-illumination-direction to the default value.");
- XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, defaultExpression,
- @"hillshadeIlluminationDirection should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationDirection = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationDirection = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // hillshade-shadow-color
- {
- XCTAssertTrue(rawLayer->getHillshadeShadowColor().isUndefined(),
- @"hillshade-shadow-color should be unset initially.");
- NSExpression *defaultExpression = layer.hillshadeShadowColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.hillshadeShadowColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getHillshadeShadowColor(), propertyValue,
- @"Setting hillshadeShadowColor to a constant value expression should update hillshade-shadow-color.");
- XCTAssertEqualObjects(layer.hillshadeShadowColor, constantExpression,
- @"hillshadeShadowColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.hillshadeShadowColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getHillshadeShadowColor(), propertyValue,
- @"Setting hillshadeShadowColor to a camera expression should update hillshade-shadow-color.");
- XCTAssertEqualObjects(layer.hillshadeShadowColor, functionExpression,
- @"hillshadeShadowColor should round-trip camera expressions.");
-
-
- layer.hillshadeShadowColor = nil;
- XCTAssertTrue(rawLayer->getHillshadeShadowColor().isUndefined(),
- @"Unsetting hillshadeShadowColor should return hillshade-shadow-color to the default value.");
- XCTAssertEqualObjects(layer.hillshadeShadowColor, defaultExpression,
- @"hillshadeShadowColor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.hillshadeShadowColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.hillshadeShadowColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.hillshadeShadowColorTransition = transitionTest;
- auto toptions = rawLayer->getHillshadeShadowColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition hillshadeShadowColorTransition = layer.hillshadeShadowColorTransition;
- XCTAssertEqual(hillshadeShadowColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(hillshadeShadowColorTransition.duration, transitionTest.duration);
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"hillshade-accent-color" isBoolean:NO];
- [self testPropertyName:@"hillshade-exaggeration" isBoolean:NO];
- [self testPropertyName:@"hillshade-highlight-color" isBoolean:NO];
- [self testPropertyName:@"hillshade-illumination-anchor" isBoolean:NO];
- [self testPropertyName:@"hillshade-illumination-direction" isBoolean:NO];
- [self testPropertyName:@"hillshade-shadow-color" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLHillshadeIlluminationAnchor:MGLHillshadeIlluminationAnchorMap].MGLHillshadeIlluminationAnchorValue, MGLHillshadeIlluminationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLHillshadeIlluminationAnchor:MGLHillshadeIlluminationAnchorViewport].MGLHillshadeIlluminationAnchorValue, MGLHillshadeIlluminationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLImageSourceTests.m b/platform/darwin/test/MGLImageSourceTests.m
deleted file mode 100644
index 38fcd38709..0000000000
--- a/platform/darwin/test/MGLImageSourceTests.m
+++ /dev/null
@@ -1,42 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import <Mapbox/Mapbox.h>
-
-@interface MGLImageSourceTests : XCTestCase
-
-@end
-
-@implementation MGLImageSourceTests
-
-
-- (void)testMGLImageSourceWithImageURL {
-
- MGLCoordinateQuad quad = { { 80, 37}, { 81, 37}, { 81, 39}, { 80, 39}};
- MGLImageSource *source = [[MGLImageSource alloc] initWithIdentifier:@"source-id" coordinateQuad:quad URL:[NSURL URLWithString:@"http://host/image.png"]];
-
- XCTAssertNotNil(source.URL);
- XCTAssertEqualObjects(source.URL.absoluteString, @"http://host/image.png");
- XCTAssertNil(source.image);
-}
-
-- (void)testMGLImageSourceWithImage {
-
- NSString *imageName = @"RadarImage";
-#if TARGET_OS_IPHONE
- MGLImage *image = [MGLImage imageNamed:imageName
- inBundle:[NSBundle bundleForClass:[self class]]
- compatibleWithTraitCollection:nil];
-#else
- MGLImage *image = [[NSBundle bundleForClass:[self class]] imageForResource:imageName];
-#endif
- XCTAssertNotNil(image);
-
- MGLCoordinateQuad quad = { { 80, 37}, { 81, 37}, { 81, 39}, { 80, 39}};
- MGLImageSource *source = [[MGLImageSource alloc] initWithIdentifier:@"source-id" coordinateQuad:quad image:image];
-
- XCTAssertNotNil(source.image);
- XCTAssertEqualObjects(source.image, image);
- XCTAssertNil(source.URL);
-}
-
-@end
diff --git a/platform/darwin/test/MGLLightTest.mm b/platform/darwin/test/MGLLightTest.mm
deleted file mode 100644
index 0bc7b15af3..0000000000
--- a/platform/darwin/test/MGLLightTest.mm
+++ /dev/null
@@ -1,133 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-#import <XCTest/XCTest.h>
-#import <Mapbox/Mapbox.h>
-
-#import "MGLLight_Private.h"
-
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import <mbgl/style/light.hpp>
-#import <mbgl/style/types.hpp>
-#include <mbgl/style/transition_options.hpp>
-
-@interface MGLLightTest : XCTestCase
-
-@end
-
-@implementation MGLLightTest
-
-- (void)testProperties {
-
- MGLTransition defaultTransition = MGLTransitionMake(0, 0);
- MGLTransition transition = MGLTransitionMake(6, 3);
- mbgl::style::TransitionOptions transitionOptions { { MGLDurationFromTimeInterval(6) }, { MGLDurationFromTimeInterval(3) } };
-
- // anchor
- {
- mbgl::style::Light light;
- MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- auto lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getDefaultAnchor(), lightFromMGLLight.getAnchor());
- XCTAssertEqual(mglLight.anchor.expressionType, NSConstantValueExpressionType, @"mglLight.anchor isn’t a constant value expression.");
- XCTAssertEqualObjects(mglLight.anchor.constantValue, @"viewport");
-
- mbgl::style::PropertyValue<mbgl::style::LightAnchorType> propertyValue = { mbgl::style::LightAnchorType::Viewport };
- light.setAnchor(propertyValue);
- mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getAnchor(), lightFromMGLLight.getAnchor());
- }
-
- // position
- {
- mbgl::style::Light light;
- MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- auto lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getDefaultPosition(), lightFromMGLLight.getPosition());
- auto positionTransition = lightFromMGLLight.getPositionTransition();
- XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == defaultTransition.delay);
- XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == defaultTransition.duration);
-
- std::array<float, 3> positionArray = { { 6, 180, 90 } };
- mbgl::style::Position position = { positionArray };
- mbgl::style::PropertyValue<mbgl::style::Position> propertyValue = { position };
- light.setPosition(propertyValue);
- light.setPositionTransition(transitionOptions);
-
- mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getPosition(), lightFromMGLLight.getPosition());
- positionTransition = lightFromMGLLight.getPositionTransition();
- XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == transition.delay);
- XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == transition.duration);
-
- }
-
- // color
- {
- mbgl::style::Light light;
- MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- auto lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getDefaultColor(), lightFromMGLLight.getColor());
- auto colorTransition = lightFromMGLLight.getColorTransition();
- XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == defaultTransition.delay);
- XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == defaultTransition.duration);
-
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- light.setColor(propertyValue);
- light.setColorTransition(transitionOptions);
-
- mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getColor(), lightFromMGLLight.getColor());
- colorTransition = lightFromMGLLight.getColorTransition();
- XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == transition.delay);
- XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == transition.duration);
-
- }
-
- // intensity
- {
- mbgl::style::Light light;
- MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- auto lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getDefaultIntensity(), lightFromMGLLight.getIntensity());
- auto intensityTransition = lightFromMGLLight.getIntensityTransition();
- XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == defaultTransition.delay);
- XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == defaultTransition.duration);
-
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- light.setIntensity(propertyValue);
- light.setIntensityTransition(transitionOptions);
-
- mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getIntensity(), lightFromMGLLight.getIntensity());
- intensityTransition = lightFromMGLLight.getIntensityTransition();
- XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == transition.delay);
- XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == transition.duration);
-
- }
-
-}
-
-- (void)testValueAdditions {
- MGLSphericalPosition position = MGLSphericalPositionMake(1.15, 210, 30);
-
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.radial, position.radial);
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.azimuthal, position.azimuthal);
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.polar, position.polar);
- XCTAssertEqual([NSValue valueWithMGLLightAnchor:MGLLightAnchorMap].MGLLightAnchorValue, MGLLightAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLLightAnchor:MGLLightAnchorViewport].MGLLightAnchorValue, MGLLightAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLLightTest.mm.ejs b/platform/darwin/test/MGLLightTest.mm.ejs
deleted file mode 100644
index 35ff58b6d5..0000000000
--- a/platform/darwin/test/MGLLightTest.mm.ejs
+++ /dev/null
@@ -1,91 +0,0 @@
-<%
- const type = locals.type;
- const properties = locals.properties;
--%>
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-#import <XCTest/XCTest.h>
-#import <Mapbox/Mapbox.h>
-
-#import "MGLLight_Private.h"
-
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import <mbgl/style/light.hpp>
-#import <mbgl/style/types.hpp>
-#include <mbgl/style/transition_options.hpp>
-
-@interface MGLLightTest : XCTestCase
-
-@end
-
-@implementation MGLLightTest
-
-- (void)testProperties {
-
- MGLTransition defaultTransition = MGLTransitionMake(0, 0);
- MGLTransition transition = MGLTransitionMake(6, 3);
- mbgl::style::TransitionOptions transitionOptions { { MGLDurationFromTimeInterval(6) }, { MGLDurationFromTimeInterval(3) } };
-
-<% for (const property of properties) { -%>
- // <%- property.name %>
- {
- mbgl::style::Light light;
- MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- auto lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.getDefault<%- camelize(property.name) -%>(), lightFromMGLLight.get<%- camelize(property.name) -%>());
-<% if (property.transition) { -%>
- auto <%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMGLLight.get<%- camelize(property.name) -%>Transition();
- XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == defaultTransition.delay);
- XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == defaultTransition.duration);
-
-<% } -%>
-<% if (property.type == "enum" && property.default) { -%>
- XCTAssertEqual(mglLight.<%- camelizeWithLeadingLowercase(property.name) -%>.expressionType, NSConstantValueExpressionType, @"mglLight.<%- camelizeWithLeadingLowercase(property.name) -%> isn’t a constant value expression.");
- XCTAssertEqualObjects(mglLight.<%- camelizeWithLeadingLowercase(property.name) -%>.constantValue, @"<%- property.default -%>");
-
-<% } -%>
-<% if (property.type == "array") { -%>
- std::array<float, 3> positionArray = { { 6, 180, 90 } };
- mbgl::style::Position position = { positionArray };
- mbgl::style::PropertyValue<mbgl::style::Position> propertyValue = { position };
-<% } else { -%>
- mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> };
-<% } -%>
- light.set<%- camelize(property.name) -%>(propertyValue);
-<% if (property.transition) { -%>
- light.set<%- camelize(property.name) -%>Transition(transitionOptions);
-
-<% } -%>
- mglLight = [[MGLLight alloc] initWithMBGLLight:&light];
- lightFromMGLLight = mglLight.mbglLight;
-
- XCTAssertEqual(light.get<%- camelize(property.name) -%>(), lightFromMGLLight.get<%- camelize(property.name) -%>());
-<% if (property.transition) { -%>
- <%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMGLLight.get<%- camelize(property.name) -%>Transition();
- XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == transition.delay);
- XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MGLTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == transition.duration);
-
-<% } -%>
- }
-
-<% } -%>
-}
-
-- (void)testValueAdditions {
- MGLSphericalPosition position = MGLSphericalPositionMake(1.15, 210, 30);
-
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.radial, position.radial);
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.azimuthal, position.azimuthal);
- XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.polar, position.polar);
-<% for (const property of properties) { -%>
-<% if (property.type == "enum") { -%>
-<% for (const value in property.values) { -%>
- XCTAssertEqual([NSValue valueWithMGLLight<%- camelize(property.name) %>:MGLLight<%- camelize(property.name) %><%- camelize(value) %>].MGLLight<%- camelize(property.name) %>Value, MGLLight<%- camelize(property.name) %><%- camelize(value) %>);
-<% } -%>
-<% } -%>
-<% } -%>
-}
-
-@end
diff --git a/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/darwin/test/MGLLineStyleLayerTests.mm
deleted file mode 100644
index 46f040b601..0000000000
--- a/platform/darwin/test/MGLLineStyleLayerTests.mm
+++ /dev/null
@@ -1,904 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/line_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLLineLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLLineLayerTests
-
-+ (NSString *)layerType {
- return @"line";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"line");
- auto rawLayer = static_cast<mbgl::style::LineLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // line-cap
- {
- XCTAssertTrue(rawLayer->getLineCap().isUndefined(),
- @"line-cap should be unset initially.");
- NSExpression *defaultExpression = layer.lineCap;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'square'"];
- layer.lineCap = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::LineCapType> propertyValue = { mbgl::style::LineCapType::Square };
- XCTAssertEqual(rawLayer->getLineCap(), propertyValue,
- @"Setting lineCap to a constant value expression should update line-cap.");
- XCTAssertEqualObjects(layer.lineCap, constantExpression,
- @"lineCap should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'square'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineCap = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::LineCapType>(
- step(zoom(), literal("square"), 18.0, literal("square"))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineCap(), propertyValue,
- @"Setting lineCap to a camera expression should update line-cap.");
- XCTAssertEqualObjects(layer.lineCap, functionExpression,
- @"lineCap should round-trip camera expressions.");
-
-
- layer.lineCap = nil;
- XCTAssertTrue(rawLayer->getLineCap().isUndefined(),
- @"Unsetting lineCap should return line-cap to the default value.");
- XCTAssertEqualObjects(layer.lineCap, defaultExpression,
- @"lineCap should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineCap = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineCap = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-join
- {
- XCTAssertTrue(rawLayer->getLineJoin().isUndefined(),
- @"line-join should be unset initially.");
- NSExpression *defaultExpression = layer.lineJoin;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'miter'"];
- layer.lineJoin = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::LineJoinType> propertyValue = { mbgl::style::LineJoinType::Miter };
- XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
- @"Setting lineJoin to a constant value expression should update line-join.");
- XCTAssertEqualObjects(layer.lineJoin, constantExpression,
- @"lineJoin should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'miter'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineJoin = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::LineJoinType>(
- step(zoom(), literal("miter"), 18.0, literal("miter"))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
- @"Setting lineJoin to a camera expression should update line-join.");
- XCTAssertEqualObjects(layer.lineJoin, functionExpression,
- @"lineJoin should round-trip camera expressions.");
-
-
- layer.lineJoin = nil;
- XCTAssertTrue(rawLayer->getLineJoin().isUndefined(),
- @"Unsetting lineJoin should return line-join to the default value.");
- XCTAssertEqualObjects(layer.lineJoin, defaultExpression,
- @"lineJoin should return the default value after being unset.");
- }
-
- // line-miter-limit
- {
- XCTAssertTrue(rawLayer->getLineMiterLimit().isUndefined(),
- @"line-miter-limit should be unset initially.");
- NSExpression *defaultExpression = layer.lineMiterLimit;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineMiterLimit = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
- @"Setting lineMiterLimit to a constant value expression should update line-miter-limit.");
- XCTAssertEqualObjects(layer.lineMiterLimit, constantExpression,
- @"lineMiterLimit should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineMiterLimit = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
- @"Setting lineMiterLimit to a camera expression should update line-miter-limit.");
- XCTAssertEqualObjects(layer.lineMiterLimit, functionExpression,
- @"lineMiterLimit should round-trip camera expressions.");
-
-
- layer.lineMiterLimit = nil;
- XCTAssertTrue(rawLayer->getLineMiterLimit().isUndefined(),
- @"Unsetting lineMiterLimit should return line-miter-limit to the default value.");
- XCTAssertEqualObjects(layer.lineMiterLimit, defaultExpression,
- @"lineMiterLimit should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineMiterLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineMiterLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-round-limit
- {
- XCTAssertTrue(rawLayer->getLineRoundLimit().isUndefined(),
- @"line-round-limit should be unset initially.");
- NSExpression *defaultExpression = layer.lineRoundLimit;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineRoundLimit = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
- @"Setting lineRoundLimit to a constant value expression should update line-round-limit.");
- XCTAssertEqualObjects(layer.lineRoundLimit, constantExpression,
- @"lineRoundLimit should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineRoundLimit = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
- @"Setting lineRoundLimit to a camera expression should update line-round-limit.");
- XCTAssertEqualObjects(layer.lineRoundLimit, functionExpression,
- @"lineRoundLimit should round-trip camera expressions.");
-
-
- layer.lineRoundLimit = nil;
- XCTAssertTrue(rawLayer->getLineRoundLimit().isUndefined(),
- @"Unsetting lineRoundLimit should return line-round-limit to the default value.");
- XCTAssertEqualObjects(layer.lineRoundLimit, defaultExpression,
- @"lineRoundLimit should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineRoundLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineRoundLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-blur
- {
- XCTAssertTrue(rawLayer->getLineBlur().isUndefined(),
- @"line-blur should be unset initially.");
- NSExpression *defaultExpression = layer.lineBlur;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineBlur = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
- @"Setting lineBlur to a constant value expression should update line-blur.");
- XCTAssertEqualObjects(layer.lineBlur, constantExpression,
- @"lineBlur should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
- @"Setting lineBlur to a camera expression should update line-blur.");
- XCTAssertEqualObjects(layer.lineBlur, functionExpression,
- @"lineBlur should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
- @"Setting lineBlur to a data expression should update line-blur.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineBlur, pedanticFunctionExpression,
- @"lineBlur should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
- @"Setting lineBlur to a camera-data expression should update line-blur.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineBlur, pedanticFunctionExpression,
- @"lineBlur should round-trip camera-data expressions.");
-
- layer.lineBlur = nil;
- XCTAssertTrue(rawLayer->getLineBlur().isUndefined(),
- @"Unsetting lineBlur should return line-blur to the default value.");
- XCTAssertEqualObjects(layer.lineBlur, defaultExpression,
- @"lineBlur should return the default value after being unset.");
- // Transition property test
- layer.lineBlurTransition = transitionTest;
- auto toptions = rawLayer->getLineBlurTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineBlurTransition = layer.lineBlurTransition;
- XCTAssertEqual(lineBlurTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineBlurTransition.duration, transitionTest.duration);
- }
-
- // line-color
- {
- XCTAssertTrue(rawLayer->getLineColor().isUndefined(),
- @"line-color should be unset initially.");
- NSExpression *defaultExpression = layer.lineColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.lineColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
- @"Setting lineColor to a constant value expression should update line-color.");
- XCTAssertEqualObjects(layer.lineColor, constantExpression,
- @"lineColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
- @"Setting lineColor to a camera expression should update line-color.");
- XCTAssertEqualObjects(layer.lineColor, functionExpression,
- @"lineColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
- @"Setting lineColor to a data expression should update line-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineColor, pedanticFunctionExpression,
- @"lineColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
- @"Setting lineColor to a camera-data expression should update line-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineColor, pedanticFunctionExpression,
- @"lineColor should round-trip camera-data expressions.");
-
- layer.lineColor = nil;
- XCTAssertTrue(rawLayer->getLineColor().isUndefined(),
- @"Unsetting lineColor should return line-color to the default value.");
- XCTAssertEqualObjects(layer.lineColor, defaultExpression,
- @"lineColor should return the default value after being unset.");
- // Transition property test
- layer.lineColorTransition = transitionTest;
- auto toptions = rawLayer->getLineColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineColorTransition = layer.lineColorTransition;
- XCTAssertEqual(lineColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineColorTransition.duration, transitionTest.duration);
- }
-
- // line-dasharray
- {
- XCTAssertTrue(rawLayer->getLineDasharray().isUndefined(),
- @"line-dasharray should be unset initially.");
- NSExpression *defaultExpression = layer.lineDashPattern;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{1, 2}"];
- layer.lineDashPattern = constantExpression;
- mbgl::style::PropertyValue<std::vector<float>> propertyValue = { {1, 2} };
- XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue,
- @"Setting lineDashPattern to a constant value expression should update line-dasharray.");
- XCTAssertEqualObjects(layer.lineDashPattern, constantExpression,
- @"lineDashPattern should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 2}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineDashPattern = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::vector<float>>(
- step(zoom(), literal({1, 2}), 18.0, literal({1, 2}))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue,
- @"Setting lineDashPattern to a camera expression should update line-dasharray.");
- XCTAssertEqualObjects(layer.lineDashPattern, functionExpression,
- @"lineDashPattern should round-trip camera expressions.");
-
-
- layer.lineDashPattern = nil;
- XCTAssertTrue(rawLayer->getLineDasharray().isUndefined(),
- @"Unsetting lineDashPattern should return line-dasharray to the default value.");
- XCTAssertEqualObjects(layer.lineDashPattern, defaultExpression,
- @"lineDashPattern should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-gap-width
- {
- XCTAssertTrue(rawLayer->getLineGapWidth().isUndefined(),
- @"line-gap-width should be unset initially.");
- NSExpression *defaultExpression = layer.lineGapWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineGapWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
- @"Setting lineGapWidth to a constant value expression should update line-gap-width.");
- XCTAssertEqualObjects(layer.lineGapWidth, constantExpression,
- @"lineGapWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineGapWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
- @"Setting lineGapWidth to a camera expression should update line-gap-width.");
- XCTAssertEqualObjects(layer.lineGapWidth, functionExpression,
- @"lineGapWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineGapWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
- @"Setting lineGapWidth to a data expression should update line-gap-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineGapWidth, pedanticFunctionExpression,
- @"lineGapWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineGapWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
- @"Setting lineGapWidth to a camera-data expression should update line-gap-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineGapWidth, pedanticFunctionExpression,
- @"lineGapWidth should round-trip camera-data expressions.");
-
- layer.lineGapWidth = nil;
- XCTAssertTrue(rawLayer->getLineGapWidth().isUndefined(),
- @"Unsetting lineGapWidth should return line-gap-width to the default value.");
- XCTAssertEqualObjects(layer.lineGapWidth, defaultExpression,
- @"lineGapWidth should return the default value after being unset.");
- // Transition property test
- layer.lineGapWidthTransition = transitionTest;
- auto toptions = rawLayer->getLineGapWidthTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineGapWidthTransition = layer.lineGapWidthTransition;
- XCTAssertEqual(lineGapWidthTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineGapWidthTransition.duration, transitionTest.duration);
- }
-
- // line-offset
- {
- XCTAssertTrue(rawLayer->getLineOffset().isUndefined(),
- @"line-offset should be unset initially.");
- NSExpression *defaultExpression = layer.lineOffset;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineOffset = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
- @"Setting lineOffset to a constant value expression should update line-offset.");
- XCTAssertEqualObjects(layer.lineOffset, constantExpression,
- @"lineOffset should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
- @"Setting lineOffset to a camera expression should update line-offset.");
- XCTAssertEqualObjects(layer.lineOffset, functionExpression,
- @"lineOffset should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
- @"Setting lineOffset to a data expression should update line-offset.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineOffset, pedanticFunctionExpression,
- @"lineOffset should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
- @"Setting lineOffset to a camera-data expression should update line-offset.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineOffset, pedanticFunctionExpression,
- @"lineOffset should round-trip camera-data expressions.");
-
- layer.lineOffset = nil;
- XCTAssertTrue(rawLayer->getLineOffset().isUndefined(),
- @"Unsetting lineOffset should return line-offset to the default value.");
- XCTAssertEqualObjects(layer.lineOffset, defaultExpression,
- @"lineOffset should return the default value after being unset.");
- // Transition property test
- layer.lineOffsetTransition = transitionTest;
- auto toptions = rawLayer->getLineOffsetTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineOffsetTransition = layer.lineOffsetTransition;
- XCTAssertEqual(lineOffsetTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineOffsetTransition.duration, transitionTest.duration);
- }
-
- // line-opacity
- {
- XCTAssertTrue(rawLayer->getLineOpacity().isUndefined(),
- @"line-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.lineOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
- @"Setting lineOpacity to a constant value expression should update line-opacity.");
- XCTAssertEqualObjects(layer.lineOpacity, constantExpression,
- @"lineOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
- @"Setting lineOpacity to a camera expression should update line-opacity.");
- XCTAssertEqualObjects(layer.lineOpacity, functionExpression,
- @"lineOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
- @"Setting lineOpacity to a data expression should update line-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineOpacity, pedanticFunctionExpression,
- @"lineOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
- @"Setting lineOpacity to a camera-data expression should update line-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineOpacity, pedanticFunctionExpression,
- @"lineOpacity should round-trip camera-data expressions.");
-
- layer.lineOpacity = nil;
- XCTAssertTrue(rawLayer->getLineOpacity().isUndefined(),
- @"Unsetting lineOpacity should return line-opacity to the default value.");
- XCTAssertEqualObjects(layer.lineOpacity, defaultExpression,
- @"lineOpacity should return the default value after being unset.");
- // Transition property test
- layer.lineOpacityTransition = transitionTest;
- auto toptions = rawLayer->getLineOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineOpacityTransition = layer.lineOpacityTransition;
- XCTAssertEqual(lineOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineOpacityTransition.duration, transitionTest.duration);
- }
-
- // line-pattern
- {
- XCTAssertTrue(rawLayer->getLinePattern().isUndefined(),
- @"line-pattern should be unset initially.");
- NSExpression *defaultExpression = layer.linePattern;
-
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Line Pattern"];
- layer.linePattern = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Image> propertyValue = { "Line Pattern" };
- XCTAssertEqual(rawLayer->getLinePattern(), propertyValue,
- @"Setting linePattern to a constant value expression should update line-pattern.");
- XCTAssertEqualObjects(layer.linePattern, constantExpression,
- @"linePattern should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Line Pattern')"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.linePattern = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- step(zoom(), image(literal("Line Pattern")), 18.0, image(literal("Line Pattern")))
- );
- }
-
- XCTAssertEqual(rawLayer->getLinePattern(), propertyValue,
- @"Setting linePattern to a camera expression should update line-pattern.");
- XCTAssertEqualObjects(layer.linePattern, functionExpression,
- @"linePattern should round-trip camera expressions.");
-
-
- layer.linePattern = nil;
- XCTAssertTrue(rawLayer->getLinePattern().isUndefined(),
- @"Unsetting linePattern should return line-pattern to the default value.");
- XCTAssertEqualObjects(layer.linePattern, defaultExpression,
- @"linePattern should return the default value after being unset.");
- // Transition property test
- layer.linePatternTransition = transitionTest;
- auto toptions = rawLayer->getLinePatternTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition linePatternTransition = layer.linePatternTransition;
- XCTAssertEqual(linePatternTransition.delay, transitionTest.delay);
- XCTAssertEqual(linePatternTransition.duration, transitionTest.duration);
- }
-
- // line-translate
- {
- XCTAssertTrue(rawLayer->getLineTranslate().isUndefined(),
- @"line-translate should be unset initially.");
- NSExpression *defaultExpression = layer.lineTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.lineTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue,
- @"Setting lineTranslation to a constant value expression should update line-translate.");
- XCTAssertEqualObjects(layer.lineTranslation, constantExpression,
- @"lineTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue,
- @"Setting lineTranslation to a camera expression should update line-translate.");
- XCTAssertEqualObjects(layer.lineTranslation, functionExpression,
- @"lineTranslation should round-trip camera expressions.");
-
-
- layer.lineTranslation = nil;
- XCTAssertTrue(rawLayer->getLineTranslate().isUndefined(),
- @"Unsetting lineTranslation should return line-translate to the default value.");
- XCTAssertEqualObjects(layer.lineTranslation, defaultExpression,
- @"lineTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-translate-anchor
- {
- XCTAssertTrue(rawLayer->getLineTranslateAnchor().isUndefined(),
- @"line-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.lineTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.lineTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue,
- @"Setting lineTranslationAnchor to a constant value expression should update line-translate-anchor.");
- XCTAssertEqualObjects(layer.lineTranslationAnchor, constantExpression,
- @"lineTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue,
- @"Setting lineTranslationAnchor to a camera expression should update line-translate-anchor.");
- XCTAssertEqualObjects(layer.lineTranslationAnchor, functionExpression,
- @"lineTranslationAnchor should round-trip camera expressions.");
-
-
- layer.lineTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getLineTranslateAnchor().isUndefined(),
- @"Unsetting lineTranslationAnchor should return line-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.lineTranslationAnchor, defaultExpression,
- @"lineTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // line-width
- {
- XCTAssertTrue(rawLayer->getLineWidth().isUndefined(),
- @"line-width should be unset initially.");
- NSExpression *defaultExpression = layer.lineWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.lineWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
- @"Setting lineWidth to a constant value expression should update line-width.");
- XCTAssertEqualObjects(layer.lineWidth, constantExpression,
- @"lineWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.lineWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
- @"Setting lineWidth to a camera expression should update line-width.");
- XCTAssertEqualObjects(layer.lineWidth, functionExpression,
- @"lineWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.lineWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
- @"Setting lineWidth to a data expression should update line-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.lineWidth, pedanticFunctionExpression,
- @"lineWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.lineWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
- @"Setting lineWidth to a camera-data expression should update line-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.lineWidth, pedanticFunctionExpression,
- @"lineWidth should round-trip camera-data expressions.");
-
- layer.lineWidth = nil;
- XCTAssertTrue(rawLayer->getLineWidth().isUndefined(),
- @"Unsetting lineWidth should return line-width to the default value.");
- XCTAssertEqualObjects(layer.lineWidth, defaultExpression,
- @"lineWidth should return the default value after being unset.");
- // Transition property test
- layer.lineWidthTransition = transitionTest;
- auto toptions = rawLayer->getLineWidthTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition lineWidthTransition = layer.lineWidthTransition;
- XCTAssertEqual(lineWidthTransition.delay, transitionTest.delay);
- XCTAssertEqual(lineWidthTransition.duration, transitionTest.duration);
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"line-cap" isBoolean:NO];
- [self testPropertyName:@"line-join" isBoolean:NO];
- [self testPropertyName:@"line-miter-limit" isBoolean:NO];
- [self testPropertyName:@"line-round-limit" isBoolean:NO];
- [self testPropertyName:@"line-blur" isBoolean:NO];
- [self testPropertyName:@"line-color" isBoolean:NO];
- [self testPropertyName:@"line-dash-pattern" isBoolean:NO];
- [self testPropertyName:@"line-gap-width" isBoolean:NO];
- [self testPropertyName:@"line-offset" isBoolean:NO];
- [self testPropertyName:@"line-opacity" isBoolean:NO];
- [self testPropertyName:@"line-pattern" isBoolean:NO];
- [self testPropertyName:@"line-translation" isBoolean:NO];
- [self testPropertyName:@"line-translation-anchor" isBoolean:NO];
- [self testPropertyName:@"line-width" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapButt].MGLLineCapValue, MGLLineCapButt);
- XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapRound].MGLLineCapValue, MGLLineCapRound);
- XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapSquare].MGLLineCapValue, MGLLineCapSquare);
- XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinBevel].MGLLineJoinValue, MGLLineJoinBevel);
- XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinRound].MGLLineJoinValue, MGLLineJoinRound);
- XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinMiter].MGLLineJoinValue, MGLLineJoinMiter);
- XCTAssertEqual([NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorMap].MGLLineTranslationAnchorValue, MGLLineTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorViewport].MGLLineTranslationAnchorValue, MGLLineTranslationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLMapCameraTests.m b/platform/darwin/test/MGLMapCameraTests.m
deleted file mode 100644
index 9fbf6b9e45..0000000000
--- a/platform/darwin/test/MGLMapCameraTests.m
+++ /dev/null
@@ -1,106 +0,0 @@
-#import <XCTest/XCTest.h>
-#import <CoreLocation/CoreLocation.h>
-#import <Mapbox/Mapbox.h>
-#import <MapKit/MapKit.h>
-
-@interface MGLMapCameraTests : XCTestCase
-
-@end
-
-@implementation MGLMapCameraTests
-
-- (void)testEyeCoordinateInitialization {
- CLLocationCoordinate2D fountainSquare = CLLocationCoordinate2DMake(39.10152215, -84.5124439696089);
- CLLocationCoordinate2D unionTerminal = CLLocationCoordinate2DMake(39.10980955, -84.5352778794236);
-
- MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromEyeCoordinate:fountainSquare
- eyeAltitude:1000];
- MKMapCamera *mkCamera = [MKMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromEyeCoordinate:fountainSquare
- eyeAltitude:1000];
- XCTAssertEqual(camera.centerCoordinate.latitude, fountainSquare.latitude);
- XCTAssertEqual(camera.centerCoordinate.longitude, fountainSquare.longitude);
- XCTAssertEqual(camera.centerCoordinate.latitude, mkCamera.centerCoordinate.latitude);
- XCTAssertEqual(camera.centerCoordinate.longitude, mkCamera.centerCoordinate.longitude);
- XCTAssertEqual(camera.altitude, 1000, @"Eye altitude should be equivalent to altitude in untilted camera.");
- XCTAssertEqual(camera.altitude, mkCamera.altitude, @"Eye altitude in untilted camera should match MapKit.");
- XCTAssertEqual(camera.pitch, 0, @"Camera directly over center coordinate should be untilted.");
- XCTAssertEqual(camera.pitch, mkCamera.pitch, @"Camera directly over center coordinate should have same pitch as MapKit.");
- XCTAssertEqual(camera.heading, 0, @"Camera directly over center coordinate should be unrotated.");
- XCTAssertEqual(camera.heading, mkCamera.heading, @"Camera directly over center coordinate should have same heading as MapKit.");
-
- camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromEyeCoordinate:unionTerminal
- eyeAltitude:1000];
- mkCamera = [MKMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromEyeCoordinate:unionTerminal
- eyeAltitude:1000];
- XCTAssertEqual(camera.centerCoordinate.latitude, fountainSquare.latitude);
- XCTAssertEqual(camera.centerCoordinate.longitude, fountainSquare.longitude);
- XCTAssertEqual(camera.centerCoordinate.latitude, mkCamera.centerCoordinate.latitude);
- XCTAssertEqual(camera.centerCoordinate.longitude, mkCamera.centerCoordinate.longitude);
- XCTAssertEqual(camera.altitude, 1000);
- XCTAssertEqual(camera.altitude, mkCamera.altitude, @"Eye altitude in tilted camera should match MapKit.");
- XCTAssertEqualWithAccuracy(camera.pitch, 65.3469146074, 0.01);
- XCTAssertEqual(camera.pitch, mkCamera.pitch);
- XCTAssertEqualWithAccuracy(camera.heading, 115.066396383, 0.01);
- XCTAssertEqualWithAccuracy(camera.heading, mkCamera.heading, 0.01);
-}
-
-- (void)testViewingDistanceInitialization {
- CLLocationCoordinate2D fountainSquare = CLLocationCoordinate2DMake(39.10152215, -84.5124439696089);
- MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- acrossDistance:10000
- pitch:0
- heading:0];
- MKMapCamera *mkCamera = [MKMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromDistance:10000
- pitch:0
- heading:0];
- XCTAssertEqualWithAccuracy(camera.altitude, 10000, 0.01, @"Untilted camera should use distance verbatim.");
- XCTAssertEqualWithAccuracy(camera.altitude, mkCamera.altitude, 0.01, @"Untilted camera altitude should match MapKit.");
-
- camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- altitude:10000
- pitch:0
- heading:0];
- XCTAssertEqual(camera.altitude, 10000, @"Untilted camera should use altitude verbatim.");
-
- camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- acrossDistance:10000
- pitch:60
- heading:0];
- mkCamera = [MKMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- fromDistance:10000
- pitch:60
- heading:0];
- XCTAssertEqualWithAccuracy(camera.altitude, 5000, 0.01, @"Tilted camera altitude should account for pitch.");
- XCTAssertEqualWithAccuracy(camera.altitude, mkCamera.altitude, 0.01, @"Tilted camera altitude should match MapKit.");
-
- camera = [MGLMapCamera cameraLookingAtCenterCoordinate:fountainSquare
- altitude:10000
- pitch:60
- heading:0];
- XCTAssertEqual(camera.altitude, 10000, @"Tilted camera should use altitude verbatim.");
-}
-
-- (void)testViewingDistance {
- MGLMapCamera *camera = [MGLMapCamera camera];
- camera.altitude = 10000;
- XCTAssertEqual(camera.altitude, 10000);
- XCTAssertEqual(camera.viewingDistance, 10000);
- camera.viewingDistance = 10000;
- XCTAssertEqual(camera.altitude, 10000);
- XCTAssertEqual(camera.viewingDistance, 10000);
-
- camera.pitch = 60;
- camera.altitude = 10000;
- XCTAssertEqual(camera.altitude, 10000);
- XCTAssertEqualWithAccuracy(camera.viewingDistance, 20000, 0.01);
- camera.viewingDistance = 10000;
- XCTAssertEqualWithAccuracy(camera.altitude, 5000, 0.01);
- XCTAssertEqual(camera.viewingDistance, 10000);
-}
-
-@end
diff --git a/platform/darwin/test/MGLMapViewTests.m b/platform/darwin/test/MGLMapViewTests.m
deleted file mode 100644
index 9ad7016a61..0000000000
--- a/platform/darwin/test/MGLMapViewTests.m
+++ /dev/null
@@ -1,155 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-#import <TargetConditionals.h>
-
-#if TARGET_OS_IPHONE
- #define MGLEdgeInsetsZero UIEdgeInsetsZero
-#else
- #define MGLEdgeInsetsZero NSEdgeInsetsZero
-#endif
-
-static MGLMapView *mapView;
-
-@interface MGLMapViewTests : XCTestCase
-@end
-
-@implementation MGLMapViewTests
-
-- (void)setUp {
- [super setUp];
-
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
- NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
- mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 64, 64) styleURL:styleURL];
-}
-
-- (void)tearDown {
- mapView = nil;
- [MGLAccountManager setAccessToken:nil];
- [super tearDown];
-}
-
-- (void)testCoordinateBoundsConversion {
- [mapView setCenterCoordinate:CLLocationCoordinate2DMake(33, 179)];
-
- MGLCoordinateBounds leftAntimeridianBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(-75, 175), CLLocationCoordinate2DMake(75, 180));
- CGRect leftAntimeridianBoundsRect = [mapView convertCoordinateBounds:leftAntimeridianBounds toRectToView:mapView];
-
- MGLCoordinateBounds rightAntimeridianBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(-75, -180), CLLocationCoordinate2DMake(75, -175));
- CGRect rightAntimeridianBoundsRect = [mapView convertCoordinateBounds:rightAntimeridianBounds toRectToView:mapView];
-
- MGLCoordinateBounds spanningBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(24, 140), CLLocationCoordinate2DMake(44, 240));
- CGRect spanningBoundsRect = [mapView convertCoordinateBounds:spanningBounds toRectToView:mapView];
-
- // If the resulting CGRect from -convertCoordinateBounds:toRectToView:
- // intersects the set of bounds to the left and right of the
- // antimeridian, then we know that the CGRect spans across the antimeridian
- XCTAssertTrue(CGRectIntersectsRect(spanningBoundsRect, leftAntimeridianBoundsRect), @"Resulting");
- XCTAssertTrue(CGRectIntersectsRect(spanningBoundsRect, rightAntimeridianBoundsRect), @"Something");
-}
-
-#if TARGET_OS_IPHONE
-- (void)testUserTrackingModeCompletion {
- __block BOOL completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeNone animated:NO completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when the mode is unchanged.");
-
- completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeNone animated:YES completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when the mode is unchanged.");
-
- completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeFollow animated:NO completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when there’s no location.");
-
- completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeFollowWithHeading animated:YES completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when there’s no location.");
-}
-
-- (void)testTargetCoordinateCompletion {
- __block BOOL completed = NO;
- [mapView setTargetCoordinate:kCLLocationCoordinate2DInvalid animated:NO completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when the target coordinate is unchanged.");
-
- completed = NO;
- [mapView setTargetCoordinate:kCLLocationCoordinate2DInvalid animated:YES completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when the target coordinate is unchanged.");
-
- completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeFollow animated:NO completionHandler:nil];
- [mapView setTargetCoordinate:CLLocationCoordinate2DMake(39.128106, -84.516293) animated:YES completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when not tracking user course.");
-
- completed = NO;
- [mapView setUserTrackingMode:MGLUserTrackingModeFollowWithCourse animated:NO completionHandler:nil];
- [mapView setTargetCoordinate:CLLocationCoordinate2DMake(39.224407, -84.394957) animated:YES completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when there’s no location.");
-}
-#endif
-
-- (void)testVisibleCoordinatesCompletion {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should get called when not animated"];
- MGLCoordinateBounds unitBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(1, 1));
- [mapView setVisibleCoordinateBounds:unitBounds edgePadding:MGLEdgeInsetsZero animated:NO completionHandler:^{
- [expectation fulfill];
- }];
- [self waitForExpectations:@[expectation] timeout:1];
-
-#if TARGET_OS_IPHONE
- expectation = [self expectationWithDescription:@"Completion block should get called when animated"];
- CLLocationCoordinate2D antiunitCoordinates[] = {
- CLLocationCoordinate2DMake(0, 0),
- CLLocationCoordinate2DMake(-1, -1),
- };
- [mapView setVisibleCoordinates:antiunitCoordinates
- count:sizeof(antiunitCoordinates) / sizeof(antiunitCoordinates[0])
- edgePadding:UIEdgeInsetsZero
- direction:0
- duration:0
- animationTimingFunction:nil
- completionHandler:^{
- [expectation fulfill];
- }];
- [self waitForExpectations:@[expectation] timeout:1];
-#endif
-}
-
-- (void)testShowAnnotationsCompletion {
- __block BOOL completed = NO;
- [mapView showAnnotations:@[] edgePadding:MGLEdgeInsetsZero animated:NO completionHandler:^{
- completed = YES;
- }];
- XCTAssertTrue(completed, @"Completion block should get called synchronously when there are no annotations to show.");
-
- XCTestExpectation *expectation = [self expectationWithDescription:@"Completion block should get called when not animated"];
- MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
- [mapView showAnnotations:@[annotation] edgePadding:MGLEdgeInsetsZero animated:NO completionHandler:^{
- [expectation fulfill];
- }];
- [self waitForExpectations:@[expectation] timeout:1];
-
- expectation = [self expectationWithDescription:@"Completion block should get called when animated."];
- [mapView showAnnotations:@[annotation] edgePadding:MGLEdgeInsetsZero animated:YES completionHandler:^{
- [expectation fulfill];
- }];
- [self waitForExpectations:@[expectation] timeout:1];
-}
-
-@end
diff --git a/platform/darwin/test/MGLNSDateAdditionsTests.mm b/platform/darwin/test/MGLNSDateAdditionsTests.mm
deleted file mode 100644
index 6d8d951024..0000000000
--- a/platform/darwin/test/MGLNSDateAdditionsTests.mm
+++ /dev/null
@@ -1,40 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#include <mbgl/util/chrono.hpp>
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-using namespace std::chrono_literals;
-
-@interface MGLNSDateAdditionsTests : XCTestCase
-@end
-
-@implementation MGLNSDateAdditionsTests
-
-- (void)testDurationToNSTimeInterval {
-
- NSTimeInterval timeInterval = 5;
- mbgl::Duration duration = MGLDurationFromTimeInterval(timeInterval);
- NSTimeInterval durationTimeInterval = MGLTimeIntervalFromDuration(duration);
-
- mbgl::Duration expectedDuration = 5s;
- mbgl::Duration expectedDurationMiliSeconds = 5000ms;
- mbgl::Duration expectedDurationMicroSeconds = 5000000us;
- mbgl::Duration expectedDurationNanoSeconds = 5000000000ns;
-
- XCTAssertEqual(timeInterval, durationTimeInterval);
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDuration));
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationMiliSeconds));
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationMicroSeconds));
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationNanoSeconds));
-
- mbgl::Duration durationMiliSeconds = 2500ms;
- mbgl::Duration durationMicroSeconds = 2500000us;
- mbgl::Duration durationNanoSeconds = 2500000000ns;
-
- XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationMiliSeconds));
- XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationMicroSeconds));
- XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationNanoSeconds));
-
-}
-
-@end
diff --git a/platform/darwin/test/MGLNSStringAdditionsTests.m b/platform/darwin/test/MGLNSStringAdditionsTests.m
deleted file mode 100644
index 872a8ce664..0000000000
--- a/platform/darwin/test/MGLNSStringAdditionsTests.m
+++ /dev/null
@@ -1,89 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import "NSString+MGLAdditions.h"
-
-@interface MGLNSStringAdditionsTests : XCTestCase
-
-@end
-
-@implementation MGLNSStringAdditionsTests
-
-- (void)testTitleCasedString {
- NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
-
- XCTAssertEqualObjects([@"© OpenStreetMap" mgl_titleCasedStringWithLocale:locale], @"© OpenStreetMap");
- XCTAssertEqualObjects([@"© OSM" mgl_titleCasedStringWithLocale:locale], @"© OSM");
-
- XCTAssertEqualObjects([@"Improve this map" mgl_titleCasedStringWithLocale:locale], @"Improve This Map");
- XCTAssertEqualObjects([@"Improve This Map" mgl_titleCasedStringWithLocale:locale], @"Improve This Map");
-
- XCTAssertEqualObjects([@"Improve the map" mgl_titleCasedStringWithLocale:locale], @"Improve the Map");
- XCTAssertEqualObjects([@"Improve The Map" mgl_titleCasedStringWithLocale:locale], @"Improve The Map");
-
- XCTAssertEqualObjects([@"Improve a map" mgl_titleCasedStringWithLocale:locale], @"Improve a Map");
- XCTAssertEqualObjects([@"Improve A Map" mgl_titleCasedStringWithLocale:locale], @"Improve A Map");
-
- XCTAssertEqualObjects([@"Improve for the map" mgl_titleCasedStringWithLocale:locale], @"Improve for the Map");
- XCTAssertEqualObjects([@"Improve For The Map" mgl_titleCasedStringWithLocale:locale], @"Improve For The Map");
-
- XCTAssertEqualObjects([@"Improve and map" mgl_titleCasedStringWithLocale:locale], @"Improve and Map");
- XCTAssertEqualObjects([@"Improve And Map" mgl_titleCasedStringWithLocale:locale], @"Improve And Map");
-
- XCTAssertEqualObjects([@"Improve while mapping" mgl_titleCasedStringWithLocale:locale], @"Improve While Mapping");
- XCTAssertEqualObjects([@"Improve While Mapping" mgl_titleCasedStringWithLocale:locale], @"Improve While Mapping");
-
- XCTAssertEqualObjects([@"Improve with the map" mgl_titleCasedStringWithLocale:locale], @"Improve With the Map");
- XCTAssertEqualObjects([@"Improve With The Map" mgl_titleCasedStringWithLocale:locale], @"Improve With The Map");
-
- XCTAssertEqualObjects([@"Improve this iPhone" mgl_titleCasedStringWithLocale:locale], @"Improve This iPhone");
- XCTAssertEqualObjects([@"Improve This iPhone" mgl_titleCasedStringWithLocale:locale], @"Improve This iPhone");
-}
-
-- (void)testTransliteratedString {
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Latn"], @"Portland");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Hans"], @"Portland");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Hant"], @"Portland");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"Портланд");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Arab"], @"پُرتلَند");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ポルテランデ");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Kore"], @"폹란드");
- XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Fake"], @"Portland");
-
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Latn"], @"běi jīng");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Hans"], @"北京");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Hant"], @"北京");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"бе̌и йӣнг");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Arab"], @"بِِ̌ جِينگ");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ベ̌イ ジーング");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Kore"], @"베̌이 지̄늑");
- XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Fake"], @"北京");
-
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Latn"], @"jiǔ lóng");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Hans"], @"九龙");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Hant"], @"九龍");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"йиу̌ ло́нг");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Arab"], @"جُِ̌ لُ́نگ");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ジウ̌ ロ́ング");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Kore"], @"지우̌ 로́늑");
- XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Fake"], @"九龍");
-
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Latn"], @"Moskva");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Hans"], @"Mосква");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Hant"], @"Mосква");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"Москва");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Arab"], @"مُسكڤَ");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"モスクヷ");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Kore"], @"못크바");
- XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Fake"], @"Mосква");
-
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Latn"], @"rondon");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Hans"], @"ロンドン");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Hant"], @"ロンドン");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"рондон");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Arab"], @"رُندُن");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ロンドン");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Kore"], @"론돈");
- XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Fake"], @"ロンドン");
-}
-
-@end
diff --git a/platform/darwin/test/MGLOfflinePackTests.mm b/platform/darwin/test/MGLOfflinePackTests.mm
deleted file mode 100644
index 6b454ee8ca..0000000000
--- a/platform/darwin/test/MGLOfflinePackTests.mm
+++ /dev/null
@@ -1,58 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-#import "MGLOfflinePack_Private.h"
-#import "MGLTestAssertionHandler.h"
-
-@interface MGLOfflinePackTests : XCTestCase
-
-@end
-
-@implementation MGLOfflinePackTests
-
-- (void)testInvalidation {
- MGLOfflinePack *invalidPack = [[MGLOfflinePack alloc] init];
-
- XCTAssertEqual(invalidPack.state, MGLOfflinePackStateInvalid, @"Offline pack should be invalid when initialized independently of MGLOfflineStorage.");
-
- XCTAssertThrowsSpecificNamed(invalidPack.region, NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when accessing its region.");
- XCTAssertThrowsSpecificNamed(invalidPack.context, NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when accessing its context.");
- XCTAssertThrowsSpecificNamed([invalidPack resume], NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when being resumed.");
- XCTAssertThrowsSpecificNamed([invalidPack suspend], NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when being suspended.");
-}
-
-- (void)testInvalidatingAnInvalidPack {
- MGLOfflinePack *invalidPack = [[MGLOfflinePack alloc] init];
-
- XCTAssertThrowsSpecificNamed([invalidPack invalidate], NSException, NSInternalInconsistencyException, @"Invalid offline pack should raise an exception when being invalidated.");
-
- // Now try again, without asserts
- NSAssertionHandler *oldHandler = [NSAssertionHandler currentHandler];
- MGLTestAssertionHandler *newHandler = [[MGLTestAssertionHandler alloc] initWithTestCase:self];
- [[[NSThread currentThread] threadDictionary] setValue:newHandler forKey:NSAssertionHandlerKey];
-
- // Make sure this doesn't crash without asserts
- [invalidPack invalidate];
-
- [[[NSThread currentThread] threadDictionary] setValue:oldHandler forKey:NSAssertionHandlerKey];
-}
-
-- (void)testProgressBoxing {
- MGLOfflinePackProgress progress = {
- .countOfResourcesCompleted = 3,
- .countOfResourcesExpected = 2,
- .countOfBytesCompleted = 7,
- .countOfTilesCompleted = 1,
- .countOfTileBytesCompleted = 6,
- .maximumResourcesExpected = UINT64_MAX,
- };
- MGLOfflinePackProgress roundTrippedProgress = [NSValue valueWithMGLOfflinePackProgress:progress].MGLOfflinePackProgressValue;
-
- XCTAssertEqual(progress.countOfResourcesCompleted, roundTrippedProgress.countOfResourcesCompleted, @"Completed resources should round-trip.");
- XCTAssertEqual(progress.countOfResourcesExpected, roundTrippedProgress.countOfResourcesExpected, @"Expected resources should round-trip.");
- XCTAssertEqual(progress.countOfBytesCompleted, roundTrippedProgress.countOfBytesCompleted, @"Completed bytes should round-trip.");
- XCTAssertEqual(progress.countOfTilesCompleted, roundTrippedProgress.countOfTilesCompleted, @"Completed tiles should round-trip.");
- XCTAssertEqual(progress.countOfTileBytesCompleted, roundTrippedProgress.countOfTileBytesCompleted, @"Completed tile bytes should round-trip.");
- XCTAssertEqual(progress.maximumResourcesExpected, roundTrippedProgress.maximumResourcesExpected, @"Maximum expected resources should round-trip.");
-}
-
-@end
diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m
deleted file mode 100644
index 0af9ebb5fa..0000000000
--- a/platform/darwin/test/MGLOfflineRegionTests.m
+++ /dev/null
@@ -1,71 +0,0 @@
-#import <Mapbox/Mapbox.h>
-
-#import <XCTest/XCTest.h>
-
-@interface MGLOfflineRegionTests : XCTestCase
-
-@end
-
-@implementation MGLOfflineRegionTests
-
-- (void)testStyleURLs {
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid);
- MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:nil bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX];
- XCTAssertEqualObjects(region.styleURL, [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion], @"Streets isn’t the default style.");
-
- NSURL *localURL = [NSURL URLWithString:@"beautiful.style"];
- XCTAssertThrowsSpecificNamed([[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:localURL bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX], NSException, MGLInvalidStyleURLException, @"No exception raised when initializing region with a local file URL as the style URL.");
-}
-
-- (void)testTilePyramidRegionEquality {
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid);
- MGLTilePyramidOfflineRegion *original = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] bounds:bounds fromZoomLevel:5 toZoomLevel:10];
- MGLTilePyramidOfflineRegion *copy = [original copy];
- XCTAssertEqualObjects(original, copy, @"Tile pyramid region should be equal to its copy.");
-
- XCTAssertEqualObjects(original.styleURL, copy.styleURL, @"Style URL has changed.");
- XCTAssert(MGLCoordinateBoundsEqualToCoordinateBounds(original.bounds, copy.bounds), @"Bounds have changed.");
- XCTAssertEqual(original.minimumZoomLevel, copy.minimumZoomLevel, @"Minimum zoom level has changed.");
- XCTAssertEqual(original.maximumZoomLevel, copy.maximumZoomLevel, @"Maximum zoom level has changed.");
- XCTAssertEqual(original.includesIdeographicGlyphs, copy.includesIdeographicGlyphs, @"Include ideographs has changed.");
-}
-
-- (void)testGeometryRegionEquality {
- NSString *geojson = @"{\"type\": \"Point\", \"coordinates\": [-3.8671874999999996, 52.482780222078226] }";
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData: [geojson dataUsingEncoding:NSUTF8StringEncoding] encoding: NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
-
- MGLShapeOfflineRegion *original = [[MGLShapeOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] shape:shape fromZoomLevel:5 toZoomLevel:10];
- original.includesIdeographicGlyphs = NO;
- MGLShapeOfflineRegion *copy = [original copy];
- XCTAssertEqualObjects(original, copy, @"Shape region should be equal to its copy.");
-
- XCTAssertEqualObjects(original.styleURL, copy.styleURL, @"Style URL has changed.");
- XCTAssertEqualObjects(original.shape, copy.shape, @"Geometry has changed.");
- XCTAssertEqual(original.minimumZoomLevel, copy.minimumZoomLevel, @"Minimum zoom level has changed.");
- XCTAssertEqual(original.maximumZoomLevel, copy.maximumZoomLevel, @"Maximum zoom level has changed.");
- XCTAssertEqual(original.includesIdeographicGlyphs, copy.includesIdeographicGlyphs, @"Include ideographs has changed.");
-}
-
-- (void)testIncludesIdeographicGlyphsByDefault {
-
- // Tile pyramid offline region
- {
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid);
- MGLTilePyramidOfflineRegion *tilePyramidOfflineRegion = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] bounds:bounds fromZoomLevel:5 toZoomLevel:10];
- XCTAssertFalse(tilePyramidOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs");
- }
-
- // Shape offline region
- {
- NSString *geojson = @"{\"type\": \"Point\", \"coordinates\": [-3.8671874999999996, 52.482780222078226] }";
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData: [geojson dataUsingEncoding:NSUTF8StringEncoding] encoding: NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
- MGLShapeOfflineRegion *shapeOfflineRegion = [[MGLShapeOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] shape:shape fromZoomLevel:5 toZoomLevel:10];
- XCTAssertFalse(shapeOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs");
- }
-}
-
-@end
diff --git a/platform/darwin/test/MGLOfflineStorageTests.mm b/platform/darwin/test/MGLOfflineStorageTests.mm
deleted file mode 100644
index 8f6114658a..0000000000
--- a/platform/darwin/test/MGLOfflineStorageTests.mm
+++ /dev/null
@@ -1,671 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#import "MGLOfflineStorage_Private.h"
-#import "NSBundle+MGLAdditions.h"
-#import "NSDate+MGLAdditions.h"
-#import "MGLTestAssertionHandler.h"
-
-#include <mbgl/storage/resource.hpp>
-#include <mbgl/util/run_loop.hpp>
-
-#pragma clang diagnostic ignored "-Wshadow"
-
-
-@interface MGLOfflineStorageTests : XCTestCase <MGLOfflineStorageDelegate>
-@end
-
-@implementation MGLOfflineStorageTests
-
-+ (void)tearDown {
- NSURL *cacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
- inDomain:NSUserDomainMask
- appropriateForURL:nil
- create:NO
- error:nil];
- NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier];
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier];
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@".mapbox"];
- XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectoryURL.path], @"Cache subdirectory should exist.");
-
- NSURL *cacheURL = [cacheDirectoryURL URLByAppendingPathComponent:@"cache.db"];
-
- [[NSFileManager defaultManager] removeItemAtURL:cacheURL error:nil];
- XCTAssertFalse([[NSFileManager defaultManager] fileExistsAtPath:cacheURL.path], @"Cache subdirectory should not exist.");
-}
-
-- (void)setUp {
- [super setUp];
-
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- XCTestExpectation *expectation = [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- return changeKind == NSKeyValueChangeSetting;
- }];
- if ([MGLOfflineStorage sharedOfflineStorage].packs) {
- [expectation fulfill];
- [self waitForExpectationsWithTimeout:0 handler:nil];
- } else {
- [self waitForExpectationsWithTimeout:10 handler:nil];
- }
-
- XCTAssertNotNil([MGLOfflineStorage sharedOfflineStorage].packs, @"Shared offline storage object should have a non-nil collection of packs by this point.");
- });
-}
-
-- (void)testSharedObject {
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage], [MGLOfflineStorage sharedOfflineStorage], @"There should only be one shared offline storage object.");
-}
-
-- (void)testAddPackForBounds {
- NSUInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
-
- NSURL *styleURL = [MGLStyle lightStyleURLWithVersion:8];
- /// Somewhere near Grape Grove, Ohio, United States.
- MGLCoordinateBounds bounds = {
- { .latitude = 39.70358155855172, .longitude = -83.69506472545841 },
- { .latitude = 39.703818870225376, .longitude = -83.69420641857361 },
- };
- double zoomLevel = 20;
- MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:styleURL bounds:bounds fromZoomLevel:zoomLevel toZoomLevel:zoomLevel];
-
- NSString *nameKey = @"Name";
- NSString *name = @"🍇 Grape Grove";
-
- NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{
- nameKey: name,
- }];
-
- __block MGLOfflinePack *pack;
- [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
- return changeKind == NSKeyValueChangeInsertion && indices.count == 1;
- }];
- XCTestExpectation *additionCompletionHandlerExpectation = [self expectationWithDescription:@"add pack completion handler"];
- [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable completionHandlerPack, NSError * _Nullable error) {
- XCTAssertNotNil(completionHandlerPack, @"Added pack should exist.");
- XCTAssertEqual(completionHandlerPack.state, MGLOfflinePackStateInactive, @"New pack should initially have inactive state.");
- pack = completionHandlerPack;
- [additionCompletionHandlerExpectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:5 handler:nil];
-
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks + 1, @"Added pack should have been added to the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks.");
-
- XCTAssertEqual(pack, [MGLOfflineStorage sharedOfflineStorage].packs.lastObject, @"Pack should be appended to end of packs array.");
-
- XCTAssertEqualObjects(pack.region, region, @"Added pack’s region has changed.");
-
- NSDictionary *userInfo = [NSKeyedUnarchiver unarchiveObjectWithData:pack.context];
- XCTAssert([userInfo isKindOfClass:[NSDictionary class]], @"Context of offline pack isn’t a dictionary.");
- XCTAssert([userInfo[nameKey] isKindOfClass:[NSString class]], @"Name of offline pack isn’t a string.");
- XCTAssertEqualObjects(userInfo[nameKey], name, @"Name of offline pack has changed.");
-
- XCTAssertEqual(pack.state, MGLOfflinePackStateInactive, @"New pack should initially have inactive state.");
-
- [self keyValueObservingExpectationForObject:pack keyPath:@"state" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- const auto state = static_cast<MGLOfflinePackState>([change[NSKeyValueChangeNewKey] longValue]);
- return changeKind == NSKeyValueChangeSetting && state == MGLOfflinePackStateInactive;
- }];
- [self expectationForNotification:MGLOfflinePackProgressChangedNotification object:pack handler:^BOOL(NSNotification * _Nonnull notification) {
- MGLOfflinePack *notificationPack = notification.object;
- XCTAssert([notificationPack isKindOfClass:[MGLOfflinePack class]], @"Object of notification should be an MGLOfflinePack.");
-
- NSDictionary *userInfo = notification.userInfo;
- XCTAssertNotNil(userInfo, @"Progress change notification should have a userInfo dictionary.");
-
- NSNumber *stateNumber = userInfo[MGLOfflinePackUserInfoKeyState];
- XCTAssert([stateNumber isKindOfClass:[NSNumber class]], @"Progress change notification’s state should be an NSNumber.");
- XCTAssertEqual(stateNumber.integerValue, pack.state, @"State in a progress change notification should match the pack’s state.");
-
- NSValue *progressValue = userInfo[MGLOfflinePackUserInfoKeyProgress];
- XCTAssert([progressValue isKindOfClass:[NSValue class]], @"Progress change notification’s progress should be an NSValue.");
- XCTAssertEqualObjects(progressValue, [NSValue valueWithMGLOfflinePackProgress:pack.progress], @"Progress change notification’s progress should match pack’s progress.");
-
- return notificationPack == pack && pack.state == MGLOfflinePackStateInactive;
- }];
- [pack requestProgress];
- [self waitForExpectationsWithTimeout:5 handler:nil];
-}
-
-- (void)testAddPackForGeometry {
- NSUInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
-
- NSURL *styleURL = [MGLStyle lightStyleURLWithVersion:8];
- double zoomLevel = 20;
- NSString *geojson = @"{ \"type\": \"Polygon\", \"coordinates\": [ [ [ 5.1299285888671875, 52.10365839097971 ], [ 5.103063583374023, 52.110037078604236 ], [ 5.080232620239258, 52.09548601177304 ], [ 5.106925964355469, 52.07987524347506 ], [ 5.1299285888671875, 52.10365839097971 ] ] ]}";
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData: [geojson dataUsingEncoding:NSUTF8StringEncoding] encoding: NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
- MGLShapeOfflineRegion *region = [[MGLShapeOfflineRegion alloc] initWithStyleURL:styleURL shape:shape fromZoomLevel:zoomLevel toZoomLevel:zoomLevel];
- region.includesIdeographicGlyphs = NO;
-
- NSString *nameKey = @"Name";
- NSString *name = @"Utrecht centrum";
-
- NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{nameKey: name}];
-
- __block MGLOfflinePack *pack;
- [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
- return changeKind == NSKeyValueChangeInsertion && indices.count == 1;
- }];
- XCTestExpectation *additionCompletionHandlerExpectation = [self expectationWithDescription:@"add pack completion handler"];
- [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable completionHandlerPack, NSError * _Nullable error) {
- XCTAssertNotNil(completionHandlerPack, @"Added pack should exist.");
- XCTAssertEqual(completionHandlerPack.state, MGLOfflinePackStateInactive, @"New pack should initially have inactive state.");
- pack = completionHandlerPack;
- [additionCompletionHandlerExpectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:5 handler:nil];
-
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks + 1, @"Added pack should have been added to the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks.");
-
- XCTAssertEqual(pack, [MGLOfflineStorage sharedOfflineStorage].packs.lastObject, @"Pack should be appended to end of packs array.");
-
- XCTAssertEqualObjects(pack.region, region, @"Added pack’s region has changed.");
-
- NSDictionary *userInfo = [NSKeyedUnarchiver unarchiveObjectWithData:pack.context];
- XCTAssert([userInfo isKindOfClass:[NSDictionary class]], @"Context of offline pack isn’t a dictionary.");
- XCTAssert([userInfo[nameKey] isKindOfClass:[NSString class]], @"Name of offline pack isn’t a string.");
- XCTAssertEqualObjects(userInfo[nameKey], name, @"Name of offline pack has changed.");
-
- XCTAssertEqual(pack.state, MGLOfflinePackStateInactive, @"New pack should initially have inactive state.");
-
- [self keyValueObservingExpectationForObject:pack keyPath:@"state" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- const auto state = static_cast<MGLOfflinePackState>([change[NSKeyValueChangeNewKey] longValue]);
- return changeKind == NSKeyValueChangeSetting && state == MGLOfflinePackStateInactive;
- }];
- [self expectationForNotification:MGLOfflinePackProgressChangedNotification object:pack handler:^BOOL(NSNotification * _Nonnull notification) {
- MGLOfflinePack *notificationPack = notification.object;
- XCTAssert([notificationPack isKindOfClass:[MGLOfflinePack class]], @"Object of notification should be an MGLOfflinePack.");
-
- NSDictionary *userInfo = notification.userInfo;
- XCTAssertNotNil(userInfo, @"Progress change notification should have a userInfo dictionary.");
-
- NSNumber *stateNumber = userInfo[MGLOfflinePackUserInfoKeyState];
- XCTAssert([stateNumber isKindOfClass:[NSNumber class]], @"Progress change notification’s state should be an NSNumber.");
- XCTAssertEqual(stateNumber.integerValue, pack.state, @"State in a progress change notification should match the pack’s state.");
-
- NSValue *progressValue = userInfo[MGLOfflinePackUserInfoKeyProgress];
- XCTAssert([progressValue isKindOfClass:[NSValue class]], @"Progress change notification’s progress should be an NSValue.");
- XCTAssertEqualObjects(progressValue, [NSValue valueWithMGLOfflinePackProgress:pack.progress], @"Progress change notification’s progress should match pack’s progress.");
-
- return notificationPack == pack && pack.state == MGLOfflinePackStateInactive;
- }];
- [pack requestProgress];
- [self waitForExpectationsWithTimeout:5 handler:nil];
- pack = nil;
-}
-
-- (void)testInvalidatePack {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Expect offline pack to be invalidated without an error."];
- MGLCoordinateBounds bounds = {
- { .latitude = 48.8660, .longitude = 2.3306 },
- { .latitude = 48.8603, .longitude = 2.3213 },
- };
-
- NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
- MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:styleURL bounds:bounds fromZoomLevel:10 toZoomLevel:11];
-
- NSString *nameKey = @"Name";
- NSString *name = @"Paris square";
-
- NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{nameKey: name}];
- [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable pack, NSError * _Nullable error) {
- XCTAssertNotNil(pack);
- [[MGLOfflineStorage sharedOfflineStorage] invalidatePack:pack withCompletionHandler:^(NSError * _Nullable) {
- XCTAssertNotNil(pack);
- XCTAssertNil(error);
- [expectation fulfill];
- }];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
-}
-
-- (void)testSetMaximumAmbientCache {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Expect maximum cache size to be raised without an error."];
- [[MGLOfflineStorage sharedOfflineStorage] setMaximumAmbientCacheSize:0 withCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
-
- [self waitForExpectationsWithTimeout:10 handler:nil];
-}
-
-- (void)testInvalidateAmbientCache {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Expect cache to be invalidated without an error."];
- [[MGLOfflineStorage sharedOfflineStorage] invalidateAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
-}
-
-- (void)testClearCache {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Expect cache to be cleared without an error."];
- [[MGLOfflineStorage sharedOfflineStorage] clearAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
-}
-
-- (void)testResetDatabase {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Expect database to be reset without an error."];
- [[MGLOfflineStorage sharedOfflineStorage] resetDatabaseWithCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertNil(error);
- [expectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
-}
-
-- (void)testBackupExclusion {
- NSURL *cacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
- inDomain:NSUserDomainMask
- appropriateForURL:nil
- create:NO
- error:nil];
- // As of iOS SDK 12.2 unit tests now have a bundle id: com.apple.dt.xctest.tool
- NSString *bundleIdentifier = [NSBundle mgl_applicationBundleIdentifier];
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier];
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@".mapbox"];
- XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectoryURL.path], @"Cache subdirectory should exist.");
-
- NSURL *cacheURL = [cacheDirectoryURL URLByAppendingPathComponent:@"cache.db"];
- XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:cacheURL.path], @"Cache database should exist.");
-
- NSError *error = nil;
- NSNumber *exclusionFlag = nil;
- [cacheDirectoryURL getResourceValue:&exclusionFlag
- forKey:NSURLIsExcludedFromBackupKey
- error:&error];
- XCTAssertTrue(exclusionFlag && [exclusionFlag boolValue], @"Backup exclusion flag should be set for the directory containing the cache database.");
- XCTAssertNil(error, @"No errors should be returned when checking backup exclusion flag.");
-}
-
-- (void)testRemovePack {
- NSUInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
-
- MGLOfflinePack *pack = [MGLOfflineStorage sharedOfflineStorage].packs.lastObject;
- XCTAssertNotNil(pack, @"Added pack should still exist.");
-
- [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
- return changeKind == NSKeyValueChangeRemoval && indices.count == 1;
- }];
- XCTestExpectation *completionHandlerExpectation = [self expectationWithDescription:@"remove pack completion handler"];
- [[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertEqual(pack.state, MGLOfflinePackStateInvalid, @"Removed pack should be invalid in the completion handler.");
- [completionHandlerExpectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:5 handler:nil];
-
- XCTAssertEqual(pack.state, MGLOfflinePackStateInvalid, @"Removed pack should have been invalidated synchronously.");
-
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks - 1, @"Removed pack should have been removed from the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks or -testAddPack.");
-}
-
-- (void)addPacks:(NSInteger)count {
-
- XCTestExpectation *expectation = [self expectationWithDescription:@"added packs"];
-
- NSURL *styleURL = [MGLStyle lightStyleURLWithVersion:8];
-
- MGLCoordinateBounds bounds[] = {
- {{51.5, -0.2}, {51.6, -0.1}}, // London
- {{60.1, 24.8}, {60.3, 25.1}}, // Helsinki
- {{38.9, -77.1}, {38.9, -77.0}}, // DC
- {{37.7, -122.5}, {37.9, -122.4}} // SF
- };
-
- int arraySize = sizeof(bounds)/sizeof(bounds[0]);
-
- count = MIN(count, arraySize);
-
- dispatch_group_t group = dispatch_group_create();
-
- for (int i = 0; i < count; i++) {
-
- dispatch_group_enter(group);
- MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:styleURL bounds:bounds[i] fromZoomLevel:20 toZoomLevel:20];
- NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{
- @"index": @(i)
- }];
-
- [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region
- withContext:context
- completionHandler:^(MGLOfflinePack * _Nullable pack, NSError * _Nullable error) {
- XCTAssertNotNil(pack);
- XCTAssertNil(error);
-
- dispatch_group_leave(group);
- }];
- }
-
- dispatch_group_notify(group, dispatch_get_main_queue(), ^{
- [expectation fulfill];
- });
-
- [self waitForExpectations:@[expectation] timeout:1.0];
-}
-
-- (void)testRemovePackTwiceInSuccession {
-
- [self addPacks:1];
-
- NSUInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
-
- MGLOfflinePack *pack = [MGLOfflineStorage sharedOfflineStorage].packs.lastObject;
- XCTAssertNotNil(pack, @"Added pack should still exist.");
-
- [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
- return changeKind == NSKeyValueChangeRemoval && indices.count == 1;
- }];
-
- XCTestExpectation *completionHandlerExpectation = [self expectationWithDescription:@"remove pack completion handler"];
-
- [[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:nil];
-
- NSAssertionHandler *oldHandler = [NSAssertionHandler currentHandler];
- MGLTestAssertionHandler *newHandler = [[MGLTestAssertionHandler alloc] initWithTestCase:self];
-
- [[[NSThread currentThread] threadDictionary] setValue:newHandler forKey:NSAssertionHandlerKey];
-
- [[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:^(NSError * _Nullable error) {
- XCTAssertEqual(pack.state, MGLOfflinePackStateInvalid, @"Removed pack should be invalid in the completion handler.");
- [completionHandlerExpectation fulfill];
- }];
-
- [self waitForExpectationsWithTimeout:5 handler:nil];
-
- [[[NSThread currentThread] threadDictionary] setValue:oldHandler forKey:NSAssertionHandlerKey];
-
- XCTAssertEqual(pack.state, MGLOfflinePackStateInvalid, @"Removed pack should have been invalidated synchronously.");
-
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks - 1, @"Removed pack should have been removed from the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks or -testAddPack.");
-
- NSLog(@"Test `%@` complete", NSStringFromSelector(_cmd));
-}
-
-- (void)test15536RemovePacksWhileReloading {
-
- // This test triggers
- //
- // throw std::runtime_error("Malformed offline region definition");
- //
- // in offline.cpp
- //
- // Reloading packs, while trying to remove them is currently problematic.
-
- [self addPacks:4];
-
- NSInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
- XCTAssert(countOfPacks > 0);
-
- // Now delete packs one by one
- XCTestExpectation *expectation = [self expectationWithDescription:@"All packs removed"];
- expectation.expectedFulfillmentCount = countOfPacks;
-
- MGLOfflineStorage *storage = [MGLOfflineStorage sharedOfflineStorage];
- NSArray *packs = [storage.packs copy];
-
- // Simulate what happens the first time sharedOfflineStorage is accessed
- [storage reloadPacks];
-
- NSArray *validPacks = [packs filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
- MGLOfflinePack *pack = (MGLOfflinePack*)evaluatedObject;
- return pack.state != MGLOfflinePackStateInvalid;
- }]];
-
- NSAssertionHandler *oldHandler = [NSAssertionHandler currentHandler];
- MGLTestAssertionHandler *newHandler = [[MGLTestAssertionHandler alloc] initWithTestCase:self];
-
- [[[NSThread currentThread] threadDictionary] setValue:newHandler forKey:NSAssertionHandlerKey];
-
- for (MGLOfflinePack *pack in validPacks) {
- [storage removePack:pack withCompletionHandler:^(NSError * _Nullable error) {
- [expectation fulfill];
- }];
- }
-
- [[[NSThread currentThread] threadDictionary] setValue:oldHandler forKey:NSAssertionHandlerKey];
-
- [self waitForExpectations:@[expectation] timeout:10.0];
-
- // TODO: What should we expect here? All packs removed?
-
- NSLog(@"Test `%@` complete", NSStringFromSelector(_cmd));
-}
-
-// Test to explore https://github.com/mapbox/mapbox-gl-native/issues/15536
-- (void)test15536RemovePacksOnBackgroundQueueWhileReloading {
-
- [self addPacks:4];
-
- NSInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
- XCTAssert(countOfPacks > 0);
-
- // Now delete packs one by one
- dispatch_queue_t queue = dispatch_queue_create("com.mapbox.testRemovePacks", DISPATCH_QUEUE_SERIAL);
-
- XCTestExpectation *expectation = [self expectationWithDescription:@"all packs removed"];
- expectation.expectedFulfillmentCount = countOfPacks;
-
- MGLOfflineStorage *storage = [MGLOfflineStorage sharedOfflineStorage];
-
- // Simulate what happens the first time sharedOfflineStorage is accessed
- [storage reloadPacks];
-
-// NSArray *packs = [storage.packs copy];
-
- dispatch_async(queue, ^{
- NSArray *packs = storage.packs;
- NSAssertionHandler *oldHandler = [NSAssertionHandler currentHandler];
- MGLTestAssertionHandler *newHandler = [[MGLTestAssertionHandler alloc] initWithTestCase:self];
-
- [[[NSThread currentThread] threadDictionary] setValue:newHandler forKey:NSAssertionHandlerKey];
-
- NSArray *validPacks = [packs filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
- MGLOfflinePack *pack = (MGLOfflinePack*)evaluatedObject;
- return pack.state != MGLOfflinePackStateInvalid;
- }]];
-
- for (MGLOfflinePack *pack in validPacks) {
- // NOTE: pack can be invalid, as we have two threads potentially
- // modifying the same MGLOfflinePack.
-
- dispatch_group_t group = dispatch_group_create();
- dispatch_group_enter(group);
- [storage removePack:pack withCompletionHandler:^(NSError * _Nullable error) {
- dispatch_group_leave(group);
- }];
- dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
-
- [expectation fulfill];
- }
-
- [[[NSThread currentThread] threadDictionary] setValue:oldHandler forKey:NSAssertionHandlerKey];
- });
-
- [self waitForExpectations:@[expectation] timeout:60.0];
-
- // TODO: What should we expect here? All packs removed?
-
- NSLog(@"Test `%@` complete", NSStringFromSelector(_cmd));
-}
-
-- (void)testCountOfBytesCompleted {
- XCTAssertGreaterThan([MGLOfflineStorage sharedOfflineStorage].countOfBytesCompleted, 0UL);
-}
-
-- (NSURL *)offlineStorage:(MGLOfflineStorage *)storage
- URLForResourceOfKind:(MGLResourceKind)kind
- withURL:(NSURL *)url {
- if ([url.scheme isEqual: @"test"] && [url.host isEqual: @"api"]) {
- return [NSURL URLWithString:@"https://api.mapbox.com"];
- } else {
- return url;
- }
-}
-
-- (void)testResourceTransform {
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- [os setDelegate:self];
-
- auto fs = os.mbglFileSource;
-
- // Delegate returns "https://api.mapbox.com" as a replacement URL.
- const mbgl::Resource resource { mbgl::Resource::Unknown, "test://api" };
- std::unique_ptr<mbgl::AsyncRequest> req;
- req = fs->request(resource, [&](mbgl::Response res) {
- req.reset();
- XCTAssertFalse(res.error.get(), @"Request should not return an error");
- XCTAssertTrue(res.data.get(), @"Request should return data");
- XCTAssertEqual("{\"api\":\"mapbox\"}", *res.data, @"Request did not return expected data");
- CFRunLoopStop(CFRunLoopGetCurrent());
- });
-
- CFRunLoopRun();
-
- [os setDelegate:nil];
-}
-
-- (void)testAddFileContent {
- NSFileManager *fileManager = [NSFileManager defaultManager];
-
- // Valid database
- [XCTContext runActivityNamed:@"Valid database" block:^(id<XCTActivity> activity) {
- NSURL *resourceURL = [NSURL fileURLWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"sideload_sat" ofType:@"db"]];
-
- NSError *error;
- NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:resourceURL.path error:&error];
- XCTAssertNil(error, @"Getting the file's attributes should not return an error. (%@)", resourceURL.path);
-
- NSNumber *fileSizeNumber = [fileAttributes objectForKey:NSFileSize];
- long long fileSize = [fileSizeNumber longLongValue];
- long long databaseFileSize = 73728;
- // Merging databases creates an empty file if the file does not exist at the given path.
- XCTAssertEqual(fileSize, databaseFileSize, @"The database file size must be:%lld actual size:%lld", databaseFileSize, fileSize);
-
- NSUInteger countOfPacks = [MGLOfflineStorage sharedOfflineStorage].packs.count;
-
- [self keyValueObservingExpectationForObject:[MGLOfflineStorage sharedOfflineStorage] keyPath:@"packs" handler:^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) {
- const auto changeKind = static_cast<NSKeyValueChange>([change[NSKeyValueChangeKindKey] unsignedLongValue]);
- NSIndexSet *indices = change[NSKeyValueChangeIndexesKey];
- return changeKind == NSKeyValueChangeInsertion && indices.count == 1;
- }];
-
- XCTestExpectation *fileAdditionCompletionHandlerExpectation = [self expectationWithDescription:@"add database content completion handler"];
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- [os addContentsOfURL:resourceURL withCompletionHandler:^(NSURL *fileURL, NSArray<MGLOfflinePack *> * _Nullable packs, NSError * _Nullable error) {
- XCTAssertNotNil(fileURL, @"The fileURL should not be nil.");
- XCTAssertNotNil(packs, @"Adding the contents of the sideload_sat.db should update one pack.");
- XCTAssertNil(error, @"Adding contents to a file should not return an error.");
- for (MGLOfflinePack *pack in [MGLOfflineStorage sharedOfflineStorage].packs) {
- NSLog(@"PACK:%@", pack);
- }
- [fileAdditionCompletionHandlerExpectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
- // Depending on the database it may update or add a pack. For this case specifically the offline database adds one pack.
- XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks + 1, @"Adding contents of sideload_sat.db should add one pack.");
- }];
-
- // Invalid database type
- [XCTContext runActivityNamed:@"Invalid database type" block:^(id<XCTActivity> activity) {
- NSURL *resourceURL = [NSURL fileURLWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"one-liner" ofType:@"json"]];
-
- XCTestExpectation *invalidFileCompletionHandlerExpectation = [self expectationWithDescription:@"invalid content database completion handler"];
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- [os addContentsOfFile:resourceURL.path withCompletionHandler:^(NSURL *fileURL, NSArray<MGLOfflinePack *> * _Nullable packs, NSError * _Nullable error) {
- XCTAssertNotNil(error, @"Passing an invalid offline database file should return an error.");
- XCTAssertNil(packs, @"Passing an invalid offline database file should not add packs to the offline database.");
- [invalidFileCompletionHandlerExpectation fulfill];
- }];
- [self waitForExpectationsWithTimeout:10 handler:nil];
- }];
-
- // File does not exist
- [XCTContext runActivityNamed:@"File does not exist" block:^(id<XCTActivity> activity) {
- NSURL *resourceURL = [NSURL URLWithString:@"nonexistent.db"];
-
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- XCTAssertThrowsSpecificNamed([os addContentsOfURL:resourceURL withCompletionHandler:nil], NSException, NSInvalidArgumentException, "MGLOfflineStorage should rise an exception if an invalid database file is passed.");
- }];
-
- // URL to a non-file
- [XCTContext runActivityNamed:@"URL to a non-file" block:^(id<XCTActivity> activity) {
- NSURL *resourceURL = [NSURL URLWithString:@"https://www.mapbox.com"];
-
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- XCTAssertThrowsSpecificNamed([os addContentsOfURL:resourceURL withCompletionHandler:nil], NSException, NSInvalidArgumentException, "MGLOfflineStorage should rise an exception if an invalid URL file is passed.");
- }];
-}
-
-- (void)testPutResourceForURL {
- NSURL *styleURL = [NSURL URLWithString:@"https://api.mapbox.com/some/thing"];
-
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- std::string testData("test data");
- NSData *data = [NSData dataWithBytes:testData.c_str() length:testData.length()];
- [os preloadData:data forURL:styleURL modificationDate:nil expirationDate:nil eTag:nil mustRevalidate:NO];
-
- auto fs = os.mbglFileSource;
- const mbgl::Resource resource { mbgl::Resource::Unknown, "https://api.mapbox.com/some/thing" };
- std::unique_ptr<mbgl::AsyncRequest> req;
- req = fs->request(resource, [&](mbgl::Response res) {
- req.reset();
- XCTAssertFalse(res.error.get(), @"Request should not return an error");
- XCTAssertTrue(res.data.get(), @"Request should return data");
- XCTAssertFalse(res.modified, @"Request should not have a modification timestamp");
- XCTAssertFalse(res.expires, @"Request should not have an expiration timestamp");
- XCTAssertFalse(res.etag, @"Request should not have an entity tag");
- XCTAssertFalse(res.mustRevalidate, @"Request should not require revalidation");
- XCTAssertEqual("test data", *res.data, @"Request did not return expected data");
- CFRunLoopStop(CFRunLoopGetCurrent());
- });
-
- CFRunLoopRun();
-}
-
-- (void)testPutResourceForURLWithTimestamps {
- NSURL *styleURL = [NSURL URLWithString:@"https://api.mapbox.com/some/thing"];
-
- MGLOfflineStorage *os = [MGLOfflineStorage sharedOfflineStorage];
- std::string testData("test data");
- NSDate *now = [NSDate date];
- NSDate *future = [now dateByAddingTimeInterval:600];
- NSData *data = [NSData dataWithBytes:testData.c_str() length:testData.length()];
- [os preloadData:data forURL:styleURL modificationDate:now expirationDate:future eTag:@"some etag" mustRevalidate:YES];
-
- auto fs = os.mbglFileSource;
- const mbgl::Resource resource { mbgl::Resource::Unknown, "https://api.mapbox.com/some/thing" };
- std::unique_ptr<mbgl::AsyncRequest> req;
- req = fs->request(resource, [&](mbgl::Response res) {
- req.reset();
- XCTAssertFalse(res.error.get(), @"Request should not return an error");
- XCTAssertTrue(res.data.get(), @"Request should return data");
- XCTAssertTrue(res.modified, @"Request should have a modification timestamp");
- XCTAssertEqual(MGLTimeIntervalFromDuration(res.modified->time_since_epoch()), floor(now.timeIntervalSince1970), @"Modification timestamp should roundtrip");
- XCTAssertTrue(res.expires, @"Request should have an expiration timestamp");
- XCTAssertEqual(MGLTimeIntervalFromDuration(res.expires->time_since_epoch()), floor(future.timeIntervalSince1970), @"Expiration timestamp should roundtrip");
- XCTAssertTrue(res.etag, @"Request should have an entity tag");
- XCTAssertEqual(*res.etag, "some etag", @"Entity tag should roundtrip");
- XCTAssertTrue(res.mustRevalidate, @"Request should require revalidation");
- XCTAssertEqual("test data", *res.data, @"Request did not return expected data");
- CFRunLoopStop(CFRunLoopGetCurrent());
- });
-
- CFRunLoopRun();
-}
-
-@end
diff --git a/platform/darwin/test/MGLPredicateTests.mm b/platform/darwin/test/MGLPredicateTests.mm
deleted file mode 100644
index 2ed18d48fc..0000000000
--- a/platform/darwin/test/MGLPredicateTests.mm
+++ /dev/null
@@ -1,426 +0,0 @@
-#import <XCTest/XCTest.h>
-#import <Mapbox/Mapbox.h>
-
-#import "NSPredicate+MGLPrivateAdditions.h"
-#import "MGLValueEvaluator.h"
-
-@interface MGLPredicateTests : XCTestCase
-@end
-
-@implementation MGLPredicateTests
-
-- (void)testUnsupportedFilterPredicates {
- XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a BEGINSWITH 'L'"].mgl_filter, NSException, NSInvalidArgumentException);
- XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a ENDSWITH 'itude'"].mgl_filter, NSException, NSInvalidArgumentException);
- XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a LIKE 'glob?trotter'"].mgl_filter, NSException, NSInvalidArgumentException);
- XCTAssertThrowsSpecificNamed([NSPredicate predicateWithFormat:@"a MATCHES 'i\\w{18}n'"].mgl_filter, NSException, NSInvalidArgumentException);
- NSPredicate *selectorPredicate = [NSPredicate predicateWithFormat:@"(SELF isKindOfClass: %@)", [MGLPolyline class]];
- XCTAssertThrowsSpecificNamed(selectorPredicate.mgl_filter, NSException, NSInvalidArgumentException);
-
- XCTAssertThrowsSpecificNamed([NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *, id> * _Nullable bindings) {
- XCTAssertTrue(NO, @"Predicate block should not be evaluated.");
- return NO;
- }].mgl_filter, NSException, NSInvalidArgumentException);
-}
-
-- (void)testComparisonPredicates {
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"x == YES"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"x"], @YES];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') < 5"];
- NSArray *jsonExpression = @[@"<", @[@"to-number", @[@"get", @"x"]], @5];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') > 5"];
- NSArray *jsonExpression = @[@">", @[@"to-number", @[@"get", @"x"]], @5];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') <= 5"];
- NSArray *jsonExpression = @[@"<=", @[@"to-number", @[@"get", @"x"]], @5];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') >= 5"];
- NSArray *jsonExpression = @[@">=", @[@"to-number", @[@"get", @"x"]], @5];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSString') > 'value'"];
- NSArray *jsonExpression = @[@">", @[@"to-string", @[@"get", @"x"]], @"value"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a = 'b'"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$geometryType = 'Point'"];
- NSArray *jsonExpression = @[@"==", @[@"geometry-type"], @"Point"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 67086180"];
- NSArray *jsonExpression = @[@"==", @[@"id"], @67086180];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = nil"];
- NSArray *jsonExpression = @[@"==", @[@"id"], [NSNull null]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a = nil"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], [NSNull null]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$geometryType != 'Point'"];
- NSArray *jsonExpression = @[@"!=", @[@"geometry-type"], @"Point"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier != 67086180"];
- NSArray *jsonExpression = @[@"!=", @[@"id"], @67086180];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier != nil"];
- NSArray *jsonExpression = @[@"!=", @[@"id"], [NSNull null]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a != 'b'"];
- NSArray *jsonExpression = @[@"!=", @[@"get", @"a"], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a != nil"];
- NSArray *jsonExpression = @[@"!=", @[@"get", @"a"], [NSNull null]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') < 'b'"];
- NSArray *jsonExpression = @[@"<", @[@"to-string", @[@"get", @"a"]], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') <= 'b'"];
- NSArray *jsonExpression = @[@"<=", @[@"to-string", @[@"get", @"a"]], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') > 'b'"];
- NSArray *jsonExpression = @[@">", @[@"to-string", @[@"get", @"a"]], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') >= 'b'"];
- NSArray *jsonExpression = @[@">=", @[@"to-string", @[@"get", @"a"]], @"b"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') BETWEEN {'b', 'z'}"];
- NSArray *jsonExpression =@[@"all", @[@"<=", @"b", @[@"to-string", @[@"get", @"a"]]], @[@"<=", @[@"to-string", @[@"get", @"a"]], @"z"]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits];
- NSArray *jsonExpression = @[@"all", @[@">=", @[@"to-number", @[@"get", @"x"]], @10], @[@"<=", @[@"to-number", @[@"get", @"x"]], @100]];
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSArray *expected = @[@"all", @[@"<=", @10, @[@"to-number", @[@"get", @"x"]]], @[@"<=", @[@"to-number", @[@"get", @"x"]], @100]];
- NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected]
- mustRoundTrip:NO];
- }
- {
- NSArray *expected = @[@"all", @[@"<=", @10, @[@"to-number", @[@"get", @"x"]]], @[@">=", @100, @[@"to-number", @[@"get", @"x"]]]];
- NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits];
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected]
- mustRoundTrip:NO];
- }
- {
- NSArray *expected = @[@"all", @[@">=", @[@"to-number", @[@"get", @"x"]], @10], @[@">=", @100, @[@"to-number", @[@"get", @"x"]]]];
- NSExpression *limits = [NSExpression expressionForAggregate:@[[NSExpression expressionForConstantValue:@10], [NSExpression expressionForConstantValue:@100]]];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(x, 'NSNumber') BETWEEN %@", limits];
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:expected], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:expected]
- mustRoundTrip:NO];
- }
- {
- NSArray *expected = @[@"match", @[@"id"], @[@6, @5, @4, @3], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier IN { 6, 5, 4, 3}"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($featureIdentifier, { 3, 4, 5, 6 }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"to-number", @[@"id"]], @[@3002970001, @3004140052, @3002950027, @3002970033], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST($featureIdentifier, 'NSNumber') IN { 3002970001, 3004140052, 3002950027, 3002970033 }"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST($featureIdentifier, 'NSNumber'), { 3002950027, 3002970001, 3002970033, 3004140052 }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"!", @[@"match", @[@"get", @"x"], @[@6, @5, @4, @3], @YES, @NO]];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT x IN { 6, 5, 4, 3}"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"NOT MGL_MATCH(x, { 3, 4, 5, 6 }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"get", @"a"], @[@"b", @"c"], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a IN { 'b', 'c' }"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(a, { 'b', 'c' }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"geometry-type"], @[@"LineString", @"Polygon"], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ IN %@", [NSExpression expressionForVariable:@"geometryType"], @[@"LineString", @"Polygon"]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($geometryType, { 'LineString', 'Polygon' }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"get", @"x"], @[@6, @5, @4, @3], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"{ 6, 5, 4, 3 } CONTAINS x"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(x, { 3, 4, 5, 6 }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"geometry-type"], @[@"LineString", @"Polygon"], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ CONTAINS %@", @[@"LineString", @"Polygon"], [NSExpression expressionForVariable:@"geometryType"]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($geometryType, { 'LineString', 'Polygon' }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
- {
- NSArray *expected = @[@"match", @[@"id"], @[@6, @5, @4, @3], @YES, @NO];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"{ 6, 5, 4, 3} CONTAINS $featureIdentifier"];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
- NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH($featureIdentifier, { 3, 4, 5, 6 }, YES, NO) == YES"];
- auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
- }
-}
-
-- (void)testComparisonPredicatesWithOptions {
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a =[c] 'b'"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @YES}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a =[d] 'b'"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], @"b", @[@"collator", @{@"case-sensitive": @YES, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a =[cd] 'b'"];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
-
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a !=[cd] 'b'"];
- NSArray *jsonExpression = @[@"!=", @[@"get", @"a"], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') <[cd] 'b'"];
- NSArray *jsonExpression = @[@"<", @[@"to-string", @[@"get", @"a"]], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') <=[cd] 'b'"];
- NSArray *jsonExpression = @[@"<=", @[@"to-string", @[@"get", @"a"]], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') >[cd] 'b'"];
- NSArray *jsonExpression = @[@">", @[@"to-string", @[@"get", @"a"]], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST(a, 'NSString') >=[cd] 'b'"];
- NSArray *jsonExpression = @[@">=", @[@"to-string", @[@"get", @"a"]], @"b", @[@"collator", @{@"case-sensitive": @NO, @"diacritic-sensitive": @NO}]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUE = MGL_FUNCTION('==', a, 'b', MGL_FUNCTION('collator', %@))", @{
- @"case-sensitive": @NO,
- @"diacritic-sensitive": @NO,
- @"locale": @"tlh",
- }];
- NSArray *jsonExpression = @[@"==", @[@"get", @"a"], @"b",
- @[@"collator",
- @{@"case-sensitive": @NO,
- @"diacritic-sensitive": @NO,
- @"locale": @"tlh"}]];
- XCTAssertEqualObjects([predicate.mgl_jsonExpressionObject lastObject], jsonExpression);
- }
-}
-
-- (void)testCompoundPredicates {
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a == 'b' AND c == 'd'"];
- NSArray *jsonExpression = @[@"all", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a == 'b' OR c == 'd'"];
- NSArray *jsonExpression = @[@"any", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(a == 'b' AND c == 'd')"];
- NSArray *jsonExpression = @[@"!", @[@"all", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(a == 'b' OR c == 'd')"];
- NSArray *jsonExpression = @[@"!", @[@"any", @[@"==", @[@"get", @"a"], @"b"], @[@"==", @[@"get", @"c"], @"d"]]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- XCTAssertEqualObjects([NSPredicate predicateWithMGLJSONObject:jsonExpression], predicate);
- [self testSymmetryWithPredicate:[NSPredicate predicateWithMGLJSONObject:jsonExpression]
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT a == nil"];
- NSArray *jsonExpression = @[@"!", @[@"==", @[@"get", @"a"], [NSNull null]]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
- {
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT a != nil"];
- NSArray *jsonExpression = @[@"!", @[@"!=", @[@"get", @"a"], [NSNull null]]];
- XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, jsonExpression);
- [self testSymmetryWithPredicate:predicate
- mustRoundTrip:NO];
- }
-}
-
-- (void)testSymmetryWithPredicate:(NSPredicate *)forwardPredicate mustRoundTrip:(BOOL)mustRoundTrip {
- auto forwardFilter = forwardPredicate.mgl_filter;
- NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
- if (mustRoundTrip) {
- // A collection of ints may turn into an aggregate of longs, for
- // example, so compare formats instead of the predicates themselves.
- XCTAssertEqualObjects(forwardPredicate.predicateFormat, forwardPredicateAfter.predicateFormat);
- } else {
- XCTAssertEqualObjects(forwardPredicate, forwardPredicateAfter);
- }
-}
-
-@end
diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/darwin/test/MGLRasterStyleLayerTests.mm
deleted file mode 100644
index 5168d2e0d4..0000000000
--- a/platform/darwin/test/MGLRasterStyleLayerTests.mm
+++ /dev/null
@@ -1,430 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/raster_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLRasterLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLRasterLayerTests
-
-+ (NSString *)layerType {
- return @"raster";
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"raster");
- auto rawLayer = static_cast<mbgl::style::RasterLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // raster-brightness-max
- {
- XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(),
- @"raster-brightness-max should be unset initially.");
- NSExpression *defaultExpression = layer.maximumRasterBrightness;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.maximumRasterBrightness = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
- @"Setting maximumRasterBrightness to a constant value expression should update raster-brightness-max.");
- XCTAssertEqualObjects(layer.maximumRasterBrightness, constantExpression,
- @"maximumRasterBrightness should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.maximumRasterBrightness = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
- @"Setting maximumRasterBrightness to a camera expression should update raster-brightness-max.");
- XCTAssertEqualObjects(layer.maximumRasterBrightness, functionExpression,
- @"maximumRasterBrightness should round-trip camera expressions.");
-
-
- layer.maximumRasterBrightness = nil;
- XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(),
- @"Unsetting maximumRasterBrightness should return raster-brightness-max to the default value.");
- XCTAssertEqualObjects(layer.maximumRasterBrightness, defaultExpression,
- @"maximumRasterBrightness should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.maximumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.maximumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // raster-brightness-min
- {
- XCTAssertTrue(rawLayer->getRasterBrightnessMin().isUndefined(),
- @"raster-brightness-min should be unset initially.");
- NSExpression *defaultExpression = layer.minimumRasterBrightness;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.minimumRasterBrightness = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
- @"Setting minimumRasterBrightness to a constant value expression should update raster-brightness-min.");
- XCTAssertEqualObjects(layer.minimumRasterBrightness, constantExpression,
- @"minimumRasterBrightness should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.minimumRasterBrightness = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
- @"Setting minimumRasterBrightness to a camera expression should update raster-brightness-min.");
- XCTAssertEqualObjects(layer.minimumRasterBrightness, functionExpression,
- @"minimumRasterBrightness should round-trip camera expressions.");
-
-
- layer.minimumRasterBrightness = nil;
- XCTAssertTrue(rawLayer->getRasterBrightnessMin().isUndefined(),
- @"Unsetting minimumRasterBrightness should return raster-brightness-min to the default value.");
- XCTAssertEqualObjects(layer.minimumRasterBrightness, defaultExpression,
- @"minimumRasterBrightness should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.minimumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.minimumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // raster-contrast
- {
- XCTAssertTrue(rawLayer->getRasterContrast().isUndefined(),
- @"raster-contrast should be unset initially.");
- NSExpression *defaultExpression = layer.rasterContrast;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.rasterContrast = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
- @"Setting rasterContrast to a constant value expression should update raster-contrast.");
- XCTAssertEqualObjects(layer.rasterContrast, constantExpression,
- @"rasterContrast should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterContrast = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
- @"Setting rasterContrast to a camera expression should update raster-contrast.");
- XCTAssertEqualObjects(layer.rasterContrast, functionExpression,
- @"rasterContrast should round-trip camera expressions.");
-
-
- layer.rasterContrast = nil;
- XCTAssertTrue(rawLayer->getRasterContrast().isUndefined(),
- @"Unsetting rasterContrast should return raster-contrast to the default value.");
- XCTAssertEqualObjects(layer.rasterContrast, defaultExpression,
- @"rasterContrast should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterContrast = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterContrast = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.rasterContrastTransition = transitionTest;
- auto toptions = rawLayer->getRasterContrastTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition rasterContrastTransition = layer.rasterContrastTransition;
- XCTAssertEqual(rasterContrastTransition.delay, transitionTest.delay);
- XCTAssertEqual(rasterContrastTransition.duration, transitionTest.duration);
- }
-
- // raster-fade-duration
- {
- XCTAssertTrue(rawLayer->getRasterFadeDuration().isUndefined(),
- @"raster-fade-duration should be unset initially.");
- NSExpression *defaultExpression = layer.rasterFadeDuration;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.rasterFadeDuration = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
- @"Setting rasterFadeDuration to a constant value expression should update raster-fade-duration.");
- XCTAssertEqualObjects(layer.rasterFadeDuration, constantExpression,
- @"rasterFadeDuration should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterFadeDuration = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
- @"Setting rasterFadeDuration to a camera expression should update raster-fade-duration.");
- XCTAssertEqualObjects(layer.rasterFadeDuration, functionExpression,
- @"rasterFadeDuration should round-trip camera expressions.");
-
-
- layer.rasterFadeDuration = nil;
- XCTAssertTrue(rawLayer->getRasterFadeDuration().isUndefined(),
- @"Unsetting rasterFadeDuration should return raster-fade-duration to the default value.");
- XCTAssertEqualObjects(layer.rasterFadeDuration, defaultExpression,
- @"rasterFadeDuration should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterFadeDuration = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterFadeDuration = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // raster-hue-rotate
- {
- XCTAssertTrue(rawLayer->getRasterHueRotate().isUndefined(),
- @"raster-hue-rotate should be unset initially.");
- NSExpression *defaultExpression = layer.rasterHueRotation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.rasterHueRotation = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
- @"Setting rasterHueRotation to a constant value expression should update raster-hue-rotate.");
- XCTAssertEqualObjects(layer.rasterHueRotation, constantExpression,
- @"rasterHueRotation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterHueRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
- @"Setting rasterHueRotation to a camera expression should update raster-hue-rotate.");
- XCTAssertEqualObjects(layer.rasterHueRotation, functionExpression,
- @"rasterHueRotation should round-trip camera expressions.");
-
-
- layer.rasterHueRotation = nil;
- XCTAssertTrue(rawLayer->getRasterHueRotate().isUndefined(),
- @"Unsetting rasterHueRotation should return raster-hue-rotate to the default value.");
- XCTAssertEqualObjects(layer.rasterHueRotation, defaultExpression,
- @"rasterHueRotation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterHueRotation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterHueRotation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // raster-opacity
- {
- XCTAssertTrue(rawLayer->getRasterOpacity().isUndefined(),
- @"raster-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.rasterOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.rasterOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
- @"Setting rasterOpacity to a constant value expression should update raster-opacity.");
- XCTAssertEqualObjects(layer.rasterOpacity, constantExpression,
- @"rasterOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
- @"Setting rasterOpacity to a camera expression should update raster-opacity.");
- XCTAssertEqualObjects(layer.rasterOpacity, functionExpression,
- @"rasterOpacity should round-trip camera expressions.");
-
-
- layer.rasterOpacity = nil;
- XCTAssertTrue(rawLayer->getRasterOpacity().isUndefined(),
- @"Unsetting rasterOpacity should return raster-opacity to the default value.");
- XCTAssertEqualObjects(layer.rasterOpacity, defaultExpression,
- @"rasterOpacity should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.rasterOpacityTransition = transitionTest;
- auto toptions = rawLayer->getRasterOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition rasterOpacityTransition = layer.rasterOpacityTransition;
- XCTAssertEqual(rasterOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(rasterOpacityTransition.duration, transitionTest.duration);
- }
-
- // raster-resampling
- {
- XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
- @"raster-resampling should be unset initially.");
- NSExpression *defaultExpression = layer.rasterResamplingMode;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
- layer.rasterResamplingMode = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::RasterResamplingType> propertyValue = { mbgl::style::RasterResamplingType::Nearest };
- XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
- @"Setting rasterResamplingMode to a constant value expression should update raster-resampling.");
- XCTAssertEqualObjects(layer.rasterResamplingMode, constantExpression,
- @"rasterResamplingMode should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'nearest'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterResamplingMode = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::RasterResamplingType>(
- step(zoom(), literal("nearest"), 18.0, literal("nearest"))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
- @"Setting rasterResamplingMode to a camera expression should update raster-resampling.");
- XCTAssertEqualObjects(layer.rasterResamplingMode, functionExpression,
- @"rasterResamplingMode should round-trip camera expressions.");
-
-
- layer.rasterResamplingMode = nil;
- XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(),
- @"Unsetting rasterResamplingMode should return raster-resampling to the default value.");
- XCTAssertEqualObjects(layer.rasterResamplingMode, defaultExpression,
- @"rasterResamplingMode should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // raster-saturation
- {
- XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(),
- @"raster-saturation should be unset initially.");
- NSExpression *defaultExpression = layer.rasterSaturation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.rasterSaturation = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
- @"Setting rasterSaturation to a constant value expression should update raster-saturation.");
- XCTAssertEqualObjects(layer.rasterSaturation, constantExpression,
- @"rasterSaturation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.rasterSaturation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
- @"Setting rasterSaturation to a camera expression should update raster-saturation.");
- XCTAssertEqualObjects(layer.rasterSaturation, functionExpression,
- @"rasterSaturation should round-trip camera expressions.");
-
-
- layer.rasterSaturation = nil;
- XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(),
- @"Unsetting rasterSaturation should return raster-saturation to the default value.");
- XCTAssertEqualObjects(layer.rasterSaturation, defaultExpression,
- @"rasterSaturation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.rasterSaturation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.rasterSaturation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- // Transition property test
- layer.rasterSaturationTransition = transitionTest;
- auto toptions = rawLayer->getRasterSaturationTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition rasterSaturationTransition = layer.rasterSaturationTransition;
- XCTAssertEqual(rasterSaturationTransition.delay, transitionTest.delay);
- XCTAssertEqual(rasterSaturationTransition.duration, transitionTest.duration);
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"maximum-raster-brightness" isBoolean:NO];
- [self testPropertyName:@"minimum-raster-brightness" isBoolean:NO];
- [self testPropertyName:@"raster-contrast" isBoolean:NO];
- [self testPropertyName:@"raster-fade-duration" isBoolean:NO];
- [self testPropertyName:@"raster-hue-rotation" isBoolean:NO];
- [self testPropertyName:@"raster-opacity" isBoolean:NO];
- [self testPropertyName:@"raster-resampling-mode" isBoolean:NO];
- [self testPropertyName:@"raster-saturation" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeLinear].MGLRasterResamplingModeValue, MGLRasterResamplingModeLinear);
- XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeNearest].MGLRasterResamplingModeValue, MGLRasterResamplingModeNearest);
-}
-
-@end
diff --git a/platform/darwin/test/MGLRendererConfigurationTests.mm b/platform/darwin/test/MGLRendererConfigurationTests.mm
deleted file mode 100644
index 6483aa3587..0000000000
--- a/platform/darwin/test/MGLRendererConfigurationTests.mm
+++ /dev/null
@@ -1,197 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-#import "MGLRendererConfiguration.h"
-
-static NSString * const MGLRendererConfigurationTests_collisionBehaviorKey = @"MGLCollisionBehaviorPre4_0";
-
-@interface MGLRendererConfiguration (Tests)
-- (instancetype)initWithPropertyDictionary:(nonnull NSDictionary*)bundle;
-- (mbgl::optional<std::string>)_localFontFamilyNameWithPropertyDictionary:(nonnull NSDictionary *)properties;
-@end
-
-
-@interface MGLRendererConfigurationTests : XCTestCase
-@end
-
-@implementation MGLRendererConfigurationTests
-- (void)setUp {
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:MGLRendererConfigurationTests_collisionBehaviorKey];
-}
-
-- (void)tearDown {
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:MGLRendererConfigurationTests_collisionBehaviorKey];
-}
-
-// Emulate what would happen with an Info.plist.
-- (void)testSettingMGLCollisionBehaviorPre40WithEmptyDictionary
-{
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{}];
- XCTAssertFalse(config.perSourceCollisions);
-}
-
-- (void)testSettingMGLCollisionBehaviorPre40WithYESDictionary
-{
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(NO)}];
- XCTAssertFalse(config.perSourceCollisions);
-}
-
-- (void)testSettingMGLCollisionBehaviorPre40WithNODictionary
-{
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(YES)}];
- XCTAssert(config.perSourceCollisions);
-}
-
-- (void)testSettingMGLCollisionBehaviorPre40InNSUserDefaults {
- {
- XCTAssertNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]);
- MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
- XCTAssertFalse(config.perSourceCollisions);
- }
-
- [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:MGLRendererConfigurationTests_collisionBehaviorKey];
- {
- XCTAssertNotNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]);
- MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
- XCTAssertFalse(config.perSourceCollisions);
- }
-
- [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:MGLRendererConfigurationTests_collisionBehaviorKey];
- {
- XCTAssertNotNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]);
- MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration];
- XCTAssert(config.perSourceCollisions);
- }
-}
-
-- (void)testSettingMGLCollisionBehaviorPre40PListValueUsingString {
- // Dictionary = "NO"
- {
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@"NO"}];
- XCTAssertFalse(config.perSourceCollisions);
- }
-
- // Dictionary = "YES"
- {
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@"YES"}];
- XCTAssert(config.perSourceCollisions);
- }
-}
-
-- (void)testOverridingMGLCollisionBehaviorPre40 {
- // Dictionary = NO, NSUserDefaults = YES
- {
- [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:MGLRendererConfigurationTests_collisionBehaviorKey];
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(NO)}];
- XCTAssert(config.perSourceCollisions);
- }
- // Dictionary = YES, NSUserDefaults = NO
- {
- [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:MGLRendererConfigurationTests_collisionBehaviorKey];
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(YES)}];
- XCTAssertFalse(config.perSourceCollisions);
- }
-}
-
-- (void)testDefaultLocalFontFamilyName {
-
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] init];
- std::string localFontFamilyName = config.localFontFamilyName.value();
-
- std::string systemFontFamilyName;
-#if TARGET_OS_IPHONE
- systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
-#else
- systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
-#endif
-
- XCTAssertEqual(localFontFamilyName, systemFontFamilyName, @"Default local font family name should match default system font");
-}
-
-- (void)testSettingMGLIdeographicFontFamilyNameWithPlistValue {
-
- MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] init];
- NSDictionary *dic;
-
- // `MGLIdeographicFontFamilyName` set to bool value `YES`
- {
- dic = @{@"MGLIdeographicFontFamilyName": @(YES)};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
-
- std::string systemFontFamilyName;
-#if TARGET_OS_IPHONE
- systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
-#else
- systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
-#endif
- XCTAssertEqual(localFontFamilyName, systemFontFamilyName, @"Local font family name should match default system font name when setting `YES`");
- }
-
- // `MGLIdeographicFontFamilyName` set to bool value `NO`
- {
- dic = @{@"MGLIdeographicFontFamilyName": @(NO)};
- mbgl::optional<std::string> localFontFamilyName = [config _localFontFamilyNameWithPropertyDictionary:dic];
- XCTAssertFalse(localFontFamilyName.has_value(), @"Client rendering font should use remote font when setting `NO`");
- }
-
- // `MGLIdeographicFontFamilyName` set to a valid font string value
- {
- dic = @{@"MGLIdeographicFontFamilyName": @"PingFang TC"};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
- std::string targetFontFamilyName = std::string([@"PingFang TC" UTF8String]);
- XCTAssertEqual(localFontFamilyName, targetFontFamilyName, @"Local font family name should match a custom valid font name");
- }
-
- // `MGLIdeographicFontFamilyName` set to an invalid font string value
- {
- dic = @{@"MGLIdeographicFontFamilyName": @"test font"};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
-
- std::string systemFontFamilyName;
-#if TARGET_OS_IPHONE
- systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
-#else
- systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
-#endif
- XCTAssertEqual(localFontFamilyName, systemFontFamilyName, @"Local font family name should match default system font name when setting an invalid font string");
- }
-
- // `MGLIdeographicFontFamilyName` set to a valid font family names array value
- {
- dic = @{@"MGLIdeographicFontFamilyName": @[@"test font 1", @"PingFang TC", @"test font 2"]};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
- std::string targetFontFamilyName = std::string([@"PingFang TC" UTF8String]);
- XCTAssertEqual(localFontFamilyName, targetFontFamilyName, @"Local font family name should match a custom valid font name in a font family names array");
- }
-
- // `MGLIdeographicFontFamilyName` set to an invalid font family names array value
- {
- dic = @{@"MGLIdeographicFontFamilyName": @[@"test font 1", @"test font 2", @"test font 3"]};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
-
- std::string systemFontFamilyName;
-#if TARGET_OS_IPHONE
- systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
-#else
- systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
-#endif
- XCTAssertEqual(localFontFamilyName, systemFontFamilyName, @"Local font family name should match default system font name when setting an invalid font family names array");
- }
-
- // `MGLIdeographicFontFamilyName` set to an invalid value type: NSDictionary, NSNumber, NSData, etc.
- {
- dic = @{@"MGLIdeographicFontFamilyName": [@"test font 1" dataUsingEncoding:NSUTF8StringEncoding]};
- std::string localFontFamilyName = ([config _localFontFamilyNameWithPropertyDictionary:dic]).value();
-
- std::string systemFontFamilyName;
-#if TARGET_OS_IPHONE
- systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
-#else
- systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
-#endif
- XCTAssertEqual(localFontFamilyName, systemFontFamilyName, @"Local font family name should match default system font name when setting an invalid value type");
- }
-}
-
-
-
-@end
diff --git a/platform/darwin/test/MGLResourceTests.mm b/platform/darwin/test/MGLResourceTests.mm
deleted file mode 100644
index 7fcccc535c..0000000000
--- a/platform/darwin/test/MGLResourceTests.mm
+++ /dev/null
@@ -1,85 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-#import <mbgl/storage/resource.hpp>
-
-namespace mbgl {
- extern NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountType);
-}
-
-@interface MGLResourceTests : XCTestCase
-@end
-
-@implementation MGLResourceTests
-
-- (void)testOfflineQueryParameterIsAddedForOfflineResource {
-
- using namespace mbgl;
-
- std::string testURL = "test://mapbox.com/testing_offline_query?a=one&b=two";
-
- // Is our test URL "correct" for subsequent checks?
- {
- NSURL *url = [NSURL URLWithString:@(testURL.c_str())];
- NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
- NSArray<NSURLQueryItem *> *items = components.queryItems;
- XCTAssert(items.count == 2);
- }
-
- Resource resource(Resource::Kind::Unknown, testURL);
-
- // By default, resources are NOT offline
- {
- bool skuTokenQueryItemFound;
- NSURL *url = resourceURLWithAccountType(resource, 0);
- NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
- for (NSURLQueryItem *item in components.queryItems) {
- XCTAssertFalse([item.name isEqualToString:@"offline"]);
- if ([item.name isEqualToString:@"sku"]) {
- skuTokenQueryItemFound = YES;
- }
- }
-
-#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- XCTAssertTrue(skuTokenQueryItemFound, "Default resource URL should have SKU token query item");
-#else
- XCTAssertFalse(skuTokenQueryItemFound, "Non-iOS platforms should not have a SKU token query item");
-#endif
- }
-
- // Now check offline
- resource.setUsage(Resource::Usage::Offline);
-
- {
- NSURL *url = resourceURLWithAccountType(resource, 0);
- NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
-
- // For offline, we expect a single offline query item
- NSInteger foundCount = 0;
-
-#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- for (NSURLQueryItem *item in components.queryItems) {
- if (([item.name isEqualToString:@"offline"] && [item.value isEqualToString:@"true"]) ||
- ([item.name isEqualToString:@"a"] && [item.value isEqualToString:@"one"]) ||
- ([item.name isEqualToString:@"b"] && [item.value isEqualToString:@"two"])) {
- foundCount++;
- }
- XCTAssertFalse([item.name isEqualToString:@"sku"]);
- }
-
- XCTAssert(foundCount == 3);
-#else
- // NOTE: Currently the macOS SDK does not supply the sku or offline query parameters
- for (NSURLQueryItem *item in components.queryItems) {
- if (([item.name isEqualToString:@"a"] && [item.value isEqualToString:@"one"]) ||
- ([item.name isEqualToString:@"b"] && [item.value isEqualToString:@"two"])) {
- foundCount++;
- }
- XCTAssertFalse([item.name isEqualToString:@"sku"]);
- }
-
- XCTAssert(foundCount == 2);
-#endif
- }
-}
-
-@end
diff --git a/platform/darwin/test/MGLSDKTestHelpers.swift b/platform/darwin/test/MGLSDKTestHelpers.swift
deleted file mode 100644
index c836f7c2fd..0000000000
--- a/platform/darwin/test/MGLSDKTestHelpers.swift
+++ /dev/null
@@ -1,48 +0,0 @@
-import XCTest
-
-class MGLSDKTestHelpers {
-
- class func checkTestsContainAllMethods(testClass: Swift.AnyClass, in p: Protocol) {
- let testMethods = self.classMethodDescriptions(testClass)
- let subjectMethods = self.protocolMethodDescriptions(p)
-
- for method in subjectMethods {
- if !testMethods.contains(method) {
- XCTFail("\(String(describing: testClass)) does not contain \(method) from \(String(describing: p))")
- }
- }
-
- XCTAssert(true)
- }
-
-}
-
-extension MGLSDKTestHelpers {
-
- class func protocolMethodDescriptions(_ p: Protocol) -> Set<String> {
- var methods = Set<String>()
- var methodCount = UInt32()
- let methodDescriptionList = protocol_copyMethodDescriptionList(p, false, true, &methodCount)
- for i in 0..<Int(methodCount) {
- let description = methodDescriptionList![i]
- XCTAssertNotNil(description.name?.description)
- methods.insert(description.name!.description)
- }
- free(methodDescriptionList)
- return methods
- }
-
- class func classMethodDescriptions(_ cls: Swift.AnyClass) -> Set<String> {
- var methods = Set<String>()
- var methodCount = UInt32()
- let methodList = class_copyMethodList(cls, &methodCount)
- for i in 0..<Int(methodCount) {
- let method = methodList![i]
- let selector = method_getName(method)
- methods.insert(selector.description)
- }
- free(methodList)
- return methods
- }
-
-}
diff --git a/platform/darwin/test/MGLShapeSourceTests.mm b/platform/darwin/test/MGLShapeSourceTests.mm
deleted file mode 100644
index 9046607010..0000000000
--- a/platform/darwin/test/MGLShapeSourceTests.mm
+++ /dev/null
@@ -1,330 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import <Mapbox/Mapbox.h>
-#import "MGLFeature_Private.h"
-#import "MGLShapeSource_Private.h"
-#import "MGLSource_Private.h"
-
-#include <mbgl/style/sources/geojson_source.hpp>
-
-@interface MGLShapeSourceTests : XCTestCase
-@end
-
-@implementation MGLShapeSourceTests
-
-- (void)testGeoJSONOptionsFromDictionary {
- NSExpression *reduceExpression = [NSExpression expressionForFunction:@"sum:" arguments:@[[NSExpression expressionForKeyPath:@"featureAccumulated"], [NSExpression expressionForKeyPath:@"sumValue"]]];
- NSExpression *mapExpression = [NSExpression expressionForKeyPath:@"mag"];
- NSArray *clusterPropertyArray = @[reduceExpression, mapExpression];
- NSDictionary *options = @{MGLShapeSourceOptionClustered: @YES,
- MGLShapeSourceOptionClusterRadius: @42,
- MGLShapeSourceOptionClusterProperties: @{@"sumValue": clusterPropertyArray},
- MGLShapeSourceOptionMaximumZoomLevelForClustering: @98,
- MGLShapeSourceOptionMaximumZoomLevel: @99,
- MGLShapeSourceOptionBuffer: @1976,
- MGLShapeSourceOptionSimplificationTolerance: @0.42,
- MGLShapeSourceOptionLineDistanceMetrics: @YES};
-
- auto mbglOptions = MGLGeoJSONOptionsFromDictionary(options);
- XCTAssertTrue(mbglOptions->cluster);
- XCTAssertEqual(mbglOptions->clusterRadius, 42);
- XCTAssertEqual(mbglOptions->clusterMaxZoom, 98);
- XCTAssertEqual(mbglOptions->maxzoom, 99);
- XCTAssertEqual(mbglOptions->buffer, 1976);
- XCTAssertEqual(mbglOptions->tolerance, 0.42);
- XCTAssertTrue(mbglOptions->lineMetrics);
- XCTAssertTrue(!mbglOptions->clusterProperties.empty());
-
- options = @{MGLShapeSourceOptionClustered: @"number 1"};
- XCTAssertThrows(MGLGeoJSONOptionsFromDictionary(options));
-}
-
-- (void)testNilShape {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"id" shape:nil options:nil];
- XCTAssertNil(source.shape);
-}
-
-- (void)testUnclusterableShape {
- NSDictionary *options = @{
- MGLShapeSourceOptionClustered: @YES,
- };
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"id" shape:[[MGLPointFeature alloc] init] options:options];
- XCTAssertTrue([source.shape isKindOfClass:[MGLPointFeature class]]);
-
- MGLShapeCollectionFeature *feature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[]];
- source = [[MGLShapeSource alloc] initWithIdentifier:@"id" shape:feature options:options];
- XCTAssertTrue([source.shape isKindOfClass:[MGLShapeCollectionFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithDataMultipleFeatures {
-
- NSString *geoJSON = @"{\"type\": \"FeatureCollection\",\"features\": [{\"type\": \"Feature\",\"properties\": {},\"geometry\": {\"type\": \"LineString\",\"coordinates\": [[-107.75390625,40.329795743702064],[-104.34814453125,37.64903402157866]]}}]}";
-
- NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
- XCTAssertNotNil(shape);
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:shape options:nil];
-
- MGLShapeCollection *collection = (MGLShapeCollection *)source.shape;
- XCTAssertNotNil(collection);
- XCTAssertEqual(collection.shapes.count, 1UL);
- XCTAssertTrue([collection.shapes.firstObject isMemberOfClass:[MGLPolylineFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithSingleGeometry {
- NSData *data = [@"{\"type\": \"Point\", \"coordinates\": [0, 0]}" dataUsingEncoding:NSUTF8StringEncoding];
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
- XCTAssertNotNil(shape);
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson" shape:shape options:nil];
- XCTAssertNotNil(source.shape);
- XCTAssert([source.shape isKindOfClass:[MGLPointAnnotation class]]);
-}
-
-- (void)testMGLGeoJSONSourceWithSingleFeature {
- NSString *geoJSON = @"{\"type\": \"Feature\", \"properties\": {\"color\": \"green\"}, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -114.06847000122069, 51.050459433092655 ] }}";
- NSData *data = [geoJSON dataUsingEncoding:NSUTF8StringEncoding];
- NSError *error;
- MGLShape *shape = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
- XCTAssertNil(error);
- XCTAssertNotNil(shape);
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"geojson" shape:shape options:nil];
- XCTAssertNotNil(source.shape);
- XCTAssert([source.shape isKindOfClass:[MGLPointFeature class]]);
- MGLPointFeature *feature = (MGLPointFeature *)source.shape;
- XCTAssert([feature.attributes.allKeys containsObject:@"color"]);
-}
-
-- (void)testMGLShapeSourceWithPolylineFeatures {
- CLLocationCoordinate2D coordinates[] = { CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(10, 10)};
- MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:coordinates count:2];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:polylineFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLPolylineFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithPolygonFeatures {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5];
- polygonFeature.identifier = @"feature-id";
- NSString *stringAttribute = @"string";
- NSNumber *boolAttribute = [NSNumber numberWithBool:YES];
- NSNumber *doubleAttribute = [NSNumber numberWithDouble:1.23];
- NSDictionary *nestedDictionaryValue = @{@"nested-key-1": @"nested-string-value"};
- NSArray *arrayValue = @[@"string-value", @2];
- NSDictionary *dictionaryValue = @{@"key-1": @"string-value",
- @"key-2": @1,
- @"key-3": nestedDictionaryValue,
- @"key-4": arrayValue};
- NSArray *arrayOfArrays = @[@[@1, @"string-value", @[@"jagged"]]];
- NSArray *arrayOfDictionaries = @[@{@"key": @"value"}];
-
- polygonFeature.attributes = @{@"name": stringAttribute,
- @"bool": boolAttribute,
- @"double": doubleAttribute,
- @"dictionary-attribute": dictionaryValue,
- @"array-attribute": arrayValue,
- @"array-of-array-attribute": arrayOfArrays,
- @"array-of-dictionary-attribute": arrayOfDictionaries};
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:polygonFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- MGLPolygonFeature *expectedPolygonFeature = (MGLPolygonFeature *)source.shape;
- XCTAssertEqualObjects(expectedPolygonFeature.identifier, polygonFeature.identifier);
- XCTAssertTrue([expectedPolygonFeature isMemberOfClass:[MGLPolygonFeature class]]);
- XCTAssertEqualObjects(expectedPolygonFeature.identifier, polygonFeature.identifier);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"name"], stringAttribute);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"bool"], boolAttribute);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"double"], doubleAttribute);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"dictionary-attribute"], dictionaryValue);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"array-attribute"], arrayValue);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"array-of-array-attribute"], arrayOfArrays);
- XCTAssertEqualObjects(expectedPolygonFeature.attributes[@"array-of-dictionary-attribute"], arrayOfDictionaries);
-}
-
-- (void)testMGLShapeSourceWithPolygonFeaturesInculdingInteriorPolygons {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- CLLocationCoordinate2D interiorCoordinates[] = {
- CLLocationCoordinate2DMake(0.2, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.2)};
-
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:interiorCoordinates count:5];
-
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5 interiorPolygons:@[polygon]];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:polygonFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLPolygonFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithMultiPolylineFeatures {
- CLLocationCoordinate2D firstCoordinates[] = { CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(10, 10)};
- MGLPolylineFeature *firstPolylineFeature = [MGLPolylineFeature polylineWithCoordinates:firstCoordinates count:2];
- CLLocationCoordinate2D secondCoordinates[] = { CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(10, 10)};
- MGLPolylineFeature *secondPolylineFeature = [MGLPolylineFeature polylineWithCoordinates:secondCoordinates count:2];
- MGLMultiPolylineFeature *multiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:@[firstPolylineFeature, secondPolylineFeature]];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:multiPolylineFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLMultiPolylineFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithMultiPolygonFeatures {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- CLLocationCoordinate2D interiorCoordinates[] = {
- CLLocationCoordinate2DMake(0.2, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.2)};
-
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:interiorCoordinates count:5];
-
- MGLPolygonFeature *firstPolygon = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5 interiorPolygons:@[polygon]];
- MGLPolygonFeature *secondPolygon = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5 interiorPolygons:@[polygon]];
-
- MGLMultiPolygonFeature *multiPolygonFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:@[firstPolygon, secondPolygon]];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:multiPolygonFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLMultiPolygonFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithPointFeature {
- MGLPointFeature *pointFeature = [MGLPointFeature new];
- pointFeature.coordinate = CLLocationCoordinate2DMake(0.2, 100.2);
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"souce-id" shape:pointFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLPointFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithPointCollectionFeature {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
- MGLPointCollectionFeature *pointCollectionFeature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coordinates count:5];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"souce-id" shape:pointCollectionFeature options:nil];
-
- XCTAssertNotNil(source.shape);
- XCTAssertTrue([source.shape isMemberOfClass:[MGLPointCollectionFeature class]]);
-}
-
-- (void)testMGLShapeSourceWithShapeCollectionFeatures {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- CLLocationCoordinate2D interiorCoordinates[] = {
- CLLocationCoordinate2DMake(0.2, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.8),
- CLLocationCoordinate2DMake(0.8, 100.2),
- CLLocationCoordinate2DMake(0.2, 100.2)};
-
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:interiorCoordinates count:5];
-
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:5 interiorPolygons:@[polygon]];
-
- CLLocationCoordinate2D coordinates_2[] = { CLLocationCoordinate2DMake(0, 0), CLLocationCoordinate2DMake(10, 10)};
- MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:coordinates_2 count:2];
-
- MGLMultiPolygonFeature *multiPolygonFeature = [MGLMultiPolygonFeature multiPolygonWithPolygons:@[polygonFeature, polygonFeature]];
-
- MGLMultiPolylineFeature *multiPolylineFeature = [MGLMultiPolylineFeature multiPolylineWithPolylines:@[polylineFeature, polylineFeature]];
-
- MGLPointCollectionFeature *pointCollectionFeature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coordinates count:5];
-
- MGLPointFeature *pointFeature = [MGLPointFeature new];
- pointFeature.coordinate = CLLocationCoordinate2DMake(0.2, 100.2);
-
- MGLShapeCollectionFeature *shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[polygonFeature, polylineFeature, multiPolygonFeature, multiPolylineFeature, pointCollectionFeature, pointFeature]];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shape:shapeCollectionFeature options:nil];
-
- MGLShapeCollectionFeature *shape = (MGLShapeCollectionFeature *)source.shape;
- XCTAssertNotNil(shape);
- XCTAssert(shape.shapes.count == 6, @"Shape collection should contain 6 shapes");
-}
-
-- (void)testMGLShapeSourceWithFeaturesConvenienceInitializer {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- MGLPolygonFeature *polygonFeature = [MGLPolygonFeature polygonWithCoordinates:coordinates count:sizeof(coordinates)/sizeof(coordinates[0]) interiorPolygons:nil];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" features:@[polygonFeature] options:nil];
- MGLShapeCollectionFeature *shape = (MGLShapeCollectionFeature *)source.shape;
-
- XCTAssertTrue([shape isKindOfClass:[MGLShapeCollectionFeature class]]);
- XCTAssertEqual(shape.shapes.count, 1UL, @"Shape collection should contain 1 shape");
-
- // when a shape is included in the features array
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:sizeof(coordinates)/sizeof(coordinates[0]) interiorPolygons:nil];
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wobjc-literal-conversion"
- XCTAssertThrowsSpecificNamed([[MGLShapeSource alloc] initWithIdentifier:@"source-id-invalid" features:@[polygon] options:nil], NSException, NSInvalidArgumentException, @"Shape source should raise an exception if a shape is sent to the features initializer");
-#pragma clang diagnostic pop
-}
-
-- (void)testMGLShapeSourceWithShapesConvenienceInitializer {
- CLLocationCoordinate2D coordinates[] = {
- CLLocationCoordinate2DMake(0.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 101.0),
- CLLocationCoordinate2DMake(1.0, 100.0),
- CLLocationCoordinate2DMake(0.0, 100.0)};
-
- MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:coordinates count:sizeof(coordinates)/sizeof(coordinates[0]) interiorPolygons:nil];
-
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"source-id" shapes:@[polygon] options:nil];
- MGLShapeCollectionFeature *shape = (MGLShapeCollectionFeature *)source.shape;
-
- XCTAssertTrue([shape isKindOfClass:[MGLShapeCollection class]]);
- XCTAssertEqual(shape.shapes.count, 1UL, @"Shape collection should contain 1 shape");
-}
-
-@end
diff --git a/platform/darwin/test/MGLSourceQueryTests.m b/platform/darwin/test/MGLSourceQueryTests.m
deleted file mode 100644
index b321da1ea4..0000000000
--- a/platform/darwin/test/MGLSourceQueryTests.m
+++ /dev/null
@@ -1,25 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-@interface MGLSourceQueryTests : XCTestCase <MGLMapViewDelegate>
-
-@end
-
-@implementation MGLSourceQueryTests
-
-- (void) testQueryVectorTileSource {
- MGLVectorTileSource *source = [[MGLVectorTileSource alloc] initWithIdentifier:@"vector" tileURLTemplates:@[@"fake"] options:nil];
- NSSet *sourceLayers = [NSSet setWithObjects:@"buildings", @"water", nil];
- NSArray* features = [source featuresInSourceLayersWithIdentifiers:sourceLayers predicate:nil];
- // Source not added yet, so features is 0
- XCTAssertEqual([features count], 0);
-}
-
-- (void) testQueryShapeSource {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape" shape:[MGLShapeCollection shapeCollectionWithShapes:@[]] options:nil];
- NSArray* features = [source featuresMatchingPredicate:nil];
- // Source not added yet, so features is 0
- XCTAssertEqual([features count], 0);
-}
-
-@end
diff --git a/platform/darwin/test/MGLStyleLayerTests.h b/platform/darwin/test/MGLStyleLayerTests.h
deleted file mode 100644
index c7577819b8..0000000000
--- a/platform/darwin/test/MGLStyleLayerTests.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#import <Mapbox/Mapbox.h>
-#import <XCTest/XCTest.h>
-
-#define MGLConstantExpression(constant) \
- [NSExpression expressionForConstantValue:constant]
-
-@interface MGLStyleLayerTests : XCTestCase <MGLMapViewDelegate>
-
-@property (nonatomic, copy, readonly, class) NSString *layerType;
-
-- (void)testPropertyName:(NSString *)name isBoolean:(BOOL)isBoolean;
-
-@end
-
-@interface NSString (MGLStyleLayerTestAdditions)
-
-@property (nonatomic, readonly, copy) NSArray<NSString *> *lexicalClasses;
-@property (nonatomic, readonly, copy) NSString *lemma;
-
-@end
-
-@interface NSValue (MGLStyleLayerTestAdditions)
-
-+ (instancetype)valueWithMGLVector:(CGVector)vector;
-
-@property (readonly) CGVector MGLVectorValue;
-
-@end
diff --git a/platform/darwin/test/MGLStyleLayerTests.m b/platform/darwin/test/MGLStyleLayerTests.m
deleted file mode 100644
index 5dc97dc581..0000000000
--- a/platform/darwin/test/MGLStyleLayerTests.m
+++ /dev/null
@@ -1,125 +0,0 @@
-#import "MGLStyleLayerTests.h"
-
-#import "NSString+MGLAdditions.h"
-
-#define TEST_STRICT_NAMING_CONVENTIONS 0
-
-@implementation MGLStyleLayerTests
-
-@dynamic layerType;
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertEqualObjects(layer.identifier, @"layerID");
- XCTAssertEqualObjects(layer.sourceIdentifier, source.identifier);
-
- XCTAssertTrue(layer.visible);
- layer.visible = NO;
- XCTAssertFalse(layer.visible);
- layer.visible = YES;
- XCTAssertTrue(layer.visible);
-
- XCTAssertEqual(layer.minimumZoomLevel, -INFINITY);
- layer.minimumZoomLevel = 22;
- XCTAssertEqual(layer.minimumZoomLevel, 22);
-
- XCTAssertEqual(layer.maximumZoomLevel, INFINITY);
- layer.maximumZoomLevel = 0;
- XCTAssertEqual(layer.maximumZoomLevel, 0);
-}
-
-- (void)testPropertyName:(NSString *)name isBoolean:(BOOL)isBoolean {
- NSMutableArray<NSString *> *components = [name componentsSeparatedByString:@"-"].mutableCopy;
- if (isBoolean) {
- if ([components.firstObject isEqualToString:@"is"]) {
- [components removeObjectAtIndex:0];
-
- // Xcode 10 incorrectly classifies "optional" as a verb, so return early to avoid the verb checks.
- // https://openradar.appspot.com/44149950
- if ([components.lastObject isEqualToString:@"optional"] && NSFoundationVersionNumber >= 1548) {
- return;
- }
-
- if (![components.lastObject.lexicalClasses containsObject:NSLinguisticTagAdjective]) {
- XCTAssertTrue([components.lastObject.lexicalClasses containsObject:NSLinguisticTagVerb],
- @"Boolean getter %@ that starts with “is” should contain an adjective, past participle, or verb.", name);
- XCTAssertNotEqualObjects(components.lastObject.lemma, components.lastObject,
- @"Boolean getter %@ should not have infinitive, imperative, or present tense verb.", name);
- }
- } else {
- if ([components.firstObject isEqualToString:[self class].layerType]
- || [components.firstObject isEqualToString:@"icon"] || [components.firstObject isEqualToString:@"text"]) {
- [components removeObjectAtIndex:0];
- }
-#if TEST_STRICT_NAMING_CONVENTIONS
- XCTAssertTrue([components.firstObject.lexicalClasses containsObject:NSLinguisticTagVerb],
- @"Boolean getter %@ that doesn’t start with “is” should contain a verb.", name);
- XCTAssertNotEqualObjects(components.firstObject.lemma, components.lastObject);
-#endif
- }
- } else {
- XCTAssertFalse([components.firstObject isEqualToString:@"is"]);
-#if TEST_STRICT_NAMING_CONVENTIONS
- XCTAssertTrue([components.lastObject.lexicalClasses containsObject:NSLinguisticTagNoun],
- @"Non-Boolean getter %@ should contain a noun.", name);
-#endif
- }
-}
-
-@end
-
-@implementation NSString (MGLStyleLayerTestAdditions)
-
-- (NSArray<NSString *> *)lexicalClasses {
- NSOrthography *orthography = [NSOrthography orthographyWithDominantScript:@"Latn"
- languageMap:@{@"Latn": @[@"en"]}];
- NSLinguisticTaggerOptions options = (NSLinguisticTaggerOmitPunctuation
- | NSLinguisticTaggerOmitWhitespace
- | NSLinguisticTaggerOmitOther);
- return [self linguisticTagsInRange:self.mgl_wholeRange
- scheme:NSLinguisticTagSchemeLexicalClass
- options:options
- orthography:orthography
- tokenRanges:NULL];
-}
-
-- (NSString *)lemma {
- NSOrthography *orthography = [NSOrthography orthographyWithDominantScript:@"Latn"
- languageMap:@{@"Latn": @[@"en"]}];
- NSLinguisticTaggerOptions options = (NSLinguisticTaggerOmitPunctuation
- | NSLinguisticTaggerOmitWhitespace
- | NSLinguisticTaggerOmitOther);
- return [self linguisticTagsInRange:self.mgl_wholeRange
- scheme:NSLinguisticTagSchemeLemma
- options:options
- orthography:orthography
- tokenRanges:NULL].firstObject;
-}
-
-@end
-
-@implementation NSValue (MGLStyleLayerTestAdditions)
-
-+ (instancetype)valueWithMGLVector:(CGVector)vector {
-#if TARGET_OS_IPHONE
- return [self valueWithCGVector:vector];
-#else
- return [self value:&vector withObjCType:@encode(CGVector)];
-#endif
-}
-
-- (CGVector)MGLVectorValue {
-#if TARGET_OS_IPHONE
- return self.CGVectorValue;
-#else
- CGVector vector;
- [self getValue:&vector];
- return vector;
-#endif
-}
-
-@end
diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs
deleted file mode 100644
index a764f163be..0000000000
--- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs
+++ /dev/null
@@ -1,232 +0,0 @@
-<%
- const type = locals.type;
- const properties = locals.properties;
- const enumProperties = locals.enumProperties;
--%>
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-<% if (type === 'symbol') { -%>
-#include "../../darwin/src/MGLAttributedExpression.h"
-<% } -%>
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGL<%- camelize(type) %>LayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGL<%- camelize(type) %>LayerTests
-
-+ (NSString *)layerType {
- return @"<%- type %>";
-}
-
-<% if (type !== 'background' && type !== 'raster' && type !== 'hillshade') { -%>
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-<% } -%>
-- (void)testProperties {
-<% if (type === 'background') { -%>
- MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID"];
-<% } else { -%>
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-<% } -%>
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"<%- type %>");
- auto rawLayer = static_cast<mbgl::style::<%- camelize(type) %>Layer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-<% for (const property of properties) { -%>
-<% if (property['property-type'] === 'color-ramp') continue; -%>
-
- // <%- originalPropertyName(property) %>
- {
- XCTAssertTrue(rawLayer->get<%- camelize(originalPropertyName(property)) %>().isUndefined(),
- @"<%- originalPropertyName(property) %> should be unset initially.");
- NSExpression *defaultExpression = layer.<%- objCName(property) %>;
-
-<% if (property.type === 'formatted') { -%>
- NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, 'string', true, 3) %>];
-<% } else if (property.type === 'resolvedImage'){ -%>
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:<%- objCTestValue(property, 'string', true, 3) %>];
-<% } else { -%>
- NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, type, true, 3) %>];
-<% } -%>
- layer.<%- objCName(property) %> = constantExpression;
- mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> };
- XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
- @"Setting <%- objCName(property) %> to a constant value expression should update <%- originalPropertyName(property) %>.");
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, constantExpression,
- @"<%- objCName(property) %> should round-trip constant value expressions.");
-
-<% if (property.type !== 'formatted') { -%>
- constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, type, false, 3) %>];
-<% } else { -%>
- MGLAttributedExpression *attributedConstantExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:<%- objCTestValue(property, 'string', true, 3) %>]
- attributes:@{}];
- constantExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:attributedConstantExpression]]];
-<% } -%>
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.<%- objCName(property) %> = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>(
-<% if (property.type === 'formatted') { -%>
- step(zoom(), format(<%- mbglExpressionTestValue(property, type) %>), 18.0, format(<%- mbglExpressionTestValue(property, type) %>))
-<% } else if (property.type === 'resolvedImage') { -%>
- step(zoom(), image(literal(<%- mbglExpressionTestValue(property, type) %>)), 18.0, image(literal(<%- mbglExpressionTestValue(property, type) %>)))
-<% } else { -%>
- step(zoom(), literal(<%- mbglExpressionTestValue(property, type) %>), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>))
-<% } -%>
- );
- }
-
- XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
- @"Setting <%- objCName(property) %> to a camera expression should update <%- originalPropertyName(property) %>.");
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, functionExpression,
- @"<%- objCName(property) %> should round-trip camera expressions.");
-
-<% if (isDataDriven(property) && isInterpolatable(property)) { -%>
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.<%- objCName(property) %> = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>))
- );
- }
-
- XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
- @"Setting <%- objCName(property) %> to a data expression should update <%- originalPropertyName(property) %>.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, pedanticFunctionExpression,
- @"<%- objCName(property) %> should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.<%- objCName(property) %> = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>)))
- );
- }
-
- XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
- @"Setting <%- objCName(property) %> to a camera-data expression should update <%- originalPropertyName(property) %>.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, pedanticFunctionExpression,
- @"<%- objCName(property) %> should round-trip camera-data expressions.");
-<% } -%>
-<% if (!property.required) { -%>
-
- layer.<%- objCName(property) %> = nil;
- XCTAssertTrue(rawLayer->get<%- camelize(originalPropertyName(property)) %>().isUndefined(),
- @"Unsetting <%- objCName(property) %> should return <%- originalPropertyName(property) %> to the default value.");
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, defaultExpression,
- @"<%- objCName(property) %> should return the default value after being unset.");
-<% } -%>
-<% if (!isDataDriven(property)) { -%>
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.<%- objCName(property) %> = functionExpression, NSException, NSInvalidArgumentException, @"MGL<%- camelize(type) %>Layer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.<%- objCName(property) %> = functionExpression, NSException, NSInvalidArgumentException, @"MGL<%- camelize(type) %>Layer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
-<% } -%>
-<% if (property["transition"] && !property.original) { -%>
- // Transition property test
- layer.<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>Transition = transitionTest;
- auto toptions = rawLayer->get<%- camelize(originalPropertyName(property)) %>Transition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition <%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>Transition = layer.<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>Transition;
- XCTAssertEqual(<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>Transition.delay, transitionTest.delay);
- XCTAssertEqual(<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>Transition.duration, transitionTest.duration);
-<% } -%>
-<% if (property.tokens) { -%>
-
- // Tokens test
- layer.<%- objCName(property) %> = [NSExpression expressionForConstantValue:@"{token}"];
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<<%- mbglType(property) %>>(
-<% if (property.type === 'formatted') { -%>
- format(toString(get(literal("token"))))
-<% } else if (property.type === 'resolvedImage') { -%>
- image(toString(get(literal("token"))))
-<% } else { -%>
- toString(get(literal("token")))
-<% } -%>
- );
- }
-
- XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
- @"Setting <%- objCName(property) %> to a constant string with tokens should convert to an expression.");
-
-<% if (property.type === 'formatted') { -%>
- MGLAttributedExpression *tokenAttibutedExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"CAST(token, 'NSString')"]
- attributes:@{}];
- NSExpression* tokenExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:tokenAttibutedExpression]]];
-<% } else if (property.type === 'resolvedImage') { -%>
- NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', CAST(token, \"NSString\"))"];
-<% } else { -%>
- NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"];
-<% } -%>
- XCTAssertEqualObjects(layer.<%- objCName(property) %>, tokenExpression,
- @"Setting <%- objCName(property) %> to a constant string with tokens should convert to an expression.");
-<% } -%>
- }
-<% } -%>
-}
-
-- (void)testPropertyNames {
-<% for (const property of properties) { -%>
-<% if (property['property-type'] === 'color-ramp') continue; -%>
- [self testPropertyName:@"<%- property.getter || property.name %>" isBoolean:<%- property.type === 'boolean' ? 'YES' : 'NO' %>];
-<% } -%>
-}
-
-<% if (enumProperties) { -%>
-- (void)testValueAdditions {
-<% for (let property of enumProperties) { -%>
-<% for (let value in property.values) { -%>
-<% if (property.values.hasOwnProperty(value)) { -%>
- XCTAssertEqual([NSValue valueWithMGL<%- camelize(enumName(property)) %>:MGL<%- camelize(enumName(property)) %><%- camelize(value) %>].MGL<%- camelize(enumName(property)) %>Value, MGL<%- camelize(enumName(property)) %><%- camelize(value) %>);
-<% } -%>
-<% } -%>
-<% } -%>
-}
-
-<% } -%>
-@end
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
deleted file mode 100644
index ec2605646c..0000000000
--- a/platform/darwin/test/MGLStyleTests.mm
+++ /dev/null
@@ -1,500 +0,0 @@
-#import <Mapbox/Mapbox.h>
-
-#import "NSBundle+MGLAdditions.h"
-#import "MGLVectorTileSource_Private.h"
-
-#import <mbgl/util/default_styles.hpp>
-
-#import <XCTest/XCTest.h>
-#if TARGET_OS_IPHONE
- #import <UIKit/UIKit.h>
-#else
- #import <Cocoa/Cocoa.h>
-#endif
-#import <objc/runtime.h>
-
-@interface MGLStyleTests : XCTestCase <MGLMapViewDelegate>
-
-@property (nonatomic) MGLMapView *mapView;
-@property (nonatomic) MGLStyle *style;
-
-@end
-
-@implementation MGLStyleTests {
- XCTestExpectation *_styleLoadingExpectation;
-}
-
-- (void)setUp {
- [super setUp];
-
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
- NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
- self.mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) styleURL:styleURL];
- self.mapView.delegate = self;
- if (!self.mapView.style) {
- _styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
- [self waitForExpectationsWithTimeout:10 handler:nil];
- }
-}
-
-- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
- XCTAssertNotNil(mapView.style);
- XCTAssertEqual(mapView.style, style);
-
- [_styleLoadingExpectation fulfill];
-}
-
-- (void)tearDown {
- _styleLoadingExpectation = nil;
- self.mapView = nil;
-
- [super tearDown];
-}
-
-- (MGLStyle *)style {
- return self.mapView.style;
-}
-
-- (void)testUnversionedStyleURLs {
- XCTAssertEqual(mbgl::util::default_styles::streets.currentVersion, MGLStyleDefaultVersion,
- "mbgl::util::default_styles::streets.currentVersion and MGLStyleDefaultVersion disagree.");
-
- XCTAssertEqualObjects([MGLStyle streetsStyleURL].absoluteString, @(mbgl::util::default_styles::streets.url));
- XCTAssertEqualObjects([MGLStyle outdoorsStyleURL].absoluteString, @(mbgl::util::default_styles::outdoors.url));
- XCTAssertEqualObjects([MGLStyle lightStyleURL].absoluteString, @(mbgl::util::default_styles::light.url));
- XCTAssertEqualObjects([MGLStyle darkStyleURL].absoluteString, @(mbgl::util::default_styles::dark.url));
- XCTAssertEqualObjects([MGLStyle satelliteStyleURL].absoluteString, @(mbgl::util::default_styles::satellite.url));
- XCTAssertEqualObjects([MGLStyle satelliteStreetsStyleURL].absoluteString, @(mbgl::util::default_styles::satelliteStreets.url));
-}
-
-- (void)testVersionedStyleURLs {
- // Test that all the default styles have publicly-declared MGLStyle class
- // methods and that the URLs all have the right values.
- XCTAssertEqualObjects([MGLStyle streetsStyleURLWithVersion:mbgl::util::default_styles::streets.currentVersion].absoluteString,
- @(mbgl::util::default_styles::streets.url));
- XCTAssertEqualObjects([MGLStyle streetsStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/streets-v99");
- XCTAssertEqualObjects([MGLStyle outdoorsStyleURLWithVersion:mbgl::util::default_styles::outdoors.currentVersion].absoluteString,
- @(mbgl::util::default_styles::outdoors.url));
- XCTAssertEqualObjects([MGLStyle outdoorsStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/outdoors-v99");
- XCTAssertEqualObjects([MGLStyle lightStyleURLWithVersion:mbgl::util::default_styles::light.currentVersion].absoluteString,
- @(mbgl::util::default_styles::light.url));
- XCTAssertEqualObjects([MGLStyle lightStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/light-v99");
- XCTAssertEqualObjects([MGLStyle darkStyleURLWithVersion:mbgl::util::default_styles::dark.currentVersion].absoluteString,
- @(mbgl::util::default_styles::dark.url));
- XCTAssertEqualObjects([MGLStyle darkStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/dark-v99");
- XCTAssertEqualObjects([MGLStyle satelliteStyleURLWithVersion:mbgl::util::default_styles::satellite.currentVersion].absoluteString,
- @(mbgl::util::default_styles::satellite.url));
- XCTAssertEqualObjects([MGLStyle satelliteStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/satellite-v99");
- XCTAssertEqualObjects([MGLStyle satelliteStreetsStyleURLWithVersion:mbgl::util::default_styles::satelliteStreets.currentVersion].absoluteString,
- @(mbgl::util::default_styles::satelliteStreets.url));
- XCTAssertEqualObjects([MGLStyle satelliteStreetsStyleURLWithVersion:99].absoluteString,
- @"mapbox://styles/mapbox/satellite-streets-v99");
-
- static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
- "MGLStyleTests isn’t testing all the styles in mbgl::util::default_styles.");
-}
-
-- (void)testStyleURLDeclarations {
- // Make sure this test is comprehensive.
- const unsigned numImplicitArgs = 2 /* _cmd, self */;
- unsigned numMethods = 0;
- Method *methods = class_copyMethodList(object_getClass([MGLStyle class]), &numMethods);
- unsigned numVersionedMethods = 0;
- for (NSUInteger i = 0; i < numMethods; i++) {
- Method method = methods[i];
- SEL selector = method_getName(method);
- NSString *name = @(sel_getName(selector));
- unsigned numArgs = method_getNumberOfArguments(method);
- if ([name hasSuffix:@"StyleURL"]) {
- XCTAssertEqual(numArgs, numImplicitArgs, @"Unversioned style URL method should have no parameters, but it has %u.", numArgs - numImplicitArgs);
- } else if ([name hasSuffix:@"StyleURLWithVersion:"]) {
- XCTAssertEqual(numArgs, numImplicitArgs + 1, @"Versioned style URL method should have one parameter, but it has %u.", numArgs - numImplicitArgs);
- numVersionedMethods++;
- } else {
- XCTAssertEqual([name rangeOfString:@"URL"].location, NSNotFound, @"MGLStyle style URL method %@ is malformed.", name);
- }
- }
- XCTAssertEqual(mbgl::util::default_styles::numOrderedStyles, numVersionedMethods,
- @"There are %lu default styles but MGLStyleTests only provides versioned style URL methods for %u of them.",
- mbgl::util::default_styles::numOrderedStyles, numVersionedMethods);
-
- // Test that all the versioned style methods are in the public header.
- NSString *styleHeader = self.stringWithContentsOfStyleHeader;
-
- NSError *versionedMethodError;
- NSString *versionedMethodExpressionString = @(R"RE(^\+\s*\(NSURL\s*\*\s*\)\s*(?!traffic)\w+StyleURLWithVersion\s*:\s*\(\s*NSInteger\s*\)\s*version\s*\b)RE");
- NSRegularExpression *versionedMethodExpression = [NSRegularExpression regularExpressionWithPattern:versionedMethodExpressionString options:NSRegularExpressionAnchorsMatchLines error:&versionedMethodError];
- XCTAssertNil(versionedMethodError, @"Error compiling regular expression to search for versioned methods.");
- NSUInteger numVersionedMethodDeclarations = [versionedMethodExpression numberOfMatchesInString:styleHeader options:0 range:NSMakeRange(0, styleHeader.length)];
- XCTAssertEqual(numVersionedMethodDeclarations, numVersionedMethods);
-}
-
-- (void)testName {
- XCTAssertNil(self.style.name);
-}
-
-- (void)testSources {
- NSSet<MGLSource *> *initialSources = self.style.sources;
- if ([initialSources.anyObject.identifier isEqualToString:@"com.mapbox.annotations"]) {
- XCTAssertEqual(self.style.sources.count, 1UL);
- } else {
- XCTAssertEqual(self.style.sources.count, 0UL);
- }
- MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil];
- [self.style addSource:shapeSource];
- XCTAssertEqual(self.style.sources.count, initialSources.count + 1);
- XCTAssertEqual(shapeSource, [self.style sourceWithIdentifier:@"shapeSource"]);
- [self.style removeSource:shapeSource];
- XCTAssertEqual(self.style.sources.count, initialSources.count);
-}
-
-- (void)testAddingSourcesTwice {
- MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil];
- [self.style addSource:shapeSource];
- XCTAssertThrowsSpecificNamed([self.style addSource:shapeSource], NSException, MGLRedundantSourceException);
-
- MGLRasterTileSource *rasterTileSource = [[MGLRasterTileSource alloc] initWithIdentifier:@"rasterTileSource" configurationURL:[NSURL URLWithString:@".json"] tileSize:42];
- [self.style addSource:rasterTileSource];
- XCTAssertThrowsSpecificNamed([self.style addSource:rasterTileSource], NSException, MGLRedundantSourceException);
-
- MGLVectorTileSource *vectorTileSource = [[MGLVectorTileSource alloc] initWithIdentifier:@"vectorTileSource" configurationURL:[NSURL URLWithString:@".json"]];
- [self.style addSource:vectorTileSource];
- XCTAssertThrowsSpecificNamed([self.style addSource:vectorTileSource], NSException, MGLRedundantSourceException);
-}
-
-- (void)testAddingSourcesWithDuplicateIdentifiers {
- MGLVectorTileSource *source1 = [[MGLVectorTileSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
- MGLVectorTileSource *source2 = [[MGLVectorTileSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
-
- [self.style addSource: source1];
- XCTAssertThrowsSpecificNamed([self.style addSource: source2], NSException, MGLRedundantSourceIdentifierException);
-}
-
-- (void)testRemovingSourcesBeforeAddingThem {
- MGLRasterTileSource *rasterTileSource = [[MGLRasterTileSource alloc] initWithIdentifier:@"raster-tile-source" tileURLTemplates:@[] options:nil];
- [self.style removeSource:rasterTileSource];
- [self.style addSource:rasterTileSource];
- XCTAssertNotNil([self.style sourceWithIdentifier:rasterTileSource.identifier]);
-
- MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source" shape:nil options:nil];
- [self.style removeSource:shapeSource];
- [self.style addSource:shapeSource];
- XCTAssertNotNil([self.style sourceWithIdentifier:shapeSource.identifier]);
-
- MGLVectorTileSource *vectorTileSource = [[MGLVectorTileSource alloc] initWithIdentifier:@"vector-tile-source" tileURLTemplates:@[] options:nil];
- [self.style removeSource:vectorTileSource];
- [self.style addSource:vectorTileSource];
- XCTAssertNotNil([self.style sourceWithIdentifier:vectorTileSource.identifier]);
-}
-
-- (void)testAddingSourceOfTypeABeforeSourceOfTypeBWithSameIdentifier {
- // Add a raster tile source
- MGLRasterTileSource *rasterTileSource = [[MGLRasterTileSource alloc] initWithIdentifier:@"some-identifier" tileURLTemplates:@[] options:nil];
- [self.style addSource:rasterTileSource];
-
- // Attempt to remove an image source with the same identifier as the raster tile source
- MGLImageSource *imageSource = [[MGLImageSource alloc] initWithIdentifier:@"some-identifier" coordinateQuad: { } URL:[NSURL URLWithString:@"http://host/image.png"]];
- [self.style removeSource:imageSource];
- // The raster tile source should still be added
- XCTAssertTrue([[self.style sourceWithIdentifier:rasterTileSource.identifier] isMemberOfClass:[MGLRasterTileSource class]]);
-
- // Remove the raster tile source
- [self.style removeSource:rasterTileSource];
-
- // Add the shape source
- [self.style addSource:imageSource];
-
- // Attempt to remove a vector tile source with the same identifer as the shape source
- MGLVectorTileSource *vectorTileSource = [[MGLVectorTileSource alloc] initWithIdentifier:@"some-identifier" tileURLTemplates:@[] options:nil];
- [self.style removeSource:vectorTileSource];
- // The image source should still be added
- XCTAssertTrue([[self.style sourceWithIdentifier:imageSource.identifier] isMemberOfClass:[MGLImageSource class]]);
-
- // Remove the image source
- [self.style removeSource:imageSource];
-
- // Add the vector tile source
- [self.style addSource:vectorTileSource];
-
- // Attempt to remove the previously created raster tile source that has the same identifer as the shape source
- [self.style removeSource:rasterTileSource];
- // The vector tile source should still be added
- XCTAssertTrue([[self.style sourceWithIdentifier:imageSource.identifier] isMemberOfClass:[MGLVectorTileSource class]]);
-}
-
-- (void)testRemovingSourceInUse {
- // Add a raster tile source
- MGLVectorTileSource *vectorTileSource = [[MGLVectorTileSource alloc] initWithIdentifier:@"some-identifier" tileURLTemplates:@[] options:nil];
- [self.style addSource:vectorTileSource];
-
- // Add a layer using it
- MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:vectorTileSource];
- [self.style addLayer:fillLayer];
-
- // Attempt to remove the raster tile source
- NSError *error;
- BOOL result = [self.style removeSource:vectorTileSource error:&error];
-
- XCTAssertFalse(result);
- XCTAssertEqualObjects(error.domain, MGLErrorDomain);
- XCTAssertEqual(error.code, MGLErrorCodeSourceIsInUseCannotRemove);
-
- // Ensure it is still there
- XCTAssertTrue([[self.style sourceWithIdentifier:vectorTileSource.identifier] isMemberOfClass:[MGLVectorTileSource class]]);
-}
-
-- (void)testLayers {
- NSArray<MGLStyleLayer *> *initialLayers = self.style.layers;
- if ([initialLayers.firstObject.identifier isEqualToString:@"com.mapbox.annotations.points"]) {
- XCTAssertEqual(self.style.layers.count, 1UL);
- } else {
- XCTAssertEqual(self.style.layers.count, 0UL);
- }
- MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil];
- [self.style addSource:shapeSource];
- MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:shapeSource];
- [self.style addLayer:fillLayer];
- XCTAssertEqual(self.style.layers.count, initialLayers.count + 1);
- XCTAssertEqual(fillLayer, [self.style layerWithIdentifier:@"fillLayer"]);
- [self.style removeLayer:fillLayer];
- XCTAssertEqual(self.style.layers.count, initialLayers.count);
-}
-
-- (void)testAddingLayersTwice {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil];
-
- MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"backgroundLayer"];
- [self.style addLayer:backgroundLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:backgroundLayer], NSException, MGLRedundantLayerException);
-
- MGLCircleStyleLayer *circleLayer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"circleLayer" source:source];
- [self.style addLayer:circleLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:circleLayer], NSException, MGLRedundantLayerException);
-
- MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:source];
- [self.style addLayer:fillLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:fillLayer], NSException, MGLRedundantLayerException);
-
- MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"lineLayer" source:source];
- [self.style addLayer:lineLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:lineLayer], NSException, MGLRedundantLayerException);
-
- MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"rasterLayer" source:source];
- [self.style addLayer:rasterLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:rasterLayer], NSException, MGLRedundantLayerException);
-
- MGLSymbolStyleLayer *symbolLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"symbolLayer" source:source];
- [self.style addLayer:symbolLayer];
- XCTAssertThrowsSpecificNamed([self.style addLayer:symbolLayer], NSException, MGLRedundantLayerException);
-}
-
-- (void)testAddingLayersWithDuplicateIdentifiers {
- // Just some source
- MGLVectorTileSource *source = [[MGLVectorTileSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
- [self.style addSource: source];
-
- // Add initial layer
- MGLFillStyleLayer *initial = [[MGLFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source];
- [self.style addLayer:initial];
-
- // Try to add the duplicate
- XCTAssertThrowsSpecificNamed([self.style addLayer:[[MGLFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source]], NSException, @"MGLRedundantLayerIdentifierException");
- XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MGLFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] belowLayer:initial],NSException, @"MGLRedundantLayerIdentifierException");
- XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MGLFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] aboveLayer:initial], NSException, @"MGLRedundantLayerIdentifierException");
- XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MGLFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] atIndex:0], NSException, @"MGLRedundantLayerIdentifierException");
- XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"my-layer"] atIndex:0], NSException, @"MGLRedundantLayerIdentifierException");
-}
-
-- (void)testRemovingLayerBeforeAddingSameLayer {
- {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source-removing-before-adding" shape:nil options:nil];
-
- // Attempting to find a layer with identifier will trigger an exception if the source associated with the layer is not added
- [self.style addSource:source];
-
- MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fill-layer" source:source];
- [self.style removeLayer:fillLayer];
- [self.style addLayer:fillLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:fillLayer.identifier]);
-
- MGLSymbolStyleLayer *symbolLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"symbol-layer" source:source];
- [self.style removeLayer:symbolLayer];
- [self.style addLayer:symbolLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:symbolLayer.identifier]);
-
- MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"line-layer" source:source];
- [self.style removeLayer:lineLayer];
- [self.style addLayer:lineLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:lineLayer.identifier]);
-
- MGLCircleStyleLayer *circleLayer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"circle-layer" source:source];
- [self.style removeLayer:circleLayer];
- [self.style addLayer:circleLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:circleLayer.identifier]);
-
- MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"background-layer"];
- [self.style removeLayer:backgroundLayer];
- [self.style addLayer:backgroundLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:backgroundLayer.identifier]);
- }
-
- {
- MGLRasterTileSource *rasterSource = [[MGLRasterTileSource alloc] initWithIdentifier:@"raster-tile-source" tileURLTemplates:@[] options:nil];
- [self.style addSource:rasterSource];
-
- MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"raster-layer" source:rasterSource];
- [self.style removeLayer:rasterLayer];
- [self.style addLayer:rasterLayer];
- XCTAssertNotNil([self.style layerWithIdentifier:rasterLayer.identifier]);
- }
-}
-
-- (void)testAddingLayerOfTypeABeforeRemovingLayerOfTypeBWithSameIdentifier {
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source-identifier" shape:nil options:nil];
- [self.style addSource:source];
-
- // Add a fill layer
- MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"some-identifier" source:source];
- [self.style addLayer:fillLayer];
-
- // Attempt to remove a line layer with the same identifier as the fill layer
- MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:fillLayer.identifier source:source];
- [self.style removeLayer:lineLayer];
-
- XCTAssertTrue([[self.style layerWithIdentifier:fillLayer.identifier] isMemberOfClass:[MGLFillStyleLayer class]]);
-}
-
-- (NSString *)stringWithContentsOfStyleHeader {
- NSURL *styleHeaderURL = [[[NSBundle mgl_frameworkBundle].bundleURL
- URLByAppendingPathComponent:@"Headers" isDirectory:YES]
- URLByAppendingPathComponent:@"MGLStyle.h"];
- NSError *styleHeaderError;
- NSString *styleHeader = [NSString stringWithContentsOfURL:styleHeaderURL usedEncoding:nil error:&styleHeaderError];
- XCTAssertNil(styleHeaderError, @"Error getting contents of MGLStyle.h.");
- return styleHeader;
-}
-
-- (void)testImages {
- NSString *imageName = @"TrackingLocationMask";
-#if TARGET_OS_IPHONE
- MGLImage *image = [MGLImage imageNamed:imageName
- inBundle:[NSBundle bundleForClass:[self class]]
- compatibleWithTraitCollection:nil];
-#else
- MGLImage *image = [[NSBundle bundleForClass:[self class]] imageForResource:imageName];
-#endif
- XCTAssertNotNil(image);
-
- [self.style setImage:image forName:imageName];
- MGLImage *styleImage = [self.style imageForName:imageName];
-
- XCTAssertNotNil(styleImage);
- XCTAssertEqual(image.size.width, styleImage.size.width);
- XCTAssertEqual(image.size.height, styleImage.size.height);
-}
-
-- (void)testLayersOrder {
- NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
- NSURL *url = [NSURL fileURLWithPath:filePath];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil];
- [self.style addSource:source];
-
- MGLCircleStyleLayer *layer1 = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layer1" source:source];
- [self.style addLayer:layer1];
-
- MGLCircleStyleLayer *layer3 = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layer3" source:source];
- [self.style addLayer:layer3];
-
- MGLCircleStyleLayer *layer2 = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layer2" source:source];
- [self.style insertLayer:layer2 aboveLayer:layer1];
-
- MGLCircleStyleLayer *layer4 = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layer4" source:source];
- [self.style insertLayer:layer4 aboveLayer:layer3];
-
- MGLCircleStyleLayer *layer0 = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layer0" source:source];
- [self.style insertLayer:layer0 belowLayer:layer1];
-
- NSArray<MGLStyleLayer *> *layers = [self.style layers];
- NSUInteger startIndex = 0;
- if ([layers.firstObject.identifier isEqualToString:@"com.mapbox.annotations.points"]) {
- startIndex++;
- }
-
- XCTAssertEqualObjects(layers[startIndex++].identifier, layer0.identifier);
- XCTAssertEqualObjects(layers[startIndex++].identifier, layer1.identifier);
- XCTAssertEqualObjects(layers[startIndex++].identifier, layer2.identifier);
- XCTAssertEqualObjects(layers[startIndex++].identifier, layer3.identifier);
- XCTAssertEqualObjects(layers[startIndex++].identifier, layer4.identifier);
-}
-
-#pragma mark Localization tests
-
-- (void)testLanguageMatching {
- {
- NSArray *preferences = @[@"en"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"en");
- }
- {
- NSArray *preferences = @[@"en-US"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"en");
- }
- {
- NSArray *preferences = @[@"fr"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"fr");
- }
- {
- NSArray *preferences = @[@"zh-Hans"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"zh-Hans");
- }
- {
- NSArray *preferences = @[@"zh-Hans", @"en"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"zh-Hans");
- }
- {
- NSArray *preferences = @[@"zh-Hant"];
- XCTAssertNil([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences]);
- }
- {
- NSArray *preferences = @[@"en", @"fr", @"el"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"en");
- }
- {
- NSArray *preferences = @[@"tlh"];
- XCTAssertNil([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences]);
- }
- {
- NSArray *preferences = @[@"tlh", @"en"];
- XCTAssertEqualObjects([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences], @"en");
- }
- {
- NSArray *preferences = @[@"mul"];
- XCTAssertNil([MGLVectorTileSource preferredMapboxStreetsLanguageForPreferences:preferences]);
- }
-}
-
-#pragma mark Transition tests
-
-- (void)testTransition
-{
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
- self.style.transition = transitionTest;
-
- XCTAssert(self.style.transition.delay == transitionTest.delay);
- XCTAssert(self.style.transition.duration == transitionTest.duration);
-}
-
-- (void)testPerformsPlacementTransitions
-{
- XCTAssertTrue(self.style.performsPlacementTransitions, @"The default value for enabling placement transitions should be YES.");
-
- self.style.performsPlacementTransitions = NO;
- XCTAssertFalse(self.style.performsPlacementTransitions, @"Enabling placement transitions should be NO.");
-}
-
-@end
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
deleted file mode 100644
index 04ef3fc712..0000000000
--- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm
+++ /dev/null
@@ -1,3204 +0,0 @@
-// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
-
-#import "MGLStyleLayerTests.h"
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-#include "../../darwin/src/MGLAttributedExpression.h"
-
-#import "MGLStyleLayer_Private.h"
-
-#include <mbgl/style/layers/symbol_layer.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/expression/dsl.hpp>
-
-@interface MGLSymbolLayerTests : MGLStyleLayerTests
-@end
-
-@implementation MGLSymbolLayerTests
-
-+ (NSString *)layerType {
- return @"symbol";
-}
-
-- (void)testPredicates {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
- MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
-
- XCTAssertNil(layer.sourceLayerIdentifier);
- layer.sourceLayerIdentifier = @"layerID";
- XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID");
- layer.sourceLayerIdentifier = nil;
- XCTAssertNil(layer.sourceLayerIdentifier);
-
- XCTAssertNil(layer.predicate);
- layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"];
- XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]);
- layer.predicate = nil;
- XCTAssertNil(layer.predicate);
-}
-
-- (void)testProperties {
- MGLPointFeature *feature = [[MGLPointFeature alloc] init];
- MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil];
-
- MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
- XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"symbol");
- auto rawLayer = static_cast<mbgl::style::SymbolLayer*>(layer.rawLayer);
-
- MGLTransition transitionTest = MGLTransitionMake(5, 4);
-
-
- // icon-allow-overlap
- {
- XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(),
- @"icon-allow-overlap should be unset initially.");
- NSExpression *defaultExpression = layer.iconAllowsOverlap;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.iconAllowsOverlap = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue,
- @"Setting iconAllowsOverlap to a constant value expression should update icon-allow-overlap.");
- XCTAssertEqualObjects(layer.iconAllowsOverlap, constantExpression,
- @"iconAllowsOverlap should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconAllowsOverlap = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue,
- @"Setting iconAllowsOverlap to a camera expression should update icon-allow-overlap.");
- XCTAssertEqualObjects(layer.iconAllowsOverlap, functionExpression,
- @"iconAllowsOverlap should round-trip camera expressions.");
-
-
- layer.iconAllowsOverlap = nil;
- XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(),
- @"Unsetting iconAllowsOverlap should return icon-allow-overlap to the default value.");
- XCTAssertEqualObjects(layer.iconAllowsOverlap, defaultExpression,
- @"iconAllowsOverlap should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-anchor
- {
- XCTAssertTrue(rawLayer->getIconAnchor().isUndefined(),
- @"icon-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.iconAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"];
- layer.iconAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::SymbolAnchorType> propertyValue = { mbgl::style::SymbolAnchorType::BottomRight };
- XCTAssertEqual(rawLayer->getIconAnchor(), propertyValue,
- @"Setting iconAnchor to a constant value expression should update icon-anchor.");
- XCTAssertEqualObjects(layer.iconAnchor, constantExpression,
- @"iconAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::SymbolAnchorType>(
- step(zoom(), literal("bottom-right"), 18.0, literal("bottom-right"))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconAnchor(), propertyValue,
- @"Setting iconAnchor to a camera expression should update icon-anchor.");
- XCTAssertEqualObjects(layer.iconAnchor, functionExpression,
- @"iconAnchor should round-trip camera expressions.");
-
-
- layer.iconAnchor = nil;
- XCTAssertTrue(rawLayer->getIconAnchor().isUndefined(),
- @"Unsetting iconAnchor should return icon-anchor to the default value.");
- XCTAssertEqualObjects(layer.iconAnchor, defaultExpression,
- @"iconAnchor should return the default value after being unset.");
- }
-
- // icon-ignore-placement
- {
- XCTAssertTrue(rawLayer->getIconIgnorePlacement().isUndefined(),
- @"icon-ignore-placement should be unset initially.");
- NSExpression *defaultExpression = layer.iconIgnoresPlacement;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.iconIgnoresPlacement = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue,
- @"Setting iconIgnoresPlacement to a constant value expression should update icon-ignore-placement.");
- XCTAssertEqualObjects(layer.iconIgnoresPlacement, constantExpression,
- @"iconIgnoresPlacement should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconIgnoresPlacement = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue,
- @"Setting iconIgnoresPlacement to a camera expression should update icon-ignore-placement.");
- XCTAssertEqualObjects(layer.iconIgnoresPlacement, functionExpression,
- @"iconIgnoresPlacement should round-trip camera expressions.");
-
-
- layer.iconIgnoresPlacement = nil;
- XCTAssertTrue(rawLayer->getIconIgnorePlacement().isUndefined(),
- @"Unsetting iconIgnoresPlacement should return icon-ignore-placement to the default value.");
- XCTAssertEqualObjects(layer.iconIgnoresPlacement, defaultExpression,
- @"iconIgnoresPlacement should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-image
- {
- XCTAssertTrue(rawLayer->getIconImage().isUndefined(),
- @"icon-image should be unset initially.");
- NSExpression *defaultExpression = layer.iconImageName;
-
- NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Icon Image"];
- layer.iconImageName = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Image> propertyValue = { "Icon Image" };
- XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
- @"Setting iconImageName to a constant value expression should update icon-image.");
- XCTAssertEqualObjects(layer.iconImageName, constantExpression,
- @"iconImageName should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Icon Image')"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconImageName = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- step(zoom(), image(literal("Icon Image")), 18.0, image(literal("Icon Image")))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
- @"Setting iconImageName to a camera expression should update icon-image.");
- XCTAssertEqualObjects(layer.iconImageName, functionExpression,
- @"iconImageName should round-trip camera expressions.");
-
-
- layer.iconImageName = nil;
- XCTAssertTrue(rawLayer->getIconImage().isUndefined(),
- @"Unsetting iconImageName should return icon-image to the default value.");
- XCTAssertEqualObjects(layer.iconImageName, defaultExpression,
- @"iconImageName should return the default value after being unset.");
-
- // Tokens test
- layer.iconImageName = [NSExpression expressionForConstantValue:@"{token}"];
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Image>(
- image(toString(get(literal("token"))))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
- @"Setting iconImageName to a constant string with tokens should convert to an expression.");
-
- NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', CAST(token, \"NSString\"))"];
- XCTAssertEqualObjects(layer.iconImageName, tokenExpression,
- @"Setting iconImageName to a constant string with tokens should convert to an expression.");
- }
-
- // icon-offset
- {
- XCTAssertTrue(rawLayer->getIconOffset().isUndefined(),
- @"icon-offset should be unset initially.");
- NSExpression *defaultExpression = layer.iconOffset;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.iconOffset = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
- @"Setting iconOffset to a constant value expression should update icon-offset.");
- XCTAssertEqualObjects(layer.iconOffset, constantExpression,
- @"iconOffset should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
- @"Setting iconOffset to a camera expression should update icon-offset.");
- XCTAssertEqualObjects(layer.iconOffset, functionExpression,
- @"iconOffset should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
- @"Setting iconOffset to a data expression should update icon-offset.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconOffset, pedanticFunctionExpression,
- @"iconOffset should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 })))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
- @"Setting iconOffset to a camera-data expression should update icon-offset.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconOffset, pedanticFunctionExpression,
- @"iconOffset should round-trip camera-data expressions.");
-
- layer.iconOffset = nil;
- XCTAssertTrue(rawLayer->getIconOffset().isUndefined(),
- @"Unsetting iconOffset should return icon-offset to the default value.");
- XCTAssertEqualObjects(layer.iconOffset, defaultExpression,
- @"iconOffset should return the default value after being unset.");
- }
-
- // icon-optional
- {
- XCTAssertTrue(rawLayer->getIconOptional().isUndefined(),
- @"icon-optional should be unset initially.");
- NSExpression *defaultExpression = layer.iconOptional;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.iconOptional = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getIconOptional(), propertyValue,
- @"Setting iconOptional to a constant value expression should update icon-optional.");
- XCTAssertEqualObjects(layer.iconOptional, constantExpression,
- @"iconOptional should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconOptional = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOptional(), propertyValue,
- @"Setting iconOptional to a camera expression should update icon-optional.");
- XCTAssertEqualObjects(layer.iconOptional, functionExpression,
- @"iconOptional should round-trip camera expressions.");
-
-
- layer.iconOptional = nil;
- XCTAssertTrue(rawLayer->getIconOptional().isUndefined(),
- @"Unsetting iconOptional should return icon-optional to the default value.");
- XCTAssertEqualObjects(layer.iconOptional, defaultExpression,
- @"iconOptional should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-padding
- {
- XCTAssertTrue(rawLayer->getIconPadding().isUndefined(),
- @"icon-padding should be unset initially.");
- NSExpression *defaultExpression = layer.iconPadding;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconPadding = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconPadding(), propertyValue,
- @"Setting iconPadding to a constant value expression should update icon-padding.");
- XCTAssertEqualObjects(layer.iconPadding, constantExpression,
- @"iconPadding should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconPadding = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconPadding(), propertyValue,
- @"Setting iconPadding to a camera expression should update icon-padding.");
- XCTAssertEqualObjects(layer.iconPadding, functionExpression,
- @"iconPadding should round-trip camera expressions.");
-
-
- layer.iconPadding = nil;
- XCTAssertTrue(rawLayer->getIconPadding().isUndefined(),
- @"Unsetting iconPadding should return icon-padding to the default value.");
- XCTAssertEqualObjects(layer.iconPadding, defaultExpression,
- @"iconPadding should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-pitch-alignment
- {
- XCTAssertTrue(rawLayer->getIconPitchAlignment().isUndefined(),
- @"icon-pitch-alignment should be unset initially.");
- NSExpression *defaultExpression = layer.iconPitchAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- layer.iconPitchAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
- XCTAssertEqual(rawLayer->getIconPitchAlignment(), propertyValue,
- @"Setting iconPitchAlignment to a constant value expression should update icon-pitch-alignment.");
- XCTAssertEqualObjects(layer.iconPitchAlignment, constantExpression,
- @"iconPitchAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconPitchAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::AlignmentType>(
- step(zoom(), literal("auto"), 18.0, literal("auto"))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconPitchAlignment(), propertyValue,
- @"Setting iconPitchAlignment to a camera expression should update icon-pitch-alignment.");
- XCTAssertEqualObjects(layer.iconPitchAlignment, functionExpression,
- @"iconPitchAlignment should round-trip camera expressions.");
-
-
- layer.iconPitchAlignment = nil;
- XCTAssertTrue(rawLayer->getIconPitchAlignment().isUndefined(),
- @"Unsetting iconPitchAlignment should return icon-pitch-alignment to the default value.");
- XCTAssertEqualObjects(layer.iconPitchAlignment, defaultExpression,
- @"iconPitchAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-rotate
- {
- XCTAssertTrue(rawLayer->getIconRotate().isUndefined(),
- @"icon-rotate should be unset initially.");
- NSExpression *defaultExpression = layer.iconRotation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconRotation = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
- @"Setting iconRotation to a constant value expression should update icon-rotate.");
- XCTAssertEqualObjects(layer.iconRotation, constantExpression,
- @"iconRotation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
- @"Setting iconRotation to a camera expression should update icon-rotate.");
- XCTAssertEqualObjects(layer.iconRotation, functionExpression,
- @"iconRotation should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
- @"Setting iconRotation to a data expression should update icon-rotate.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconRotation, pedanticFunctionExpression,
- @"iconRotation should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
- @"Setting iconRotation to a camera-data expression should update icon-rotate.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconRotation, pedanticFunctionExpression,
- @"iconRotation should round-trip camera-data expressions.");
-
- layer.iconRotation = nil;
- XCTAssertTrue(rawLayer->getIconRotate().isUndefined(),
- @"Unsetting iconRotation should return icon-rotate to the default value.");
- XCTAssertEqualObjects(layer.iconRotation, defaultExpression,
- @"iconRotation should return the default value after being unset.");
- }
-
- // icon-rotation-alignment
- {
- XCTAssertTrue(rawLayer->getIconRotationAlignment().isUndefined(),
- @"icon-rotation-alignment should be unset initially.");
- NSExpression *defaultExpression = layer.iconRotationAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- layer.iconRotationAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
- XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue,
- @"Setting iconRotationAlignment to a constant value expression should update icon-rotation-alignment.");
- XCTAssertEqualObjects(layer.iconRotationAlignment, constantExpression,
- @"iconRotationAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconRotationAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::AlignmentType>(
- step(zoom(), literal("auto"), 18.0, literal("auto"))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue,
- @"Setting iconRotationAlignment to a camera expression should update icon-rotation-alignment.");
- XCTAssertEqualObjects(layer.iconRotationAlignment, functionExpression,
- @"iconRotationAlignment should round-trip camera expressions.");
-
-
- layer.iconRotationAlignment = nil;
- XCTAssertTrue(rawLayer->getIconRotationAlignment().isUndefined(),
- @"Unsetting iconRotationAlignment should return icon-rotation-alignment to the default value.");
- XCTAssertEqualObjects(layer.iconRotationAlignment, defaultExpression,
- @"iconRotationAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-size
- {
- XCTAssertTrue(rawLayer->getIconSize().isUndefined(),
- @"icon-size should be unset initially.");
- NSExpression *defaultExpression = layer.iconScale;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconScale = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
- @"Setting iconScale to a constant value expression should update icon-size.");
- XCTAssertEqualObjects(layer.iconScale, constantExpression,
- @"iconScale should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconScale = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
- @"Setting iconScale to a camera expression should update icon-size.");
- XCTAssertEqualObjects(layer.iconScale, functionExpression,
- @"iconScale should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconScale = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
- @"Setting iconScale to a data expression should update icon-size.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconScale, pedanticFunctionExpression,
- @"iconScale should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconScale = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
- @"Setting iconScale to a camera-data expression should update icon-size.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconScale, pedanticFunctionExpression,
- @"iconScale should round-trip camera-data expressions.");
-
- layer.iconScale = nil;
- XCTAssertTrue(rawLayer->getIconSize().isUndefined(),
- @"Unsetting iconScale should return icon-size to the default value.");
- XCTAssertEqualObjects(layer.iconScale, defaultExpression,
- @"iconScale should return the default value after being unset.");
- }
-
- // icon-text-fit
- {
- XCTAssertTrue(rawLayer->getIconTextFit().isUndefined(),
- @"icon-text-fit should be unset initially.");
- NSExpression *defaultExpression = layer.iconTextFit;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'both'"];
- layer.iconTextFit = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::IconTextFitType> propertyValue = { mbgl::style::IconTextFitType::Both };
- XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue,
- @"Setting iconTextFit to a constant value expression should update icon-text-fit.");
- XCTAssertEqualObjects(layer.iconTextFit, constantExpression,
- @"iconTextFit should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'both'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconTextFit = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::IconTextFitType>(
- step(zoom(), literal("both"), 18.0, literal("both"))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue,
- @"Setting iconTextFit to a camera expression should update icon-text-fit.");
- XCTAssertEqualObjects(layer.iconTextFit, functionExpression,
- @"iconTextFit should round-trip camera expressions.");
-
-
- layer.iconTextFit = nil;
- XCTAssertTrue(rawLayer->getIconTextFit().isUndefined(),
- @"Unsetting iconTextFit should return icon-text-fit to the default value.");
- XCTAssertEqualObjects(layer.iconTextFit, defaultExpression,
- @"iconTextFit should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-text-fit-padding
- {
- XCTAssertTrue(rawLayer->getIconTextFitPadding().isUndefined(),
- @"icon-text-fit-padding should be unset initially.");
- NSExpression *defaultExpression = layer.iconTextFitPadding;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(1, 1, 1, 1)]
-#else
- [NSValue valueWithEdgeInsets:NSEdgeInsetsMake(1, 1, 1, 1)]
-#endif
- ];
- layer.iconTextFitPadding = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 4>> propertyValue = { { 1, 1, 1, 1 } };
- XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue,
- @"Setting iconTextFitPadding to a constant value expression should update icon-text-fit-padding.");
- XCTAssertEqualObjects(layer.iconTextFitPadding, constantExpression,
- @"iconTextFitPadding should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1, 1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconTextFitPadding = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 4>>(
- step(zoom(), literal({ 1, 1, 1, 1 }), 18.0, literal({ 1, 1, 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue,
- @"Setting iconTextFitPadding to a camera expression should update icon-text-fit-padding.");
- XCTAssertEqualObjects(layer.iconTextFitPadding, functionExpression,
- @"iconTextFitPadding should round-trip camera expressions.");
-
-
- layer.iconTextFitPadding = nil;
- XCTAssertTrue(rawLayer->getIconTextFitPadding().isUndefined(),
- @"Unsetting iconTextFitPadding should return icon-text-fit-padding to the default value.");
- XCTAssertEqualObjects(layer.iconTextFitPadding, defaultExpression,
- @"iconTextFitPadding should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconTextFitPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconTextFitPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-keep-upright
- {
- XCTAssertTrue(rawLayer->getIconKeepUpright().isUndefined(),
- @"icon-keep-upright should be unset initially.");
- NSExpression *defaultExpression = layer.keepsIconUpright;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.keepsIconUpright = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue,
- @"Setting keepsIconUpright to a constant value expression should update icon-keep-upright.");
- XCTAssertEqualObjects(layer.keepsIconUpright, constantExpression,
- @"keepsIconUpright should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.keepsIconUpright = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue,
- @"Setting keepsIconUpright to a camera expression should update icon-keep-upright.");
- XCTAssertEqualObjects(layer.keepsIconUpright, functionExpression,
- @"keepsIconUpright should round-trip camera expressions.");
-
-
- layer.keepsIconUpright = nil;
- XCTAssertTrue(rawLayer->getIconKeepUpright().isUndefined(),
- @"Unsetting keepsIconUpright should return icon-keep-upright to the default value.");
- XCTAssertEqualObjects(layer.keepsIconUpright, defaultExpression,
- @"keepsIconUpright should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-keep-upright
- {
- XCTAssertTrue(rawLayer->getTextKeepUpright().isUndefined(),
- @"text-keep-upright should be unset initially.");
- NSExpression *defaultExpression = layer.keepsTextUpright;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"];
- layer.keepsTextUpright = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { false };
- XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue,
- @"Setting keepsTextUpright to a constant value expression should update text-keep-upright.");
- XCTAssertEqualObjects(layer.keepsTextUpright, constantExpression,
- @"keepsTextUpright should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"false"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.keepsTextUpright = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(false), 18.0, literal(false))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue,
- @"Setting keepsTextUpright to a camera expression should update text-keep-upright.");
- XCTAssertEqualObjects(layer.keepsTextUpright, functionExpression,
- @"keepsTextUpright should round-trip camera expressions.");
-
-
- layer.keepsTextUpright = nil;
- XCTAssertTrue(rawLayer->getTextKeepUpright().isUndefined(),
- @"Unsetting keepsTextUpright should return text-keep-upright to the default value.");
- XCTAssertEqualObjects(layer.keepsTextUpright, defaultExpression,
- @"keepsTextUpright should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-max-angle
- {
- XCTAssertTrue(rawLayer->getTextMaxAngle().isUndefined(),
- @"text-max-angle should be unset initially.");
- NSExpression *defaultExpression = layer.maximumTextAngle;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.maximumTextAngle = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue,
- @"Setting maximumTextAngle to a constant value expression should update text-max-angle.");
- XCTAssertEqualObjects(layer.maximumTextAngle, constantExpression,
- @"maximumTextAngle should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.maximumTextAngle = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue,
- @"Setting maximumTextAngle to a camera expression should update text-max-angle.");
- XCTAssertEqualObjects(layer.maximumTextAngle, functionExpression,
- @"maximumTextAngle should round-trip camera expressions.");
-
-
- layer.maximumTextAngle = nil;
- XCTAssertTrue(rawLayer->getTextMaxAngle().isUndefined(),
- @"Unsetting maximumTextAngle should return text-max-angle to the default value.");
- XCTAssertEqualObjects(layer.maximumTextAngle, defaultExpression,
- @"maximumTextAngle should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.maximumTextAngle = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.maximumTextAngle = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-max-width
- {
- XCTAssertTrue(rawLayer->getTextMaxWidth().isUndefined(),
- @"text-max-width should be unset initially.");
- NSExpression *defaultExpression = layer.maximumTextWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.maximumTextWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
- @"Setting maximumTextWidth to a constant value expression should update text-max-width.");
- XCTAssertEqualObjects(layer.maximumTextWidth, constantExpression,
- @"maximumTextWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.maximumTextWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
- @"Setting maximumTextWidth to a camera expression should update text-max-width.");
- XCTAssertEqualObjects(layer.maximumTextWidth, functionExpression,
- @"maximumTextWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.maximumTextWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
- @"Setting maximumTextWidth to a data expression should update text-max-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.maximumTextWidth, pedanticFunctionExpression,
- @"maximumTextWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.maximumTextWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
- @"Setting maximumTextWidth to a camera-data expression should update text-max-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.maximumTextWidth, pedanticFunctionExpression,
- @"maximumTextWidth should round-trip camera-data expressions.");
-
- layer.maximumTextWidth = nil;
- XCTAssertTrue(rawLayer->getTextMaxWidth().isUndefined(),
- @"Unsetting maximumTextWidth should return text-max-width to the default value.");
- XCTAssertEqualObjects(layer.maximumTextWidth, defaultExpression,
- @"maximumTextWidth should return the default value after being unset.");
- }
-
- // symbol-avoid-edges
- {
- XCTAssertTrue(rawLayer->getSymbolAvoidEdges().isUndefined(),
- @"symbol-avoid-edges should be unset initially.");
- NSExpression *defaultExpression = layer.symbolAvoidsEdges;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.symbolAvoidsEdges = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue,
- @"Setting symbolAvoidsEdges to a constant value expression should update symbol-avoid-edges.");
- XCTAssertEqualObjects(layer.symbolAvoidsEdges, constantExpression,
- @"symbolAvoidsEdges should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.symbolAvoidsEdges = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue,
- @"Setting symbolAvoidsEdges to a camera expression should update symbol-avoid-edges.");
- XCTAssertEqualObjects(layer.symbolAvoidsEdges, functionExpression,
- @"symbolAvoidsEdges should round-trip camera expressions.");
-
-
- layer.symbolAvoidsEdges = nil;
- XCTAssertTrue(rawLayer->getSymbolAvoidEdges().isUndefined(),
- @"Unsetting symbolAvoidsEdges should return symbol-avoid-edges to the default value.");
- XCTAssertEqualObjects(layer.symbolAvoidsEdges, defaultExpression,
- @"symbolAvoidsEdges should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // symbol-placement
- {
- XCTAssertTrue(rawLayer->getSymbolPlacement().isUndefined(),
- @"symbol-placement should be unset initially.");
- NSExpression *defaultExpression = layer.symbolPlacement;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'line-center'"];
- layer.symbolPlacement = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::SymbolPlacementType> propertyValue = { mbgl::style::SymbolPlacementType::LineCenter };
- XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue,
- @"Setting symbolPlacement to a constant value expression should update symbol-placement.");
- XCTAssertEqualObjects(layer.symbolPlacement, constantExpression,
- @"symbolPlacement should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'line-center'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.symbolPlacement = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::SymbolPlacementType>(
- step(zoom(), literal("line-center"), 18.0, literal("line-center"))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue,
- @"Setting symbolPlacement to a camera expression should update symbol-placement.");
- XCTAssertEqualObjects(layer.symbolPlacement, functionExpression,
- @"symbolPlacement should round-trip camera expressions.");
-
-
- layer.symbolPlacement = nil;
- XCTAssertTrue(rawLayer->getSymbolPlacement().isUndefined(),
- @"Unsetting symbolPlacement should return symbol-placement to the default value.");
- XCTAssertEqualObjects(layer.symbolPlacement, defaultExpression,
- @"symbolPlacement should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // symbol-sort-key
- {
- XCTAssertTrue(rawLayer->getSymbolSortKey().isUndefined(),
- @"symbol-sort-key should be unset initially.");
- NSExpression *defaultExpression = layer.symbolSortKey;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.symbolSortKey = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue,
- @"Setting symbolSortKey to a constant value expression should update symbol-sort-key.");
- XCTAssertEqualObjects(layer.symbolSortKey, constantExpression,
- @"symbolSortKey should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.symbolSortKey = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue,
- @"Setting symbolSortKey to a camera expression should update symbol-sort-key.");
- XCTAssertEqualObjects(layer.symbolSortKey, functionExpression,
- @"symbolSortKey should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.symbolSortKey = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue,
- @"Setting symbolSortKey to a data expression should update symbol-sort-key.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.symbolSortKey, pedanticFunctionExpression,
- @"symbolSortKey should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.symbolSortKey = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue,
- @"Setting symbolSortKey to a camera-data expression should update symbol-sort-key.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.symbolSortKey, pedanticFunctionExpression,
- @"symbolSortKey should round-trip camera-data expressions.");
-
- layer.symbolSortKey = nil;
- XCTAssertTrue(rawLayer->getSymbolSortKey().isUndefined(),
- @"Unsetting symbolSortKey should return symbol-sort-key to the default value.");
- XCTAssertEqualObjects(layer.symbolSortKey, defaultExpression,
- @"symbolSortKey should return the default value after being unset.");
- }
-
- // symbol-spacing
- {
- XCTAssertTrue(rawLayer->getSymbolSpacing().isUndefined(),
- @"symbol-spacing should be unset initially.");
- NSExpression *defaultExpression = layer.symbolSpacing;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.symbolSpacing = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue,
- @"Setting symbolSpacing to a constant value expression should update symbol-spacing.");
- XCTAssertEqualObjects(layer.symbolSpacing, constantExpression,
- @"symbolSpacing should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.symbolSpacing = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue,
- @"Setting symbolSpacing to a camera expression should update symbol-spacing.");
- XCTAssertEqualObjects(layer.symbolSpacing, functionExpression,
- @"symbolSpacing should round-trip camera expressions.");
-
-
- layer.symbolSpacing = nil;
- XCTAssertTrue(rawLayer->getSymbolSpacing().isUndefined(),
- @"Unsetting symbolSpacing should return symbol-spacing to the default value.");
- XCTAssertEqualObjects(layer.symbolSpacing, defaultExpression,
- @"symbolSpacing should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.symbolSpacing = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.symbolSpacing = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // symbol-z-order
- {
- XCTAssertTrue(rawLayer->getSymbolZOrder().isUndefined(),
- @"symbol-z-order should be unset initially.");
- NSExpression *defaultExpression = layer.symbolZOrder;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'source'"];
- layer.symbolZOrder = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::SymbolZOrderType> propertyValue = { mbgl::style::SymbolZOrderType::Source };
- XCTAssertEqual(rawLayer->getSymbolZOrder(), propertyValue,
- @"Setting symbolZOrder to a constant value expression should update symbol-z-order.");
- XCTAssertEqualObjects(layer.symbolZOrder, constantExpression,
- @"symbolZOrder should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'source'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.symbolZOrder = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::SymbolZOrderType>(
- step(zoom(), literal("source"), 18.0, literal("source"))
- );
- }
-
- XCTAssertEqual(rawLayer->getSymbolZOrder(), propertyValue,
- @"Setting symbolZOrder to a camera expression should update symbol-z-order.");
- XCTAssertEqualObjects(layer.symbolZOrder, functionExpression,
- @"symbolZOrder should round-trip camera expressions.");
-
-
- layer.symbolZOrder = nil;
- XCTAssertTrue(rawLayer->getSymbolZOrder().isUndefined(),
- @"Unsetting symbolZOrder should return symbol-z-order to the default value.");
- XCTAssertEqualObjects(layer.symbolZOrder, defaultExpression,
- @"symbolZOrder should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.symbolZOrder = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.symbolZOrder = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-field
- {
- XCTAssertTrue(rawLayer->getTextField().isUndefined(),
- @"text-field should be unset initially.");
- NSExpression *defaultExpression = layer.text;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"];
- layer.text = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::expression::Formatted> propertyValue = { "Text Field" };
- XCTAssertEqual(rawLayer->getTextField(), propertyValue,
- @"Setting text to a constant value expression should update text-field.");
- XCTAssertEqualObjects(layer.text, constantExpression,
- @"text should round-trip constant value expressions.");
-
- MGLAttributedExpression *attributedConstantExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"'Text Field'"]
- attributes:@{}];
- constantExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:attributedConstantExpression]]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.text = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>(
- step(zoom(), format("Text Field"), 18.0, format("Text Field"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextField(), propertyValue,
- @"Setting text to a camera expression should update text-field.");
- XCTAssertEqualObjects(layer.text, functionExpression,
- @"text should round-trip camera expressions.");
-
-
- layer.text = nil;
- XCTAssertTrue(rawLayer->getTextField().isUndefined(),
- @"Unsetting text should return text-field to the default value.");
- XCTAssertEqualObjects(layer.text, defaultExpression,
- @"text should return the default value after being unset.");
-
- // Tokens test
- layer.text = [NSExpression expressionForConstantValue:@"{token}"];
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>(
- format(toString(get(literal("token"))))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextField(), propertyValue,
- @"Setting text to a constant string with tokens should convert to an expression.");
-
- MGLAttributedExpression *tokenAttibutedExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"CAST(token, 'NSString')"]
- attributes:@{}];
- NSExpression* tokenExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:tokenAttibutedExpression]]];
- XCTAssertEqualObjects(layer.text, tokenExpression,
- @"Setting text to a constant string with tokens should convert to an expression.");
- }
-
- // text-allow-overlap
- {
- XCTAssertTrue(rawLayer->getTextAllowOverlap().isUndefined(),
- @"text-allow-overlap should be unset initially.");
- NSExpression *defaultExpression = layer.textAllowsOverlap;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.textAllowsOverlap = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue,
- @"Setting textAllowsOverlap to a constant value expression should update text-allow-overlap.");
- XCTAssertEqualObjects(layer.textAllowsOverlap, constantExpression,
- @"textAllowsOverlap should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textAllowsOverlap = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue,
- @"Setting textAllowsOverlap to a camera expression should update text-allow-overlap.");
- XCTAssertEqualObjects(layer.textAllowsOverlap, functionExpression,
- @"textAllowsOverlap should round-trip camera expressions.");
-
-
- layer.textAllowsOverlap = nil;
- XCTAssertTrue(rawLayer->getTextAllowOverlap().isUndefined(),
- @"Unsetting textAllowsOverlap should return text-allow-overlap to the default value.");
- XCTAssertEqualObjects(layer.textAllowsOverlap, defaultExpression,
- @"textAllowsOverlap should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-anchor
- {
- XCTAssertTrue(rawLayer->getTextAnchor().isUndefined(),
- @"text-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.textAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"];
- layer.textAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::SymbolAnchorType> propertyValue = { mbgl::style::SymbolAnchorType::BottomRight };
- XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue,
- @"Setting textAnchor to a constant value expression should update text-anchor.");
- XCTAssertEqualObjects(layer.textAnchor, constantExpression,
- @"textAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::SymbolAnchorType>(
- step(zoom(), literal("bottom-right"), 18.0, literal("bottom-right"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue,
- @"Setting textAnchor to a camera expression should update text-anchor.");
- XCTAssertEqualObjects(layer.textAnchor, functionExpression,
- @"textAnchor should round-trip camera expressions.");
-
-
- layer.textAnchor = nil;
- XCTAssertTrue(rawLayer->getTextAnchor().isUndefined(),
- @"Unsetting textAnchor should return text-anchor to the default value.");
- XCTAssertEqualObjects(layer.textAnchor, defaultExpression,
- @"textAnchor should return the default value after being unset.");
- }
-
- // text-font
- {
- XCTAssertTrue(rawLayer->getTextFont().isUndefined(),
- @"text-font should be unset initially.");
- NSExpression *defaultExpression = layer.textFontNames;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'Text Font', 'Tnof Txet'}"];
- layer.textFontNames = constantExpression;
- mbgl::style::PropertyValue<std::vector<std::string>> propertyValue = { { "Text Font", "Tnof Txet" } };
- XCTAssertEqual(rawLayer->getTextFont(), propertyValue,
- @"Setting textFontNames to a constant value expression should update text-font.");
- XCTAssertEqualObjects(layer.textFontNames, constantExpression,
- @"textFontNames should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{'Text Font', 'Tnof Txet'}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textFontNames = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::vector<std::string>>(
- step(zoom(), literal({ "Text Font", "Tnof Txet" }), 18.0, literal({ "Text Font", "Tnof Txet" }))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextFont(), propertyValue,
- @"Setting textFontNames to a camera expression should update text-font.");
- XCTAssertEqualObjects(layer.textFontNames, functionExpression,
- @"textFontNames should round-trip camera expressions.");
-
-
- layer.textFontNames = nil;
- XCTAssertTrue(rawLayer->getTextFont().isUndefined(),
- @"Unsetting textFontNames should return text-font to the default value.");
- XCTAssertEqualObjects(layer.textFontNames, defaultExpression,
- @"textFontNames should return the default value after being unset.");
- }
-
- // text-size
- {
- XCTAssertTrue(rawLayer->getTextSize().isUndefined(),
- @"text-size should be unset initially.");
- NSExpression *defaultExpression = layer.textFontSize;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textFontSize = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
- @"Setting textFontSize to a constant value expression should update text-size.");
- XCTAssertEqualObjects(layer.textFontSize, constantExpression,
- @"textFontSize should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textFontSize = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
- @"Setting textFontSize to a camera expression should update text-size.");
- XCTAssertEqualObjects(layer.textFontSize, functionExpression,
- @"textFontSize should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textFontSize = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
- @"Setting textFontSize to a data expression should update text-size.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textFontSize, pedanticFunctionExpression,
- @"textFontSize should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textFontSize = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
- @"Setting textFontSize to a camera-data expression should update text-size.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textFontSize, pedanticFunctionExpression,
- @"textFontSize should round-trip camera-data expressions.");
-
- layer.textFontSize = nil;
- XCTAssertTrue(rawLayer->getTextSize().isUndefined(),
- @"Unsetting textFontSize should return text-size to the default value.");
- XCTAssertEqualObjects(layer.textFontSize, defaultExpression,
- @"textFontSize should return the default value after being unset.");
- }
-
- // text-ignore-placement
- {
- XCTAssertTrue(rawLayer->getTextIgnorePlacement().isUndefined(),
- @"text-ignore-placement should be unset initially.");
- NSExpression *defaultExpression = layer.textIgnoresPlacement;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.textIgnoresPlacement = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue,
- @"Setting textIgnoresPlacement to a constant value expression should update text-ignore-placement.");
- XCTAssertEqualObjects(layer.textIgnoresPlacement, constantExpression,
- @"textIgnoresPlacement should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textIgnoresPlacement = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue,
- @"Setting textIgnoresPlacement to a camera expression should update text-ignore-placement.");
- XCTAssertEqualObjects(layer.textIgnoresPlacement, functionExpression,
- @"textIgnoresPlacement should round-trip camera expressions.");
-
-
- layer.textIgnoresPlacement = nil;
- XCTAssertTrue(rawLayer->getTextIgnorePlacement().isUndefined(),
- @"Unsetting textIgnoresPlacement should return text-ignore-placement to the default value.");
- XCTAssertEqualObjects(layer.textIgnoresPlacement, defaultExpression,
- @"textIgnoresPlacement should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-justify
- {
- XCTAssertTrue(rawLayer->getTextJustify().isUndefined(),
- @"text-justify should be unset initially.");
- NSExpression *defaultExpression = layer.textJustification;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'right'"];
- layer.textJustification = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TextJustifyType> propertyValue = { mbgl::style::TextJustifyType::Right };
- XCTAssertEqual(rawLayer->getTextJustify(), propertyValue,
- @"Setting textJustification to a constant value expression should update text-justify.");
- XCTAssertEqualObjects(layer.textJustification, constantExpression,
- @"textJustification should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'right'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textJustification = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TextJustifyType>(
- step(zoom(), literal("right"), 18.0, literal("right"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextJustify(), propertyValue,
- @"Setting textJustification to a camera expression should update text-justify.");
- XCTAssertEqualObjects(layer.textJustification, functionExpression,
- @"textJustification should round-trip camera expressions.");
-
-
- layer.textJustification = nil;
- XCTAssertTrue(rawLayer->getTextJustify().isUndefined(),
- @"Unsetting textJustification should return text-justify to the default value.");
- XCTAssertEqualObjects(layer.textJustification, defaultExpression,
- @"textJustification should return the default value after being unset.");
- }
-
- // text-letter-spacing
- {
- XCTAssertTrue(rawLayer->getTextLetterSpacing().isUndefined(),
- @"text-letter-spacing should be unset initially.");
- NSExpression *defaultExpression = layer.textLetterSpacing;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textLetterSpacing = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
- @"Setting textLetterSpacing to a constant value expression should update text-letter-spacing.");
- XCTAssertEqualObjects(layer.textLetterSpacing, constantExpression,
- @"textLetterSpacing should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textLetterSpacing = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
- @"Setting textLetterSpacing to a camera expression should update text-letter-spacing.");
- XCTAssertEqualObjects(layer.textLetterSpacing, functionExpression,
- @"textLetterSpacing should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textLetterSpacing = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
- @"Setting textLetterSpacing to a data expression should update text-letter-spacing.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textLetterSpacing, pedanticFunctionExpression,
- @"textLetterSpacing should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textLetterSpacing = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
- @"Setting textLetterSpacing to a camera-data expression should update text-letter-spacing.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textLetterSpacing, pedanticFunctionExpression,
- @"textLetterSpacing should round-trip camera-data expressions.");
-
- layer.textLetterSpacing = nil;
- XCTAssertTrue(rawLayer->getTextLetterSpacing().isUndefined(),
- @"Unsetting textLetterSpacing should return text-letter-spacing to the default value.");
- XCTAssertEqualObjects(layer.textLetterSpacing, defaultExpression,
- @"textLetterSpacing should return the default value after being unset.");
- }
-
- // text-line-height
- {
- XCTAssertTrue(rawLayer->getTextLineHeight().isUndefined(),
- @"text-line-height should be unset initially.");
- NSExpression *defaultExpression = layer.textLineHeight;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textLineHeight = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue,
- @"Setting textLineHeight to a constant value expression should update text-line-height.");
- XCTAssertEqualObjects(layer.textLineHeight, constantExpression,
- @"textLineHeight should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textLineHeight = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue,
- @"Setting textLineHeight to a camera expression should update text-line-height.");
- XCTAssertEqualObjects(layer.textLineHeight, functionExpression,
- @"textLineHeight should round-trip camera expressions.");
-
-
- layer.textLineHeight = nil;
- XCTAssertTrue(rawLayer->getTextLineHeight().isUndefined(),
- @"Unsetting textLineHeight should return text-line-height to the default value.");
- XCTAssertEqualObjects(layer.textLineHeight, defaultExpression,
- @"textLineHeight should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textLineHeight = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textLineHeight = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-offset
- {
- XCTAssertTrue(rawLayer->getTextOffset().isUndefined(),
- @"text-offset should be unset initially.");
- NSExpression *defaultExpression = layer.textOffset;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.textOffset = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
- @"Setting textOffset to a constant value expression should update text-offset.");
- XCTAssertEqualObjects(layer.textOffset, constantExpression,
- @"textOffset should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
- @"Setting textOffset to a camera expression should update text-offset.");
- XCTAssertEqualObjects(layer.textOffset, functionExpression,
- @"textOffset should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
- @"Setting textOffset to a data expression should update text-offset.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textOffset, pedanticFunctionExpression,
- @"textOffset should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 })))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
- @"Setting textOffset to a camera-data expression should update text-offset.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textOffset, pedanticFunctionExpression,
- @"textOffset should round-trip camera-data expressions.");
-
- layer.textOffset = nil;
- XCTAssertTrue(rawLayer->getTextOffset().isUndefined(),
- @"Unsetting textOffset should return text-offset to the default value.");
- XCTAssertEqualObjects(layer.textOffset, defaultExpression,
- @"textOffset should return the default value after being unset.");
- }
-
- // text-optional
- {
- XCTAssertTrue(rawLayer->getTextOptional().isUndefined(),
- @"text-optional should be unset initially.");
- NSExpression *defaultExpression = layer.textOptional;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"];
- layer.textOptional = constantExpression;
- mbgl::style::PropertyValue<bool> propertyValue = { true };
- XCTAssertEqual(rawLayer->getTextOptional(), propertyValue,
- @"Setting textOptional to a constant value expression should update text-optional.");
- XCTAssertEqualObjects(layer.textOptional, constantExpression,
- @"textOptional should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"true"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textOptional = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<bool>(
- step(zoom(), literal(true), 18.0, literal(true))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOptional(), propertyValue,
- @"Setting textOptional to a camera expression should update text-optional.");
- XCTAssertEqualObjects(layer.textOptional, functionExpression,
- @"textOptional should round-trip camera expressions.");
-
-
- layer.textOptional = nil;
- XCTAssertTrue(rawLayer->getTextOptional().isUndefined(),
- @"Unsetting textOptional should return text-optional to the default value.");
- XCTAssertEqualObjects(layer.textOptional, defaultExpression,
- @"textOptional should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-padding
- {
- XCTAssertTrue(rawLayer->getTextPadding().isUndefined(),
- @"text-padding should be unset initially.");
- NSExpression *defaultExpression = layer.textPadding;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textPadding = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextPadding(), propertyValue,
- @"Setting textPadding to a constant value expression should update text-padding.");
- XCTAssertEqualObjects(layer.textPadding, constantExpression,
- @"textPadding should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textPadding = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextPadding(), propertyValue,
- @"Setting textPadding to a camera expression should update text-padding.");
- XCTAssertEqualObjects(layer.textPadding, functionExpression,
- @"textPadding should round-trip camera expressions.");
-
-
- layer.textPadding = nil;
- XCTAssertTrue(rawLayer->getTextPadding().isUndefined(),
- @"Unsetting textPadding should return text-padding to the default value.");
- XCTAssertEqualObjects(layer.textPadding, defaultExpression,
- @"textPadding should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-pitch-alignment
- {
- XCTAssertTrue(rawLayer->getTextPitchAlignment().isUndefined(),
- @"text-pitch-alignment should be unset initially.");
- NSExpression *defaultExpression = layer.textPitchAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- layer.textPitchAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
- XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue,
- @"Setting textPitchAlignment to a constant value expression should update text-pitch-alignment.");
- XCTAssertEqualObjects(layer.textPitchAlignment, constantExpression,
- @"textPitchAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textPitchAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::AlignmentType>(
- step(zoom(), literal("auto"), 18.0, literal("auto"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue,
- @"Setting textPitchAlignment to a camera expression should update text-pitch-alignment.");
- XCTAssertEqualObjects(layer.textPitchAlignment, functionExpression,
- @"textPitchAlignment should round-trip camera expressions.");
-
-
- layer.textPitchAlignment = nil;
- XCTAssertTrue(rawLayer->getTextPitchAlignment().isUndefined(),
- @"Unsetting textPitchAlignment should return text-pitch-alignment to the default value.");
- XCTAssertEqualObjects(layer.textPitchAlignment, defaultExpression,
- @"textPitchAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-radial-offset
- {
- XCTAssertTrue(rawLayer->getTextRadialOffset().isUndefined(),
- @"text-radial-offset should be unset initially.");
- NSExpression *defaultExpression = layer.textRadialOffset;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textRadialOffset = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue,
- @"Setting textRadialOffset to a constant value expression should update text-radial-offset.");
- XCTAssertEqualObjects(layer.textRadialOffset, constantExpression,
- @"textRadialOffset should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textRadialOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue,
- @"Setting textRadialOffset to a camera expression should update text-radial-offset.");
- XCTAssertEqualObjects(layer.textRadialOffset, functionExpression,
- @"textRadialOffset should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textRadialOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue,
- @"Setting textRadialOffset to a data expression should update text-radial-offset.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textRadialOffset, pedanticFunctionExpression,
- @"textRadialOffset should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textRadialOffset = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue,
- @"Setting textRadialOffset to a camera-data expression should update text-radial-offset.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textRadialOffset, pedanticFunctionExpression,
- @"textRadialOffset should round-trip camera-data expressions.");
-
- layer.textRadialOffset = nil;
- XCTAssertTrue(rawLayer->getTextRadialOffset().isUndefined(),
- @"Unsetting textRadialOffset should return text-radial-offset to the default value.");
- XCTAssertEqualObjects(layer.textRadialOffset, defaultExpression,
- @"textRadialOffset should return the default value after being unset.");
- }
-
- // text-rotate
- {
- XCTAssertTrue(rawLayer->getTextRotate().isUndefined(),
- @"text-rotate should be unset initially.");
- NSExpression *defaultExpression = layer.textRotation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textRotation = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
- @"Setting textRotation to a constant value expression should update text-rotate.");
- XCTAssertEqualObjects(layer.textRotation, constantExpression,
- @"textRotation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
- @"Setting textRotation to a camera expression should update text-rotate.");
- XCTAssertEqualObjects(layer.textRotation, functionExpression,
- @"textRotation should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
- @"Setting textRotation to a data expression should update text-rotate.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textRotation, pedanticFunctionExpression,
- @"textRotation should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textRotation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
- @"Setting textRotation to a camera-data expression should update text-rotate.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textRotation, pedanticFunctionExpression,
- @"textRotation should round-trip camera-data expressions.");
-
- layer.textRotation = nil;
- XCTAssertTrue(rawLayer->getTextRotate().isUndefined(),
- @"Unsetting textRotation should return text-rotate to the default value.");
- XCTAssertEqualObjects(layer.textRotation, defaultExpression,
- @"textRotation should return the default value after being unset.");
- }
-
- // text-rotation-alignment
- {
- XCTAssertTrue(rawLayer->getTextRotationAlignment().isUndefined(),
- @"text-rotation-alignment should be unset initially.");
- NSExpression *defaultExpression = layer.textRotationAlignment;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- layer.textRotationAlignment = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
- XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue,
- @"Setting textRotationAlignment to a constant value expression should update text-rotation-alignment.");
- XCTAssertEqualObjects(layer.textRotationAlignment, constantExpression,
- @"textRotationAlignment should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'auto'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textRotationAlignment = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::AlignmentType>(
- step(zoom(), literal("auto"), 18.0, literal("auto"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue,
- @"Setting textRotationAlignment to a camera expression should update text-rotation-alignment.");
- XCTAssertEqualObjects(layer.textRotationAlignment, functionExpression,
- @"textRotationAlignment should round-trip camera expressions.");
-
-
- layer.textRotationAlignment = nil;
- XCTAssertTrue(rawLayer->getTextRotationAlignment().isUndefined(),
- @"Unsetting textRotationAlignment should return text-rotation-alignment to the default value.");
- XCTAssertEqualObjects(layer.textRotationAlignment, defaultExpression,
- @"textRotationAlignment should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-transform
- {
- XCTAssertTrue(rawLayer->getTextTransform().isUndefined(),
- @"text-transform should be unset initially.");
- NSExpression *defaultExpression = layer.textTransform;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'lowercase'"];
- layer.textTransform = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TextTransformType> propertyValue = { mbgl::style::TextTransformType::Lowercase };
- XCTAssertEqual(rawLayer->getTextTransform(), propertyValue,
- @"Setting textTransform to a constant value expression should update text-transform.");
- XCTAssertEqualObjects(layer.textTransform, constantExpression,
- @"textTransform should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'lowercase'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textTransform = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TextTransformType>(
- step(zoom(), literal("lowercase"), 18.0, literal("lowercase"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextTransform(), propertyValue,
- @"Setting textTransform to a camera expression should update text-transform.");
- XCTAssertEqualObjects(layer.textTransform, functionExpression,
- @"textTransform should round-trip camera expressions.");
-
-
- layer.textTransform = nil;
- XCTAssertTrue(rawLayer->getTextTransform().isUndefined(),
- @"Unsetting textTransform should return text-transform to the default value.");
- XCTAssertEqualObjects(layer.textTransform, defaultExpression,
- @"textTransform should return the default value after being unset.");
- }
-
- // text-variable-anchor
- {
- XCTAssertTrue(rawLayer->getTextVariableAnchor().isUndefined(),
- @"text-variable-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.textVariableAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'top','bottom'}"];
- layer.textVariableAnchor = constantExpression;
- mbgl::style::PropertyValue<std::vector<mbgl::style::SymbolAnchorType>> propertyValue = { { mbgl::style::SymbolAnchorType::Top, mbgl::style::SymbolAnchorType::Bottom } };
- XCTAssertEqual(rawLayer->getTextVariableAnchor(), propertyValue,
- @"Setting textVariableAnchor to a constant value expression should update text-variable-anchor.");
- XCTAssertEqualObjects(layer.textVariableAnchor, constantExpression,
- @"textVariableAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{'top','bottom'}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textVariableAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::vector<mbgl::style::SymbolAnchorType>>(
- step(zoom(), literal({"top", "bottom"}), 18.0, literal({"top", "bottom"}))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextVariableAnchor(), propertyValue,
- @"Setting textVariableAnchor to a camera expression should update text-variable-anchor.");
- XCTAssertEqualObjects(layer.textVariableAnchor, functionExpression,
- @"textVariableAnchor should round-trip camera expressions.");
-
-
- layer.textVariableAnchor = nil;
- XCTAssertTrue(rawLayer->getTextVariableAnchor().isUndefined(),
- @"Unsetting textVariableAnchor should return text-variable-anchor to the default value.");
- XCTAssertEqualObjects(layer.textVariableAnchor, defaultExpression,
- @"textVariableAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textVariableAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textVariableAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-writing-mode
- {
- XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(),
- @"text-writing-mode should be unset initially.");
- NSExpression *defaultExpression = layer.textWritingModes;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"];
- layer.textWritingModes = constantExpression;
- mbgl::style::PropertyValue<std::vector<mbgl::style::TextWritingModeType>> propertyValue = { { mbgl::style::TextWritingModeType::Horizontal, mbgl::style::TextWritingModeType::Vertical } };
- XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue,
- @"Setting textWritingModes to a constant value expression should update text-writing-mode.");
- XCTAssertEqualObjects(layer.textWritingModes, constantExpression,
- @"textWritingModes should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textWritingModes = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::vector<mbgl::style::TextWritingModeType>>(
- step(zoom(), literal({"horizontal", "vertical"}), 18.0, literal({"horizontal", "vertical"}))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue,
- @"Setting textWritingModes to a camera expression should update text-writing-mode.");
- XCTAssertEqualObjects(layer.textWritingModes, functionExpression,
- @"textWritingModes should round-trip camera expressions.");
-
-
- layer.textWritingModes = nil;
- XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(),
- @"Unsetting textWritingModes should return text-writing-mode to the default value.");
- XCTAssertEqualObjects(layer.textWritingModes, defaultExpression,
- @"textWritingModes should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-color
- {
- XCTAssertTrue(rawLayer->getIconColor().isUndefined(),
- @"icon-color should be unset initially.");
- NSExpression *defaultExpression = layer.iconColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.iconColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
- @"Setting iconColor to a constant value expression should update icon-color.");
- XCTAssertEqualObjects(layer.iconColor, constantExpression,
- @"iconColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
- @"Setting iconColor to a camera expression should update icon-color.");
- XCTAssertEqualObjects(layer.iconColor, functionExpression,
- @"iconColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
- @"Setting iconColor to a data expression should update icon-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconColor, pedanticFunctionExpression,
- @"iconColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
- @"Setting iconColor to a camera-data expression should update icon-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconColor, pedanticFunctionExpression,
- @"iconColor should round-trip camera-data expressions.");
-
- layer.iconColor = nil;
- XCTAssertTrue(rawLayer->getIconColor().isUndefined(),
- @"Unsetting iconColor should return icon-color to the default value.");
- XCTAssertEqualObjects(layer.iconColor, defaultExpression,
- @"iconColor should return the default value after being unset.");
- // Transition property test
- layer.iconColorTransition = transitionTest;
- auto toptions = rawLayer->getIconColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition iconColorTransition = layer.iconColorTransition;
- XCTAssertEqual(iconColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(iconColorTransition.duration, transitionTest.duration);
- }
-
- // icon-halo-blur
- {
- XCTAssertTrue(rawLayer->getIconHaloBlur().isUndefined(),
- @"icon-halo-blur should be unset initially.");
- NSExpression *defaultExpression = layer.iconHaloBlur;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconHaloBlur = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
- @"Setting iconHaloBlur to a constant value expression should update icon-halo-blur.");
- XCTAssertEqualObjects(layer.iconHaloBlur, constantExpression,
- @"iconHaloBlur should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
- @"Setting iconHaloBlur to a camera expression should update icon-halo-blur.");
- XCTAssertEqualObjects(layer.iconHaloBlur, functionExpression,
- @"iconHaloBlur should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
- @"Setting iconHaloBlur to a data expression should update icon-halo-blur.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconHaloBlur, pedanticFunctionExpression,
- @"iconHaloBlur should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
- @"Setting iconHaloBlur to a camera-data expression should update icon-halo-blur.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconHaloBlur, pedanticFunctionExpression,
- @"iconHaloBlur should round-trip camera-data expressions.");
-
- layer.iconHaloBlur = nil;
- XCTAssertTrue(rawLayer->getIconHaloBlur().isUndefined(),
- @"Unsetting iconHaloBlur should return icon-halo-blur to the default value.");
- XCTAssertEqualObjects(layer.iconHaloBlur, defaultExpression,
- @"iconHaloBlur should return the default value after being unset.");
- // Transition property test
- layer.iconHaloBlurTransition = transitionTest;
- auto toptions = rawLayer->getIconHaloBlurTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition iconHaloBlurTransition = layer.iconHaloBlurTransition;
- XCTAssertEqual(iconHaloBlurTransition.delay, transitionTest.delay);
- XCTAssertEqual(iconHaloBlurTransition.duration, transitionTest.duration);
- }
-
- // icon-halo-color
- {
- XCTAssertTrue(rawLayer->getIconHaloColor().isUndefined(),
- @"icon-halo-color should be unset initially.");
- NSExpression *defaultExpression = layer.iconHaloColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.iconHaloColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
- @"Setting iconHaloColor to a constant value expression should update icon-halo-color.");
- XCTAssertEqualObjects(layer.iconHaloColor, constantExpression,
- @"iconHaloColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
- @"Setting iconHaloColor to a camera expression should update icon-halo-color.");
- XCTAssertEqualObjects(layer.iconHaloColor, functionExpression,
- @"iconHaloColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
- @"Setting iconHaloColor to a data expression should update icon-halo-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconHaloColor, pedanticFunctionExpression,
- @"iconHaloColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
- @"Setting iconHaloColor to a camera-data expression should update icon-halo-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconHaloColor, pedanticFunctionExpression,
- @"iconHaloColor should round-trip camera-data expressions.");
-
- layer.iconHaloColor = nil;
- XCTAssertTrue(rawLayer->getIconHaloColor().isUndefined(),
- @"Unsetting iconHaloColor should return icon-halo-color to the default value.");
- XCTAssertEqualObjects(layer.iconHaloColor, defaultExpression,
- @"iconHaloColor should return the default value after being unset.");
- // Transition property test
- layer.iconHaloColorTransition = transitionTest;
- auto toptions = rawLayer->getIconHaloColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition iconHaloColorTransition = layer.iconHaloColorTransition;
- XCTAssertEqual(iconHaloColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(iconHaloColorTransition.duration, transitionTest.duration);
- }
-
- // icon-halo-width
- {
- XCTAssertTrue(rawLayer->getIconHaloWidth().isUndefined(),
- @"icon-halo-width should be unset initially.");
- NSExpression *defaultExpression = layer.iconHaloWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconHaloWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
- @"Setting iconHaloWidth to a constant value expression should update icon-halo-width.");
- XCTAssertEqualObjects(layer.iconHaloWidth, constantExpression,
- @"iconHaloWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
- @"Setting iconHaloWidth to a camera expression should update icon-halo-width.");
- XCTAssertEqualObjects(layer.iconHaloWidth, functionExpression,
- @"iconHaloWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
- @"Setting iconHaloWidth to a data expression should update icon-halo-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconHaloWidth, pedanticFunctionExpression,
- @"iconHaloWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
- @"Setting iconHaloWidth to a camera-data expression should update icon-halo-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconHaloWidth, pedanticFunctionExpression,
- @"iconHaloWidth should round-trip camera-data expressions.");
-
- layer.iconHaloWidth = nil;
- XCTAssertTrue(rawLayer->getIconHaloWidth().isUndefined(),
- @"Unsetting iconHaloWidth should return icon-halo-width to the default value.");
- XCTAssertEqualObjects(layer.iconHaloWidth, defaultExpression,
- @"iconHaloWidth should return the default value after being unset.");
- // Transition property test
- layer.iconHaloWidthTransition = transitionTest;
- auto toptions = rawLayer->getIconHaloWidthTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition iconHaloWidthTransition = layer.iconHaloWidthTransition;
- XCTAssertEqual(iconHaloWidthTransition.delay, transitionTest.delay);
- XCTAssertEqual(iconHaloWidthTransition.duration, transitionTest.duration);
- }
-
- // icon-opacity
- {
- XCTAssertTrue(rawLayer->getIconOpacity().isUndefined(),
- @"icon-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.iconOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.iconOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
- @"Setting iconOpacity to a constant value expression should update icon-opacity.");
- XCTAssertEqualObjects(layer.iconOpacity, constantExpression,
- @"iconOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
- @"Setting iconOpacity to a camera expression should update icon-opacity.");
- XCTAssertEqualObjects(layer.iconOpacity, functionExpression,
- @"iconOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.iconOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
- @"Setting iconOpacity to a data expression should update icon-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.iconOpacity, pedanticFunctionExpression,
- @"iconOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.iconOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
- @"Setting iconOpacity to a camera-data expression should update icon-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.iconOpacity, pedanticFunctionExpression,
- @"iconOpacity should round-trip camera-data expressions.");
-
- layer.iconOpacity = nil;
- XCTAssertTrue(rawLayer->getIconOpacity().isUndefined(),
- @"Unsetting iconOpacity should return icon-opacity to the default value.");
- XCTAssertEqualObjects(layer.iconOpacity, defaultExpression,
- @"iconOpacity should return the default value after being unset.");
- // Transition property test
- layer.iconOpacityTransition = transitionTest;
- auto toptions = rawLayer->getIconOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition iconOpacityTransition = layer.iconOpacityTransition;
- XCTAssertEqual(iconOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(iconOpacityTransition.duration, transitionTest.duration);
- }
-
- // icon-translate
- {
- XCTAssertTrue(rawLayer->getIconTranslate().isUndefined(),
- @"icon-translate should be unset initially.");
- NSExpression *defaultExpression = layer.iconTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.iconTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue,
- @"Setting iconTranslation to a constant value expression should update icon-translate.");
- XCTAssertEqualObjects(layer.iconTranslation, constantExpression,
- @"iconTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue,
- @"Setting iconTranslation to a camera expression should update icon-translate.");
- XCTAssertEqualObjects(layer.iconTranslation, functionExpression,
- @"iconTranslation should round-trip camera expressions.");
-
-
- layer.iconTranslation = nil;
- XCTAssertTrue(rawLayer->getIconTranslate().isUndefined(),
- @"Unsetting iconTranslation should return icon-translate to the default value.");
- XCTAssertEqualObjects(layer.iconTranslation, defaultExpression,
- @"iconTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // icon-translate-anchor
- {
- XCTAssertTrue(rawLayer->getIconTranslateAnchor().isUndefined(),
- @"icon-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.iconTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.iconTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue,
- @"Setting iconTranslationAnchor to a constant value expression should update icon-translate-anchor.");
- XCTAssertEqualObjects(layer.iconTranslationAnchor, constantExpression,
- @"iconTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.iconTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue,
- @"Setting iconTranslationAnchor to a camera expression should update icon-translate-anchor.");
- XCTAssertEqualObjects(layer.iconTranslationAnchor, functionExpression,
- @"iconTranslationAnchor should round-trip camera expressions.");
-
-
- layer.iconTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getIconTranslateAnchor().isUndefined(),
- @"Unsetting iconTranslationAnchor should return icon-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.iconTranslationAnchor, defaultExpression,
- @"iconTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-color
- {
- XCTAssertTrue(rawLayer->getTextColor().isUndefined(),
- @"text-color should be unset initially.");
- NSExpression *defaultExpression = layer.textColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.textColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
- @"Setting textColor to a constant value expression should update text-color.");
- XCTAssertEqualObjects(layer.textColor, constantExpression,
- @"textColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
- @"Setting textColor to a camera expression should update text-color.");
- XCTAssertEqualObjects(layer.textColor, functionExpression,
- @"textColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
- @"Setting textColor to a data expression should update text-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textColor, pedanticFunctionExpression,
- @"textColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
- @"Setting textColor to a camera-data expression should update text-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textColor, pedanticFunctionExpression,
- @"textColor should round-trip camera-data expressions.");
-
- layer.textColor = nil;
- XCTAssertTrue(rawLayer->getTextColor().isUndefined(),
- @"Unsetting textColor should return text-color to the default value.");
- XCTAssertEqualObjects(layer.textColor, defaultExpression,
- @"textColor should return the default value after being unset.");
- // Transition property test
- layer.textColorTransition = transitionTest;
- auto toptions = rawLayer->getTextColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition textColorTransition = layer.textColorTransition;
- XCTAssertEqual(textColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(textColorTransition.duration, transitionTest.duration);
- }
-
- // text-halo-blur
- {
- XCTAssertTrue(rawLayer->getTextHaloBlur().isUndefined(),
- @"text-halo-blur should be unset initially.");
- NSExpression *defaultExpression = layer.textHaloBlur;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textHaloBlur = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
- @"Setting textHaloBlur to a constant value expression should update text-halo-blur.");
- XCTAssertEqualObjects(layer.textHaloBlur, constantExpression,
- @"textHaloBlur should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
- @"Setting textHaloBlur to a camera expression should update text-halo-blur.");
- XCTAssertEqualObjects(layer.textHaloBlur, functionExpression,
- @"textHaloBlur should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
- @"Setting textHaloBlur to a data expression should update text-halo-blur.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textHaloBlur, pedanticFunctionExpression,
- @"textHaloBlur should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textHaloBlur = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
- @"Setting textHaloBlur to a camera-data expression should update text-halo-blur.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textHaloBlur, pedanticFunctionExpression,
- @"textHaloBlur should round-trip camera-data expressions.");
-
- layer.textHaloBlur = nil;
- XCTAssertTrue(rawLayer->getTextHaloBlur().isUndefined(),
- @"Unsetting textHaloBlur should return text-halo-blur to the default value.");
- XCTAssertEqualObjects(layer.textHaloBlur, defaultExpression,
- @"textHaloBlur should return the default value after being unset.");
- // Transition property test
- layer.textHaloBlurTransition = transitionTest;
- auto toptions = rawLayer->getTextHaloBlurTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition textHaloBlurTransition = layer.textHaloBlurTransition;
- XCTAssertEqual(textHaloBlurTransition.delay, transitionTest.delay);
- XCTAssertEqual(textHaloBlurTransition.duration, transitionTest.duration);
- }
-
- // text-halo-color
- {
- XCTAssertTrue(rawLayer->getTextHaloColor().isUndefined(),
- @"text-halo-color should be unset initially.");
- NSExpression *defaultExpression = layer.textHaloColor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- layer.textHaloColor = constantExpression;
- mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
- XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
- @"Setting textHaloColor to a constant value expression should update text-halo-color.");
- XCTAssertEqualObjects(layer.textHaloColor, constantExpression,
- @"textHaloColor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
- @"Setting textHaloColor to a camera expression should update text-halo-color.");
- XCTAssertEqualObjects(layer.textHaloColor, functionExpression,
- @"textHaloColor should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
- @"Setting textHaloColor to a data expression should update text-halo-color.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textHaloColor, pedanticFunctionExpression,
- @"textHaloColor should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textHaloColor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::Color>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
- @"Setting textHaloColor to a camera-data expression should update text-halo-color.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textHaloColor, pedanticFunctionExpression,
- @"textHaloColor should round-trip camera-data expressions.");
-
- layer.textHaloColor = nil;
- XCTAssertTrue(rawLayer->getTextHaloColor().isUndefined(),
- @"Unsetting textHaloColor should return text-halo-color to the default value.");
- XCTAssertEqualObjects(layer.textHaloColor, defaultExpression,
- @"textHaloColor should return the default value after being unset.");
- // Transition property test
- layer.textHaloColorTransition = transitionTest;
- auto toptions = rawLayer->getTextHaloColorTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition textHaloColorTransition = layer.textHaloColorTransition;
- XCTAssertEqual(textHaloColorTransition.delay, transitionTest.delay);
- XCTAssertEqual(textHaloColorTransition.duration, transitionTest.duration);
- }
-
- // text-halo-width
- {
- XCTAssertTrue(rawLayer->getTextHaloWidth().isUndefined(),
- @"text-halo-width should be unset initially.");
- NSExpression *defaultExpression = layer.textHaloWidth;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textHaloWidth = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
- @"Setting textHaloWidth to a constant value expression should update text-halo-width.");
- XCTAssertEqualObjects(layer.textHaloWidth, constantExpression,
- @"textHaloWidth should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
- @"Setting textHaloWidth to a camera expression should update text-halo-width.");
- XCTAssertEqualObjects(layer.textHaloWidth, functionExpression,
- @"textHaloWidth should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
- @"Setting textHaloWidth to a data expression should update text-halo-width.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textHaloWidth, pedanticFunctionExpression,
- @"textHaloWidth should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textHaloWidth = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
- @"Setting textHaloWidth to a camera-data expression should update text-halo-width.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textHaloWidth, pedanticFunctionExpression,
- @"textHaloWidth should round-trip camera-data expressions.");
-
- layer.textHaloWidth = nil;
- XCTAssertTrue(rawLayer->getTextHaloWidth().isUndefined(),
- @"Unsetting textHaloWidth should return text-halo-width to the default value.");
- XCTAssertEqualObjects(layer.textHaloWidth, defaultExpression,
- @"textHaloWidth should return the default value after being unset.");
- // Transition property test
- layer.textHaloWidthTransition = transitionTest;
- auto toptions = rawLayer->getTextHaloWidthTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition textHaloWidthTransition = layer.textHaloWidthTransition;
- XCTAssertEqual(textHaloWidthTransition.delay, transitionTest.delay);
- XCTAssertEqual(textHaloWidthTransition.duration, transitionTest.duration);
- }
-
- // text-opacity
- {
- XCTAssertTrue(rawLayer->getTextOpacity().isUndefined(),
- @"text-opacity should be unset initially.");
- NSExpression *defaultExpression = layer.textOpacity;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
- layer.textOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
- XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
- @"Setting textOpacity to a constant value expression should update text-opacity.");
- XCTAssertEqualObjects(layer.textOpacity, constantExpression,
- @"textOpacity should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"1"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- step(zoom(), literal(1.0), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
- @"Setting textOpacity to a camera expression should update text-opacity.");
- XCTAssertEqualObjects(layer.textOpacity, functionExpression,
- @"textOpacity should round-trip camera expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
- layer.textOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
- @"Setting textOpacity to a data expression should update text-opacity.");
- NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}];
- XCTAssertEqualObjects(layer.textOpacity, pedanticFunctionExpression,
- @"textOpacity should round-trip data expressions.");
-
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- layer.textOpacity = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<float>(
- interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
- @"Setting textOpacity to a camera-data expression should update text-opacity.");
- pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
- XCTAssertEqualObjects(layer.textOpacity, pedanticFunctionExpression,
- @"textOpacity should round-trip camera-data expressions.");
-
- layer.textOpacity = nil;
- XCTAssertTrue(rawLayer->getTextOpacity().isUndefined(),
- @"Unsetting textOpacity should return text-opacity to the default value.");
- XCTAssertEqualObjects(layer.textOpacity, defaultExpression,
- @"textOpacity should return the default value after being unset.");
- // Transition property test
- layer.textOpacityTransition = transitionTest;
- auto toptions = rawLayer->getTextOpacityTransition();
- XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay);
- XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration);
-
- MGLTransition textOpacityTransition = layer.textOpacityTransition;
- XCTAssertEqual(textOpacityTransition.delay, transitionTest.delay);
- XCTAssertEqual(textOpacityTransition.duration, transitionTest.duration);
- }
-
- // text-translate
- {
- XCTAssertTrue(rawLayer->getTextTranslate().isUndefined(),
- @"text-translate should be unset initially.");
- NSExpression *defaultExpression = layer.textTranslation;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@",
-#if TARGET_OS_IPHONE
- [NSValue valueWithCGVector:CGVectorMake(1, 1)]
-#else
- [NSValue valueWithMGLVector:CGVectorMake(1, -1)]
-#endif
- ];
- layer.textTranslation = constantExpression;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
- XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue,
- @"Setting textTranslation to a constant value expression should update text-translate.");
- XCTAssertEqualObjects(layer.textTranslation, constantExpression,
- @"textTranslation should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textTranslation = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<std::array<float, 2>>(
- step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue,
- @"Setting textTranslation to a camera expression should update text-translate.");
- XCTAssertEqualObjects(layer.textTranslation, functionExpression,
- @"textTranslation should round-trip camera expressions.");
-
-
- layer.textTranslation = nil;
- XCTAssertTrue(rawLayer->getTextTranslate().isUndefined(),
- @"Unsetting textTranslation should return text-translate to the default value.");
- XCTAssertEqualObjects(layer.textTranslation, defaultExpression,
- @"textTranslation should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-
- // text-translate-anchor
- {
- XCTAssertTrue(rawLayer->getTextTranslateAnchor().isUndefined(),
- @"text-translate-anchor should be unset initially.");
- NSExpression *defaultExpression = layer.textTranslationAnchor;
-
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- layer.textTranslationAnchor = constantExpression;
- mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
- XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue,
- @"Setting textTranslationAnchor to a constant value expression should update text-translate-anchor.");
- XCTAssertEqualObjects(layer.textTranslationAnchor, constantExpression,
- @"textTranslationAnchor should round-trip constant value expressions.");
-
- constantExpression = [NSExpression expressionWithFormat:@"'viewport'"];
- NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
- layer.textTranslationAnchor = functionExpression;
-
- {
- using namespace mbgl::style::expression::dsl;
- propertyValue = mbgl::style::PropertyExpression<mbgl::style::TranslateAnchorType>(
- step(zoom(), literal("viewport"), 18.0, literal("viewport"))
- );
- }
-
- XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue,
- @"Setting textTranslationAnchor to a camera expression should update text-translate-anchor.");
- XCTAssertEqualObjects(layer.textTranslationAnchor, functionExpression,
- @"textTranslationAnchor should round-trip camera expressions.");
-
-
- layer.textTranslationAnchor = nil;
- XCTAssertTrue(rawLayer->getTextTranslateAnchor().isUndefined(),
- @"Unsetting textTranslationAnchor should return text-translate-anchor to the default value.");
- XCTAssertEqualObjects(layer.textTranslationAnchor, defaultExpression,
- @"textTranslationAnchor should return the default value after being unset.");
-
- functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
- XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
- functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
- XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
- }
-}
-
-- (void)testPropertyNames {
- [self testPropertyName:@"icon-allows-overlap" isBoolean:YES];
- [self testPropertyName:@"icon-anchor" isBoolean:NO];
- [self testPropertyName:@"icon-ignores-placement" isBoolean:YES];
- [self testPropertyName:@"icon-image-name" isBoolean:NO];
- [self testPropertyName:@"icon-offset" isBoolean:NO];
- [self testPropertyName:@"is-icon-optional" isBoolean:YES];
- [self testPropertyName:@"icon-padding" isBoolean:NO];
- [self testPropertyName:@"icon-pitch-alignment" isBoolean:NO];
- [self testPropertyName:@"icon-rotation" isBoolean:NO];
- [self testPropertyName:@"icon-rotation-alignment" isBoolean:NO];
- [self testPropertyName:@"icon-scale" isBoolean:NO];
- [self testPropertyName:@"icon-text-fit" isBoolean:NO];
- [self testPropertyName:@"icon-text-fit-padding" isBoolean:NO];
- [self testPropertyName:@"keeps-icon-upright" isBoolean:YES];
- [self testPropertyName:@"keeps-text-upright" isBoolean:YES];
- [self testPropertyName:@"maximum-text-angle" isBoolean:NO];
- [self testPropertyName:@"maximum-text-width" isBoolean:NO];
- [self testPropertyName:@"symbol-avoids-edges" isBoolean:YES];
- [self testPropertyName:@"symbol-placement" isBoolean:NO];
- [self testPropertyName:@"symbol-sort-key" isBoolean:NO];
- [self testPropertyName:@"symbol-spacing" isBoolean:NO];
- [self testPropertyName:@"symbol-z-order" isBoolean:NO];
- [self testPropertyName:@"text" isBoolean:NO];
- [self testPropertyName:@"text-allows-overlap" isBoolean:YES];
- [self testPropertyName:@"text-anchor" isBoolean:NO];
- [self testPropertyName:@"text-font-names" isBoolean:NO];
- [self testPropertyName:@"text-font-size" isBoolean:NO];
- [self testPropertyName:@"text-ignores-placement" isBoolean:YES];
- [self testPropertyName:@"text-justification" isBoolean:NO];
- [self testPropertyName:@"text-letter-spacing" isBoolean:NO];
- [self testPropertyName:@"text-line-height" isBoolean:NO];
- [self testPropertyName:@"text-offset" isBoolean:NO];
- [self testPropertyName:@"is-text-optional" isBoolean:YES];
- [self testPropertyName:@"text-padding" isBoolean:NO];
- [self testPropertyName:@"text-pitch-alignment" isBoolean:NO];
- [self testPropertyName:@"text-radial-offset" isBoolean:NO];
- [self testPropertyName:@"text-rotation" isBoolean:NO];
- [self testPropertyName:@"text-rotation-alignment" isBoolean:NO];
- [self testPropertyName:@"text-transform" isBoolean:NO];
- [self testPropertyName:@"text-variable-anchor" isBoolean:NO];
- [self testPropertyName:@"text-writing-modes" isBoolean:NO];
- [self testPropertyName:@"icon-color" isBoolean:NO];
- [self testPropertyName:@"icon-halo-blur" isBoolean:NO];
- [self testPropertyName:@"icon-halo-color" isBoolean:NO];
- [self testPropertyName:@"icon-halo-width" isBoolean:NO];
- [self testPropertyName:@"icon-opacity" isBoolean:NO];
- [self testPropertyName:@"icon-translation" isBoolean:NO];
- [self testPropertyName:@"icon-translation-anchor" isBoolean:NO];
- [self testPropertyName:@"text-color" isBoolean:NO];
- [self testPropertyName:@"text-halo-blur" isBoolean:NO];
- [self testPropertyName:@"text-halo-color" isBoolean:NO];
- [self testPropertyName:@"text-halo-width" isBoolean:NO];
- [self testPropertyName:@"text-opacity" isBoolean:NO];
- [self testPropertyName:@"text-translation" isBoolean:NO];
- [self testPropertyName:@"text-translation-anchor" isBoolean:NO];
-}
-
-- (void)testValueAdditions {
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorCenter].MGLIconAnchorValue, MGLIconAnchorCenter);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorLeft].MGLIconAnchorValue, MGLIconAnchorLeft);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorRight].MGLIconAnchorValue, MGLIconAnchorRight);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTop].MGLIconAnchorValue, MGLIconAnchorTop);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottom].MGLIconAnchorValue, MGLIconAnchorBottom);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTopLeft].MGLIconAnchorValue, MGLIconAnchorTopLeft);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTopRight].MGLIconAnchorValue, MGLIconAnchorTopRight);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottomLeft].MGLIconAnchorValue, MGLIconAnchorBottomLeft);
- XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottomRight].MGLIconAnchorValue, MGLIconAnchorBottomRight);
- XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentMap].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentViewport].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentAuto].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentAuto);
- XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentMap].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentViewport].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentAuto].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentAuto);
- XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitNone].MGLIconTextFitValue, MGLIconTextFitNone);
- XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitWidth].MGLIconTextFitValue, MGLIconTextFitWidth);
- XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitHeight].MGLIconTextFitValue, MGLIconTextFitHeight);
- XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitBoth].MGLIconTextFitValue, MGLIconTextFitBoth);
- XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementPoint].MGLSymbolPlacementValue, MGLSymbolPlacementPoint);
- XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLine].MGLSymbolPlacementValue, MGLSymbolPlacementLine);
- XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLineCenter].MGLSymbolPlacementValue, MGLSymbolPlacementLineCenter);
- XCTAssertEqual([NSValue valueWithMGLSymbolZOrder:MGLSymbolZOrderAuto].MGLSymbolZOrderValue, MGLSymbolZOrderAuto);
- XCTAssertEqual([NSValue valueWithMGLSymbolZOrder:MGLSymbolZOrderViewportY].MGLSymbolZOrderValue, MGLSymbolZOrderViewportY);
- XCTAssertEqual([NSValue valueWithMGLSymbolZOrder:MGLSymbolZOrderSource].MGLSymbolZOrderValue, MGLSymbolZOrderSource);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorCenter].MGLTextAnchorValue, MGLTextAnchorCenter);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorLeft].MGLTextAnchorValue, MGLTextAnchorLeft);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorRight].MGLTextAnchorValue, MGLTextAnchorRight);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTop].MGLTextAnchorValue, MGLTextAnchorTop);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottom].MGLTextAnchorValue, MGLTextAnchorBottom);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTopLeft].MGLTextAnchorValue, MGLTextAnchorTopLeft);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTopRight].MGLTextAnchorValue, MGLTextAnchorTopRight);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomLeft].MGLTextAnchorValue, MGLTextAnchorBottomLeft);
- XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomRight].MGLTextAnchorValue, MGLTextAnchorBottomRight);
- XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationAuto].MGLTextJustificationValue, MGLTextJustificationAuto);
- XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationLeft].MGLTextJustificationValue, MGLTextJustificationLeft);
- XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationCenter].MGLTextJustificationValue, MGLTextJustificationCenter);
- XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationRight].MGLTextJustificationValue, MGLTextJustificationRight);
- XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentMap].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentViewport].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentAuto].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentAuto);
- XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentMap].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentMap);
- XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentViewport].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentViewport);
- XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentAuto].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentAuto);
- XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformNone].MGLTextTransformValue, MGLTextTransformNone);
- XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformUppercase].MGLTextTransformValue, MGLTextTransformUppercase);
- XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformLowercase].MGLTextTransformValue, MGLTextTransformLowercase);
- XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeHorizontal].MGLTextWritingModeValue, MGLTextWritingModeHorizontal);
- XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeVertical].MGLTextWritingModeValue, MGLTextWritingModeVertical);
- XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorMap].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorViewport].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorViewport);
- XCTAssertEqual([NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorMap].MGLTextTranslationAnchorValue, MGLTextTranslationAnchorMap);
- XCTAssertEqual([NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorViewport].MGLTextTranslationAnchorValue, MGLTextTranslationAnchorViewport);
-}
-
-@end
diff --git a/platform/darwin/test/MGLTestAssertionHandler.h b/platform/darwin/test/MGLTestAssertionHandler.h
deleted file mode 100644
index f1aa39921e..0000000000
--- a/platform/darwin/test/MGLTestAssertionHandler.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#import <Foundation/Foundation.h>
-#import <XCTest/XCTest.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-// Use to catch or log assertions that occur in dispatch blocks, timers or
-// other asynchronous operations.
-@interface MGLTestAssertionHandler : NSAssertionHandler
-
-- (instancetype)initWithTestCase:(XCTestCase *)testCase;
-@property (nonatomic, weak) XCTestCase *testCase;
-
-// If YES, use `_XCTPreformattedFailureHandler` to "fail" the test,
-// otherwise log the assert.
-@property (nonatomic) BOOL shouldFail;
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/test/MGLTestAssertionHandler.m b/platform/darwin/test/MGLTestAssertionHandler.m
deleted file mode 100644
index 4b504427b5..0000000000
--- a/platform/darwin/test/MGLTestAssertionHandler.m
+++ /dev/null
@@ -1,77 +0,0 @@
-#import "MGLTestAssertionHandler.h"
-
-@implementation MGLTestAssertionHandler
-
-- (instancetype)initWithTestCase:(XCTestCase *)testCase {
- if ((self = [super init])) {
- _testCase = testCase;
- }
- return self;
-}
-
-- (void)handleFailureInMethod:(SEL)selector
- object:(id)object
- file:(NSString *)fileName
- lineNumber:(NSInteger)line
- description:(NSString *)format, ...
-{
- va_list args;
- va_start(args, format);
- NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
- va_end(args);
-
- NSString *condition = [NSString stringWithFormat:
- @"`[%@ %@]`",
- object, NSStringFromSelector(selector)
- ];
-
- if (self.testCase && self.shouldFail) {
- _XCTPreformattedFailureHandler(self.testCase,
- YES,
- fileName,
- line,
- condition,
- description
- );
- }
- else {
- NSLog(@"Assertion Failure: %@:%lu: %@ - %@",
- fileName,
- line,
- condition,
- description);
- }
-}
-
-- (void)handleFailureInFunction:(NSString *)functionName
- file:(NSString *)fileName
- lineNumber:(NSInteger)line
- description:(NSString *)format, ...
-{
- va_list args;
- va_start(args, format);
- NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
- va_end(args);
-
- NSString *condition = [NSString stringWithFormat:
- @"`%@`",
- functionName];
-
- if (self.testCase && self.shouldFail) {
- _XCTPreformattedFailureHandler(self.testCase,
- YES,
- fileName,
- line,
- condition,
- description);
- }
- else {
- NSLog(@"Assertion Failure: %@:%lu: %@ - %@",
- fileName,
- line,
- condition,
- description);
- }
-}
-@end
-
diff --git a/platform/darwin/test/MGLTestUtility.h b/platform/darwin/test/MGLTestUtility.h
deleted file mode 100644
index 2e02e4f9de..0000000000
--- a/platform/darwin/test/MGLTestUtility.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-/**
- MGL_CHECK_IF_PENDING_TEST_SHOULD_RUN()
-
- Include this macro at the top of a "pending" test - one that would normally fail,
- but you want to include is as a compile-time test or as a reminder.
-
- This will output the included warning in the test log, which `xcpretty` will detect.
- This allows such pending tests to be identified in CI logs.
-
- If you provide `MAPBOX_RUN_PENDING_TESTS` as an environment variable ALL pending
- tests will run.
-
- In addition, it's a good idea to append `PENDING` to the test method name, as this
- will also be picked up by xcpretty. PENDING tests will be distinguished by a `⧖`
- and `[PENDING]`
- */
-#define MGL_CHECK_IF_PENDING_TEST_SHOULD_RUN() \
- /* By default, skip pending tests. Otherwise check environment for MAPBOX_RUN_PENDING_TESTS */ \
- { \
- NSString *runPendingTests = [[NSProcessInfo processInfo] environment][@"MAPBOX_RUN_PENDING_TESTS"]; \
- if (![runPendingTests boolValue]) { \
- /* The following warning will be picked up by xcpretty */ \
- printf("warning: '%s' is a pending test - skipping\n", __PRETTY_FUNCTION__); \
- return; \
- } \
- }
diff --git a/platform/darwin/test/MGLTileSetTests.mm b/platform/darwin/test/MGLTileSetTests.mm
deleted file mode 100644
index 65e096ae7f..0000000000
--- a/platform/darwin/test/MGLTileSetTests.mm
+++ /dev/null
@@ -1,149 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#import <Mapbox/Mapbox.h>
-#import "MGLTileSource_Private.h"
-#import "MGLGeometry_Private.h"
-
-#include <mbgl/util/tileset.hpp>
-
-@interface MGLTileSetTests : XCTestCase
-
-@end
-
-@implementation MGLTileSetTests
-
-- (void)testTileSetFromTileURLTemplates {
- // a tile set that provides an mbgl tile set
- NSArray *tileURLTemplates = @[@"tile.1", @"tile.2", @"tile.3"];
- mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, nil);
-
- // has the correct URL templates
- XCTAssertEqual(tileSet.tiles.size(), 3UL);
- XCTAssertEqual(tileSet.tiles[0], "tile.1");
- XCTAssertEqual(tileSet.tiles[1], "tile.2");
- XCTAssertEqual(tileSet.tiles[2], "tile.3");
-
- // has the default scheme
- XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::XYZ);
-
- // when the tile set has no min or max zoom level set
- // the mbgl object has default values for min and max zoom level
- XCTAssertEqual(tileSet.zoomRange.min, 0);
- XCTAssertEqual(tileSet.zoomRange.max, 22);
-
- // when the tile set has min and/or max zoom level set
- tileSet = MGLTileSetFromTileURLTemplates(@[@"tile.1"], @{
- MGLTileSourceOptionMinimumZoomLevel: @1,
- MGLTileSourceOptionMaximumZoomLevel: @2,
- });
-
- // the mbgl object reflects the set values for min and max zoom level
- XCTAssertEqual(tileSet.zoomRange.min, 1);
- XCTAssertEqual(tileSet.zoomRange.max, 2);
-
- // when the tile set has a bounds set
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(12, 34), CLLocationCoordinate2DMake(56, 78));
- tileSet = MGLTileSetFromTileURLTemplates(@[@"tile.1"], @{
- MGLTileSourceOptionCoordinateBounds: @(bounds),
- });
-
- // the mbgl object reflects the set values for the bounds
- XCTAssert(!!tileSet.bounds, @"The bounds are set after setting the bounds");
- if (tileSet.bounds) {
- MGLCoordinateBounds actual = MGLCoordinateBoundsFromLatLngBounds(*tileSet.bounds);
- XCTAssert(MGLCoordinateBoundsEqualToCoordinateBounds(bounds, actual), @"The bounds round-trip");
- }
-
- // when the tile set has an attribution
- NSString *attribution = @"my tileset © ©️🎈";
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionAttributionHTMLString: attribution,
- });
-
- // the attribution is reflected by the mbgl tileset
- XCTAssertEqual(tileSet.attribution, attribution.UTF8String);
-
- // when the tile set has attribution infos
- MGLAttributionInfo *mapboxInfo = [[MGLAttributionInfo alloc] initWithTitle:[[NSAttributedString alloc] initWithString:@"Mapbox"]
- URL:[NSURL URLWithString:@"https://www.mapbox.com/"]];
-#if TARGET_OS_IPHONE
- UIColor *redColor = [UIColor redColor];
-#else
- // CSS uses the sRGB color space. In macOS 10.12 Sierra and below,
- // -[NSColor redColor] is in the calibrated RGB space and has a slightly
- // different sRGB value than on iOS and macOS 10.13 High Sierra.
- NSColor *redColor = [NSColor colorWithSRGBRed:1 green:0 blue:0 alpha:1];
-#endif
- NSAttributedString *gl = [[NSAttributedString alloc] initWithString:@"GL" attributes:@{
- NSBackgroundColorAttributeName: redColor,
- }];
- MGLAttributionInfo *glInfo = [[MGLAttributionInfo alloc] initWithTitle:gl URL:nil];
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionAttributionInfos: @[mapboxInfo, glInfo],
- });
-
- // the attribution is reflected by the mbgl tileset
-#if TARGET_OS_IPHONE
- NSString *html;
- if (@available(iOS 13.0, *)) {
- // TODO: investigate visual impact
- // iOS 13 evidently changes font size from points to pixels
- html = (@"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00px\">"
- @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>"
- @"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00px; background-color: #ff0000\">GL</font>\n");
- } else {
- html = (@"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00pt\">"
- @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>"
- @"<font style=\"font-family: 'Helvetica'; font-weight: normal; font-style: normal; font-size: 12.00pt; background-color: #ff0000\">GL</font>\n");
- }
-#else
- NSString *html = (@"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica\">"
- @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>"
- @"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica; background-color: #ff0000\">GL</font>\n");
-#endif
- XCTAssertEqualObjects(@(tileSet.attribution.c_str()), html);
-
- // when the tile coordinate system is changed using an NSNumber
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionTileCoordinateSystem: @(MGLTileCoordinateSystemTMS),
- });
-
- // the scheme is reflected by the mbgl tileset
- XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::TMS);
-
- // when the tile coordinate system is changed using an NSValue
- MGLTileCoordinateSystem tms = MGLTileCoordinateSystemTMS;
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionTileCoordinateSystem: [NSValue value:&tms withObjCType:@encode(MGLTileCoordinateSystem)],
- });
-
- // the scheme is reflected by the mbgl tileset
- XCTAssertEqual(tileSet.scheme, mbgl::Tileset::Scheme::TMS);
-
- // when the dem encoding is changed using an NSNumber
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionDEMEncoding: @(MGLDEMEncodingTerrarium),
- });
-
- // the encoding is reflected by the mbgl tileset
- XCTAssertEqual(tileSet.encoding, mbgl::Tileset::DEMEncoding::Terrarium);
-
- // when the dem encoding is changed using an NSValue
- MGLDEMEncoding terrarium = MGLDEMEncodingTerrarium;
- tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{
- MGLTileSourceOptionDEMEncoding: [NSValue value:&terrarium withObjCType:@encode(MGLDEMEncoding)],
- });
-
- // the encoding is reflected by the mbgl tileset
- XCTAssertEqual(tileSet.encoding, mbgl::Tileset::DEMEncoding::Terrarium);
-}
-
-- (void)testInvalidTileSet {
- // a tile set that provides an mbgl tile set and invalid (crossed) minimum and maximum zoom levels throws an exception
- XCTAssertThrowsSpecificNamed(MGLTileSetFromTileURLTemplates(@[@"tile.1"], @{
- MGLTileSourceOptionMinimumZoomLevel: @10,
- MGLTileSourceOptionMaximumZoomLevel: @9,
- }), NSException, NSInvalidArgumentException);
-}
-
-@end
diff --git a/platform/darwin/test/MGLVersionNumber.m b/platform/darwin/test/MGLVersionNumber.m
deleted file mode 100644
index fae08a087d..0000000000
--- a/platform/darwin/test/MGLVersionNumber.m
+++ /dev/null
@@ -1,15 +0,0 @@
-#import <Mapbox/Mapbox.h>
-
-#import <XCTest/XCTest.h>
-
-@interface MGLVersionTests : XCTestCase
-
-@end
-
-@implementation MGLVersionTests
-
-- (void)testVersionNumber {
- XCTAssertEqual(1, MapboxVersionNumber);
-}
-
-@end
diff --git a/platform/darwin/test/Media.xcassets/Contents.json b/platform/darwin/test/Media.xcassets/Contents.json
deleted file mode 100644
index da4a164c91..0000000000
--- a/platform/darwin/test/Media.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-} \ No newline at end of file
diff --git a/platform/darwin/test/Media.xcassets/RadarImage.imageset/Contents.json b/platform/darwin/test/Media.xcassets/RadarImage.imageset/Contents.json
deleted file mode 100644
index 79be9ed970..0000000000
--- a/platform/darwin/test/Media.xcassets/RadarImage.imageset/Contents.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "universal",
- "filename" : "radar.png",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-} \ No newline at end of file
diff --git a/platform/darwin/test/Media.xcassets/RadarImage.imageset/radar.png b/platform/darwin/test/Media.xcassets/RadarImage.imageset/radar.png
deleted file mode 100644
index e23697f42a..0000000000
--- a/platform/darwin/test/Media.xcassets/RadarImage.imageset/radar.png
+++ /dev/null
Binary files differ
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json
deleted file mode 100644
index 08cd551fc7..0000000000
--- a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/Contents.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "universal",
- "filename" : "TrackingLocationMask.png",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "filename" : "TrackingLocationMask@2x.png",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "filename" : "TrackingLocationMask@3x.png",
- "scale" : "3x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- },
- "properties" : {
- "template-rendering-intent" : "template"
- }
-} \ No newline at end of file
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png
deleted file mode 100644
index bb7348c482..0000000000
--- a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask.png
+++ /dev/null
Binary files differ
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png
deleted file mode 100644
index 35c5a293ec..0000000000
--- a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@2x.png
+++ /dev/null
Binary files differ
diff --git a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png b/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png
deleted file mode 100644
index af523975a5..0000000000
--- a/platform/darwin/test/Media.xcassets/TrackingLocationMask.imageset/TrackingLocationMask@3x.png
+++ /dev/null
Binary files differ
diff --git a/platform/darwin/test/amsterdam.geojson b/platform/darwin/test/amsterdam.geojson
deleted file mode 100644
index a690f8c8aa..0000000000
--- a/platform/darwin/test/amsterdam.geojson
+++ /dev/null
@@ -1,2283 +0,0 @@
-{
- "type": "FeatureCollection",
- "features": [
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Westerpark",
- "type": "park",
- "description": "The \"Westerpark\" is a public urban park in Amsterdam, Netherlands. The former borough of Westerpark is named after the park, as is the current neighborhood. The verdant space of the former Westergasfabriek (gasworks) along Haarlemmerweg has become a place for cultural avant-garde businesses and events. The park is stretched along the railway, offering a biotope area to experience nature in the city. In addition Westerpark is home to one of the Netherlands’ oldest volkstuin (Gardenpark)."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.88093376159668,
- 52.38560608655206
- ],
- [
- 4.881706237792968,
- 52.3864966440161
- ],
- [
- 4.870891571044922,
- 52.388696767789725
- ],
- [
- 4.864625930786133,
- 52.38906344442449
- ],
- [
- 4.85072135925293,
- 52.389220590621235
- ],
- [
- 4.846086502075195,
- 52.38864438516467
- ],
- [
- 4.84522819519043,
- 52.38607756038855
- ],
- [
- 4.845314025878906,
- 52.38560608655206
- ],
- [
- 4.84745979309082,
- 52.38560608655206
- ],
- [
- 4.848232269287109,
- 52.38518699447024
- ],
- [
- 4.88093376159668,
- 52.38560608655206
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "vondelpark",
- "type": "park",
- "description": "Vondelpark has opened its gates since 1885 and is Amsterdam's busiest park, with 10 Million visitors per year, situated at the south-west corner of the canal ring. It is very popular in summer for both tourists and locals, and all year round as a training area for runners, with many bootcamps taking place all over the park."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.881491661071777,
- 52.36194735288177
- ],
- [
- 4.882135391235352,
- 52.361711487760196
- ],
- [
- 4.882307052612305,
- 52.361475621379526
- ],
- [
- 4.875826835632324,
- 52.35966727063089
- ],
- [
- 4.875226020812988,
- 52.35846166234964
- ],
- [
- 4.866771697998047,
- 52.356207610808546
- ],
- [
- 4.867458343505859,
- 52.355159175569305
- ],
- [
- 4.86668586730957,
- 52.35497569684526
- ],
- [
- 4.864239692687988,
- 52.35563097450493
- ],
- [
- 4.861965179443359,
- 52.35578823969753
- ],
- [
- 4.858918190002441,
- 52.35437283281734
- ],
- [
- 4.857029914855957,
- 52.35468737159704
- ],
- [
- 4.855892658233642,
- 52.354634948622525
- ],
- [
- 4.855034351348877,
- 52.356391084418235
- ],
- [
- 4.875226020812988,
- 52.36126596131745
- ],
- [
- 4.876556396484375,
- 52.360453519180375
- ],
- [
- 4.881491661071777,
- 52.36194735288177
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Jordaan",
- "type": "neighbourhood",
- "description": "The Jordan was originally a working-class neighbourhood, and has now become a more upscale neighborhood. It is home to many art galleries, particularly for modern art, and is also dotted with speciality shops and restaurants. Markets are held regularly at Noordermarkt, the Westerstraat and Lindengracht."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.888465404510498,
- 52.38053742479665
- ],
- [
- 4.883208274841309,
- 52.374865596670936
- ],
- [
- 4.882457256317139,
- 52.36667749309006
- ],
- [
- 4.882757663726807,
- 52.36619270976844
- ],
- [
- 4.879302978515624,
- 52.36490866337324
- ],
- [
- 4.874324798583984,
- 52.37186565170666
- ],
- [
- 4.8818135261535645,
- 52.38427021667093
- ],
- [
- 4.888465404510498,
- 52.38053742479665
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Prinseneiland",
- "type": "neighbourhood",
- "description": "Between 1610 and 1615 Prinseneiland was built as an extension of the harbor. Until the end of the 19th century this was an area with many wharfs, little industries and warehouses, related to the shipping trades. After the second World war the desolated area was discovered by many artists, who established their homes and studios in the vacant buildings. During the second half of the 20th century the old warehouses were transformed into apartments one after another, and new apartments were built. Nevertheless a lot of the atmosphere of the glorious past is still present in the old buildings and wooden drawbridges."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.883251190185547,
- 52.38618233166844
- ],
- [
- 4.889817237854004,
- 52.38264616355127
- ],
- [
- 4.896254539489746,
- 52.38356297507495
- ],
- [
- 4.891490936279297,
- 52.390425359543386
- ],
- [
- 4.884967803955078,
- 52.39068726147953
- ],
- [
- 4.883251190185547,
- 52.38618233166844
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Sarphatipark",
- "type": "park",
- "description": "Sarphatipark is a small park in the popular De Pijp neighbourhood. It was openend in late 19th century, and named after Samuel Sarphati."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.894580841064453,
- 52.35337022551748
- ],
- [
- 4.899033308029174,
- 52.354267986060016
- ],
- [
- 4.89815354347229,
- 52.35544094498385
- ],
- [
- 4.893786907196045,
- 52.35446457352601
- ],
- [
- 4.894580841064453,
- 52.35337022551748
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Museumsplein",
- "type": "area",
- "description": "Museumplein is a large open space which hosts different events throughout the year. Along the edges of the open square, some of the Dutch capitals most important art museums, such as Stedelijk Museum, Van Gogh Museum and Rijksmuseum."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.880322217941284,
- 52.35625347928239
- ],
- [
- 4.881459474563598,
- 52.35610932106146
- ],
- [
- 4.882693290710448,
- 52.356921843071525
- ],
- [
- 4.883508682250977,
- 52.357996446011384
- ],
- [
- 4.884324073791504,
- 52.35783263627572
- ],
- [
- 4.884721040725708,
- 52.35903498560687
- ],
- [
- 4.886341094970703,
- 52.35875651523955
- ],
- [
- 4.886770248413086,
- 52.36003418836164
- ],
- [
- 4.884881973266602,
- 52.36113492327348
- ],
- [
- 4.884538650512695,
- 52.36066318309746
- ],
- [
- 4.883229732513428,
- 52.36028971855292
- ],
- [
- 4.883841276168823,
- 52.35953622784582
- ],
- [
- 4.882038831710815,
- 52.35897929167382
- ],
- [
- 4.882339239120483,
- 52.35861236518361
- ],
- [
- 4.880794286727905,
- 52.35790471263422
- ],
- [
- 4.880847930908203,
- 52.357780217032044
- ],
- [
- 4.879699945449829,
- 52.35691529053445
- ],
- [
- 4.880322217941284,
- 52.35625347928239
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Marineterrein",
- "type": "area",
- "description": "The Marineterrein exists already for more than 350 years. The area lies on the island known as ‘Kattenburg’, in close vicinity to Centraal Station and Amsterdam’s Maritime Museum. During the Golden Age the VOC used this area to build large warships. After years of use through the Dutch marines, the area has now been opened for the public and workspaces are filled by tech startups."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.914064407348633,
- 52.37083068892153
- ],
- [
- 4.917154312133789,
- 52.37187875234601
- ],
- [
- 4.921102523803711,
- 52.37444640263532
- ],
- [
- 4.921188354492187,
- 52.37481319763409
- ],
- [
- 4.914150238037109,
- 52.37586116655898
- ],
- [
- 4.913034439086914,
- 52.374917995645625
- ],
- [
- 4.914493560791016,
- 52.37339840013861
- ],
- [
- 4.914064407348633,
- 52.37083068892153
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "erasmuspark"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.849905967712402,
- 52.37300539279099
- ],
- [
- 4.852695465087891,
- 52.37350320150736
- ],
- [
- 4.855098724365234,
- 52.37428920384616
- ],
- [
- 4.854240417480469,
- 52.3765423330248
- ],
- [
- 4.848318099975586,
- 52.37552057938607
- ],
- [
- 4.849905967712402,
- 52.37300539279099
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Sloterdijk",
- "type": "area",
- "description": "To protect the area around Sloten from the as-yet undrained IJ the Spaarndammerdijk was laid along the south bank of this inlet. In this vicinity at the same time, a dam on the Slochter (or Slooter) river was built, the Slooterdam. Trade grew in the vicinity, and in the 15th century a weigh house and a church were built. The area is nowadays best known as a large intersection of train lines and a business and industrial centre north-west of Amsterdam."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.8665571212768555,
- 52.39312287505632
- ],
- [
- 4.849648475646973,
- 52.400638383557414
- ],
- [
- 4.845571517944336,
- 52.39681532315127
- ],
- [
- 4.8445844650268555,
- 52.39411803332277
- ],
- [
- 4.844756126403809,
- 52.38911582655221
- ],
- [
- 4.85072135925293,
- 52.38935154535783
- ],
- [
- 4.871063232421875,
- 52.389299163509826
- ],
- [
- 4.8665571212768555,
- 52.39312287505632
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Nine Streets (Negen Straatjes)",
- "type": "poi",
- "description": "De Negen Straatjes (Dutch for \"the nine little streets\") are nine side streets of the Prinsengracht, Keizersgracht, Herengracht and Singel in central Amsterdam which have been promoting themselves with that name since the 1990s. Together they form a sub-neighborhood within the larger western Grachtengordel (\"Canal Belt\"), one with many small and diverse shops and restaurants. The construction in this area goes back to the first half of the 17th century."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.887650012969971,
- 52.368629674781644
- ],
- [
- 4.8884546756744385,
- 52.37242897568859
- ],
- [
- 4.883047342300415,
- 52.372664783594274
- ],
- [
- 4.882628917694092,
- 52.36839384533322
- ],
- [
- 4.887650012969971,
- 52.368629674781644
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Artis",
- "type": "poi",
- "description": "Artis, short for Natura Artis Magistra (Latin for \"Nature is the teacher of art and science\"), is a zoo in the centre of Amsterdam. It is the oldest zoo in the Netherlands and one of the oldest zoos of mainland Europe. Artis Royal Zoo is not just a zoo, it also contains an aquarium and a planetarium. Artis also has an arboretum and a fairly large art collection. A part of the art collection is on display in the Aquarium building of the zoo. Artis contains 27 monumental buildings, most of which are used as enclosures for the animals, making Artis a unique cultural heritage of the 19th century."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.911768436431885,
- 52.36642855096776
- ],
- [
- 4.913313388824463,
- 52.36802699702209
- ],
- [
- 4.916939735412598,
- 52.36679541255308
- ],
- [
- 4.9175190925598145,
- 52.3673456992188
- ],
- [
- 4.921274185180664,
- 52.366048583971256
- ],
- [
- 4.921660423278808,
- 52.36551138367574
- ],
- [
- 4.918656349182129,
- 52.36400456750192
- ],
- [
- 4.911768436431885,
- 52.36642855096776
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Oosterpark",
- "type": "park",
- "description": "Oosterpark was the first large park opened by the municipality of Amsterdam in 1891. The park was designed as an English garden by Dutch landscape architect Leonard Anthony Springer."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.915802478790282,
- 52.36062387118878
- ],
- [
- 4.9173688888549805,
- 52.35804231262857
- ],
- [
- 4.925351142883301,
- 52.36002108420944
- ],
- [
- 4.923892021179199,
- 52.36192114570822
- ],
- [
- 4.92213249206543,
- 52.36150182881734
- ],
- [
- 4.92161750793457,
- 52.36223563076494
- ],
- [
- 4.919493198394775,
- 52.36159355472725
- ],
- [
- 4.91987943649292,
- 52.36101698870163
- ],
- [
- 4.918956756591797,
- 52.360741806809884
- ],
- [
- 4.918656349182129,
- 52.36097767710775
- ],
- [
- 4.917240142822266,
- 52.36063697516221
- ],
- [
- 4.916982650756836,
- 52.360899053815025
- ],
- [
- 4.915802478790282,
- 52.36062387118878
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Park Frankendael",
- "type": "park",
- "description": "As Amsterdam rapidly grew in the sixteen and the beginning of eighteen century, the real estate in the city became so expensive, that rich people who wanted to enjoy a bigger property had to move further from the capital. The Park Frankendael (7 acres) in East Amsterdam, was originally one of these wealthy estates. The entrance to the park with an old ornamented gate is at the Middenweg, less than one mile (1300m) from the Tropenmuseum, driving out of the city. The beautiful old land house Frankendael (built in 1659) is visible from the street – it is one of the few of these estates remaining in Amsterdam"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.925265312194824,
- 52.35007391180776
- ],
- [
- 4.9283552169799805,
- 52.352079253210675
- ],
- [
- 4.930479526519775,
- 52.3535995821349
- ],
- [
- 4.93483543395996,
- 52.35080790353051
- ],
- [
- 4.929170608520508,
- 52.34772767795072
- ],
- [
- 4.925265312194824,
- 52.35007391180776
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Stedelijk Museum",
- "type": "poi",
- "description": "Colloquially known as the Stedelijk, it is a museum for modern art, contemporary art, and design. The 19th century building was designed by Adriaan Willem Weissman and the 21st century wing with the current entrance was designed by Benthem Crouwel Architects. The collection comprises art from the early 20th century up to the 21st century. "
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.879399538040161,
- 52.357400175655954
- ],
- [
- 4.88067626953125,
- 52.3577933218488
- ],
- [
- 4.880236387252808,
- 52.35841579616774
- ],
- [
- 4.8789381980896,
- 52.35808817919812
- ],
- [
- 4.879399538040161,
- 52.357400175655954
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Rembrandtpark",
- "type": "park",
- "description": "Rembrandtpark is a hidden gem west of the 'famous' Vondelpark. It is often not known to tourists and expats, but loved by locals for the outdoor gym and kids' playgrounds. It's great to combine both, Vondelpark and Rembrandtpark on a run or walk."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.845314025878906,
- 52.369179938598464
- ],
- [
- 4.84522819519043,
- 52.36763394187947
- ],
- [
- 4.843039512634277,
- 52.36755533043126
- ],
- [
- 4.8429107666015625,
- 52.36490866337324
- ],
- [
- 4.8442840576171875,
- 52.36456799173892
- ],
- [
- 4.84419822692871,
- 52.36323148534417
- ],
- [
- 4.843082427978516,
- 52.36302183361385
- ],
- [
- 4.843254089355469,
- 52.36019143788499
- ],
- [
- 4.844799041748047,
- 52.36027006243683
- ],
- [
- 4.8451852798461905,
- 52.35924793235075
- ],
- [
- 4.843854904174805,
- 52.35888100809126
- ],
- [
- 4.844112396240234,
- 52.35822577862119
- ],
- [
- 4.848747253417969,
- 52.35825198798652
- ],
- [
- 4.8487043380737305,
- 52.36079422254044
- ],
- [
- 4.849519729614258,
- 52.361292168879636
- ],
- [
- 4.849262237548828,
- 52.363572167284175
- ],
- [
- 4.850249290466309,
- 52.3637031981001
- ],
- [
- 4.850249290466309,
- 52.36540656334422
- ],
- [
- 4.8484039306640625,
- 52.369546777334904
- ],
- [
- 4.845314025878906,
- 52.369179938598464
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Sloterpark",
- "type": "park",
- "description": "Amsterdam's largest park is Sloter Park with 91 hectares. It was created in the 1950s using excavated soil of the former Sloterdijkermeer Polder."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.823555946350098,
- 52.3639652585661
- ],
- [
- 4.826860427856445,
- 52.36414869996741
- ],
- [
- 4.826817512512207,
- 52.36585204803552
- ],
- [
- 4.830508232116699,
- 52.370280445668364
- ],
- [
- 4.826602935791016,
- 52.373031593389626
- ],
- [
- 4.822740554809569,
- 52.37360800262741
- ],
- [
- 4.821324348449707,
- 52.37235037277361
- ],
- [
- 4.819135665893555,
- 52.371695343041914
- ],
- [
- 4.81201171875,
- 52.37187875234601
- ],
- [
- 4.807548522949219,
- 52.372402774732464
- ],
- [
- 4.805660247802734,
- 52.37046386084771
- ],
- [
- 4.80926513671875,
- 52.36349354860812
- ],
- [
- 4.8105525970458975,
- 52.36328389812132
- ],
- [
- 4.8113250732421875,
- 52.36150182881734
- ],
- [
- 4.807033538818359,
- 52.360899053815025
- ],
- [
- 4.809608459472655,
- 52.35654834690599
- ],
- [
- 4.815659523010254,
- 52.3577540073869
- ],
- [
- 4.818663597106934,
- 52.357963684112846
- ],
- [
- 4.818620681762695,
- 52.359483810623004
- ],
- [
- 4.823555946350098,
- 52.3639652585661
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amsterdamse Bos",
- "type": "park",
- "description": "Every year almost 4.5 million people visit the Amsterdamse Bos, which has a size of 1,000 hectares and is approximately three times the size of New York's Central Park. The park was designed as a landscape park and is great for running, walking and cycling."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.849991798400879,
- 52.33090717211467
- ],
- [
- 4.849863052368164,
- 52.331746382485676
- ],
- [
- 4.853982925415039,
- 52.33187750766789
- ],
- [
- 4.853467941284179,
- 52.332323330379836
- ],
- [
- 4.848232269287109,
- 52.33258557693488
- ],
- [
- 4.848318099975586,
- 52.33321496232317
- ],
- [
- 4.8319244384765625,
- 52.33145790571652
- ],
- [
- 4.8181915283203125,
- 52.330828495326095
- ],
- [
- 4.820079803466797,
- 52.32327487205222
- ],
- [
- 4.816474914550781,
- 52.31299147898779
- ],
- [
- 4.813899993896484,
- 52.30879348896445
- ],
- [
- 4.809093475341796,
- 52.30585465906291
- ],
- [
- 4.824028015136719,
- 52.29000260620264
- ],
- [
- 4.832954406738281,
- 52.29441235610253
- ],
- [
- 4.8427391052246085,
- 52.29220753602784
- ],
- [
- 4.844627380371094,
- 52.30060626328963
- ],
- [
- 4.842395782470703,
- 52.30396530825102
- ],
- [
- 4.842395782470703,
- 52.30407027430016
- ],
- [
- 4.839649200439453,
- 52.30504119845803
- ],
- [
- 4.841108322143555,
- 52.30732409839935
- ],
- [
- 4.840335845947266,
- 52.31708413595253
- ],
- [
- 4.848575592041015,
- 52.317189070898415
- ],
- [
- 4.8558712005615225,
- 52.31645452105213
- ],
- [
- 4.8566436767578125,
- 52.323484712336324
- ],
- [
- 4.856557846069336,
- 52.32757639896581
- ],
- [
- 4.855785369873047,
- 52.33085472093785
- ],
- [
- 4.849991798400879,
- 52.33090717211467
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amstelpark",
- "type": "park",
- "description": "The Amstelpark is a park in Amsterdam-Zuid. The park includes a labyrinth, a café, a restaurant, two galleries, an orangery, petting zoo and a mini-golf course. The Amstelpark was built and opened for the 1972 Floriade gardening exhibition. The park offers the Amstel train which runs through the Rosarium, the rhododendron valley and the Riekermolen. The park lost about 30 percent of its larger trees due to disease. The rhododendron valley contains about 139 species of rhododendrons, blooming between April and May. At the Great Pond in the park is the Japanese Garden. At the time of the celebration of the 400-year relationship between the Netherlands and Japan in 2001, the gardens were renovated."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.892907142639159,
- 52.32445521070514
- ],
- [
- 4.891705513000488,
- 52.325110940795255
- ],
- [
- 4.890632629394531,
- 52.32513716979672
- ],
- [
- 4.89041805267334,
- 52.3336869954871
- ],
- [
- 4.892778396606445,
- 52.33373944330546
- ],
- [
- 4.894108772277832,
- 52.333949233956965
- ],
- [
- 4.897370338439941,
- 52.33255935234935
- ],
- [
- 4.897799491882323,
- 52.33085472093785
- ],
- [
- 4.897327423095702,
- 52.32907134391899
- ],
- [
- 4.895954132080078,
- 52.32734035040776
- ],
- [
- 4.894537925720215,
- 52.32458635750065
- ],
- [
- 4.892907142639159,
- 52.32445521070514
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Martin Luther Kingpark",
- "type": "park",
- "description": "Martin Luther Kingpark is part of the Rivierenbuurt and has been renamed from Amstelpark, after the new Amstelpark in Buitenveldert was created. The park hosts the famous theater festival Parade every year in summer since the 1990s. "
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.906554222106933,
- 52.33813172737753
- ],
- [
- 4.906167984008789,
- 52.33685997655858
- ],
- [
- 4.90389347076416,
- 52.33743685775091
- ],
- [
- 4.901747703552246,
- 52.33821039117558
- ],
- [
- 4.901790618896484,
- 52.3400982803501
- ],
- [
- 4.90689754486084,
- 52.34004584007248
- ],
- [
- 4.905717372894287,
- 52.33836771835187
- ],
- [
- 4.906554222106933,
- 52.33813172737753
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Beatrixpark",
- "type": "park",
- "description": "Beatrixpark, named after Queen Beatrix is located in the borough of Amsterdam-Zuid."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.87818717956543,
- 52.34435884510934
- ],
- [
- 4.88093376159668,
- 52.34582700615622
- ],
- [
- 4.882993698120117,
- 52.34456858538671
- ],
- [
- 4.8854827880859375,
- 52.34435884510934
- ],
- [
- 4.884710311889648,
- 52.33984918847747
- ],
- [
- 4.882392883300781,
- 52.33995406943698
- ],
- [
- 4.879045486450195,
- 52.33984918847747
- ],
- [
- 4.878787994384765,
- 52.340688229188224
- ],
- [
- 4.881620407104492,
- 52.34074066870404
- ],
- [
- 4.881706237792968,
- 52.341789445960536
- ],
- [
- 4.878444671630859,
- 52.341789445960536
- ],
- [
- 4.87818717956543,
- 52.34435884510934
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Park de Schinkeleilanden",
- "type": "Park",
- "description": "This park was built between 2005 and 2010 and is popular for the neighborhoods surrounding the Schinkel waterway. It's allowed to BBQ here, and it's a popular spot for running and hiking."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.851171970367432,
- 52.34405734171741
- ],
- [
- 4.851021766662597,
- 52.34514536601911
- ],
- [
- 4.851686954498291,
- 52.34628579648493
- ],
- [
- 4.851021766662597,
- 52.3465610683968
- ],
- [
- 4.848833084106445,
- 52.342785761313266
- ],
- [
- 4.849659204483032,
- 52.340747223639156
- ],
- [
- 4.852405786514282,
- 52.34110774357341
- ],
- [
- 4.852041006088257,
- 52.34196642466951
- ],
- [
- 4.852041006088257,
- 52.341979534175316
- ],
- [
- 4.851665496826172,
- 52.34280870252078
- ],
- [
- 4.851171970367432,
- 52.34405734171741
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Schiphol",
- "type": "area",
- "description": "Schiphol is the main international airport of the Netherlands. Schiphol Airport is an important European airport, ranking as Europe's fifth busiest and the world's fourteenth busiest by total passenger traffic in 2015. It also ranks as the world's fifth busiest by international passenger traffic. The entire airport is below sea level; the lowest point sits at 3.4 m (11 ft) below sea level."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.729099273681641,
- 52.28811257899827
- ],
- [
- 4.734764099121094,
- 52.28559241729168
- ],
- [
- 4.762744903564453,
- 52.292522517043615
- ],
- [
- 4.776134490966797,
- 52.284857343123655
- ],
- [
- 4.7907257080078125,
- 52.293992398835414
- ],
- [
- 4.793128967285156,
- 52.30081621106509
- ],
- [
- 4.803943634033203,
- 52.30564473517634
- ],
- [
- 4.810981750488281,
- 52.311942018805624
- ],
- [
- 4.796905517578125,
- 52.319707434957024
- ],
- [
- 4.788494110107422,
- 52.320966563244205
- ],
- [
- 4.779567718505859,
- 52.32442898129939
- ],
- [
- 4.77081298828125,
- 52.3191827875965
- ],
- [
- 4.756736755371094,
- 52.31886799619451
- ],
- [
- 4.750041961669922,
- 52.310367781878
- ],
- [
- 4.7454071044921875,
- 52.30281066528705
- ],
- [
- 4.7426605224609375,
- 52.29798183210937
- ],
- [
- 4.729099273681641,
- 52.28811257899827
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Noorderpark",
- "type": "park",
- "description": "The Noorderpark is a park just 5 minutes north of the ferry that crosses the IJ canal behind Amsterdam Central Station. It came to exist in 2014 after combining Florapark and Volewijkspark."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.921703338623047,
- 52.39046464493288
- ],
- [
- 4.921939373016357,
- 52.389652739777624
- ],
- [
- 4.92436408996582,
- 52.39068726147955
- ],
- [
- 4.924213886260986,
- 52.390922971893374
- ],
- [
- 4.92460012435913,
- 52.39105392157937
- ],
- [
- 4.923999309539795,
- 52.39326691251008
- ],
- [
- 4.924793243408203,
- 52.39486438729677
- ],
- [
- 4.922282695770264,
- 52.39698553494043
- ],
- [
- 4.919922351837158,
- 52.39847813327716
- ],
- [
- 4.917948246002197,
- 52.397705654476155
- ],
- [
- 4.918398857116699,
- 52.39618684316538
- ],
- [
- 4.917948246002197,
- 52.39527029380819
- ],
- [
- 4.917197227478027,
- 52.39200984251752
- ],
- [
- 4.9161458015441895,
- 52.39068726147955
- ],
- [
- 4.918420314788818,
- 52.389901551009025
- ],
- [
- 4.920244216918945,
- 52.39115868104846
- ],
- [
- 4.921402931213379,
- 52.39157771643836
- ],
- [
- 4.922153949737548,
- 52.39121106068977
- ],
- [
- 4.921703338623047,
- 52.39046464493288
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Vliegenbos",
- "type": "park",
- "description": "The Vliegenbos is the oldest city forest in Amsterdam. Here you've got plenty of space to run or cycle through a dense forest. It also hosts a camping ground, and is an amazingly well located starting point for excursions to the fishing villages along the IJsselmeer. "
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.925222396850586,
- 52.389403927143704
- ],
- [
- 4.925136566162109,
- 52.39003250372539
- ],
- [
- 4.926724433898926,
- 52.39105392157937
- ],
- [
- 4.933032989501953,
- 52.391525337232174
- ],
- [
- 4.93311882019043,
- 52.390739641680284
- ],
- [
- 4.938998222351074,
- 52.38969202585476
- ],
- [
- 4.9376678466796875,
- 52.38686333892666
- ],
- [
- 4.927024841308593,
- 52.38906344442449
- ],
- [
- 4.926466941833496,
- 52.38948249970591
- ],
- [
- 4.9253082275390625,
- 52.38945630886739
- ],
- [
- 4.925222396850586,
- 52.389403927143704
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Flevopark",
- "type": "park",
- "description": "Flevopark is the jewel in the East of Amsterdam. Its offerings include an outdoor swimming pool, several lakes, restaurants. It's awesome for a bbq in summer or a foggy walk or run on a winter morning."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.948225021362305,
- 52.36493486877479
- ],
- [
- 4.9527740478515625,
- 52.36517071668903
- ],
- [
- 4.954404830932617,
- 52.36517071668903
- ],
- [
- 4.955005645751953,
- 52.36459419734253
- ],
- [
- 4.952559471130371,
- 52.36215700971062
- ],
- [
- 4.952859878540038,
- 52.35953622784585
- ],
- [
- 4.952731132507324,
- 52.35809473156134
- ],
- [
- 4.944963455200195,
- 52.35859270832139
- ],
- [
- 4.946165084838867,
- 52.362314251679365
- ],
- [
- 4.947195053100586,
- 52.362602527168704
- ],
- [
- 4.947667121887207,
- 52.36417490581972
- ],
- [
- 4.948225021362305,
- 52.36493486877479
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amsterdam Centraal",
- "type": "station",
- "description": "Amsterdam's Central Station."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.896576404571533,
- 52.37985631995486
- ],
- [
- 4.89715576171875,
- 52.38066840529253
- ],
- [
- 4.90389347076416,
- 52.37820590695898
- ],
- [
- 4.902949333190918,
- 52.37738067732881
- ],
- [
- 4.896576404571533,
- 52.37985631995486
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amsterdam Amstel",
- "type": "station",
- "description": "Amsterdam Amstel is a trainstation in the South East, close to the river Amstel."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.916896820068359,
- 52.3468101224592
- ],
- [
- 4.917690753936768,
- 52.34704606711881
- ],
- [
- 4.918248653411864,
- 52.34604984776767
- ],
- [
- 4.9173903465271,
- 52.34584011451739
- ],
- [
- 4.916896820068359,
- 52.3468101224592
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Ouderkerk",
- "type": "poi",
- "description": "Ouderkerk aan de Amstel is a picturesque village in the Dutch province of North Holland. It lies about 9 km south of Amsterdam. The town is a popular destination for Amsterdammers on the weekends. The town is the location of the Beth Haim of Ouderkerk aan de Amstel, the oldest Jewish cemetery in the Netherlands."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.922518730163574,
- 52.29236502681571
- ],
- [
- 4.922819137573242,
- 52.28777131549237
- ],
- [
- 4.90788459777832,
- 52.29034385252062
- ],
- [
- 4.892692565917969,
- 52.29456983905114
- ],
- [
- 4.898228645324707,
- 52.29824428222637
- ],
- [
- 4.902563095092773,
- 52.299267822821434
- ],
- [
- 4.908742904663086,
- 52.29879542240944
- ],
- [
- 4.916167259216309,
- 52.30149853446092
- ],
- [
- 4.920544624328613,
- 52.29666955819423
- ],
- [
- 4.922518730163574,
- 52.29236502681571
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "NDSM terrein",
- "type": "poi",
- "description": "The former NDSM Amsterdam ship wharf is a stunning hangout. Just 10 minutes by free ferry and a large area is there to explore. Restaurants, bars, terraces, skatepark, new and old architecture, all with the amazing view on the IJ-waters. Many of the old buildings that were in use for the making of large ships are still there, housing creative enterprises."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.890182018280029,
- 52.401711923144106
- ],
- [
- 4.894495010375977,
- 52.40307344797437
- ],
- [
- 4.899129867553711,
- 52.400939500955296
- ],
- [
- 4.896554946899414,
- 52.39881854337136
- ],
- [
- 4.8909544944763175,
- 52.39813772055684
- ],
- [
- 4.891490936279297,
- 52.400847856747404
- ],
- [
- 4.890182018280029,
- 52.401711923144106
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amsterdam Zuid",
- "type": "station",
- "description": "Station Amsterdam Zuid"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.8720502853393555,
- 52.33950832364112
- ],
- [
- 4.874711036682129,
- 52.33969186657182
- ],
- [
- 4.8749041557312,
- 52.338459492279576
- ],
- [
- 4.872071743011475,
- 52.33835460777523
- ],
- [
- 4.8720502853393555,
- 52.33950832364112
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Het Twiske",
- "type": "park",
- "description": "Het Twiske recreational area lies to the north of Amsterdam between Zaanstad and Purmerend. It’s the ideal place for a day out on your bicycle, as Amsterdam’s bike paths connect directly to the paths in Het Twiske."
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.888744354248047,
- 52.43555429631541
- ],
- [
- 4.900503158569336,
- 52.43445541622349
- ],
- [
- 4.910116195678711,
- 52.43586825702301
- ],
- [
- 4.910888671875,
- 52.442199320554714
- ],
- [
- 4.907197952270508,
- 52.44852947442261
- ],
- [
- 4.90565299987793,
- 52.449941863962756
- ],
- [
- 4.905910491943359,
- 52.45135420821245
- ],
- [
- 4.903764724731445,
- 52.4549633266463
- ],
- [
- 4.903507232666016,
- 52.45846754991504
- ],
- [
- 4.904794692993164,
- 52.461866903001194
- ],
- [
- 4.906854629516602,
- 52.46489995032684
- ],
- [
- 4.906940460205078,
- 52.465736616263186
- ],
- [
- 4.9031639099121085,
- 52.4673576112622
- ],
- [
- 4.896640777587891,
- 52.468560246396606
- ],
- [
- 4.895782470703125,
- 52.46793278868704
- ],
- [
- 4.892778396606445,
- 52.465422868400594
- ],
- [
- 4.890289306640625,
- 52.46416785458775
- ],
- [
- 4.882049560546875,
- 52.46191919869101
- ],
- [
- 4.876041412353516,
- 52.45982732264483
- ],
- [
- 4.87492561340332,
- 52.45825835038316
- ],
- [
- 4.873895645141601,
- 52.45648011423114
- ],
- [
- 4.873037338256836,
- 52.454911022694276
- ],
- [
- 4.873552322387695,
- 52.452714200611055
- ],
- [
- 4.874839782714844,
- 52.44805866784458
- ],
- [
- 4.879388809204102,
- 52.44277482667677
- ],
- [
- 4.883165359497069,
- 52.43926935464697
- ],
- [
- 4.887542724609374,
- 52.43597291009513
- ],
- [
- 4.888744354248047,
- 52.43555429631541
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Diemerpark",
- "type": "park"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.974660873413086,
- 52.35694150067703
- ],
- [
- 4.980497360229492,
- 52.357989893633615
- ],
- [
- 4.985218048095703,
- 52.35827819733633
- ],
- [
- 4.986248016357422,
- 52.35720360124792
- ],
- [
- 4.985218048095703,
- 52.355971715048284
- ],
- [
- 4.985218048095703,
- 52.3552640202125
- ],
- [
- 4.986376762390137,
- 52.3545563140442
- ],
- [
- 4.987921714782714,
- 52.353901020450564
- ],
- [
- 4.988865852355957,
- 52.353901020450564
- ],
- [
- 4.989681243896484,
- 52.353219504806525
- ],
- [
- 4.991183280944824,
- 52.352642829515084
- ],
- [
- 4.992728233337402,
- 52.35169916280845
- ],
- [
- 4.994831085205078,
- 52.34996905485244
- ],
- [
- 4.995818138122559,
- 52.34991662628147
- ],
- [
- 4.997320175170898,
- 52.348763181988105
- ],
- [
- 4.997320175170898,
- 52.348081587122245
- ],
- [
- 4.99852180480957,
- 52.34658728467996
- ],
- [
- 4.999551773071289,
- 52.34535510256526
- ],
- [
- 4.999337196350098,
- 52.345197800248926
- ],
- [
- 4.976506233215332,
- 52.35573581802885
- ],
- [
- 4.974660873413086,
- 52.35694150067703
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Amstelfeld",
- "type": "poi"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.897080659866332,
- 52.36253045847271
- ],
- [
- 4.8978424072265625,
- 52.36269425079362
- ],
- [
- 4.89815354347229,
- 52.362137354425165
- ],
- [
- 4.896329641342163,
- 52.36185562770631
- ],
- [
- 4.896275997161865,
- 52.36240597590272
- ],
- [
- 4.897080659866332,
- 52.36253045847271
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Albert Cuyp Markt",
- "type": "poi"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.890514612197876,
- 52.35491672137934
- ],
- [
- 4.894967079162598,
- 52.35580134510498
- ],
- [
- 4.896436929702759,
- 52.356168294935955
- ],
- [
- 4.899580478668213,
- 52.3570725511568
- ],
- [
- 4.899430274963379,
- 52.35731499351983
- ],
- [
- 4.897252321243286,
- 52.356587662440496
- ],
- [
- 4.895503520965576,
- 52.356076557763856
- ],
- [
- 4.893561601638794,
- 52.355683396297984
- ],
- [
- 4.8904502391815186,
- 52.35510020034824
- ],
- [
- 4.890514612197876,
- 52.35491672137934
- ]
- ]
- ]
- }
- },
- {
- "type": "Feature",
- "properties": {
- "stroke": "#555555",
- "stroke-width": 2,
- "stroke-opacity": 1,
- "fill": "#555555",
- "fill-opacity": 0.5,
- "name": "Noordermarkt",
- "type": "poi"
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": [
- [
- [
- 4.885987043380737,
- 52.37978100483205
- ],
- [
- 4.886265993118286,
- 52.37907041669766
- ],
- [
- 4.886485934257507,
- 52.37900819875896
- ],
- [
- 4.886732697486877,
- 52.37907041669766
- ],
- [
- 4.887698292732239,
- 52.38007244089837
- ],
- [
- 4.885987043380737,
- 52.37978100483205
- ]
- ]
- ]
- }
- }
- ]
-}
diff --git a/platform/darwin/test/one-liner.json b/platform/darwin/test/one-liner.json
deleted file mode 100644
index 23c546181f..0000000000
--- a/platform/darwin/test/one-liner.json
+++ /dev/null
@@ -1 +0,0 @@
-{"version":8,"sources":{},"layers":[]} \ No newline at end of file
diff --git a/platform/darwin/test/test-Bridging-Header.h b/platform/darwin/test/test-Bridging-Header.h
deleted file mode 100644
index 1b2cb5d6d0..0000000000
--- a/platform/darwin/test/test-Bridging-Header.h
+++ /dev/null
@@ -1,4 +0,0 @@
-//
-// Use this file to import your target's public headers that you would like to expose to Swift.
-//
-