summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLSymbolStyleLayerTests.mm
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-01-04 07:35:25 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-02 09:44:42 -0800
commit22b3834caa5fe3ae91cf957124a3f1ad1d165cee (patch)
tree95439ccd498c414acfec70dc41b94ab9591f18c8 /platform/darwin/test/MGLSymbolStyleLayerTests.mm
parentf562ecdfc3a08f7b9b0c2be938f237852a82d374 (diff)
downloadqtlocation-mapboxgl-22b3834caa5fe3ae91cf957124a3f1ad1d165cee.tar.gz
[ios, macos] Add support for data-driven property functions
Diffstat (limited to 'platform/darwin/test/MGLSymbolStyleLayerTests.mm')
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.mm1528
1 files changed, 853 insertions, 675 deletions
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
index 202cbe4e9d..badd62e709 100644
--- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm
+++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
@@ -1,5 +1,5 @@
// This file is generated.
-// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
#import "MGLStyleLayerTests.h"
@@ -49,32 +49,38 @@
@"icon-allow-overlap should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconAllowsOverlap;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.iconAllowsOverlap = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.iconAllowsOverlap = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue,
@"Setting iconAllowsOverlap to a constant value should update icon-allow-overlap.");
- XCTAssertEqualObjects(layer.iconAllowsOverlap, styleValue,
+ XCTAssertEqualObjects(layer.iconAllowsOverlap, constantStyleValue,
@"iconAllowsOverlap should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconAllowsOverlap = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconAllowsOverlap = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue,
- @"Setting iconAllowsOverlap to a function should update icon-allow-overlap.");
- XCTAssertEqualObjects(layer.iconAllowsOverlap, styleValue,
- @"iconAllowsOverlap should round-trip functions.");
+ @"Setting iconAllowsOverlap to a camera function should update icon-allow-overlap.");
+ XCTAssertEqualObjects(layer.iconAllowsOverlap, functionStyleValue,
+ @"iconAllowsOverlap should round-trip camera functions.");
+
+
layer.iconAllowsOverlap = nil;
XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(),
@"Unsetting iconAllowsOverlap should return icon-allow-overlap to the default value.");
XCTAssertEqualObjects(layer.iconAllowsOverlap, defaultStyleValue,
@"iconAllowsOverlap should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-ignore-placement
@@ -83,32 +89,38 @@
@"icon-ignore-placement should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconIgnoresPlacement;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.iconIgnoresPlacement = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.iconIgnoresPlacement = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue,
@"Setting iconIgnoresPlacement to a constant value should update icon-ignore-placement.");
- XCTAssertEqualObjects(layer.iconIgnoresPlacement, styleValue,
+ XCTAssertEqualObjects(layer.iconIgnoresPlacement, constantStyleValue,
@"iconIgnoresPlacement should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconIgnoresPlacement = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconIgnoresPlacement = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue,
- @"Setting iconIgnoresPlacement to a function should update icon-ignore-placement.");
- XCTAssertEqualObjects(layer.iconIgnoresPlacement, styleValue,
- @"iconIgnoresPlacement should round-trip functions.");
+ @"Setting iconIgnoresPlacement to a camera function should update icon-ignore-placement.");
+ XCTAssertEqualObjects(layer.iconIgnoresPlacement, functionStyleValue,
+ @"iconIgnoresPlacement should round-trip camera functions.");
+
+
layer.iconIgnoresPlacement = nil;
XCTAssertTrue(rawLayer->getIconIgnorePlacement().isUndefined(),
@"Unsetting iconIgnoresPlacement should return icon-ignore-placement to the default value.");
XCTAssertEqualObjects(layer.iconIgnoresPlacement, defaultStyleValue,
@"iconIgnoresPlacement should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-image
@@ -117,32 +129,38 @@
@"icon-image should be unset initially.");
MGLStyleValue<NSString *> *defaultStyleValue = layer.iconImageName;
- MGLStyleValue<NSString *> *styleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Icon Image"];
- layer.iconImageName = styleValue;
+ MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Icon Image"];
+ layer.iconImageName = constantStyleValue;
mbgl::style::PropertyValue<std::string> propertyValue = { "Icon Image" };
XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
@"Setting iconImageName to a constant value should update icon-image.");
- XCTAssertEqualObjects(layer.iconImageName, styleValue,
+ XCTAssertEqualObjects(layer.iconImageName, constantStyleValue,
@"iconImageName should round-trip constant values.");
- styleValue = [MGLStyleValue<NSString *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconImageName = styleValue;
- propertyValue = { mbgl::style::Function<std::string> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSString *> * functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconImageName = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::string> intervalStops = { {{18, "Icon Image"}} };
+ propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconImage(), propertyValue,
- @"Setting iconImageName to a function should update icon-image.");
- XCTAssertEqualObjects(layer.iconImageName, styleValue,
- @"iconImageName should round-trip functions.");
+ @"Setting iconImageName to a camera function should update icon-image.");
+ XCTAssertEqualObjects(layer.iconImageName, functionStyleValue,
+ @"iconImageName should round-trip camera functions.");
+
+
layer.iconImageName = nil;
XCTAssertTrue(rawLayer->getIconImage().isUndefined(),
@"Unsetting iconImageName should return icon-image to the default value.");
XCTAssertEqualObjects(layer.iconImageName, defaultStyleValue,
@"iconImageName should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconImageName = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconImageName = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-offset
@@ -151,32 +169,55 @@
@"icon-offset should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconOffset;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
#if TARGET_OS_IPHONE
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
#else
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
#endif
];
- layer.iconOffset = styleValue;
- mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
+ layer.iconOffset = constantStyleValue;
+ mbgl::style::DataDrivenPropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
@"Setting iconOffset to a constant value should update icon-offset.");
- XCTAssertEqualObjects(layer.iconOffset, styleValue,
+ XCTAssertEqualObjects(layer.iconOffset, constantStyleValue,
@"iconOffset should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconOffset = styleValue;
- propertyValue = { mbgl::style::Function<std::array<float, 2>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconOffset = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
+
+ XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
+ @"Setting iconOffset to a camera function should update icon-offset.");
+ XCTAssertEqualObjects(layer.iconOffset, functionStyleValue,
+ @"iconOffset should round-trip camera functions.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
+ layer.iconOffset = functionStyleValue;
+
+ mbgl::style::ExponentialStops<std::array<float, 2>> exponentialStops = { {{18, { 1, 1 }}}, 1.0 };
+ propertyValue = mbgl::style::SourceFunction<std::array<float, 2>> { "keyName", exponentialStops };
+
+ XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
+ @"Setting iconOffset to a source function should update icon-offset.");
+ XCTAssertEqualObjects(layer.iconOffset, functionStyleValue,
+ @"iconOffset should round-trip source functions.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
+ layer.iconOffset = functionStyleValue;
+
+ mbgl::style::ExponentialStops<std::array<float, 2>> innerStops = { { {18, { 1, 1 }}}, 1.0 };
+ std::map<float, mbgl::style::ExponentialStops<std::array<float, 2>>> compositeStops = { {10.0, innerStops} };
+
+ propertyValue = mbgl::style::CompositeFunction<std::array<float, 2>> { "keyName", compositeStops };
+
XCTAssertEqual(rawLayer->getIconOffset(), propertyValue,
- @"Setting iconOffset to a function should update icon-offset.");
- XCTAssertEqualObjects(layer.iconOffset, styleValue,
- @"iconOffset should round-trip functions.");
+ @"Setting iconOffset to a composite function should update icon-offset.");
+ XCTAssertEqualObjects(layer.iconOffset, functionStyleValue,
+ @"iconOffset should round-trip composite functions.");
+
layer.iconOffset = nil;
XCTAssertTrue(rawLayer->getIconOffset().isUndefined(),
@@ -191,32 +232,38 @@
@"icon-optional should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconOptional;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.iconOptional = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.iconOptional = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getIconOptional(), propertyValue,
@"Setting iconOptional to a constant value should update icon-optional.");
- XCTAssertEqualObjects(layer.iconOptional, styleValue,
+ XCTAssertEqualObjects(layer.iconOptional, constantStyleValue,
@"iconOptional should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconOptional = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconOptional = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconOptional(), propertyValue,
- @"Setting iconOptional to a function should update icon-optional.");
- XCTAssertEqualObjects(layer.iconOptional, styleValue,
- @"iconOptional should round-trip functions.");
+ @"Setting iconOptional to a camera function should update icon-optional.");
+ XCTAssertEqualObjects(layer.iconOptional, functionStyleValue,
+ @"iconOptional should round-trip camera functions.");
+
+
layer.iconOptional = nil;
XCTAssertTrue(rawLayer->getIconOptional().isUndefined(),
@"Unsetting iconOptional should return icon-optional to the default value.");
XCTAssertEqualObjects(layer.iconOptional, defaultStyleValue,
@"iconOptional should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconOptional = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconOptional = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-padding
@@ -225,26 +272,26 @@
@"icon-padding should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconPadding;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconPadding = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconPadding = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconPadding(), propertyValue,
@"Setting iconPadding to a constant value should update icon-padding.");
- XCTAssertEqualObjects(layer.iconPadding, styleValue,
+ XCTAssertEqualObjects(layer.iconPadding, constantStyleValue,
@"iconPadding should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconPadding = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconPadding = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconPadding(), propertyValue,
- @"Setting iconPadding to a function should update icon-padding.");
- XCTAssertEqualObjects(layer.iconPadding, styleValue,
- @"iconPadding should round-trip functions.");
+ @"Setting iconPadding to a camera function should update icon-padding.");
+ XCTAssertEqualObjects(layer.iconPadding, functionStyleValue,
+ @"iconPadding should round-trip camera functions.");
+
+
layer.iconPadding = nil;
XCTAssertTrue(rawLayer->getIconPadding().isUndefined(),
@@ -259,26 +306,49 @@
@"icon-rotate should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconRotation;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconRotation = styleValue;
- mbgl::style::PropertyValue<float> propertyValue = { 0xff };
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconRotation = constantStyleValue;
+ mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
@"Setting iconRotation to a constant value should update icon-rotate.");
- XCTAssertEqualObjects(layer.iconRotation, styleValue,
+ XCTAssertEqualObjects(layer.iconRotation, constantStyleValue,
@"iconRotation should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconRotation = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconRotation = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
+ XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
+ @"Setting iconRotation to a camera function should update icon-rotate.");
+ XCTAssertEqualObjects(layer.iconRotation, functionStyleValue,
+ @"iconRotation should round-trip camera functions.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
+ layer.iconRotation = functionStyleValue;
+
+ mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
+ propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
+
+ XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
+ @"Setting iconRotation to a source function should update icon-rotate.");
+ XCTAssertEqualObjects(layer.iconRotation, functionStyleValue,
+ @"iconRotation should round-trip source functions.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
+ layer.iconRotation = functionStyleValue;
+
+ mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
+ std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
+
+ propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
+
XCTAssertEqual(rawLayer->getIconRotate(), propertyValue,
- @"Setting iconRotation to a function should update icon-rotate.");
- XCTAssertEqualObjects(layer.iconRotation, styleValue,
- @"iconRotation should round-trip functions.");
+ @"Setting iconRotation to a composite function should update icon-rotate.");
+ XCTAssertEqualObjects(layer.iconRotation, functionStyleValue,
+ @"iconRotation should round-trip composite functions.");
+
layer.iconRotation = nil;
XCTAssertTrue(rawLayer->getIconRotate().isUndefined(),
@@ -293,32 +363,38 @@
@"icon-rotation-alignment should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconRotationAlignment;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentAuto]];
- layer.iconRotationAlignment = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentAuto]];
+ layer.iconRotationAlignment = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue,
@"Setting iconRotationAlignment to a constant value should update icon-rotation-alignment.");
- XCTAssertEqualObjects(layer.iconRotationAlignment, styleValue,
+ XCTAssertEqualObjects(layer.iconRotationAlignment, constantStyleValue,
@"iconRotationAlignment should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconRotationAlignment = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::AlignmentType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconRotationAlignment = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::AlignmentType> intervalStops = { {{18, mbgl::style::AlignmentType::Auto}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::AlignmentType> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue,
- @"Setting iconRotationAlignment to a function should update icon-rotation-alignment.");
- XCTAssertEqualObjects(layer.iconRotationAlignment, styleValue,
- @"iconRotationAlignment should round-trip functions.");
+ @"Setting iconRotationAlignment to a camera function should update icon-rotation-alignment.");
+ XCTAssertEqualObjects(layer.iconRotationAlignment, functionStyleValue,
+ @"iconRotationAlignment should round-trip camera functions.");
+
+
layer.iconRotationAlignment = nil;
XCTAssertTrue(rawLayer->getIconRotationAlignment().isUndefined(),
@"Unsetting iconRotationAlignment should return icon-rotation-alignment to the default value.");
XCTAssertEqualObjects(layer.iconRotationAlignment, defaultStyleValue,
@"iconRotationAlignment should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-size
@@ -327,26 +403,26 @@
@"icon-size should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconScale;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconScale = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconScale = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
@"Setting iconScale to a constant value should update icon-size.");
- XCTAssertEqualObjects(layer.iconScale, styleValue,
+ XCTAssertEqualObjects(layer.iconScale, constantStyleValue,
@"iconScale should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconScale = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconScale = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconSize(), propertyValue,
- @"Setting iconScale to a function should update icon-size.");
- XCTAssertEqualObjects(layer.iconScale, styleValue,
- @"iconScale should round-trip functions.");
+ @"Setting iconScale to a camera function should update icon-size.");
+ XCTAssertEqualObjects(layer.iconScale, functionStyleValue,
+ @"iconScale should round-trip camera functions.");
+
+
layer.iconScale = nil;
XCTAssertTrue(rawLayer->getIconSize().isUndefined(),
@@ -361,32 +437,38 @@
@"icon-text-fit should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconTextFit;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconTextFit:MGLIconTextFitBoth]];
- layer.iconTextFit = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconTextFit:MGLIconTextFitBoth]];
+ layer.iconTextFit = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::IconTextFitType> propertyValue = { mbgl::style::IconTextFitType::Both };
XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue,
@"Setting iconTextFit to a constant value should update icon-text-fit.");
- XCTAssertEqualObjects(layer.iconTextFit, styleValue,
+ XCTAssertEqualObjects(layer.iconTextFit, constantStyleValue,
@"iconTextFit should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconTextFit = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::IconTextFitType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconTextFit = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::IconTextFitType> intervalStops = { {{18, mbgl::style::IconTextFitType::Both}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::IconTextFitType> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue,
- @"Setting iconTextFit to a function should update icon-text-fit.");
- XCTAssertEqualObjects(layer.iconTextFit, styleValue,
- @"iconTextFit should round-trip functions.");
+ @"Setting iconTextFit to a camera function should update icon-text-fit.");
+ XCTAssertEqualObjects(layer.iconTextFit, functionStyleValue,
+ @"iconTextFit should round-trip camera functions.");
+
+
layer.iconTextFit = nil;
XCTAssertTrue(rawLayer->getIconTextFit().isUndefined(),
@"Unsetting iconTextFit should return icon-text-fit to the default value.");
XCTAssertEqualObjects(layer.iconTextFit, defaultStyleValue,
@"iconTextFit should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-text-fit-padding
@@ -395,32 +477,32 @@
@"icon-text-fit-padding should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconTextFitPadding;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
#if TARGET_OS_IPHONE
[NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(1, 1, 1, 1)]
#else
[NSValue valueWithEdgeInsets:NSEdgeInsetsMake(1, 1, 1, 1)]
#endif
];
- layer.iconTextFitPadding = styleValue;
+ layer.iconTextFitPadding = constantStyleValue;
mbgl::style::PropertyValue<std::array<float, 4>> propertyValue = { { 1, 1, 1, 1 } };
XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue,
@"Setting iconTextFitPadding to a constant value should update icon-text-fit-padding.");
- XCTAssertEqualObjects(layer.iconTextFitPadding, styleValue,
+ XCTAssertEqualObjects(layer.iconTextFitPadding, constantStyleValue,
@"iconTextFitPadding should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconTextFitPadding = styleValue;
- propertyValue = { mbgl::style::Function<std::array<float, 4>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconTextFitPadding = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::array<float, 4>> intervalStops = { {{18, { 1, 1, 1, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<std::array<float, 4>> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue,
- @"Setting iconTextFitPadding to a function should update icon-text-fit-padding.");
- XCTAssertEqualObjects(layer.iconTextFitPadding, styleValue,
- @"iconTextFitPadding should round-trip functions.");
+ @"Setting iconTextFitPadding to a camera function should update icon-text-fit-padding.");
+ XCTAssertEqualObjects(layer.iconTextFitPadding, functionStyleValue,
+ @"iconTextFitPadding should round-trip camera functions.");
+
+
layer.iconTextFitPadding = nil;
XCTAssertTrue(rawLayer->getIconTextFitPadding().isUndefined(),
@@ -435,32 +517,38 @@
@"icon-keep-upright should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.keepsIconUpright;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.keepsIconUpright = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.keepsIconUpright = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue,
@"Setting keepsIconUpright to a constant value should update icon-keep-upright.");
- XCTAssertEqualObjects(layer.keepsIconUpright, styleValue,
+ XCTAssertEqualObjects(layer.keepsIconUpright, constantStyleValue,
@"keepsIconUpright should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.keepsIconUpright = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.keepsIconUpright = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue,
- @"Setting keepsIconUpright to a function should update icon-keep-upright.");
- XCTAssertEqualObjects(layer.keepsIconUpright, styleValue,
- @"keepsIconUpright should round-trip functions.");
+ @"Setting keepsIconUpright to a camera function should update icon-keep-upright.");
+ XCTAssertEqualObjects(layer.keepsIconUpright, functionStyleValue,
+ @"keepsIconUpright should round-trip camera functions.");
+
+
layer.keepsIconUpright = nil;
XCTAssertTrue(rawLayer->getIconKeepUpright().isUndefined(),
@"Unsetting keepsIconUpright should return icon-keep-upright to the default value.");
XCTAssertEqualObjects(layer.keepsIconUpright, defaultStyleValue,
@"keepsIconUpright should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-keep-upright
@@ -469,32 +557,38 @@
@"text-keep-upright should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.keepsTextUpright;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@NO];
- layer.keepsTextUpright = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@NO];
+ layer.keepsTextUpright = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { false };
XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue,
@"Setting keepsTextUpright to a constant value should update text-keep-upright.");
- XCTAssertEqualObjects(layer.keepsTextUpright, styleValue,
+ XCTAssertEqualObjects(layer.keepsTextUpright, constantStyleValue,
@"keepsTextUpright should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.keepsTextUpright = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.keepsTextUpright = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, false}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue,
- @"Setting keepsTextUpright to a function should update text-keep-upright.");
- XCTAssertEqualObjects(layer.keepsTextUpright, styleValue,
- @"keepsTextUpright should round-trip functions.");
+ @"Setting keepsTextUpright to a camera function should update text-keep-upright.");
+ XCTAssertEqualObjects(layer.keepsTextUpright, functionStyleValue,
+ @"keepsTextUpright should round-trip camera functions.");
+
+
layer.keepsTextUpright = nil;
XCTAssertTrue(rawLayer->getTextKeepUpright().isUndefined(),
@"Unsetting keepsTextUpright should return text-keep-upright to the default value.");
XCTAssertEqualObjects(layer.keepsTextUpright, defaultStyleValue,
@"keepsTextUpright should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-max-angle
@@ -503,26 +597,26 @@
@"text-max-angle should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.maximumTextAngle;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.maximumTextAngle = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.maximumTextAngle = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue,
@"Setting maximumTextAngle to a constant value should update text-max-angle.");
- XCTAssertEqualObjects(layer.maximumTextAngle, styleValue,
+ XCTAssertEqualObjects(layer.maximumTextAngle, constantStyleValue,
@"maximumTextAngle should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.maximumTextAngle = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.maximumTextAngle = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue,
- @"Setting maximumTextAngle to a function should update text-max-angle.");
- XCTAssertEqualObjects(layer.maximumTextAngle, styleValue,
- @"maximumTextAngle should round-trip functions.");
+ @"Setting maximumTextAngle to a camera function should update text-max-angle.");
+ XCTAssertEqualObjects(layer.maximumTextAngle, functionStyleValue,
+ @"maximumTextAngle should round-trip camera functions.");
+
+
layer.maximumTextAngle = nil;
XCTAssertTrue(rawLayer->getTextMaxAngle().isUndefined(),
@@ -537,26 +631,26 @@
@"text-max-width should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.maximumTextWidth;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.maximumTextWidth = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.maximumTextWidth = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
@"Setting maximumTextWidth to a constant value should update text-max-width.");
- XCTAssertEqualObjects(layer.maximumTextWidth, styleValue,
+ XCTAssertEqualObjects(layer.maximumTextWidth, constantStyleValue,
@"maximumTextWidth should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.maximumTextWidth = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.maximumTextWidth = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue,
- @"Setting maximumTextWidth to a function should update text-max-width.");
- XCTAssertEqualObjects(layer.maximumTextWidth, styleValue,
- @"maximumTextWidth should round-trip functions.");
+ @"Setting maximumTextWidth to a camera function should update text-max-width.");
+ XCTAssertEqualObjects(layer.maximumTextWidth, functionStyleValue,
+ @"maximumTextWidth should round-trip camera functions.");
+
+
layer.maximumTextWidth = nil;
XCTAssertTrue(rawLayer->getTextMaxWidth().isUndefined(),
@@ -571,32 +665,38 @@
@"symbol-avoid-edges should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.symbolAvoidsEdges;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.symbolAvoidsEdges = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.symbolAvoidsEdges = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue,
@"Setting symbolAvoidsEdges to a constant value should update symbol-avoid-edges.");
- XCTAssertEqualObjects(layer.symbolAvoidsEdges, styleValue,
+ XCTAssertEqualObjects(layer.symbolAvoidsEdges, constantStyleValue,
@"symbolAvoidsEdges should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.symbolAvoidsEdges = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.symbolAvoidsEdges = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue,
- @"Setting symbolAvoidsEdges to a function should update symbol-avoid-edges.");
- XCTAssertEqualObjects(layer.symbolAvoidsEdges, styleValue,
- @"symbolAvoidsEdges should round-trip functions.");
+ @"Setting symbolAvoidsEdges to a camera function should update symbol-avoid-edges.");
+ XCTAssertEqualObjects(layer.symbolAvoidsEdges, functionStyleValue,
+ @"symbolAvoidsEdges should round-trip camera functions.");
+
+
layer.symbolAvoidsEdges = nil;
XCTAssertTrue(rawLayer->getSymbolAvoidEdges().isUndefined(),
@"Unsetting symbolAvoidsEdges should return symbol-avoid-edges to the default value.");
XCTAssertEqualObjects(layer.symbolAvoidsEdges, defaultStyleValue,
@"symbolAvoidsEdges should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// symbol-placement
@@ -605,32 +705,38 @@
@"symbol-placement should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.symbolPlacement;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLine]];
- layer.symbolPlacement = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLine]];
+ layer.symbolPlacement = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::SymbolPlacementType> propertyValue = { mbgl::style::SymbolPlacementType::Line };
XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue,
@"Setting symbolPlacement to a constant value should update symbol-placement.");
- XCTAssertEqualObjects(layer.symbolPlacement, styleValue,
+ XCTAssertEqualObjects(layer.symbolPlacement, constantStyleValue,
@"symbolPlacement should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.symbolPlacement = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::SymbolPlacementType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.symbolPlacement = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::SymbolPlacementType> intervalStops = { {{18, mbgl::style::SymbolPlacementType::Line}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::SymbolPlacementType> { intervalStops };
+
XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue,
- @"Setting symbolPlacement to a function should update symbol-placement.");
- XCTAssertEqualObjects(layer.symbolPlacement, styleValue,
- @"symbolPlacement should round-trip functions.");
+ @"Setting symbolPlacement to a camera function should update symbol-placement.");
+ XCTAssertEqualObjects(layer.symbolPlacement, functionStyleValue,
+ @"symbolPlacement should round-trip camera functions.");
+
+
layer.symbolPlacement = nil;
XCTAssertTrue(rawLayer->getSymbolPlacement().isUndefined(),
@"Unsetting symbolPlacement should return symbol-placement to the default value.");
XCTAssertEqualObjects(layer.symbolPlacement, defaultStyleValue,
@"symbolPlacement should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// symbol-spacing
@@ -639,26 +745,26 @@
@"symbol-spacing should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.symbolSpacing;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.symbolSpacing = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.symbolSpacing = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue,
@"Setting symbolSpacing to a constant value should update symbol-spacing.");
- XCTAssertEqualObjects(layer.symbolSpacing, styleValue,
+ XCTAssertEqualObjects(layer.symbolSpacing, constantStyleValue,
@"symbolSpacing should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.symbolSpacing = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.symbolSpacing = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue,
- @"Setting symbolSpacing to a function should update symbol-spacing.");
- XCTAssertEqualObjects(layer.symbolSpacing, styleValue,
- @"symbolSpacing should round-trip functions.");
+ @"Setting symbolSpacing to a camera function should update symbol-spacing.");
+ XCTAssertEqualObjects(layer.symbolSpacing, functionStyleValue,
+ @"symbolSpacing should round-trip camera functions.");
+
+
layer.symbolSpacing = nil;
XCTAssertTrue(rawLayer->getSymbolSpacing().isUndefined(),
@@ -673,32 +779,38 @@
@"text-field should be unset initially.");
MGLStyleValue<NSString *> *defaultStyleValue = layer.text;
- MGLStyleValue<NSString *> *styleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Text Field"];
- layer.text = styleValue;
+ MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Text Field"];
+ layer.text = constantStyleValue;
mbgl::style::PropertyValue<std::string> propertyValue = { "Text Field" };
XCTAssertEqual(rawLayer->getTextField(), propertyValue,
@"Setting text to a constant value should update text-field.");
- XCTAssertEqualObjects(layer.text, styleValue,
+ XCTAssertEqualObjects(layer.text, constantStyleValue,
@"text should round-trip constant values.");
- styleValue = [MGLStyleValue<NSString *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.text = styleValue;
- propertyValue = { mbgl::style::Function<std::string> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSString *> * functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.text = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::string> intervalStops = { {{18, "Text Field"}} };
+ propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextField(), propertyValue,
- @"Setting text to a function should update text-field.");
- XCTAssertEqualObjects(layer.text, styleValue,
- @"text should round-trip functions.");
+ @"Setting text to a camera function should update text-field.");
+ XCTAssertEqualObjects(layer.text, functionStyleValue,
+ @"text should round-trip camera functions.");
+
+
layer.text = nil;
XCTAssertTrue(rawLayer->getTextField().isUndefined(),
@"Unsetting text should return text-field to the default value.");
XCTAssertEqualObjects(layer.text, defaultStyleValue,
@"text should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.text = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.text = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-allow-overlap
@@ -707,32 +819,38 @@
@"text-allow-overlap should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textAllowsOverlap;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.textAllowsOverlap = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.textAllowsOverlap = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue,
@"Setting textAllowsOverlap to a constant value should update text-allow-overlap.");
- XCTAssertEqualObjects(layer.textAllowsOverlap, styleValue,
+ XCTAssertEqualObjects(layer.textAllowsOverlap, constantStyleValue,
@"textAllowsOverlap should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textAllowsOverlap = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textAllowsOverlap = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue,
- @"Setting textAllowsOverlap to a function should update text-allow-overlap.");
- XCTAssertEqualObjects(layer.textAllowsOverlap, styleValue,
- @"textAllowsOverlap should round-trip functions.");
+ @"Setting textAllowsOverlap to a camera function should update text-allow-overlap.");
+ XCTAssertEqualObjects(layer.textAllowsOverlap, functionStyleValue,
+ @"textAllowsOverlap should round-trip camera functions.");
+
+
layer.textAllowsOverlap = nil;
XCTAssertTrue(rawLayer->getTextAllowOverlap().isUndefined(),
@"Unsetting textAllowsOverlap should return text-allow-overlap to the default value.");
XCTAssertEqualObjects(layer.textAllowsOverlap, defaultStyleValue,
@"textAllowsOverlap should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-anchor
@@ -741,32 +859,38 @@
@"text-anchor should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textAnchor;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomRight]];
- layer.textAnchor = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomRight]];
+ layer.textAnchor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::TextAnchorType> propertyValue = { mbgl::style::TextAnchorType::BottomRight };
XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue,
@"Setting textAnchor to a constant value should update text-anchor.");
- XCTAssertEqualObjects(layer.textAnchor, styleValue,
+ XCTAssertEqualObjects(layer.textAnchor, constantStyleValue,
@"textAnchor should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textAnchor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::TextAnchorType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textAnchor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::TextAnchorType> intervalStops = { {{18, mbgl::style::TextAnchorType::BottomRight}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::TextAnchorType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue,
- @"Setting textAnchor to a function should update text-anchor.");
- XCTAssertEqualObjects(layer.textAnchor, styleValue,
- @"textAnchor should round-trip functions.");
+ @"Setting textAnchor to a camera function should update text-anchor.");
+ XCTAssertEqualObjects(layer.textAnchor, functionStyleValue,
+ @"textAnchor should round-trip camera functions.");
+
+
layer.textAnchor = nil;
XCTAssertTrue(rawLayer->getTextAnchor().isUndefined(),
@"Unsetting textAnchor should return text-anchor to the default value.");
XCTAssertEqualObjects(layer.textAnchor, defaultStyleValue,
@"textAnchor should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-font
@@ -775,32 +899,38 @@
@"text-font should be unset initially.");
MGLStyleValue<NSArray<NSString *> *> *defaultStyleValue = layer.textFontNames;
- MGLStyleValue<NSArray<NSString *> *> *styleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithRawValue:@[@"Text Font", @"Tnof Txet"]];
- layer.textFontNames = styleValue;
+ MGLStyleValue<NSArray<NSString *> *> *constantStyleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithRawValue:@[@"Text Font", @"Tnof Txet"]];
+ layer.textFontNames = constantStyleValue;
mbgl::style::PropertyValue<std::vector<std::string>> propertyValue = { { "Text Font", "Tnof Txet" } };
XCTAssertEqual(rawLayer->getTextFont(), propertyValue,
@"Setting textFontNames to a constant value should update text-font.");
- XCTAssertEqualObjects(layer.textFontNames, styleValue,
+ XCTAssertEqualObjects(layer.textFontNames, constantStyleValue,
@"textFontNames should round-trip constant values.");
- styleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textFontNames = styleValue;
- propertyValue = { mbgl::style::Function<std::vector<std::string>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSArray<NSString *> *> * functionStyleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textFontNames = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::vector<std::string>> intervalStops = { {{18, { "Text Font", "Tnof Txet" }}} };
+ propertyValue = mbgl::style::CameraFunction<std::vector<std::string>> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextFont(), propertyValue,
- @"Setting textFontNames to a function should update text-font.");
- XCTAssertEqualObjects(layer.textFontNames, styleValue,
- @"textFontNames should round-trip functions.");
+ @"Setting textFontNames to a camera function should update text-font.");
+ XCTAssertEqualObjects(layer.textFontNames, functionStyleValue,
+ @"textFontNames should round-trip camera functions.");
+
+
layer.textFontNames = nil;
XCTAssertTrue(rawLayer->getTextFont().isUndefined(),
@"Unsetting textFontNames should return text-font to the default value.");
XCTAssertEqualObjects(layer.textFontNames, defaultStyleValue,
@"textFontNames should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textFontNames = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSArray<NSString *> *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textFontNames = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-size
@@ -809,26 +939,26 @@
@"text-size should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textFontSize;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textFontSize = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textFontSize = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
@"Setting textFontSize to a constant value should update text-size.");
- XCTAssertEqualObjects(layer.textFontSize, styleValue,
+ XCTAssertEqualObjects(layer.textFontSize, constantStyleValue,
@"textFontSize should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textFontSize = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textFontSize = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextSize(), propertyValue,
- @"Setting textFontSize to a function should update text-size.");
- XCTAssertEqualObjects(layer.textFontSize, styleValue,
- @"textFontSize should round-trip functions.");
+ @"Setting textFontSize to a camera function should update text-size.");
+ XCTAssertEqualObjects(layer.textFontSize, functionStyleValue,
+ @"textFontSize should round-trip camera functions.");
+
+
layer.textFontSize = nil;
XCTAssertTrue(rawLayer->getTextSize().isUndefined(),
@@ -843,32 +973,38 @@
@"text-ignore-placement should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textIgnoresPlacement;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.textIgnoresPlacement = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.textIgnoresPlacement = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue,
@"Setting textIgnoresPlacement to a constant value should update text-ignore-placement.");
- XCTAssertEqualObjects(layer.textIgnoresPlacement, styleValue,
+ XCTAssertEqualObjects(layer.textIgnoresPlacement, constantStyleValue,
@"textIgnoresPlacement should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textIgnoresPlacement = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textIgnoresPlacement = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue,
- @"Setting textIgnoresPlacement to a function should update text-ignore-placement.");
- XCTAssertEqualObjects(layer.textIgnoresPlacement, styleValue,
- @"textIgnoresPlacement should round-trip functions.");
+ @"Setting textIgnoresPlacement to a camera function should update text-ignore-placement.");
+ XCTAssertEqualObjects(layer.textIgnoresPlacement, functionStyleValue,
+ @"textIgnoresPlacement should round-trip camera functions.");
+
+
layer.textIgnoresPlacement = nil;
XCTAssertTrue(rawLayer->getTextIgnorePlacement().isUndefined(),
@"Unsetting textIgnoresPlacement should return text-ignore-placement to the default value.");
XCTAssertEqualObjects(layer.textIgnoresPlacement, defaultStyleValue,
@"textIgnoresPlacement should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-justify
@@ -877,32 +1013,38 @@
@"text-justify should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textJustification;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextJustification:MGLTextJustificationRight]];
- layer.textJustification = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextJustification:MGLTextJustificationRight]];
+ layer.textJustification = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::TextJustifyType> propertyValue = { mbgl::style::TextJustifyType::Right };
XCTAssertEqual(rawLayer->getTextJustify(), propertyValue,
@"Setting textJustification to a constant value should update text-justify.");
- XCTAssertEqualObjects(layer.textJustification, styleValue,
+ XCTAssertEqualObjects(layer.textJustification, constantStyleValue,
@"textJustification should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textJustification = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::TextJustifyType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textJustification = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::TextJustifyType> intervalStops = { {{18, mbgl::style::TextJustifyType::Right}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::TextJustifyType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextJustify(), propertyValue,
- @"Setting textJustification to a function should update text-justify.");
- XCTAssertEqualObjects(layer.textJustification, styleValue,
- @"textJustification should round-trip functions.");
+ @"Setting textJustification to a camera function should update text-justify.");
+ XCTAssertEqualObjects(layer.textJustification, functionStyleValue,
+ @"textJustification should round-trip camera functions.");
+
+
layer.textJustification = nil;
XCTAssertTrue(rawLayer->getTextJustify().isUndefined(),
@"Unsetting textJustification should return text-justify to the default value.");
XCTAssertEqualObjects(layer.textJustification, defaultStyleValue,
@"textJustification should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textJustification = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textJustification = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-letter-spacing
@@ -911,26 +1053,26 @@
@"text-letter-spacing should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textLetterSpacing;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textLetterSpacing = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textLetterSpacing = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
@"Setting textLetterSpacing to a constant value should update text-letter-spacing.");
- XCTAssertEqualObjects(layer.textLetterSpacing, styleValue,
+ XCTAssertEqualObjects(layer.textLetterSpacing, constantStyleValue,
@"textLetterSpacing should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textLetterSpacing = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textLetterSpacing = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue,
- @"Setting textLetterSpacing to a function should update text-letter-spacing.");
- XCTAssertEqualObjects(layer.textLetterSpacing, styleValue,
- @"textLetterSpacing should round-trip functions.");
+ @"Setting textLetterSpacing to a camera function should update text-letter-spacing.");
+ XCTAssertEqualObjects(layer.textLetterSpacing, functionStyleValue,
+ @"textLetterSpacing should round-trip camera functions.");
+
+
layer.textLetterSpacing = nil;
XCTAssertTrue(rawLayer->getTextLetterSpacing().isUndefined(),
@@ -945,26 +1087,26 @@
@"text-line-height should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textLineHeight;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textLineHeight = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textLineHeight = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue,
@"Setting textLineHeight to a constant value should update text-line-height.");
- XCTAssertEqualObjects(layer.textLineHeight, styleValue,
+ XCTAssertEqualObjects(layer.textLineHeight, constantStyleValue,
@"textLineHeight should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textLineHeight = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textLineHeight = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue,
- @"Setting textLineHeight to a function should update text-line-height.");
- XCTAssertEqualObjects(layer.textLineHeight, styleValue,
- @"textLineHeight should round-trip functions.");
+ @"Setting textLineHeight to a camera function should update text-line-height.");
+ XCTAssertEqualObjects(layer.textLineHeight, functionStyleValue,
+ @"textLineHeight should round-trip camera functions.");
+
+
layer.textLineHeight = nil;
XCTAssertTrue(rawLayer->getTextLineHeight().isUndefined(),
@@ -979,32 +1121,32 @@
@"text-offset should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textOffset;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
#if TARGET_OS_IPHONE
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
#else
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
#endif
];
- layer.textOffset = styleValue;
+ layer.textOffset = constantStyleValue;
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
@"Setting textOffset to a constant value should update text-offset.");
- XCTAssertEqualObjects(layer.textOffset, styleValue,
+ XCTAssertEqualObjects(layer.textOffset, constantStyleValue,
@"textOffset should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textOffset = styleValue;
- propertyValue = { mbgl::style::Function<std::array<float, 2>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textOffset = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextOffset(), propertyValue,
- @"Setting textOffset to a function should update text-offset.");
- XCTAssertEqualObjects(layer.textOffset, styleValue,
- @"textOffset should round-trip functions.");
+ @"Setting textOffset to a camera function should update text-offset.");
+ XCTAssertEqualObjects(layer.textOffset, functionStyleValue,
+ @"textOffset should round-trip camera functions.");
+
+
layer.textOffset = nil;
XCTAssertTrue(rawLayer->getTextOffset().isUndefined(),
@@ -1019,32 +1161,38 @@
@"text-optional should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textOptional;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
- layer.textOptional = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@YES];
+ layer.textOptional = constantStyleValue;
mbgl::style::PropertyValue<bool> propertyValue = { true };
XCTAssertEqual(rawLayer->getTextOptional(), propertyValue,
@"Setting textOptional to a constant value should update text-optional.");
- XCTAssertEqualObjects(layer.textOptional, styleValue,
+ XCTAssertEqualObjects(layer.textOptional, constantStyleValue,
@"textOptional should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textOptional = styleValue;
- propertyValue = { mbgl::style::Function<bool> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textOptional = functionStyleValue;
+
+ mbgl::style::IntervalStops<bool> intervalStops = { {{18, true}} };
+ propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextOptional(), propertyValue,
- @"Setting textOptional to a function should update text-optional.");
- XCTAssertEqualObjects(layer.textOptional, styleValue,
- @"textOptional should round-trip functions.");
+ @"Setting textOptional to a camera function should update text-optional.");
+ XCTAssertEqualObjects(layer.textOptional, functionStyleValue,
+ @"textOptional should round-trip camera functions.");
+
+
layer.textOptional = nil;
XCTAssertTrue(rawLayer->getTextOptional().isUndefined(),
@"Unsetting textOptional should return text-optional to the default value.");
XCTAssertEqualObjects(layer.textOptional, defaultStyleValue,
@"textOptional should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textOptional = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textOptional = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-padding
@@ -1053,26 +1201,26 @@
@"text-padding should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textPadding;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textPadding = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textPadding = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextPadding(), propertyValue,
@"Setting textPadding to a constant value should update text-padding.");
- XCTAssertEqualObjects(layer.textPadding, styleValue,
+ XCTAssertEqualObjects(layer.textPadding, constantStyleValue,
@"textPadding should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textPadding = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textPadding = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextPadding(), propertyValue,
- @"Setting textPadding to a function should update text-padding.");
- XCTAssertEqualObjects(layer.textPadding, styleValue,
- @"textPadding should round-trip functions.");
+ @"Setting textPadding to a camera function should update text-padding.");
+ XCTAssertEqualObjects(layer.textPadding, functionStyleValue,
+ @"textPadding should round-trip camera functions.");
+
+
layer.textPadding = nil;
XCTAssertTrue(rawLayer->getTextPadding().isUndefined(),
@@ -1087,32 +1235,38 @@
@"text-pitch-alignment should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textPitchAlignment;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentAuto]];
- layer.textPitchAlignment = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentAuto]];
+ layer.textPitchAlignment = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue,
@"Setting textPitchAlignment to a constant value should update text-pitch-alignment.");
- XCTAssertEqualObjects(layer.textPitchAlignment, styleValue,
+ XCTAssertEqualObjects(layer.textPitchAlignment, constantStyleValue,
@"textPitchAlignment should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textPitchAlignment = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::AlignmentType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textPitchAlignment = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::AlignmentType> intervalStops = { {{18, mbgl::style::AlignmentType::Auto}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::AlignmentType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue,
- @"Setting textPitchAlignment to a function should update text-pitch-alignment.");
- XCTAssertEqualObjects(layer.textPitchAlignment, styleValue,
- @"textPitchAlignment should round-trip functions.");
+ @"Setting textPitchAlignment to a camera function should update text-pitch-alignment.");
+ XCTAssertEqualObjects(layer.textPitchAlignment, functionStyleValue,
+ @"textPitchAlignment should round-trip camera functions.");
+
+
layer.textPitchAlignment = nil;
XCTAssertTrue(rawLayer->getTextPitchAlignment().isUndefined(),
@"Unsetting textPitchAlignment should return text-pitch-alignment to the default value.");
XCTAssertEqualObjects(layer.textPitchAlignment, defaultStyleValue,
@"textPitchAlignment should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-rotate
@@ -1121,26 +1275,26 @@
@"text-rotate should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textRotation;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textRotation = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textRotation = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
@"Setting textRotation to a constant value should update text-rotate.");
- XCTAssertEqualObjects(layer.textRotation, styleValue,
+ XCTAssertEqualObjects(layer.textRotation, constantStyleValue,
@"textRotation should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textRotation = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textRotation = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextRotate(), propertyValue,
- @"Setting textRotation to a function should update text-rotate.");
- XCTAssertEqualObjects(layer.textRotation, styleValue,
- @"textRotation should round-trip functions.");
+ @"Setting textRotation to a camera function should update text-rotate.");
+ XCTAssertEqualObjects(layer.textRotation, functionStyleValue,
+ @"textRotation should round-trip camera functions.");
+
+
layer.textRotation = nil;
XCTAssertTrue(rawLayer->getTextRotate().isUndefined(),
@@ -1155,32 +1309,38 @@
@"text-rotation-alignment should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textRotationAlignment;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentAuto]];
- layer.textRotationAlignment = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentAuto]];
+ layer.textRotationAlignment = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::AlignmentType> propertyValue = { mbgl::style::AlignmentType::Auto };
XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue,
@"Setting textRotationAlignment to a constant value should update text-rotation-alignment.");
- XCTAssertEqualObjects(layer.textRotationAlignment, styleValue,
+ XCTAssertEqualObjects(layer.textRotationAlignment, constantStyleValue,
@"textRotationAlignment should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textRotationAlignment = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::AlignmentType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textRotationAlignment = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::AlignmentType> intervalStops = { {{18, mbgl::style::AlignmentType::Auto}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::AlignmentType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue,
- @"Setting textRotationAlignment to a function should update text-rotation-alignment.");
- XCTAssertEqualObjects(layer.textRotationAlignment, styleValue,
- @"textRotationAlignment should round-trip functions.");
+ @"Setting textRotationAlignment to a camera function should update text-rotation-alignment.");
+ XCTAssertEqualObjects(layer.textRotationAlignment, functionStyleValue,
+ @"textRotationAlignment should round-trip camera functions.");
+
+
layer.textRotationAlignment = nil;
XCTAssertTrue(rawLayer->getTextRotationAlignment().isUndefined(),
@"Unsetting textRotationAlignment should return text-rotation-alignment to the default value.");
XCTAssertEqualObjects(layer.textRotationAlignment, defaultStyleValue,
@"textRotationAlignment should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-transform
@@ -1189,32 +1349,38 @@
@"text-transform should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textTransform;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextTransform:MGLTextTransformLowercase]];
- layer.textTransform = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextTransform:MGLTextTransformLowercase]];
+ layer.textTransform = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::TextTransformType> propertyValue = { mbgl::style::TextTransformType::Lowercase };
XCTAssertEqual(rawLayer->getTextTransform(), propertyValue,
@"Setting textTransform to a constant value should update text-transform.");
- XCTAssertEqualObjects(layer.textTransform, styleValue,
+ XCTAssertEqualObjects(layer.textTransform, constantStyleValue,
@"textTransform should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textTransform = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::TextTransformType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textTransform = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::TextTransformType> intervalStops = { {{18, mbgl::style::TextTransformType::Lowercase}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::TextTransformType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextTransform(), propertyValue,
- @"Setting textTransform to a function should update text-transform.");
- XCTAssertEqualObjects(layer.textTransform, styleValue,
- @"textTransform should round-trip functions.");
+ @"Setting textTransform to a camera function should update text-transform.");
+ XCTAssertEqualObjects(layer.textTransform, functionStyleValue,
+ @"textTransform should round-trip camera functions.");
+
+
layer.textTransform = nil;
XCTAssertTrue(rawLayer->getTextTransform().isUndefined(),
@"Unsetting textTransform should return text-transform to the default value.");
XCTAssertEqualObjects(layer.textTransform, defaultStyleValue,
@"textTransform should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textTransform = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textTransform = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// icon-color
@@ -1223,26 +1389,26 @@
@"icon-color should be unset initially.");
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.iconColor;
- MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
- layer.iconColor = styleValue;
+ MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
+ layer.iconColor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
@"Setting iconColor to a constant value should update icon-color.");
- XCTAssertEqualObjects(layer.iconColor, styleValue,
+ XCTAssertEqualObjects(layer.iconColor, constantStyleValue,
@"iconColor should round-trip constant values.");
- styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconColor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::Color> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconColor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconColor(), propertyValue,
- @"Setting iconColor to a function should update icon-color.");
- XCTAssertEqualObjects(layer.iconColor, styleValue,
- @"iconColor should round-trip functions.");
+ @"Setting iconColor to a camera function should update icon-color.");
+ XCTAssertEqualObjects(layer.iconColor, functionStyleValue,
+ @"iconColor should round-trip camera functions.");
+
+
layer.iconColor = nil;
XCTAssertTrue(rawLayer->getIconColor().isUndefined(),
@@ -1257,26 +1423,26 @@
@"icon-halo-blur should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconHaloBlur;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconHaloBlur = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconHaloBlur = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
@"Setting iconHaloBlur to a constant value should update icon-halo-blur.");
- XCTAssertEqualObjects(layer.iconHaloBlur, styleValue,
+ XCTAssertEqualObjects(layer.iconHaloBlur, constantStyleValue,
@"iconHaloBlur should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconHaloBlur = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconHaloBlur = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue,
- @"Setting iconHaloBlur to a function should update icon-halo-blur.");
- XCTAssertEqualObjects(layer.iconHaloBlur, styleValue,
- @"iconHaloBlur should round-trip functions.");
+ @"Setting iconHaloBlur to a camera function should update icon-halo-blur.");
+ XCTAssertEqualObjects(layer.iconHaloBlur, functionStyleValue,
+ @"iconHaloBlur should round-trip camera functions.");
+
+
layer.iconHaloBlur = nil;
XCTAssertTrue(rawLayer->getIconHaloBlur().isUndefined(),
@@ -1291,26 +1457,26 @@
@"icon-halo-color should be unset initially.");
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.iconHaloColor;
- MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
- layer.iconHaloColor = styleValue;
+ MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
+ layer.iconHaloColor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
@"Setting iconHaloColor to a constant value should update icon-halo-color.");
- XCTAssertEqualObjects(layer.iconHaloColor, styleValue,
+ XCTAssertEqualObjects(layer.iconHaloColor, constantStyleValue,
@"iconHaloColor should round-trip constant values.");
- styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconHaloColor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::Color> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconHaloColor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue,
- @"Setting iconHaloColor to a function should update icon-halo-color.");
- XCTAssertEqualObjects(layer.iconHaloColor, styleValue,
- @"iconHaloColor should round-trip functions.");
+ @"Setting iconHaloColor to a camera function should update icon-halo-color.");
+ XCTAssertEqualObjects(layer.iconHaloColor, functionStyleValue,
+ @"iconHaloColor should round-trip camera functions.");
+
+
layer.iconHaloColor = nil;
XCTAssertTrue(rawLayer->getIconHaloColor().isUndefined(),
@@ -1325,26 +1491,26 @@
@"icon-halo-width should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconHaloWidth;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconHaloWidth = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconHaloWidth = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
@"Setting iconHaloWidth to a constant value should update icon-halo-width.");
- XCTAssertEqualObjects(layer.iconHaloWidth, styleValue,
+ XCTAssertEqualObjects(layer.iconHaloWidth, constantStyleValue,
@"iconHaloWidth should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconHaloWidth = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconHaloWidth = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue,
- @"Setting iconHaloWidth to a function should update icon-halo-width.");
- XCTAssertEqualObjects(layer.iconHaloWidth, styleValue,
- @"iconHaloWidth should round-trip functions.");
+ @"Setting iconHaloWidth to a camera function should update icon-halo-width.");
+ XCTAssertEqualObjects(layer.iconHaloWidth, functionStyleValue,
+ @"iconHaloWidth should round-trip camera functions.");
+
+
layer.iconHaloWidth = nil;
XCTAssertTrue(rawLayer->getIconHaloWidth().isUndefined(),
@@ -1359,26 +1525,26 @@
@"icon-opacity should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.iconOpacity;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.iconOpacity = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.iconOpacity = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
@"Setting iconOpacity to a constant value should update icon-opacity.");
- XCTAssertEqualObjects(layer.iconOpacity, styleValue,
+ XCTAssertEqualObjects(layer.iconOpacity, constantStyleValue,
@"iconOpacity should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconOpacity = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconOpacity = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue,
- @"Setting iconOpacity to a function should update icon-opacity.");
- XCTAssertEqualObjects(layer.iconOpacity, styleValue,
- @"iconOpacity should round-trip functions.");
+ @"Setting iconOpacity to a camera function should update icon-opacity.");
+ XCTAssertEqualObjects(layer.iconOpacity, functionStyleValue,
+ @"iconOpacity should round-trip camera functions.");
+
+
layer.iconOpacity = nil;
XCTAssertTrue(rawLayer->getIconOpacity().isUndefined(),
@@ -1393,32 +1559,32 @@
@"icon-translate should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconTranslation;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
#if TARGET_OS_IPHONE
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
#else
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
#endif
];
- layer.iconTranslation = styleValue;
+ layer.iconTranslation = constantStyleValue;
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue,
@"Setting iconTranslation to a constant value should update icon-translate.");
- XCTAssertEqualObjects(layer.iconTranslation, styleValue,
+ XCTAssertEqualObjects(layer.iconTranslation, constantStyleValue,
@"iconTranslation should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconTranslation = styleValue;
- propertyValue = { mbgl::style::Function<std::array<float, 2>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconTranslation = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue,
- @"Setting iconTranslation to a function should update icon-translate.");
- XCTAssertEqualObjects(layer.iconTranslation, styleValue,
- @"iconTranslation should round-trip functions.");
+ @"Setting iconTranslation to a camera function should update icon-translate.");
+ XCTAssertEqualObjects(layer.iconTranslation, functionStyleValue,
+ @"iconTranslation should round-trip camera functions.");
+
+
layer.iconTranslation = nil;
XCTAssertTrue(rawLayer->getIconTranslate().isUndefined(),
@@ -1433,32 +1599,38 @@
@"icon-translate-anchor should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.iconTranslationAnchor;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorViewport]];
- layer.iconTranslationAnchor = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorViewport]];
+ layer.iconTranslationAnchor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue,
@"Setting iconTranslationAnchor to a constant value should update icon-translate-anchor.");
- XCTAssertEqualObjects(layer.iconTranslationAnchor, styleValue,
+ XCTAssertEqualObjects(layer.iconTranslationAnchor, constantStyleValue,
@"iconTranslationAnchor should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.iconTranslationAnchor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::TranslateAnchorType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.iconTranslationAnchor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = { {{18, mbgl::style::TranslateAnchorType::Viewport}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
+
XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue,
- @"Setting iconTranslationAnchor to a function should update icon-translate-anchor.");
- XCTAssertEqualObjects(layer.iconTranslationAnchor, styleValue,
- @"iconTranslationAnchor should round-trip functions.");
+ @"Setting iconTranslationAnchor to a camera function should update icon-translate-anchor.");
+ XCTAssertEqualObjects(layer.iconTranslationAnchor, functionStyleValue,
+ @"iconTranslationAnchor should round-trip camera functions.");
+
+
layer.iconTranslationAnchor = nil;
XCTAssertTrue(rawLayer->getIconTranslateAnchor().isUndefined(),
@"Unsetting iconTranslationAnchor should return icon-translate-anchor to the default value.");
XCTAssertEqualObjects(layer.iconTranslationAnchor, defaultStyleValue,
@"iconTranslationAnchor should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
// text-color
@@ -1467,26 +1639,26 @@
@"text-color should be unset initially.");
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.textColor;
- MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
- layer.textColor = styleValue;
+ MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
+ layer.textColor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
@"Setting textColor to a constant value should update text-color.");
- XCTAssertEqualObjects(layer.textColor, styleValue,
+ XCTAssertEqualObjects(layer.textColor, constantStyleValue,
@"textColor should round-trip constant values.");
- styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textColor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::Color> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textColor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextColor(), propertyValue,
- @"Setting textColor to a function should update text-color.");
- XCTAssertEqualObjects(layer.textColor, styleValue,
- @"textColor should round-trip functions.");
+ @"Setting textColor to a camera function should update text-color.");
+ XCTAssertEqualObjects(layer.textColor, functionStyleValue,
+ @"textColor should round-trip camera functions.");
+
+
layer.textColor = nil;
XCTAssertTrue(rawLayer->getTextColor().isUndefined(),
@@ -1501,26 +1673,26 @@
@"text-halo-blur should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textHaloBlur;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textHaloBlur = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textHaloBlur = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
@"Setting textHaloBlur to a constant value should update text-halo-blur.");
- XCTAssertEqualObjects(layer.textHaloBlur, styleValue,
+ XCTAssertEqualObjects(layer.textHaloBlur, constantStyleValue,
@"textHaloBlur should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textHaloBlur = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textHaloBlur = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue,
- @"Setting textHaloBlur to a function should update text-halo-blur.");
- XCTAssertEqualObjects(layer.textHaloBlur, styleValue,
- @"textHaloBlur should round-trip functions.");
+ @"Setting textHaloBlur to a camera function should update text-halo-blur.");
+ XCTAssertEqualObjects(layer.textHaloBlur, functionStyleValue,
+ @"textHaloBlur should round-trip camera functions.");
+
+
layer.textHaloBlur = nil;
XCTAssertTrue(rawLayer->getTextHaloBlur().isUndefined(),
@@ -1535,26 +1707,26 @@
@"text-halo-color should be unset initially.");
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.textHaloColor;
- MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
- layer.textHaloColor = styleValue;
+ MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
+ layer.textHaloColor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
@"Setting textHaloColor to a constant value should update text-halo-color.");
- XCTAssertEqualObjects(layer.textHaloColor, styleValue,
+ XCTAssertEqualObjects(layer.textHaloColor, constantStyleValue,
@"textHaloColor should round-trip constant values.");
- styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textHaloColor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::Color> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textHaloColor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue,
- @"Setting textHaloColor to a function should update text-halo-color.");
- XCTAssertEqualObjects(layer.textHaloColor, styleValue,
- @"textHaloColor should round-trip functions.");
+ @"Setting textHaloColor to a camera function should update text-halo-color.");
+ XCTAssertEqualObjects(layer.textHaloColor, functionStyleValue,
+ @"textHaloColor should round-trip camera functions.");
+
+
layer.textHaloColor = nil;
XCTAssertTrue(rawLayer->getTextHaloColor().isUndefined(),
@@ -1569,26 +1741,26 @@
@"text-halo-width should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textHaloWidth;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textHaloWidth = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textHaloWidth = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
@"Setting textHaloWidth to a constant value should update text-halo-width.");
- XCTAssertEqualObjects(layer.textHaloWidth, styleValue,
+ XCTAssertEqualObjects(layer.textHaloWidth, constantStyleValue,
@"textHaloWidth should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textHaloWidth = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textHaloWidth = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue,
- @"Setting textHaloWidth to a function should update text-halo-width.");
- XCTAssertEqualObjects(layer.textHaloWidth, styleValue,
- @"textHaloWidth should round-trip functions.");
+ @"Setting textHaloWidth to a camera function should update text-halo-width.");
+ XCTAssertEqualObjects(layer.textHaloWidth, functionStyleValue,
+ @"textHaloWidth should round-trip camera functions.");
+
+
layer.textHaloWidth = nil;
XCTAssertTrue(rawLayer->getTextHaloWidth().isUndefined(),
@@ -1603,26 +1775,26 @@
@"text-opacity should be unset initially.");
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.textOpacity;
- MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
- layer.textOpacity = styleValue;
+ MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
+ layer.textOpacity = constantStyleValue;
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
@"Setting textOpacity to a constant value should update text-opacity.");
- XCTAssertEqualObjects(layer.textOpacity, styleValue,
+ XCTAssertEqualObjects(layer.textOpacity, constantStyleValue,
@"textOpacity should round-trip constant values.");
- styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textOpacity = styleValue;
- propertyValue = { mbgl::style::Function<float> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textOpacity = functionStyleValue;
+
+ mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
+ propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue,
- @"Setting textOpacity to a function should update text-opacity.");
- XCTAssertEqualObjects(layer.textOpacity, styleValue,
- @"textOpacity should round-trip functions.");
+ @"Setting textOpacity to a camera function should update text-opacity.");
+ XCTAssertEqualObjects(layer.textOpacity, functionStyleValue,
+ @"textOpacity should round-trip camera functions.");
+
+
layer.textOpacity = nil;
XCTAssertTrue(rawLayer->getTextOpacity().isUndefined(),
@@ -1637,32 +1809,32 @@
@"text-translate should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textTranslation;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
#if TARGET_OS_IPHONE
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
#else
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
#endif
];
- layer.textTranslation = styleValue;
+ layer.textTranslation = constantStyleValue;
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue,
@"Setting textTranslation to a constant value should update text-translate.");
- XCTAssertEqualObjects(layer.textTranslation, styleValue,
+ XCTAssertEqualObjects(layer.textTranslation, constantStyleValue,
@"textTranslation should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textTranslation = styleValue;
- propertyValue = { mbgl::style::Function<std::array<float, 2>> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textTranslation = functionStyleValue;
+
+ mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
+ propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue,
- @"Setting textTranslation to a function should update text-translate.");
- XCTAssertEqualObjects(layer.textTranslation, styleValue,
- @"textTranslation should round-trip functions.");
+ @"Setting textTranslation to a camera function should update text-translate.");
+ XCTAssertEqualObjects(layer.textTranslation, functionStyleValue,
+ @"textTranslation should round-trip camera functions.");
+
+
layer.textTranslation = nil;
XCTAssertTrue(rawLayer->getTextTranslate().isUndefined(),
@@ -1677,32 +1849,38 @@
@"text-translate-anchor should be unset initially.");
MGLStyleValue<NSValue *> *defaultStyleValue = layer.textTranslationAnchor;
- MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorViewport]];
- layer.textTranslationAnchor = styleValue;
+ MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorViewport]];
+ layer.textTranslationAnchor = constantStyleValue;
mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue,
@"Setting textTranslationAnchor to a constant value should update text-translate-anchor.");
- XCTAssertEqualObjects(layer.textTranslationAnchor, styleValue,
+ XCTAssertEqualObjects(layer.textTranslationAnchor, constantStyleValue,
@"textTranslationAnchor should round-trip constant values.");
- styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
- @18: styleValue,
- }];
- layer.textTranslationAnchor = styleValue;
- propertyValue = { mbgl::style::Function<mbgl::style::TranslateAnchorType> {
- {{ 18, propertyValue.asConstant() }},
- 1,
- }};
+ MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
+ layer.textTranslationAnchor = functionStyleValue;
+
+ mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = { {{18, mbgl::style::TranslateAnchorType::Viewport}} };
+ propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
+
XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue,
- @"Setting textTranslationAnchor to a function should update text-translate-anchor.");
- XCTAssertEqualObjects(layer.textTranslationAnchor, styleValue,
- @"textTranslationAnchor should round-trip functions.");
+ @"Setting textTranslationAnchor to a camera function should update text-translate-anchor.");
+ XCTAssertEqualObjects(layer.textTranslationAnchor, functionStyleValue,
+ @"textTranslationAnchor should round-trip camera functions.");
+
+
layer.textTranslationAnchor = nil;
XCTAssertTrue(rawLayer->getTextTranslateAnchor().isUndefined(),
@"Unsetting textTranslationAnchor should return text-translate-anchor to the default value.");
XCTAssertEqualObjects(layer.textTranslationAnchor, defaultStyleValue,
@"textTranslationAnchor should return the default value after being unset.");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
+
+ functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
+ XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
}
}