diff --git a/Apps/Examples/Examples.xcodeproj/xcshareddata/xcschemes/Examples.xcscheme b/Apps/Examples/Examples.xcodeproj/xcshareddata/xcschemes/Examples.xcscheme index 5884e48d2808..707b60f156dd 100644 --- a/Apps/Examples/Examples.xcodeproj/xcshareddata/xcschemes/Examples.xcscheme +++ b/Apps/Examples/Examples.xcodeproj/xcshareddata/xcschemes/Examples.xcscheme @@ -4,8 +4,7 @@ version = "1.7"> + buildImplicitDependencies = "YES"> - - - - - - + shouldUseLaunchSchemeArgsEnv = "NO"> - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - Annotation.feature + /// Secondly, it tries to read the value from `layerProperties` dictionary from annotation manager. + /// In the end if the property is not set either on annotation or on annotation manager we just use default value from the style.gst let dataDrivenProperties = Dictionary( - uniqueKeysWithValues: dataDrivenLayerPropertyKeys - .map { (key) -> (String, Any) in - (key, ["get", key, ["get", "layerProperties"]] as [Any]) - }) + uniqueKeysWithValues: dataDrivenLayerPropertyKeys.map { (key) -> (String, Any) in (key, [ + "coalesce", + ["get", key, ["get", "layerProperties"]], + layerProperties[key] ?? StyleManager.layerPropertyDefaultValue(for: self.layerType, property: key).value + ] as [Any])}) // Merge the common layer properties - let newLayerProperties = dataDrivenProperties.merging(layerProperties, uniquingKeysWith: { $1 }) + let newLayerProperties = dataDrivenProperties.merging(layerProperties, uniquingKeysWith: { dataDriven, _ in dataDriven }) // Construct the properties dictionary to reset any properties that are no longer used let unusedPropertyKeys = previouslySetLayerPropertyKeys.subtracting(newLayerProperties.keys) diff --git a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift index b504d885f0ac..01f4af4a8566 100644 --- a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift @@ -41,6 +41,26 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern // MARK: - Common layer properties + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + public var circleSortKey: Double? { + get { impl.layerProperties["circle-sort-key"] as? Double } + set { impl.layerProperties["circle-sort-key"] = newValue } + } + + /// Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. + /// Default value: 0. + public var circleBlur: Double? { + get { impl.layerProperties["circle-blur"] as? Double } + set { impl.layerProperties["circle-blur"] = newValue } + } + + /// The fill color of the circle. + /// Default value: "#000000". + public var circleColor: StyleColor? { + get { impl.layerProperties["circle-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["circle-color"] = newValue?.rawValue } + } + /// Controls the intensity of light emitted on the source features. /// Default value: 0. Minimum value: 0. public var circleEmissiveStrength: Double? { @@ -48,6 +68,13 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern set { impl.layerProperties["circle-emissive-strength"] = newValue } } + /// The opacity at which the circle will be drawn. + /// Default value: 1. Value range: [0, 1] + public var circleOpacity: Double? { + get { impl.layerProperties["circle-opacity"] as? Double } + set { impl.layerProperties["circle-opacity"] = newValue } + } + /// Orientation of circle when map is pitched. /// Default value: "viewport". public var circlePitchAlignment: CirclePitchAlignment? { @@ -62,6 +89,34 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern set { impl.layerProperties["circle-pitch-scale"] = newValue?.rawValue } } + /// Circle radius. + /// Default value: 5. Minimum value: 0. + public var circleRadius: Double? { + get { impl.layerProperties["circle-radius"] as? Double } + set { impl.layerProperties["circle-radius"] = newValue } + } + + /// The stroke color of the circle. + /// Default value: "#000000". + public var circleStrokeColor: StyleColor? { + get { impl.layerProperties["circle-stroke-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["circle-stroke-color"] = newValue?.rawValue } + } + + /// The opacity of the circle's stroke. + /// Default value: 1. Value range: [0, 1] + public var circleStrokeOpacity: Double? { + get { impl.layerProperties["circle-stroke-opacity"] as? Double } + set { impl.layerProperties["circle-stroke-opacity"] = newValue } + } + + /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. + /// Default value: 0. Minimum value: 0. + public var circleStrokeWidth: Double? { + get { impl.layerProperties["circle-stroke-width"] as? Double } + set { impl.layerProperties["circle-stroke-width"] = newValue } + } + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. public var circleTranslate: [Double]? { @@ -84,7 +139,6 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern get { impl.layerProperties["slot"] as? String } set { impl.layerProperties["slot"] = newValue } } - } // End of generated file. diff --git a/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift index 2eda773ac68b..ecbdb367008a 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift @@ -93,6 +93,13 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-allow-overlap"] = newValue } } + /// Part of the icon placed closest to the anchor. + /// Default value: "center". + public var iconAnchor: IconAnchor? { + get { impl.layerProperties["icon-anchor"].flatMap { $0 as? String }.flatMap(IconAnchor.init(rawValue:)) } + set { impl.layerProperties["icon-anchor"] = newValue?.rawValue } + } + /// If true, other symbols can be visible even if they collide with the icon. /// Default value: false. public var iconIgnorePlacement: Bool? { @@ -100,6 +107,12 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-ignore-placement"] = newValue } } + /// Name of image in sprite to use for drawing an image background. + public var iconImage: String? { + get { impl.layerProperties["icon-image"] as? String } + set { impl.layerProperties["icon-image"] = newValue } + } + /// If true, the icon may be flipped to prevent it from being rendered upside-down. /// Default value: false. public var iconKeepUpright: Bool? { @@ -107,6 +120,13 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-keep-upright"] = newValue } } + /// Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up. + /// Default value: [0,0]. + public var iconOffset: [Double]? { + get { impl.layerProperties["icon-offset"] as? [Double] } + set { impl.layerProperties["icon-offset"] = newValue } + } + /// If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not. /// Default value: false. public var iconOptional: Bool? { @@ -128,6 +148,13 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-pitch-alignment"] = newValue?.rawValue } } + /// Rotates the icon clockwise. + /// Default value: 0. + public var iconRotate: Double? { + get { impl.layerProperties["icon-rotate"] as? Double } + set { impl.layerProperties["icon-rotate"] = newValue } + } + /// In combination with `symbol-placement`, determines the rotation behavior of icons. /// Default value: "auto". public var iconRotationAlignment: IconRotationAlignment? { @@ -135,6 +162,27 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-rotation-alignment"] = newValue?.rawValue } } + /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. + /// Default value: 1. Minimum value: 0. + public var iconSize: Double? { + get { impl.layerProperties["icon-size"] as? Double } + set { impl.layerProperties["icon-size"] = newValue } + } + + /// Scales the icon to fit around the associated text. + /// Default value: "none". + public var iconTextFit: IconTextFit? { + get { impl.layerProperties["icon-text-fit"].flatMap { $0 as? String }.flatMap(IconTextFit.init(rawValue:)) } + set { impl.layerProperties["icon-text-fit"] = newValue?.rawValue } + } + + /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. + /// Default value: [0,0,0,0]. + public var iconTextFitPadding: [Double]? { + get { impl.layerProperties["icon-text-fit-padding"] as? [Double] } + set { impl.layerProperties["icon-text-fit-padding"] = newValue } + } + /// If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries. /// Default value: false. public var symbolAvoidEdges: Bool? { @@ -149,6 +197,12 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["symbol-placement"] = newValue?.rawValue } } + /// Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `icon-allow-overlap` or `text-allow-overlap` is `false`, features with a lower sort key will have priority during placement. When `icon-allow-overlap` or `text-allow-overlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key. + public var symbolSortKey: Double? { + get { impl.layerProperties["symbol-sort-key"] as? Double } + set { impl.layerProperties["symbol-sort-key"] = newValue } + } + /// Distance between two symbol anchors. /// Default value: 250. Minimum value: 1. public var symbolSpacing: Double? { @@ -177,6 +231,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-allow-overlap"] = newValue } } + /// Part of the text placed closest to the anchor. + /// Default value: "center". + public var textAnchor: TextAnchor? { + get { impl.layerProperties["text-anchor"].flatMap { $0 as? String }.flatMap(TextAnchor.init(rawValue:)) } + set { impl.layerProperties["text-anchor"] = newValue?.rawValue } + } + + /// Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options. SDF images are not supported in formatted text and will be ignored. + /// Default value: "". + public var textField: String? { + get { impl.layerProperties["text-field"] as? String } + set { impl.layerProperties["text-field"] = newValue } + } + /// Font stack to use for displaying text. public var textFont: [String]? { get { (impl.layerProperties["text-font"] as? [Any])?[1] as? [String] } @@ -190,6 +258,13 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-ignore-placement"] = newValue } } + /// Text justification options. + /// Default value: "center". + public var textJustify: TextJustify? { + get { impl.layerProperties["text-justify"].flatMap { $0 as? String }.flatMap(TextJustify.init(rawValue:)) } + set { impl.layerProperties["text-justify"] = newValue?.rawValue } + } + /// If true, the text may be flipped vertically to prevent it from being rendered upside-down. /// Default value: true. public var textKeepUpright: Bool? { @@ -197,6 +272,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-keep-upright"] = newValue } } + /// Text tracking amount. + /// Default value: 0. + public var textLetterSpacing: Double? { + get { impl.layerProperties["text-letter-spacing"] as? Double } + set { impl.layerProperties["text-letter-spacing"] = newValue } + } + + /// Text leading value for multi-line text. + /// Default value: 1.2. + public var textLineHeight: Double? { + get { impl.layerProperties["text-line-height"] as? Double } + set { impl.layerProperties["text-line-height"] = newValue } + } + /// Maximum angle change between adjacent characters. /// Default value: 45. public var textMaxAngle: Double? { @@ -204,6 +293,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-max-angle"] = newValue } } + /// The maximum line width for text wrapping. + /// Default value: 10. Minimum value: 0. + public var textMaxWidth: Double? { + get { impl.layerProperties["text-max-width"] as? Double } + set { impl.layerProperties["text-max-width"] = newValue } + } + + /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. + /// Default value: [0,0]. + public var textOffset: [Double]? { + get { impl.layerProperties["text-offset"] as? [Double] } + set { impl.layerProperties["text-offset"] = newValue } + } + /// If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. /// Default value: false. public var textOptional: Bool? { @@ -225,6 +328,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-pitch-alignment"] = newValue?.rawValue } } + /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. + /// Default value: 0. + public var textRadialOffset: Double? { + get { impl.layerProperties["text-radial-offset"] as? Double } + set { impl.layerProperties["text-radial-offset"] = newValue } + } + + /// Rotates the text clockwise. + /// Default value: 0. + public var textRotate: Double? { + get { impl.layerProperties["text-rotate"] as? Double } + set { impl.layerProperties["text-rotate"] = newValue } + } + /// In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text. /// Default value: "auto". public var textRotationAlignment: TextRotationAlignment? { @@ -232,6 +349,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-rotation-alignment"] = newValue?.rawValue } } + /// Font size. + /// Default value: 16. Minimum value: 0. + public var textSize: Double? { + get { impl.layerProperties["text-size"] as? Double } + set { impl.layerProperties["text-size"] = newValue } + } + + /// Specifies how to capitalize text, similar to the CSS `text-transform` property. + /// Default value: "none". + public var textTransform: TextTransform? { + get { impl.layerProperties["text-transform"].flatMap { $0 as? String }.flatMap(TextTransform.init(rawValue:)) } + set { impl.layerProperties["text-transform"] = newValue?.rawValue } + } + /// To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`. public var textVariableAnchor: [TextAnchor]? { get { impl.layerProperties["text-variable-anchor"].flatMap { $0 as? [String] }.flatMap { $0.compactMap(TextAnchor.init(rawValue:)) } } @@ -244,6 +375,13 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["text-writing-mode"] = newValue?.map(\.rawValue) } } + /// The color of the icon. This can only be used with [SDF icons](/help/troubleshooting/using-recolorable-images-in-mapbox-maps/). + /// Default value: "#000000". + public var iconColor: StyleColor? { + get { impl.layerProperties["icon-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["icon-color"] = newValue?.rawValue } + } + /// Increase or reduce the saturation of the symbol icon. /// Default value: 0. Value range: [-1, 1] public var iconColorSaturation: Double? { @@ -251,6 +389,55 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-color-saturation"] = newValue } } + /// Controls the intensity of light emitted on the source features. + /// Default value: 1. Minimum value: 0. + public var iconEmissiveStrength: Double? { + get { impl.layerProperties["icon-emissive-strength"] as? Double } + set { impl.layerProperties["icon-emissive-strength"] = newValue } + } + + /// Fade out the halo towards the outside. + /// Default value: 0. Minimum value: 0. + public var iconHaloBlur: Double? { + get { impl.layerProperties["icon-halo-blur"] as? Double } + set { impl.layerProperties["icon-halo-blur"] = newValue } + } + + /// The color of the icon's halo. Icon halos can only be used with [SDF icons](/help/troubleshooting/using-recolorable-images-in-mapbox-maps/). + /// Default value: "rgba(0, 0, 0, 0)". + public var iconHaloColor: StyleColor? { + get { impl.layerProperties["icon-halo-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["icon-halo-color"] = newValue?.rawValue } + } + + /// Distance of halo to the icon outline. + /// Default value: 0. Minimum value: 0. + public var iconHaloWidth: Double? { + get { impl.layerProperties["icon-halo-width"] as? Double } + set { impl.layerProperties["icon-halo-width"] = newValue } + } + + /// Controls the transition progress between the image variants of icon-image. Zero means the first variant is used, one is the second, and in between they are blended together. + /// Default value: 0. Value range: [0, 1] + public var iconImageCrossFade: Double? { + get { impl.layerProperties["icon-image-cross-fade"] as? Double } + set { impl.layerProperties["icon-image-cross-fade"] = newValue } + } + + /// The opacity at which the icon will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. + /// Default value: 0. Value range: [0, 1] + public var iconOcclusionOpacity: Double? { + get { impl.layerProperties["icon-occlusion-opacity"] as? Double } + set { impl.layerProperties["icon-occlusion-opacity"] = newValue } + } + + /// The opacity at which the icon will be drawn. + /// Default value: 1. Value range: [0, 1] + public var iconOpacity: Double? { + get { impl.layerProperties["icon-opacity"] as? Double } + set { impl.layerProperties["icon-opacity"] = newValue } + } + /// Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. /// Default value: [0,0]. public var iconTranslate: [Double]? { @@ -265,6 +452,55 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna set { impl.layerProperties["icon-translate-anchor"] = newValue?.rawValue } } + /// The color with which the text will be drawn. + /// Default value: "#000000". + public var textColor: StyleColor? { + get { impl.layerProperties["text-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["text-color"] = newValue?.rawValue } + } + + /// Controls the intensity of light emitted on the source features. + /// Default value: 1. Minimum value: 0. + public var textEmissiveStrength: Double? { + get { impl.layerProperties["text-emissive-strength"] as? Double } + set { impl.layerProperties["text-emissive-strength"] = newValue } + } + + /// The halo's fadeout distance towards the outside. + /// Default value: 0. Minimum value: 0. + public var textHaloBlur: Double? { + get { impl.layerProperties["text-halo-blur"] as? Double } + set { impl.layerProperties["text-halo-blur"] = newValue } + } + + /// The color of the text's halo, which helps it stand out from backgrounds. + /// Default value: "rgba(0, 0, 0, 0)". + public var textHaloColor: StyleColor? { + get { impl.layerProperties["text-halo-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["text-halo-color"] = newValue?.rawValue } + } + + /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. + /// Default value: 0. Minimum value: 0. + public var textHaloWidth: Double? { + get { impl.layerProperties["text-halo-width"] as? Double } + set { impl.layerProperties["text-halo-width"] = newValue } + } + + /// The opacity at which the text will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. + /// Default value: 0. Value range: [0, 1] + public var textOcclusionOpacity: Double? { + get { impl.layerProperties["text-occlusion-opacity"] as? Double } + set { impl.layerProperties["text-occlusion-opacity"] = newValue } + } + + /// The opacity at which the text will be drawn. + /// Default value: 1. Value range: [0, 1] + public var textOpacity: Double? { + get { impl.layerProperties["text-opacity"] as? Double } + set { impl.layerProperties["text-opacity"] = newValue } + } + /// Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. /// Default value: [0,0]. public var textTranslate: [Double]? { @@ -287,35 +523,6 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna get { impl.layerProperties["slot"] as? String } set { impl.layerProperties["slot"] = newValue } } - - /// Scales the icon to fit around the associated text. - @available(*, deprecated, message: "icon-text-fit property is now data driven, use `PointAnnotation.iconTextFit` instead.") - public var iconTextFit: IconTextFit? { - get { impl.layerProperties["icon-text-fit"].flatMap { $0 as? String }.flatMap(IconTextFit.init(rawValue:)) } - set { impl.layerProperties["icon-text-fit"] = newValue?.rawValue } - } - - /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. - @available(*, deprecated, message: "icon-text-fit-padding property is now data driven, use `PointAnnotation.iconTextFitPadding` instead.") - public var iconTextFitPadding: [Double]? { - get {impl.layerProperties["icon-text-fit-padding"] as? [Double] } - set { impl.layerProperties["icon-text-fit-padding"] = newValue } - } - - /// The opacity at which the icon will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. - /// Default value: 0. Value range: [0, 1] - @available(*, deprecated, message: "icon-occlusion-opacity property is now data driven, use `PointAnnotation.iconOcclusionOpacity` instead.") - public var iconOcclusionOpacity: Double? { - get { impl.layerProperties["icon-occlusion-opacity"] as? Double } - set { impl.layerProperties["icon-occlusion-opacity"] = newValue } - } - /// The opacity at which the text will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. - /// Default value: 0. Value range: [0, 1] - @available(*, deprecated, message: "text-occlusion-opacity property is now data driven, use `PointAnnotation.textOcclusionOpacity` instead.") - public var textOcclusionOpacity: Double? { - get { impl.layerProperties["text-occlusion-opacity"] as? Double } - set { impl.layerProperties["text-occlusion-opacity"] = newValue } - } } // End of generated file. diff --git a/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift index 1f7a5e8b074a..ae4313f3189f 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift @@ -41,6 +41,12 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter // MARK: - Common layer properties + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + public var fillSortKey: Double? { + get { impl.layerProperties["fill-sort-key"] as? Double } + set { impl.layerProperties["fill-sort-key"] = newValue } + } + /// Whether or not the fill should be antialiased. /// Default value: true. public var fillAntialias: Bool? { @@ -48,6 +54,13 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter set { impl.layerProperties["fill-antialias"] = newValue } } + /// The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used. + /// Default value: "#000000". + public var fillColor: StyleColor? { + get { impl.layerProperties["fill-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["fill-color"] = newValue?.rawValue } + } + /// Controls the intensity of light emitted on the source features. /// Default value: 0. Minimum value: 0. public var fillEmissiveStrength: Double? { @@ -55,6 +68,25 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter set { impl.layerProperties["fill-emissive-strength"] = newValue } } + /// The opacity of the entire fill layer. In contrast to the `fill-color`, this value will also affect the 1px stroke around the fill, if the stroke is used. + /// Default value: 1. Value range: [0, 1] + public var fillOpacity: Double? { + get { impl.layerProperties["fill-opacity"] as? Double } + set { impl.layerProperties["fill-opacity"] = newValue } + } + + /// The outline color of the fill. Matches the value of `fill-color` if unspecified. + public var fillOutlineColor: StyleColor? { + get { impl.layerProperties["fill-outline-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["fill-outline-color"] = newValue?.rawValue } + } + + /// Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. + public var fillPattern: String? { + get { impl.layerProperties["fill-pattern"] as? String } + set { impl.layerProperties["fill-pattern"] = newValue } + } + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. public var fillTranslate: [Double]? { @@ -77,7 +109,6 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter get { impl.layerProperties["slot"] as? String } set { impl.layerProperties["slot"] = newValue } } - } // End of generated file. diff --git a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift index 790844c85450..41eece4c7d9f 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift @@ -48,6 +48,13 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-cap"] = newValue?.rawValue } } + /// The display of lines when joining. + /// Default value: "miter". + public var lineJoin: LineJoin? { + get { impl.layerProperties["line-join"].flatMap { $0 as? String }.flatMap(LineJoin.init(rawValue:)) } + set { impl.layerProperties["line-join"] = newValue?.rawValue } + } + /// Used to automatically convert miter joins to bevel joins for sharp angles. /// Default value: 2. public var lineMiterLimit: Double? { @@ -62,6 +69,46 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-round-limit"] = newValue } } + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + public var lineSortKey: Double? { + get { impl.layerProperties["line-sort-key"] as? Double } + set { impl.layerProperties["line-sort-key"] = newValue } + } + + /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + public var lineZOffset: Double? { + get { impl.layerProperties["line-z-offset"] as? Double } + set { impl.layerProperties["line-z-offset"] = newValue } + } + + /// Blur applied to the line, in pixels. + /// Default value: 0. Minimum value: 0. + public var lineBlur: Double? { + get { impl.layerProperties["line-blur"] as? Double } + set { impl.layerProperties["line-blur"] = newValue } + } + + /// The color of the line border. If line-border-width is greater than zero and the alpha value of this color is 0 (default), the color for the border will be selected automatically based on the line color. + /// Default value: "rgba(0, 0, 0, 0)". + public var lineBorderColor: StyleColor? { + get { impl.layerProperties["line-border-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["line-border-color"] = newValue?.rawValue } + } + + /// The width of the line border. A value of zero means no border. + /// Default value: 0. Minimum value: 0. + public var lineBorderWidth: Double? { + get { impl.layerProperties["line-border-width"] as? Double } + set { impl.layerProperties["line-border-width"] = newValue } + } + + /// The color with which the line will be drawn. + /// Default value: "#000000". + public var lineColor: StyleColor? { + get { impl.layerProperties["line-color"].flatMap { $0 as? String }.flatMap(StyleColor.init(rawValue:)) } + set { impl.layerProperties["line-color"] = newValue?.rawValue } + } + /// Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. /// Minimum value: 0. public var lineDasharray: [Double]? { @@ -83,6 +130,13 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-emissive-strength"] = newValue } } + /// Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. + /// Default value: 0. Minimum value: 0. + public var lineGapWidth: Double? { + get { impl.layerProperties["line-gap-width"] as? Double } + set { impl.layerProperties["line-gap-width"] = newValue } + } + /// Opacity multiplier (multiplies line-opacity value) of the line part that is occluded by 3D objects. Value 0 hides occluded part, value 1 means the same opacity as non-occluded part. The property is not supported when `line-opacity` has data-driven styling. /// Default value: 0. Value range: [0, 1] public var lineOcclusionOpacity: Double? { @@ -90,6 +144,26 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-occlusion-opacity"] = newValue } } + /// The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset. + /// Default value: 0. + public var lineOffset: Double? { + get { impl.layerProperties["line-offset"] as? Double } + set { impl.layerProperties["line-offset"] = newValue } + } + + /// The opacity at which the line will be drawn. + /// Default value: 1. Value range: [0, 1] + public var lineOpacity: Double? { + get { impl.layerProperties["line-opacity"] as? Double } + set { impl.layerProperties["line-opacity"] = newValue } + } + + /// Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. + public var linePattern: String? { + get { impl.layerProperties["line-pattern"] as? String } + set { impl.layerProperties["line-pattern"] = newValue } + } + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. public var lineTranslate: [Double]? { @@ -125,6 +199,13 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-trim-offset"] = newValue } } + /// Stroke thickness. + /// Default value: 1. Minimum value: 0. + public var lineWidth: Double? { + get { impl.layerProperties["line-width"] as? Double } + set { impl.layerProperties["line-width"] = newValue } + } + /// Slot for the underlying layer. /// /// Use this property to position the annotations relative to other map features if you use Mapbox Standard Style. @@ -133,7 +214,6 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte get { impl.layerProperties["slot"] as? String } set { impl.layerProperties["slot"] = newValue } } - } // End of generated file. diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift index b7c2b7cf694a..bd93558f61c7 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift @@ -35,6 +35,8 @@ /// .slot("top") /// } /// ``` +import UIKit + @available(iOS 13.0, *) public struct CircleAnnotationGroup { let annotations: [(ID, CircleAnnotation)] @@ -75,9 +77,17 @@ public struct CircleAnnotationGroup } private func updateProperties(manager: CircleAnnotationManager) { + assign(manager, \.circleSortKey, value: circleSortKey) + assign(manager, \.circleBlur, value: circleBlur) + assign(manager, \.circleColor, value: circleColor) assign(manager, \.circleEmissiveStrength, value: circleEmissiveStrength) + assign(manager, \.circleOpacity, value: circleOpacity) assign(manager, \.circlePitchAlignment, value: circlePitchAlignment) assign(manager, \.circlePitchScale, value: circlePitchScale) + assign(manager, \.circleRadius, value: circleRadius) + assign(manager, \.circleStrokeColor, value: circleStrokeColor) + assign(manager, \.circleStrokeOpacity, value: circleStrokeOpacity) + assign(manager, \.circleStrokeWidth, value: circleStrokeWidth) assign(manager, \.circleTranslate, value: circleTranslate) assign(manager, \.circleTranslateAnchor, value: circleTranslateAnchor) assign(manager, \.slot, value: slot) @@ -85,6 +95,26 @@ public struct CircleAnnotationGroup // MARK: - Common layer properties + private var circleSortKey: Double? + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + public func circleSortKey(_ newValue: Double) -> Self { + with(self, setter(\.circleSortKey, newValue)) + } + + private var circleBlur: Double? + /// Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. + /// Default value: 0. + public func circleBlur(_ newValue: Double) -> Self { + with(self, setter(\.circleBlur, newValue)) + } + + private var circleColor: StyleColor? + /// The fill color of the circle. + /// Default value: "#000000". + public func circleColor(_ color: UIColor) -> Self { + with(self, setter(\.circleColor, StyleColor(color))) + } + private var circleEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. /// Default value: 0. Minimum value: 0. @@ -92,6 +122,13 @@ public struct CircleAnnotationGroup with(self, setter(\.circleEmissiveStrength, newValue)) } + private var circleOpacity: Double? + /// The opacity at which the circle will be drawn. + /// Default value: 1. Value range: [0, 1] + public func circleOpacity(_ newValue: Double) -> Self { + with(self, setter(\.circleOpacity, newValue)) + } + private var circlePitchAlignment: CirclePitchAlignment? /// Orientation of circle when map is pitched. /// Default value: "viewport". @@ -106,6 +143,34 @@ public struct CircleAnnotationGroup with(self, setter(\.circlePitchScale, newValue)) } + private var circleRadius: Double? + /// Circle radius. + /// Default value: 5. Minimum value: 0. + public func circleRadius(_ newValue: Double) -> Self { + with(self, setter(\.circleRadius, newValue)) + } + + private var circleStrokeColor: StyleColor? + /// The stroke color of the circle. + /// Default value: "#000000". + public func circleStrokeColor(_ color: UIColor) -> Self { + with(self, setter(\.circleStrokeColor, StyleColor(color))) + } + + private var circleStrokeOpacity: Double? + /// The opacity of the circle's stroke. + /// Default value: 1. Value range: [0, 1] + public func circleStrokeOpacity(_ newValue: Double) -> Self { + with(self, setter(\.circleStrokeOpacity, newValue)) + } + + private var circleStrokeWidth: Double? + /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. + /// Default value: 0. Minimum value: 0. + public func circleStrokeWidth(_ newValue: Double) -> Self { + with(self, setter(\.circleStrokeWidth, newValue)) + } + private var circleTranslate: [Double]? /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift index 137301fa4499..b7e3bd863f30 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift @@ -33,6 +33,8 @@ /// .slot("top") /// } /// ``` +import UIKit + @available(iOS 13.0, *) public struct PointAnnotationGroup { let annotations: [(ID, PointAnnotation)] @@ -74,31 +76,65 @@ public struct PointAnnotationGroup { private func updateProperties(manager: PointAnnotationManager) { assign(manager, \.iconAllowOverlap, value: iconAllowOverlap) + assign(manager, \.iconAnchor, value: iconAnchor) assign(manager, \.iconIgnorePlacement, value: iconIgnorePlacement) + assign(manager, \.iconImage, value: iconImage) assign(manager, \.iconKeepUpright, value: iconKeepUpright) + assign(manager, \.iconOffset, value: iconOffset) assign(manager, \.iconOptional, value: iconOptional) assign(manager, \.iconPadding, value: iconPadding) assign(manager, \.iconPitchAlignment, value: iconPitchAlignment) + assign(manager, \.iconRotate, value: iconRotate) assign(manager, \.iconRotationAlignment, value: iconRotationAlignment) + assign(manager, \.iconSize, value: iconSize) + assign(manager, \.iconTextFit, value: iconTextFit) + assign(manager, \.iconTextFitPadding, value: iconTextFitPadding) assign(manager, \.symbolAvoidEdges, value: symbolAvoidEdges) assign(manager, \.symbolPlacement, value: symbolPlacement) + assign(manager, \.symbolSortKey, value: symbolSortKey) assign(manager, \.symbolSpacing, value: symbolSpacing) assign(manager, \.symbolZElevate, value: symbolZElevate) assign(manager, \.symbolZOrder, value: symbolZOrder) assign(manager, \.textAllowOverlap, value: textAllowOverlap) + assign(manager, \.textAnchor, value: textAnchor) + assign(manager, \.textField, value: textField) assign(manager, \.textFont, value: textFont) assign(manager, \.textIgnorePlacement, value: textIgnorePlacement) + assign(manager, \.textJustify, value: textJustify) assign(manager, \.textKeepUpright, value: textKeepUpright) + assign(manager, \.textLetterSpacing, value: textLetterSpacing) + assign(manager, \.textLineHeight, value: textLineHeight) assign(manager, \.textMaxAngle, value: textMaxAngle) + assign(manager, \.textMaxWidth, value: textMaxWidth) + assign(manager, \.textOffset, value: textOffset) assign(manager, \.textOptional, value: textOptional) assign(manager, \.textPadding, value: textPadding) assign(manager, \.textPitchAlignment, value: textPitchAlignment) + assign(manager, \.textRadialOffset, value: textRadialOffset) + assign(manager, \.textRotate, value: textRotate) assign(manager, \.textRotationAlignment, value: textRotationAlignment) + assign(manager, \.textSize, value: textSize) + assign(manager, \.textTransform, value: textTransform) assign(manager, \.textVariableAnchor, value: textVariableAnchor) assign(manager, \.textWritingMode, value: textWritingMode) + assign(manager, \.iconColor, value: iconColor) assign(manager, \.iconColorSaturation, value: iconColorSaturation) + assign(manager, \.iconEmissiveStrength, value: iconEmissiveStrength) + assign(manager, \.iconHaloBlur, value: iconHaloBlur) + assign(manager, \.iconHaloColor, value: iconHaloColor) + assign(manager, \.iconHaloWidth, value: iconHaloWidth) + assign(manager, \.iconImageCrossFade, value: iconImageCrossFade) + assign(manager, \.iconOcclusionOpacity, value: iconOcclusionOpacity) + assign(manager, \.iconOpacity, value: iconOpacity) assign(manager, \.iconTranslate, value: iconTranslate) assign(manager, \.iconTranslateAnchor, value: iconTranslateAnchor) + assign(manager, \.textColor, value: textColor) + assign(manager, \.textEmissiveStrength, value: textEmissiveStrength) + assign(manager, \.textHaloBlur, value: textHaloBlur) + assign(manager, \.textHaloColor, value: textHaloColor) + assign(manager, \.textHaloWidth, value: textHaloWidth) + assign(manager, \.textOcclusionOpacity, value: textOcclusionOpacity) + assign(manager, \.textOpacity, value: textOpacity) assign(manager, \.textTranslate, value: textTranslate) assign(manager, \.textTranslateAnchor, value: textTranslateAnchor) assign(manager, \.slot, value: slot) @@ -118,6 +154,13 @@ public struct PointAnnotationGroup { with(self, setter(\.iconAllowOverlap, newValue)) } + private var iconAnchor: IconAnchor? + /// Part of the icon placed closest to the anchor. + /// Default value: "center". + public func iconAnchor(_ newValue: IconAnchor) -> Self { + with(self, setter(\.iconAnchor, newValue)) + } + private var iconIgnorePlacement: Bool? /// If true, other symbols can be visible even if they collide with the icon. /// Default value: false. @@ -125,6 +168,12 @@ public struct PointAnnotationGroup { with(self, setter(\.iconIgnorePlacement, newValue)) } + private var iconImage: String? + /// Name of image in sprite to use for drawing an image background. + public func iconImage(_ newValue: String) -> Self { + with(self, setter(\.iconImage, newValue)) + } + private var iconKeepUpright: Bool? /// If true, the icon may be flipped to prevent it from being rendered upside-down. /// Default value: false. @@ -132,6 +181,13 @@ public struct PointAnnotationGroup { with(self, setter(\.iconKeepUpright, newValue)) } + private var iconOffset: [Double]? + /// Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up. + /// Default value: [0,0]. + public func iconOffset(_ newValue: [Double]) -> Self { + with(self, setter(\.iconOffset, newValue)) + } + private var iconOptional: Bool? /// If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not. /// Default value: false. @@ -153,6 +209,13 @@ public struct PointAnnotationGroup { with(self, setter(\.iconPitchAlignment, newValue)) } + private var iconRotate: Double? + /// Rotates the icon clockwise. + /// Default value: 0. + public func iconRotate(_ newValue: Double) -> Self { + with(self, setter(\.iconRotate, newValue)) + } + private var iconRotationAlignment: IconRotationAlignment? /// In combination with `symbol-placement`, determines the rotation behavior of icons. /// Default value: "auto". @@ -160,6 +223,27 @@ public struct PointAnnotationGroup { with(self, setter(\.iconRotationAlignment, newValue)) } + private var iconSize: Double? + /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. + /// Default value: 1. Minimum value: 0. + public func iconSize(_ newValue: Double) -> Self { + with(self, setter(\.iconSize, newValue)) + } + + private var iconTextFit: IconTextFit? + /// Scales the icon to fit around the associated text. + /// Default value: "none". + public func iconTextFit(_ newValue: IconTextFit) -> Self { + with(self, setter(\.iconTextFit, newValue)) + } + + private var iconTextFitPadding: [Double]? + /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. + /// Default value: [0,0,0,0]. + public func iconTextFitPadding(_ newValue: [Double]) -> Self { + with(self, setter(\.iconTextFitPadding, newValue)) + } + private var symbolAvoidEdges: Bool? /// If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries. /// Default value: false. @@ -174,6 +258,12 @@ public struct PointAnnotationGroup { with(self, setter(\.symbolPlacement, newValue)) } + private var symbolSortKey: Double? + /// Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `icon-allow-overlap` or `text-allow-overlap` is `false`, features with a lower sort key will have priority during placement. When `icon-allow-overlap` or `text-allow-overlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key. + public func symbolSortKey(_ newValue: Double) -> Self { + with(self, setter(\.symbolSortKey, newValue)) + } + private var symbolSpacing: Double? /// Distance between two symbol anchors. /// Default value: 250. Minimum value: 1. @@ -202,6 +292,20 @@ public struct PointAnnotationGroup { with(self, setter(\.textAllowOverlap, newValue)) } + private var textAnchor: TextAnchor? + /// Part of the text placed closest to the anchor. + /// Default value: "center". + public func textAnchor(_ newValue: TextAnchor) -> Self { + with(self, setter(\.textAnchor, newValue)) + } + + private var textField: String? + /// Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options. SDF images are not supported in formatted text and will be ignored. + /// Default value: "". + public func textField(_ newValue: String) -> Self { + with(self, setter(\.textField, newValue)) + } + private var textFont: [String]? /// Font stack to use for displaying text. public func textFont(_ newValue: [String]) -> Self { @@ -215,6 +319,13 @@ public struct PointAnnotationGroup { with(self, setter(\.textIgnorePlacement, newValue)) } + private var textJustify: TextJustify? + /// Text justification options. + /// Default value: "center". + public func textJustify(_ newValue: TextJustify) -> Self { + with(self, setter(\.textJustify, newValue)) + } + private var textKeepUpright: Bool? /// If true, the text may be flipped vertically to prevent it from being rendered upside-down. /// Default value: true. @@ -222,6 +333,20 @@ public struct PointAnnotationGroup { with(self, setter(\.textKeepUpright, newValue)) } + private var textLetterSpacing: Double? + /// Text tracking amount. + /// Default value: 0. + public func textLetterSpacing(_ newValue: Double) -> Self { + with(self, setter(\.textLetterSpacing, newValue)) + } + + private var textLineHeight: Double? + /// Text leading value for multi-line text. + /// Default value: 1.2. + public func textLineHeight(_ newValue: Double) -> Self { + with(self, setter(\.textLineHeight, newValue)) + } + private var textMaxAngle: Double? /// Maximum angle change between adjacent characters. /// Default value: 45. @@ -229,6 +354,20 @@ public struct PointAnnotationGroup { with(self, setter(\.textMaxAngle, newValue)) } + private var textMaxWidth: Double? + /// The maximum line width for text wrapping. + /// Default value: 10. Minimum value: 0. + public func textMaxWidth(_ newValue: Double) -> Self { + with(self, setter(\.textMaxWidth, newValue)) + } + + private var textOffset: [Double]? + /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. + /// Default value: [0,0]. + public func textOffset(_ newValue: [Double]) -> Self { + with(self, setter(\.textOffset, newValue)) + } + private var textOptional: Bool? /// If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. /// Default value: false. @@ -250,6 +389,20 @@ public struct PointAnnotationGroup { with(self, setter(\.textPitchAlignment, newValue)) } + private var textRadialOffset: Double? + /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. + /// Default value: 0. + public func textRadialOffset(_ newValue: Double) -> Self { + with(self, setter(\.textRadialOffset, newValue)) + } + + private var textRotate: Double? + /// Rotates the text clockwise. + /// Default value: 0. + public func textRotate(_ newValue: Double) -> Self { + with(self, setter(\.textRotate, newValue)) + } + private var textRotationAlignment: TextRotationAlignment? /// In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text. /// Default value: "auto". @@ -257,6 +410,20 @@ public struct PointAnnotationGroup { with(self, setter(\.textRotationAlignment, newValue)) } + private var textSize: Double? + /// Font size. + /// Default value: 16. Minimum value: 0. + public func textSize(_ newValue: Double) -> Self { + with(self, setter(\.textSize, newValue)) + } + + private var textTransform: TextTransform? + /// Specifies how to capitalize text, similar to the CSS `text-transform` property. + /// Default value: "none". + public func textTransform(_ newValue: TextTransform) -> Self { + with(self, setter(\.textTransform, newValue)) + } + private var textVariableAnchor: [TextAnchor]? /// To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`. public func textVariableAnchor(_ newValue: [TextAnchor]) -> Self { @@ -269,6 +436,13 @@ public struct PointAnnotationGroup { with(self, setter(\.textWritingMode, newValue)) } + private var iconColor: StyleColor? + /// The color of the icon. This can only be used with [SDF icons](/help/troubleshooting/using-recolorable-images-in-mapbox-maps/). + /// Default value: "#000000". + public func iconColor(_ color: UIColor) -> Self { + with(self, setter(\.iconColor, StyleColor(color))) + } + private var iconColorSaturation: Double? /// Increase or reduce the saturation of the symbol icon. /// Default value: 0. Value range: [-1, 1] @@ -276,6 +450,55 @@ public struct PointAnnotationGroup { with(self, setter(\.iconColorSaturation, newValue)) } + private var iconEmissiveStrength: Double? + /// Controls the intensity of light emitted on the source features. + /// Default value: 1. Minimum value: 0. + public func iconEmissiveStrength(_ newValue: Double) -> Self { + with(self, setter(\.iconEmissiveStrength, newValue)) + } + + private var iconHaloBlur: Double? + /// Fade out the halo towards the outside. + /// Default value: 0. Minimum value: 0. + public func iconHaloBlur(_ newValue: Double) -> Self { + with(self, setter(\.iconHaloBlur, newValue)) + } + + private var iconHaloColor: StyleColor? + /// The color of the icon's halo. Icon halos can only be used with [SDF icons](/help/troubleshooting/using-recolorable-images-in-mapbox-maps/). + /// Default value: "rgba(0, 0, 0, 0)". + public func iconHaloColor(_ color: UIColor) -> Self { + with(self, setter(\.iconHaloColor, StyleColor(color))) + } + + private var iconHaloWidth: Double? + /// Distance of halo to the icon outline. + /// Default value: 0. Minimum value: 0. + public func iconHaloWidth(_ newValue: Double) -> Self { + with(self, setter(\.iconHaloWidth, newValue)) + } + + private var iconImageCrossFade: Double? + /// Controls the transition progress between the image variants of icon-image. Zero means the first variant is used, one is the second, and in between they are blended together. + /// Default value: 0. Value range: [0, 1] + public func iconImageCrossFade(_ newValue: Double) -> Self { + with(self, setter(\.iconImageCrossFade, newValue)) + } + + private var iconOcclusionOpacity: Double? + /// The opacity at which the icon will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. + /// Default value: 0. Value range: [0, 1] + public func iconOcclusionOpacity(_ newValue: Double) -> Self { + with(self, setter(\.iconOcclusionOpacity, newValue)) + } + + private var iconOpacity: Double? + /// The opacity at which the icon will be drawn. + /// Default value: 1. Value range: [0, 1] + public func iconOpacity(_ newValue: Double) -> Self { + with(self, setter(\.iconOpacity, newValue)) + } + private var iconTranslate: [Double]? /// Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. /// Default value: [0,0]. @@ -290,6 +513,55 @@ public struct PointAnnotationGroup { with(self, setter(\.iconTranslateAnchor, newValue)) } + private var textColor: StyleColor? + /// The color with which the text will be drawn. + /// Default value: "#000000". + public func textColor(_ color: UIColor) -> Self { + with(self, setter(\.textColor, StyleColor(color))) + } + + private var textEmissiveStrength: Double? + /// Controls the intensity of light emitted on the source features. + /// Default value: 1. Minimum value: 0. + public func textEmissiveStrength(_ newValue: Double) -> Self { + with(self, setter(\.textEmissiveStrength, newValue)) + } + + private var textHaloBlur: Double? + /// The halo's fadeout distance towards the outside. + /// Default value: 0. Minimum value: 0. + public func textHaloBlur(_ newValue: Double) -> Self { + with(self, setter(\.textHaloBlur, newValue)) + } + + private var textHaloColor: StyleColor? + /// The color of the text's halo, which helps it stand out from backgrounds. + /// Default value: "rgba(0, 0, 0, 0)". + public func textHaloColor(_ color: UIColor) -> Self { + with(self, setter(\.textHaloColor, StyleColor(color))) + } + + private var textHaloWidth: Double? + /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. + /// Default value: 0. Minimum value: 0. + public func textHaloWidth(_ newValue: Double) -> Self { + with(self, setter(\.textHaloWidth, newValue)) + } + + private var textOcclusionOpacity: Double? + /// The opacity at which the text will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. + /// Default value: 0. Value range: [0, 1] + public func textOcclusionOpacity(_ newValue: Double) -> Self { + with(self, setter(\.textOcclusionOpacity, newValue)) + } + + private var textOpacity: Double? + /// The opacity at which the text will be drawn. + /// Default value: 1. Value range: [0, 1] + public func textOpacity(_ newValue: Double) -> Self { + with(self, setter(\.textOpacity, newValue)) + } + private var textTranslate: [Double]? /// Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. /// Default value: [0,0]. @@ -313,22 +585,6 @@ public struct PointAnnotationGroup { with(self, setter(\.slot, newValue)) } - private var iconOcclusionOpacity: Double? - /// The opacity at which the icon will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. - /// Default value: 0. Value range: [0, 1] - @available(*, deprecated, message: "icon-occlusion-opacity property is now data driven, use `PointAnnotation.iconOcclusionOpacity` instead.") - public func iconOcclusionOpacity(_ newValue: Double) -> Self { - with(self, setter(\.iconOcclusionOpacity, newValue)) - } - - private var textOcclusionOpacity: Double? - /// The opacity at which the text will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. - /// Default value: 0. Value range: [0, 1] - @available(*, deprecated, message: "text-occlusion-opacity property is now data driven, use `PointAnnotation.textOcclusionOpacity` instead.") - public func textOcclusionOpacity(_ newValue: Double) -> Self { - with(self, setter(\.textOcclusionOpacity, newValue)) - } - private var clusterOptions: ClusterOptions? /// Defines point annotation clustering options. diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift index 9405fe0e6ffe..7bceee018828 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift @@ -31,6 +31,8 @@ /// .slot("bottom") /// } /// ``` +import UIKit + @available(iOS 13.0, *) public struct PolygonAnnotationGroup { let annotations: [(ID, PolygonAnnotation)] @@ -71,8 +73,13 @@ public struct PolygonAnnotationGroup } private func updateProperties(manager: PolygonAnnotationManager) { + assign(manager, \.fillSortKey, value: fillSortKey) assign(manager, \.fillAntialias, value: fillAntialias) + assign(manager, \.fillColor, value: fillColor) assign(manager, \.fillEmissiveStrength, value: fillEmissiveStrength) + assign(manager, \.fillOpacity, value: fillOpacity) + assign(manager, \.fillOutlineColor, value: fillOutlineColor) + assign(manager, \.fillPattern, value: fillPattern) assign(manager, \.fillTranslate, value: fillTranslate) assign(manager, \.fillTranslateAnchor, value: fillTranslateAnchor) assign(manager, \.slot, value: slot) @@ -80,6 +87,12 @@ public struct PolygonAnnotationGroup // MARK: - Common layer properties + private var fillSortKey: Double? + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + public func fillSortKey(_ newValue: Double) -> Self { + with(self, setter(\.fillSortKey, newValue)) + } + private var fillAntialias: Bool? /// Whether or not the fill should be antialiased. /// Default value: true. @@ -87,6 +100,13 @@ public struct PolygonAnnotationGroup with(self, setter(\.fillAntialias, newValue)) } + private var fillColor: StyleColor? + /// The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used. + /// Default value: "#000000". + public func fillColor(_ color: UIColor) -> Self { + with(self, setter(\.fillColor, StyleColor(color))) + } + private var fillEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. /// Default value: 0. Minimum value: 0. @@ -94,6 +114,25 @@ public struct PolygonAnnotationGroup with(self, setter(\.fillEmissiveStrength, newValue)) } + private var fillOpacity: Double? + /// The opacity of the entire fill layer. In contrast to the `fill-color`, this value will also affect the 1px stroke around the fill, if the stroke is used. + /// Default value: 1. Value range: [0, 1] + public func fillOpacity(_ newValue: Double) -> Self { + with(self, setter(\.fillOpacity, newValue)) + } + + private var fillOutlineColor: StyleColor? + /// The outline color of the fill. Matches the value of `fill-color` if unspecified. + public func fillOutlineColor(_ color: UIColor) -> Self { + with(self, setter(\.fillOutlineColor, StyleColor(color))) + } + + private var fillPattern: String? + /// Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. + public func fillPattern(_ newValue: String) -> Self { + with(self, setter(\.fillPattern, newValue)) + } + private var fillTranslate: [Double]? /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift index dc3891d7fb66..49d2e12e4499 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift @@ -34,6 +34,8 @@ /// .slot("middle") /// } /// ``` +import UIKit + @available(iOS 13.0, *) public struct PolylineAnnotationGroup { let annotations: [(ID, PolylineAnnotation)] @@ -75,17 +77,29 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineJoin, newValue)) + } + private var lineMiterLimit: Double? /// Used to automatically convert miter joins to bevel joins for sharp angles. /// Default value: 2. @@ -112,6 +133,48 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineSortKey, newValue)) + } + + private var lineZOffset: Double? + /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + @_documentation(visibility: public) + @_spi(Experimental) + public func lineZOffset(_ newValue: Double) -> Self { + with(self, setter(\.lineZOffset, newValue)) + } + + private var lineBlur: Double? + /// Blur applied to the line, in pixels. + /// Default value: 0. Minimum value: 0. + public func lineBlur(_ newValue: Double) -> Self { + with(self, setter(\.lineBlur, newValue)) + } + + private var lineBorderColor: StyleColor? + /// The color of the line border. If line-border-width is greater than zero and the alpha value of this color is 0 (default), the color for the border will be selected automatically based on the line color. + /// Default value: "rgba(0, 0, 0, 0)". + public func lineBorderColor(_ color: UIColor) -> Self { + with(self, setter(\.lineBorderColor, StyleColor(color))) + } + + private var lineBorderWidth: Double? + /// The width of the line border. A value of zero means no border. + /// Default value: 0. Minimum value: 0. + public func lineBorderWidth(_ newValue: Double) -> Self { + with(self, setter(\.lineBorderWidth, newValue)) + } + + private var lineColor: StyleColor? + /// The color with which the line will be drawn. + /// Default value: "#000000". + public func lineColor(_ color: UIColor) -> Self { + with(self, setter(\.lineColor, StyleColor(color))) + } + private var lineDasharray: [Double]? /// Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. /// Minimum value: 0. @@ -133,6 +196,13 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineGapWidth, newValue)) + } + private var lineOcclusionOpacity: Double? /// Opacity multiplier (multiplies line-opacity value) of the line part that is occluded by 3D objects. Value 0 hides occluded part, value 1 means the same opacity as non-occluded part. The property is not supported when `line-opacity` has data-driven styling. /// Default value: 0. Value range: [0, 1] @@ -140,6 +210,26 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineOffset, newValue)) + } + + private var lineOpacity: Double? + /// The opacity at which the line will be drawn. + /// Default value: 1. Value range: [0, 1] + public func lineOpacity(_ newValue: Double) -> Self { + with(self, setter(\.lineOpacity, newValue)) + } + + private var linePattern: String? + /// Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. + public func linePattern(_ newValue: String) -> Self { + with(self, setter(\.linePattern, newValue)) + } + private var lineTranslate: [Double]? /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. /// Default value: [0,0]. @@ -159,8 +249,8 @@ public struct PolylineAnnotationGroup Self { - with(self, setter(\.lineTrimColor, newValue)) + public func lineTrimColor(_ color: UIColor) -> Self { + with(self, setter(\.lineTrimColor, StyleColor(color))) } private var lineTrimFadeRange: [Double]? @@ -179,6 +269,13 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineWidth, newValue)) + } + private var slot: String? /// Slot for the underlying layer. /// diff --git a/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift b/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift index 1f35ce26abd1..1d4be7aeeb9b 100644 --- a/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift +++ b/Tests/MapboxMapsTests/Annotations/AnnotationManagerImplTests.swift @@ -139,9 +139,17 @@ final class AnnotationManagerImplTests: XCTestCase { func testLayerSync() throws { func checkExpression(key: String, props: [String: Any]) throws { let value = try XCTUnwrap(props[key] as? [Any]) - XCTAssertEqual(value[safe: 0] as? String, "get") - XCTAssertEqual(value[safe: 1] as? String, key) - XCTAssertEqual(value[safe: 2] as? [String], ["get", "layerProperties"]) + let valueData = try XCTUnwrap(JSONSerialization.data(withJSONObject: value)) + let valueString = try XCTUnwrap(String(decoding: valueData, as: UTF8.self)) + + let fallbackValue = me.layerProperties[key] ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: key).value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + + let expectedString = "[\"coalesce\",[\"get\",\"\(key)\",[\"get\",\"layerProperties\"]],\(fallbackValueString)]" + XCTAssertEqual(valueString, expectedString) } me.annotations = annotations diff --git a/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationIntegrationTests.swift index 3cd1114626f4..442eecb154aa 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationIntegrationTests.swift @@ -46,16 +46,14 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { guard let layer = try? self.mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) else { return false } - return layer.circleRadius == .expression(Exp(.number) { - Exp(.get) { - "circle-radius" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - }) + let fallbackValue = self.manager.circleRadius ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-radius").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? (try? JSONSerialization.data(withJSONObject: fallbackValue)) ?? Data() + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = String(decoding: fallbackValueData, as: UTF8.self) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-radius\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + let currentValueString = (try? layer.circleRadius.toString()) ?? "" + return currentValueString == expectedString }), evaluatedWith: nil, handler: nil) waitForExpectations(timeout: 2, handler: nil) @@ -228,16 +226,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleSortKey, .expression(Exp(.number) { - Exp(.get) { - "circle-sort-key" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleSortKey ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-sort-key").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-sort-key\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleSortKey.toString(), expectedString) // Test that the property can be reset to nil annotation.circleSortKey = nil @@ -264,16 +259,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleBlur, .expression(Exp(.number) { - Exp(.get) { - "circle-blur" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleBlur ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-blur").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-blur\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleBlur.toString(), expectedString) // Test that the property can be reset to nil annotation.circleBlur = nil @@ -300,16 +292,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleColor, .expression(Exp(.toColor) { - Exp(.get) { - "circle-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleColor ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"circle-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleColor.toString(), expectedString) // Test that the property can be reset to nil annotation.circleColor = nil @@ -336,16 +325,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleOpacity, .expression(Exp(.number) { - Exp(.get) { - "circle-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleOpacity ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.circleOpacity = nil @@ -372,16 +358,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleRadius, .expression(Exp(.number) { - Exp(.get) { - "circle-radius" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleRadius ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-radius").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-radius\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleRadius.toString(), expectedString) // Test that the property can be reset to nil annotation.circleRadius = nil @@ -408,16 +391,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleStrokeColor, .expression(Exp(.toColor) { - Exp(.get) { - "circle-stroke-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleStrokeColor ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"circle-stroke-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleStrokeColor.toString(), expectedString) // Test that the property can be reset to nil annotation.circleStrokeColor = nil @@ -444,16 +424,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleStrokeOpacity, .expression(Exp(.number) { - Exp(.get) { - "circle-stroke-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleStrokeOpacity ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-stroke-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleStrokeOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.circleStrokeOpacity = nil @@ -480,16 +457,13 @@ final class CircleAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: CircleLayer.self) - XCTAssertEqual(layer.circleStrokeWidth, .expression(Exp(.number) { - Exp(.get) { - "circle-stroke-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.circleStrokeWidth ?? StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"circle-stroke-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.circleStrokeWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.circleStrokeWidth = nil diff --git a/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationManagerTests.swift index e342c9068afa..5cabf77c2eb9 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/CircleAnnotationManagerTests.swift @@ -29,6 +29,82 @@ final class CircleAnnotationManagerTests: XCTestCase, AnnotationInteractionDeleg super.tearDown() } + func testInitialCircleSortKey() { + let initialValue = manager.circleSortKey + XCTAssertNil(initialValue) + } + + func testSetCircleSortKey() { + let value = 0.0 + manager.circleSortKey = value + XCTAssertEqual(manager.circleSortKey, value) + XCTAssertEqual(manager.impl.layerProperties["circle-sort-key"] as! Double, value) + } + + func testSetToNilCircleSortKey() { + let newCircleSortKeyProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-sort-key").value as! Double + manager.circleSortKey = newCircleSortKeyProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-sort-key"]) + harness.triggerDisplayLink() + + manager.circleSortKey = nil + XCTAssertNil(manager.circleSortKey) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-sort-key"] as! Double, defaultValue) + } + func testInitialCircleBlur() { + let initialValue = manager.circleBlur + XCTAssertNil(initialValue) + } + + func testSetCircleBlur() { + let value = 0.0 + manager.circleBlur = value + XCTAssertEqual(manager.circleBlur, value) + XCTAssertEqual(manager.impl.layerProperties["circle-blur"] as! Double, value) + } + + func testSetToNilCircleBlur() { + let newCircleBlurProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-blur").value as! Double + manager.circleBlur = newCircleBlurProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-blur"]) + harness.triggerDisplayLink() + + manager.circleBlur = nil + XCTAssertNil(manager.circleBlur) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-blur"] as! Double, defaultValue) + } + func testInitialCircleColor() { + let initialValue = manager.circleColor + XCTAssertNil(initialValue) + } + + func testSetCircleColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.circleColor = value + XCTAssertEqual(manager.circleColor, value) + XCTAssertEqual(manager.impl.layerProperties["circle-color"] as? String, value?.rawValue) + } + + func testSetToNilCircleColor() { + let newCircleColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-color").value as! [Any], options: [])) + manager.circleColor = newCircleColorProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-color"]) + harness.triggerDisplayLink() + + manager.circleColor = nil + XCTAssertNil(manager.circleColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } func testInitialCircleEmissiveStrength() { let initialValue = manager.circleEmissiveStrength XCTAssertNil(initialValue) @@ -54,6 +130,31 @@ final class CircleAnnotationManagerTests: XCTestCase, AnnotationInteractionDeleg XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-emissive-strength"] as! Double, defaultValue) } + func testInitialCircleOpacity() { + let initialValue = manager.circleOpacity + XCTAssertNil(initialValue) + } + + func testSetCircleOpacity() { + let value = 0.5 + manager.circleOpacity = value + XCTAssertEqual(manager.circleOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["circle-opacity"] as! Double, value) + } + + func testSetToNilCircleOpacity() { + let newCircleOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-opacity").value as! Double + manager.circleOpacity = newCircleOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-opacity"]) + harness.triggerDisplayLink() + + manager.circleOpacity = nil + XCTAssertNil(manager.circleOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-opacity"] as! Double, defaultValue) + } func testInitialCirclePitchAlignment() { let initialValue = manager.circlePitchAlignment XCTAssertNil(initialValue) @@ -104,6 +205,107 @@ final class CircleAnnotationManagerTests: XCTestCase, AnnotationInteractionDeleg XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-pitch-scale"] as! String, defaultValue) } + func testInitialCircleRadius() { + let initialValue = manager.circleRadius + XCTAssertNil(initialValue) + } + + func testSetCircleRadius() { + let value = 50000.0 + manager.circleRadius = value + XCTAssertEqual(manager.circleRadius, value) + XCTAssertEqual(manager.impl.layerProperties["circle-radius"] as! Double, value) + } + + func testSetToNilCircleRadius() { + let newCircleRadiusProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-radius").value as! Double + manager.circleRadius = newCircleRadiusProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-radius"]) + harness.triggerDisplayLink() + + manager.circleRadius = nil + XCTAssertNil(manager.circleRadius) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-radius"] as! Double, defaultValue) + } + func testInitialCircleStrokeColor() { + let initialValue = manager.circleStrokeColor + XCTAssertNil(initialValue) + } + + func testSetCircleStrokeColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.circleStrokeColor = value + XCTAssertEqual(manager.circleStrokeColor, value) + XCTAssertEqual(manager.impl.layerProperties["circle-stroke-color"] as? String, value?.rawValue) + } + + func testSetToNilCircleStrokeColor() { + let newCircleStrokeColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-color").value as! [Any], options: [])) + manager.circleStrokeColor = newCircleStrokeColorProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-stroke-color"]) + harness.triggerDisplayLink() + + manager.circleStrokeColor = nil + XCTAssertNil(manager.circleStrokeColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-stroke-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialCircleStrokeOpacity() { + let initialValue = manager.circleStrokeOpacity + XCTAssertNil(initialValue) + } + + func testSetCircleStrokeOpacity() { + let value = 0.5 + manager.circleStrokeOpacity = value + XCTAssertEqual(manager.circleStrokeOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["circle-stroke-opacity"] as! Double, value) + } + + func testSetToNilCircleStrokeOpacity() { + let newCircleStrokeOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-opacity").value as! Double + manager.circleStrokeOpacity = newCircleStrokeOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-stroke-opacity"]) + harness.triggerDisplayLink() + + manager.circleStrokeOpacity = nil + XCTAssertNil(manager.circleStrokeOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-stroke-opacity"] as! Double, defaultValue) + } + func testInitialCircleStrokeWidth() { + let initialValue = manager.circleStrokeWidth + XCTAssertNil(initialValue) + } + + func testSetCircleStrokeWidth() { + let value = 50000.0 + manager.circleStrokeWidth = value + XCTAssertEqual(manager.circleStrokeWidth, value) + XCTAssertEqual(manager.impl.layerProperties["circle-stroke-width"] as! Double, value) + } + + func testSetToNilCircleStrokeWidth() { + let newCircleStrokeWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .circle, property: "circle-stroke-width").value as! Double + manager.circleStrokeWidth = newCircleStrokeWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["circle-stroke-width"]) + harness.triggerDisplayLink() + + manager.circleStrokeWidth = nil + XCTAssertNil(manager.circleStrokeWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["circle-stroke-width"] as! Double, defaultValue) + } func testInitialCircleTranslate() { let initialValue = manager.circleTranslate XCTAssertNil(initialValue) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift index 4be2d82ecf39..8aa2ba73604b 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift @@ -46,16 +46,14 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { guard let layer = try? self.mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) else { return false } - return layer.textSize == .expression(Exp(.number) { - Exp(.get) { - "text-size" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - }) + let fallbackValue = self.manager.textSize ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-size").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? (try? JSONSerialization.data(withJSONObject: fallbackValue)) ?? Data() + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = String(decoding: fallbackValueData, as: UTF8.self) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-size\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + let currentValueString = (try? layer.textSize.toString()) ?? "" + return currentValueString == expectedString }), evaluatedWith: nil, handler: nil) waitForExpectations(timeout: 2, handler: nil) @@ -828,16 +826,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconAnchor, .expression(Exp(.toString) { - Exp(.get) { - "icon-anchor" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconAnchor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-anchor").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"icon-anchor\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.iconAnchor.toString(), expectedString) // Test that the property can be reset to nil annotation.iconAnchor = nil @@ -864,16 +859,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconImage, .expression(Exp(.image) { - Exp(.get) { - "icon-image" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconImage ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-image").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"image\",[\"coalesce\",[\"get\",\"icon-image\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.iconImage.toString(), expectedString) // Test that the property can be reset to nil annotation.iconImage = nil @@ -900,18 +892,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconOffset, .expression(Exp(.array) { - "number" - 2 - Exp(.get) { - "icon-offset" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconOffset ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-offset").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"array\",\"number\",2,[\"coalesce\",[\"get\",\"icon-offset\",[\"object\",[\"get\",\"layerProperties\"]]],[\"literal\",\(fallbackValueString)]]]" + XCTAssertEqual(try layer.iconOffset.toString(), expectedString) // Test that the property can be reset to nil annotation.iconOffset = nil @@ -938,16 +925,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconRotate, .expression(Exp(.number) { - Exp(.get) { - "icon-rotate" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconRotate ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-rotate").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-rotate\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconRotate.toString(), expectedString) // Test that the property can be reset to nil annotation.iconRotate = nil @@ -974,16 +958,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconSize, .expression(Exp(.number) { - Exp(.get) { - "icon-size" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconSize ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-size").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-size\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconSize.toString(), expectedString) // Test that the property can be reset to nil annotation.iconSize = nil @@ -1010,16 +991,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconTextFit, .expression(Exp(.toString) { - Exp(.get) { - "icon-text-fit" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconTextFit ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-text-fit").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"icon-text-fit\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.iconTextFit.toString(), expectedString) // Test that the property can be reset to nil annotation.iconTextFit = nil @@ -1046,18 +1024,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconTextFitPadding, .expression(Exp(.array) { - "number" - 4 - Exp(.get) { - "icon-text-fit-padding" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconTextFitPadding ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-text-fit-padding").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"array\",\"number\",4,[\"coalesce\",[\"get\",\"icon-text-fit-padding\",[\"object\",[\"get\",\"layerProperties\"]]],[\"literal\",\(fallbackValueString)]]]" + XCTAssertEqual(try layer.iconTextFitPadding.toString(), expectedString) // Test that the property can be reset to nil annotation.iconTextFitPadding = nil @@ -1084,16 +1057,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.symbolSortKey, .expression(Exp(.number) { - Exp(.get) { - "symbol-sort-key" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.symbolSortKey ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "symbol-sort-key").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"symbol-sort-key\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.symbolSortKey.toString(), expectedString) // Test that the property can be reset to nil annotation.symbolSortKey = nil @@ -1120,16 +1090,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textAnchor, .expression(Exp(.toString) { - Exp(.get) { - "text-anchor" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textAnchor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-anchor").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"text-anchor\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.textAnchor.toString(), expectedString) // Test that the property can be reset to nil annotation.textAnchor = nil @@ -1156,17 +1123,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textField, .expression(Exp(.format) { - Exp(.get) { - "text-field" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - FormatOptions() - })) + let fallbackValue = self.manager.textField ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-field").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"format\",[\"coalesce\",[\"get\",\"text-field\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)],{}]" + XCTAssertEqual(try layer.textField.toString(), expectedString) // Test that the property can be reset to nil annotation.textField = nil @@ -1178,10 +1141,10 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // the layer is returned to the default value manager.impl.syncSourceAndLayerIfNeeded() layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textField, .expression(Exp(.format) { + XCTAssertEqual(layer.textField, Value.expression(Exp(.format) { "" FormatOptions() - })) + })) } func testTextJustify() throws { @@ -1196,16 +1159,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textJustify, .expression(Exp(.toString) { - Exp(.get) { - "text-justify" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textJustify ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-justify").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"text-justify\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.textJustify.toString(), expectedString) // Test that the property can be reset to nil annotation.textJustify = nil @@ -1232,16 +1192,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textLetterSpacing, .expression(Exp(.number) { - Exp(.get) { - "text-letter-spacing" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textLetterSpacing ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-letter-spacing").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-letter-spacing\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textLetterSpacing.toString(), expectedString) // Test that the property can be reset to nil annotation.textLetterSpacing = nil @@ -1268,16 +1225,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textLineHeight, .expression(Exp(.number) { - Exp(.get) { - "text-line-height" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textLineHeight ?? (StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-line-height").value as! NSNumber).doubleValue + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-line-height\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textLineHeight.toString(), expectedString) // Test that the property can be reset to nil annotation.textLineHeight = nil @@ -1304,16 +1258,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textMaxWidth, .expression(Exp(.number) { - Exp(.get) { - "text-max-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textMaxWidth ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-max-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-max-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textMaxWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.textMaxWidth = nil @@ -1340,18 +1291,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textOffset, .expression(Exp(.array) { - "number" - 2 - Exp(.get) { - "text-offset" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textOffset ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-offset").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"array\",\"number\",2,[\"coalesce\",[\"get\",\"text-offset\",[\"object\",[\"get\",\"layerProperties\"]]],[\"literal\",\(fallbackValueString)]]]" + XCTAssertEqual(try layer.textOffset.toString(), expectedString) // Test that the property can be reset to nil annotation.textOffset = nil @@ -1378,16 +1324,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textRadialOffset, .expression(Exp(.number) { - Exp(.get) { - "text-radial-offset" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textRadialOffset ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-radial-offset").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-radial-offset\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textRadialOffset.toString(), expectedString) // Test that the property can be reset to nil annotation.textRadialOffset = nil @@ -1414,16 +1357,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textRotate, .expression(Exp(.number) { - Exp(.get) { - "text-rotate" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textRotate ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-rotate").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-rotate\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textRotate.toString(), expectedString) // Test that the property can be reset to nil annotation.textRotate = nil @@ -1450,16 +1390,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textSize, .expression(Exp(.number) { - Exp(.get) { - "text-size" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textSize ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-size").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-size\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textSize.toString(), expectedString) // Test that the property can be reset to nil annotation.textSize = nil @@ -1486,16 +1423,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textTransform, .expression(Exp(.toString) { - Exp(.get) { - "text-transform" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textTransform ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-transform").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"text-transform\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.textTransform.toString(), expectedString) // Test that the property can be reset to nil annotation.textTransform = nil @@ -1522,16 +1456,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconColor, .expression(Exp(.toColor) { - Exp(.get) { - "icon-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconColor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"icon-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconColor.toString(), expectedString) // Test that the property can be reset to nil annotation.iconColor = nil @@ -1558,16 +1489,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconEmissiveStrength, .expression(Exp(.number) { - Exp(.get) { - "icon-emissive-strength" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconEmissiveStrength ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-emissive-strength").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-emissive-strength\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconEmissiveStrength.toString(), expectedString) // Test that the property can be reset to nil annotation.iconEmissiveStrength = nil @@ -1594,16 +1522,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconHaloBlur, .expression(Exp(.number) { - Exp(.get) { - "icon-halo-blur" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconHaloBlur ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-blur").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-halo-blur\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconHaloBlur.toString(), expectedString) // Test that the property can be reset to nil annotation.iconHaloBlur = nil @@ -1630,16 +1555,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconHaloColor, .expression(Exp(.toColor) { - Exp(.get) { - "icon-halo-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconHaloColor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"icon-halo-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconHaloColor.toString(), expectedString) // Test that the property can be reset to nil annotation.iconHaloColor = nil @@ -1666,16 +1588,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconHaloWidth, .expression(Exp(.number) { - Exp(.get) { - "icon-halo-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconHaloWidth ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-halo-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconHaloWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.iconHaloWidth = nil @@ -1702,16 +1621,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconImageCrossFade, .expression(Exp(.number) { - Exp(.get) { - "icon-image-cross-fade" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconImageCrossFade ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-image-cross-fade").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-image-cross-fade\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconImageCrossFade.toString(), expectedString) // Test that the property can be reset to nil annotation.iconImageCrossFade = nil @@ -1738,16 +1654,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconOcclusionOpacity, .expression(Exp(.number) { - Exp(.get) { - "icon-occlusion-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconOcclusionOpacity ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-occlusion-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-occlusion-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconOcclusionOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.iconOcclusionOpacity = nil @@ -1774,16 +1687,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.iconOpacity, .expression(Exp(.number) { - Exp(.get) { - "icon-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.iconOpacity ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"icon-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.iconOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.iconOpacity = nil @@ -1810,16 +1720,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textColor, .expression(Exp(.toColor) { - Exp(.get) { - "text-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textColor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"text-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textColor.toString(), expectedString) // Test that the property can be reset to nil annotation.textColor = nil @@ -1846,16 +1753,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textEmissiveStrength, .expression(Exp(.number) { - Exp(.get) { - "text-emissive-strength" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textEmissiveStrength ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-emissive-strength").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-emissive-strength\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textEmissiveStrength.toString(), expectedString) // Test that the property can be reset to nil annotation.textEmissiveStrength = nil @@ -1882,16 +1786,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textHaloBlur, .expression(Exp(.number) { - Exp(.get) { - "text-halo-blur" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textHaloBlur ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-blur").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-halo-blur\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textHaloBlur.toString(), expectedString) // Test that the property can be reset to nil annotation.textHaloBlur = nil @@ -1918,16 +1819,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textHaloColor, .expression(Exp(.toColor) { - Exp(.get) { - "text-halo-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textHaloColor ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"text-halo-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textHaloColor.toString(), expectedString) // Test that the property can be reset to nil annotation.textHaloColor = nil @@ -1954,16 +1852,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textHaloWidth, .expression(Exp(.number) { - Exp(.get) { - "text-halo-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textHaloWidth ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-halo-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textHaloWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.textHaloWidth = nil @@ -1990,16 +1885,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textOcclusionOpacity, .expression(Exp(.number) { - Exp(.get) { - "text-occlusion-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textOcclusionOpacity ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-occlusion-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-occlusion-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textOcclusionOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.textOcclusionOpacity = nil @@ -2026,16 +1918,13 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) - XCTAssertEqual(layer.textOpacity, .expression(Exp(.number) { - Exp(.get) { - "text-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.textOpacity ?? StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"text-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.textOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.textOpacity = nil diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift index 8f4661a2bc09..e83935368a52 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift @@ -54,6 +54,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-allow-overlap"] as! Bool, defaultValue) } + func testInitialIconAnchor() { + let initialValue = manager.iconAnchor + XCTAssertNil(initialValue) + } + + func testSetIconAnchor() { + let value = IconAnchor.testConstantValue() + manager.iconAnchor = value + XCTAssertEqual(manager.iconAnchor, value) + XCTAssertEqual(manager.impl.layerProperties["icon-anchor"] as! String, value.rawValue) + } + + func testSetToNilIconAnchor() { + let newIconAnchorProperty = IconAnchor.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-anchor").value as! String + manager.iconAnchor = newIconAnchorProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-anchor"]) + harness.triggerDisplayLink() + + manager.iconAnchor = nil + XCTAssertNil(manager.iconAnchor) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-anchor"] as! String, defaultValue) + } func testInitialIconIgnorePlacement() { let initialValue = manager.iconIgnorePlacement XCTAssertNil(initialValue) @@ -79,6 +104,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-ignore-placement"] as! Bool, defaultValue) } + func testInitialIconImage() { + let initialValue = manager.iconImage + XCTAssertNil(initialValue) + } + + func testSetIconImage() { + let value = UUID().uuidString + manager.iconImage = value + XCTAssertEqual(manager.iconImage, value) + XCTAssertEqual(manager.impl.layerProperties["icon-image"] as! String, value) + } + + func testSetToNilIconImage() { + let newIconImageProperty = UUID().uuidString + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-image").value as! String + manager.iconImage = newIconImageProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-image"]) + harness.triggerDisplayLink() + + manager.iconImage = nil + XCTAssertNil(manager.iconImage) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-image"] as! String, defaultValue) + } func testInitialIconKeepUpright() { let initialValue = manager.iconKeepUpright XCTAssertNil(initialValue) @@ -104,6 +154,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-keep-upright"] as! Bool, defaultValue) } + func testInitialIconOffset() { + let initialValue = manager.iconOffset + XCTAssertNil(initialValue) + } + + func testSetIconOffset() { + let value = [0.0, 0.0] + manager.iconOffset = value + XCTAssertEqual(manager.iconOffset, value) + XCTAssertEqual(manager.impl.layerProperties["icon-offset"] as! [Double], value) + } + + func testSetToNilIconOffset() { + let newIconOffsetProperty = [0.0, 0.0] + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-offset").value as! [Double] + manager.iconOffset = newIconOffsetProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-offset"]) + harness.triggerDisplayLink() + + manager.iconOffset = nil + XCTAssertNil(manager.iconOffset) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-offset"] as! [Double], defaultValue) + } func testInitialIconOptional() { let initialValue = manager.iconOptional XCTAssertNil(initialValue) @@ -179,6 +254,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-pitch-alignment"] as! String, defaultValue) } + func testInitialIconRotate() { + let initialValue = manager.iconRotate + XCTAssertNil(initialValue) + } + + func testSetIconRotate() { + let value = 0.0 + manager.iconRotate = value + XCTAssertEqual(manager.iconRotate, value) + XCTAssertEqual(manager.impl.layerProperties["icon-rotate"] as! Double, value) + } + + func testSetToNilIconRotate() { + let newIconRotateProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-rotate").value as! Double + manager.iconRotate = newIconRotateProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-rotate"]) + harness.triggerDisplayLink() + + manager.iconRotate = nil + XCTAssertNil(manager.iconRotate) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-rotate"] as! Double, defaultValue) + } func testInitialIconRotationAlignment() { let initialValue = manager.iconRotationAlignment XCTAssertNil(initialValue) @@ -204,6 +304,81 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-rotation-alignment"] as! String, defaultValue) } + func testInitialIconSize() { + let initialValue = manager.iconSize + XCTAssertNil(initialValue) + } + + func testSetIconSize() { + let value = 50000.0 + manager.iconSize = value + XCTAssertEqual(manager.iconSize, value) + XCTAssertEqual(manager.impl.layerProperties["icon-size"] as! Double, value) + } + + func testSetToNilIconSize() { + let newIconSizeProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-size").value as! Double + manager.iconSize = newIconSizeProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-size"]) + harness.triggerDisplayLink() + + manager.iconSize = nil + XCTAssertNil(manager.iconSize) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-size"] as! Double, defaultValue) + } + func testInitialIconTextFit() { + let initialValue = manager.iconTextFit + XCTAssertNil(initialValue) + } + + func testSetIconTextFit() { + let value = IconTextFit.testConstantValue() + manager.iconTextFit = value + XCTAssertEqual(manager.iconTextFit, value) + XCTAssertEqual(manager.impl.layerProperties["icon-text-fit"] as! String, value.rawValue) + } + + func testSetToNilIconTextFit() { + let newIconTextFitProperty = IconTextFit.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-text-fit").value as! String + manager.iconTextFit = newIconTextFitProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-text-fit"]) + harness.triggerDisplayLink() + + manager.iconTextFit = nil + XCTAssertNil(manager.iconTextFit) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-text-fit"] as! String, defaultValue) + } + func testInitialIconTextFitPadding() { + let initialValue = manager.iconTextFitPadding + XCTAssertNil(initialValue) + } + + func testSetIconTextFitPadding() { + let value = [0.0, 0.0, 0.0, 0.0] + manager.iconTextFitPadding = value + XCTAssertEqual(manager.iconTextFitPadding, value) + XCTAssertEqual(manager.impl.layerProperties["icon-text-fit-padding"] as! [Double], value) + } + + func testSetToNilIconTextFitPadding() { + let newIconTextFitPaddingProperty = [0.0, 0.0, 0.0, 0.0] + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-text-fit-padding").value as! [Double] + manager.iconTextFitPadding = newIconTextFitPaddingProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-text-fit-padding"]) + harness.triggerDisplayLink() + + manager.iconTextFitPadding = nil + XCTAssertNil(manager.iconTextFitPadding) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-text-fit-padding"] as! [Double], defaultValue) + } func testInitialSymbolAvoidEdges() { let initialValue = manager.symbolAvoidEdges XCTAssertNil(initialValue) @@ -254,6 +429,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["symbol-placement"] as! String, defaultValue) } + func testInitialSymbolSortKey() { + let initialValue = manager.symbolSortKey + XCTAssertNil(initialValue) + } + + func testSetSymbolSortKey() { + let value = 0.0 + manager.symbolSortKey = value + XCTAssertEqual(manager.symbolSortKey, value) + XCTAssertEqual(manager.impl.layerProperties["symbol-sort-key"] as! Double, value) + } + + func testSetToNilSymbolSortKey() { + let newSymbolSortKeyProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "symbol-sort-key").value as! Double + manager.symbolSortKey = newSymbolSortKeyProperty + XCTAssertNotNil(manager.impl.layerProperties["symbol-sort-key"]) + harness.triggerDisplayLink() + + manager.symbolSortKey = nil + XCTAssertNil(manager.symbolSortKey) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["symbol-sort-key"] as! Double, defaultValue) + } func testInitialSymbolSpacing() { let initialValue = manager.symbolSpacing XCTAssertNil(initialValue) @@ -354,6 +554,61 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-allow-overlap"] as! Bool, defaultValue) } + func testInitialTextAnchor() { + let initialValue = manager.textAnchor + XCTAssertNil(initialValue) + } + + func testSetTextAnchor() { + let value = TextAnchor.testConstantValue() + manager.textAnchor = value + XCTAssertEqual(manager.textAnchor, value) + XCTAssertEqual(manager.impl.layerProperties["text-anchor"] as! String, value.rawValue) + } + + func testSetToNilTextAnchor() { + let newTextAnchorProperty = TextAnchor.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-anchor").value as! String + manager.textAnchor = newTextAnchorProperty + XCTAssertNotNil(manager.impl.layerProperties["text-anchor"]) + harness.triggerDisplayLink() + + manager.textAnchor = nil + XCTAssertNil(manager.textAnchor) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-anchor"] as! String, defaultValue) + } + func testInitialTextField() { + let initialValue = manager.textField + XCTAssertNil(initialValue) + } + + func testSetTextField() { + let value = UUID().uuidString + manager.textField = value + XCTAssertEqual(manager.textField, value) + XCTAssertEqual(manager.impl.layerProperties["text-field"] as! String, value) + } + + func testSetToNilTextField() { + let newTextFieldProperty = UUID().uuidString + let defaultValue = Value.expression(Exp(.format) { + "" + FormatOptions() + }) + manager.textField = newTextFieldProperty + XCTAssertNotNil(manager.impl.layerProperties["text-field"]) + harness.triggerDisplayLink() + + manager.textField = nil + XCTAssertNil(manager.textField) + harness.triggerDisplayLink() + + let currentValueData = try! JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last!.parameters.properties["text-field"]!) + let currentValueString = String(data: currentValueData, encoding: .utf8) + XCTAssertEqual(currentValueString, try! defaultValue.jsonString()) + } func testInitialTextFont() { let initialValue = manager.textFont XCTAssertNil(initialValue) @@ -404,6 +659,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-ignore-placement"] as! Bool, defaultValue) } + func testInitialTextJustify() { + let initialValue = manager.textJustify + XCTAssertNil(initialValue) + } + + func testSetTextJustify() { + let value = TextJustify.testConstantValue() + manager.textJustify = value + XCTAssertEqual(manager.textJustify, value) + XCTAssertEqual(manager.impl.layerProperties["text-justify"] as! String, value.rawValue) + } + + func testSetToNilTextJustify() { + let newTextJustifyProperty = TextJustify.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-justify").value as! String + manager.textJustify = newTextJustifyProperty + XCTAssertNotNil(manager.impl.layerProperties["text-justify"]) + harness.triggerDisplayLink() + + manager.textJustify = nil + XCTAssertNil(manager.textJustify) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-justify"] as! String, defaultValue) + } func testInitialTextKeepUpright() { let initialValue = manager.textKeepUpright XCTAssertNil(initialValue) @@ -429,6 +709,56 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-keep-upright"] as! Bool, defaultValue) } + func testInitialTextLetterSpacing() { + let initialValue = manager.textLetterSpacing + XCTAssertNil(initialValue) + } + + func testSetTextLetterSpacing() { + let value = 0.0 + manager.textLetterSpacing = value + XCTAssertEqual(manager.textLetterSpacing, value) + XCTAssertEqual(manager.impl.layerProperties["text-letter-spacing"] as! Double, value) + } + + func testSetToNilTextLetterSpacing() { + let newTextLetterSpacingProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-letter-spacing").value as! Double + manager.textLetterSpacing = newTextLetterSpacingProperty + XCTAssertNotNil(manager.impl.layerProperties["text-letter-spacing"]) + harness.triggerDisplayLink() + + manager.textLetterSpacing = nil + XCTAssertNil(manager.textLetterSpacing) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-letter-spacing"] as! Double, defaultValue) + } + func testInitialTextLineHeight() { + let initialValue = manager.textLineHeight + XCTAssertNil(initialValue) + } + + func testSetTextLineHeight() { + let value = 0.0 + manager.textLineHeight = value + XCTAssertEqual(manager.textLineHeight, value) + XCTAssertEqual(manager.impl.layerProperties["text-line-height"] as! Double, value) + } + + func testSetToNilTextLineHeight() { + let newTextLineHeightProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-line-height").value as! Double + manager.textLineHeight = newTextLineHeightProperty + XCTAssertNotNil(manager.impl.layerProperties["text-line-height"]) + harness.triggerDisplayLink() + + manager.textLineHeight = nil + XCTAssertNil(manager.textLineHeight) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-line-height"] as! Double, defaultValue) + } func testInitialTextMaxAngle() { let initialValue = manager.textMaxAngle XCTAssertNil(initialValue) @@ -454,6 +784,56 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-max-angle"] as! Double, defaultValue) } + func testInitialTextMaxWidth() { + let initialValue = manager.textMaxWidth + XCTAssertNil(initialValue) + } + + func testSetTextMaxWidth() { + let value = 50000.0 + manager.textMaxWidth = value + XCTAssertEqual(manager.textMaxWidth, value) + XCTAssertEqual(manager.impl.layerProperties["text-max-width"] as! Double, value) + } + + func testSetToNilTextMaxWidth() { + let newTextMaxWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-max-width").value as! Double + manager.textMaxWidth = newTextMaxWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["text-max-width"]) + harness.triggerDisplayLink() + + manager.textMaxWidth = nil + XCTAssertNil(manager.textMaxWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-max-width"] as! Double, defaultValue) + } + func testInitialTextOffset() { + let initialValue = manager.textOffset + XCTAssertNil(initialValue) + } + + func testSetTextOffset() { + let value = [0.0, 0.0] + manager.textOffset = value + XCTAssertEqual(manager.textOffset, value) + XCTAssertEqual(manager.impl.layerProperties["text-offset"] as! [Double], value) + } + + func testSetToNilTextOffset() { + let newTextOffsetProperty = [0.0, 0.0] + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-offset").value as! [Double] + manager.textOffset = newTextOffsetProperty + XCTAssertNotNil(manager.impl.layerProperties["text-offset"]) + harness.triggerDisplayLink() + + manager.textOffset = nil + XCTAssertNil(manager.textOffset) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-offset"] as! [Double], defaultValue) + } func testInitialTextOptional() { let initialValue = manager.textOptional XCTAssertNil(initialValue) @@ -529,6 +909,56 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-pitch-alignment"] as! String, defaultValue) } + func testInitialTextRadialOffset() { + let initialValue = manager.textRadialOffset + XCTAssertNil(initialValue) + } + + func testSetTextRadialOffset() { + let value = 0.0 + manager.textRadialOffset = value + XCTAssertEqual(manager.textRadialOffset, value) + XCTAssertEqual(manager.impl.layerProperties["text-radial-offset"] as! Double, value) + } + + func testSetToNilTextRadialOffset() { + let newTextRadialOffsetProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-radial-offset").value as! Double + manager.textRadialOffset = newTextRadialOffsetProperty + XCTAssertNotNil(manager.impl.layerProperties["text-radial-offset"]) + harness.triggerDisplayLink() + + manager.textRadialOffset = nil + XCTAssertNil(manager.textRadialOffset) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-radial-offset"] as! Double, defaultValue) + } + func testInitialTextRotate() { + let initialValue = manager.textRotate + XCTAssertNil(initialValue) + } + + func testSetTextRotate() { + let value = 0.0 + manager.textRotate = value + XCTAssertEqual(manager.textRotate, value) + XCTAssertEqual(manager.impl.layerProperties["text-rotate"] as! Double, value) + } + + func testSetToNilTextRotate() { + let newTextRotateProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-rotate").value as! Double + manager.textRotate = newTextRotateProperty + XCTAssertNotNil(manager.impl.layerProperties["text-rotate"]) + harness.triggerDisplayLink() + + manager.textRotate = nil + XCTAssertNil(manager.textRotate) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-rotate"] as! Double, defaultValue) + } func testInitialTextRotationAlignment() { let initialValue = manager.textRotationAlignment XCTAssertNil(initialValue) @@ -554,6 +984,56 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-rotation-alignment"] as! String, defaultValue) } + func testInitialTextSize() { + let initialValue = manager.textSize + XCTAssertNil(initialValue) + } + + func testSetTextSize() { + let value = 50000.0 + manager.textSize = value + XCTAssertEqual(manager.textSize, value) + XCTAssertEqual(manager.impl.layerProperties["text-size"] as! Double, value) + } + + func testSetToNilTextSize() { + let newTextSizeProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-size").value as! Double + manager.textSize = newTextSizeProperty + XCTAssertNotNil(manager.impl.layerProperties["text-size"]) + harness.triggerDisplayLink() + + manager.textSize = nil + XCTAssertNil(manager.textSize) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-size"] as! Double, defaultValue) + } + func testInitialTextTransform() { + let initialValue = manager.textTransform + XCTAssertNil(initialValue) + } + + func testSetTextTransform() { + let value = TextTransform.testConstantValue() + manager.textTransform = value + XCTAssertEqual(manager.textTransform, value) + XCTAssertEqual(manager.impl.layerProperties["text-transform"] as! String, value.rawValue) + } + + func testSetToNilTextTransform() { + let newTextTransformProperty = TextTransform.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-transform").value as! String + manager.textTransform = newTextTransformProperty + XCTAssertNotNil(manager.impl.layerProperties["text-transform"]) + harness.triggerDisplayLink() + + manager.textTransform = nil + XCTAssertNil(manager.textTransform) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-transform"] as! String, defaultValue) + } func testInitialTextVariableAnchor() { let initialValue = manager.textVariableAnchor XCTAssertNil(initialValue) @@ -606,6 +1086,32 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-writing-mode"] as! [TextWritingMode], defaultValue) } + func testInitialIconColor() { + let initialValue = manager.iconColor + XCTAssertNil(initialValue) + } + + func testSetIconColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.iconColor = value + XCTAssertEqual(manager.iconColor, value) + XCTAssertEqual(manager.impl.layerProperties["icon-color"] as? String, value?.rawValue) + } + + func testSetToNilIconColor() { + let newIconColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-color").value as! [Any], options: [])) + manager.iconColor = newIconColorProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-color"]) + harness.triggerDisplayLink() + + manager.iconColor = nil + XCTAssertNil(manager.iconColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } func testInitialIconColorSaturation() { let initialValue = manager.iconColorSaturation XCTAssertNil(initialValue) @@ -631,6 +1137,182 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-color-saturation"] as! Double, defaultValue) } + func testInitialIconEmissiveStrength() { + let initialValue = manager.iconEmissiveStrength + XCTAssertNil(initialValue) + } + + func testSetIconEmissiveStrength() { + let value = 50000.0 + manager.iconEmissiveStrength = value + XCTAssertEqual(manager.iconEmissiveStrength, value) + XCTAssertEqual(manager.impl.layerProperties["icon-emissive-strength"] as! Double, value) + } + + func testSetToNilIconEmissiveStrength() { + let newIconEmissiveStrengthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-emissive-strength").value as! Double + manager.iconEmissiveStrength = newIconEmissiveStrengthProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-emissive-strength"]) + harness.triggerDisplayLink() + + manager.iconEmissiveStrength = nil + XCTAssertNil(manager.iconEmissiveStrength) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-emissive-strength"] as! Double, defaultValue) + } + func testInitialIconHaloBlur() { + let initialValue = manager.iconHaloBlur + XCTAssertNil(initialValue) + } + + func testSetIconHaloBlur() { + let value = 50000.0 + manager.iconHaloBlur = value + XCTAssertEqual(manager.iconHaloBlur, value) + XCTAssertEqual(manager.impl.layerProperties["icon-halo-blur"] as! Double, value) + } + + func testSetToNilIconHaloBlur() { + let newIconHaloBlurProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-blur").value as! Double + manager.iconHaloBlur = newIconHaloBlurProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-halo-blur"]) + harness.triggerDisplayLink() + + manager.iconHaloBlur = nil + XCTAssertNil(manager.iconHaloBlur) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-halo-blur"] as! Double, defaultValue) + } + func testInitialIconHaloColor() { + let initialValue = manager.iconHaloColor + XCTAssertNil(initialValue) + } + + func testSetIconHaloColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.iconHaloColor = value + XCTAssertEqual(manager.iconHaloColor, value) + XCTAssertEqual(manager.impl.layerProperties["icon-halo-color"] as? String, value?.rawValue) + } + + func testSetToNilIconHaloColor() { + let newIconHaloColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-color").value as! [Any], options: [])) + manager.iconHaloColor = newIconHaloColorProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-halo-color"]) + harness.triggerDisplayLink() + + manager.iconHaloColor = nil + XCTAssertNil(manager.iconHaloColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-halo-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialIconHaloWidth() { + let initialValue = manager.iconHaloWidth + XCTAssertNil(initialValue) + } + + func testSetIconHaloWidth() { + let value = 50000.0 + manager.iconHaloWidth = value + XCTAssertEqual(manager.iconHaloWidth, value) + XCTAssertEqual(manager.impl.layerProperties["icon-halo-width"] as! Double, value) + } + + func testSetToNilIconHaloWidth() { + let newIconHaloWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-halo-width").value as! Double + manager.iconHaloWidth = newIconHaloWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-halo-width"]) + harness.triggerDisplayLink() + + manager.iconHaloWidth = nil + XCTAssertNil(manager.iconHaloWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-halo-width"] as! Double, defaultValue) + } + func testInitialIconImageCrossFade() { + let initialValue = manager.iconImageCrossFade + XCTAssertNil(initialValue) + } + + func testSetIconImageCrossFade() { + let value = 0.5 + manager.iconImageCrossFade = value + XCTAssertEqual(manager.iconImageCrossFade, value) + XCTAssertEqual(manager.impl.layerProperties["icon-image-cross-fade"] as! Double, value) + } + + func testSetToNilIconImageCrossFade() { + let newIconImageCrossFadeProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-image-cross-fade").value as! Double + manager.iconImageCrossFade = newIconImageCrossFadeProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-image-cross-fade"]) + harness.triggerDisplayLink() + + manager.iconImageCrossFade = nil + XCTAssertNil(manager.iconImageCrossFade) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-image-cross-fade"] as! Double, defaultValue) + } + func testInitialIconOcclusionOpacity() { + let initialValue = manager.iconOcclusionOpacity + XCTAssertNil(initialValue) + } + + func testSetIconOcclusionOpacity() { + let value = 0.5 + manager.iconOcclusionOpacity = value + XCTAssertEqual(manager.iconOcclusionOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["icon-occlusion-opacity"] as! Double, value) + } + + func testSetToNilIconOcclusionOpacity() { + let newIconOcclusionOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-occlusion-opacity").value as! Double + manager.iconOcclusionOpacity = newIconOcclusionOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-occlusion-opacity"]) + harness.triggerDisplayLink() + + manager.iconOcclusionOpacity = nil + XCTAssertNil(manager.iconOcclusionOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-occlusion-opacity"] as! Double, defaultValue) + } + func testInitialIconOpacity() { + let initialValue = manager.iconOpacity + XCTAssertNil(initialValue) + } + + func testSetIconOpacity() { + let value = 0.5 + manager.iconOpacity = value + XCTAssertEqual(manager.iconOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["icon-opacity"] as! Double, value) + } + + func testSetToNilIconOpacity() { + let newIconOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-opacity").value as! Double + manager.iconOpacity = newIconOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-opacity"]) + harness.triggerDisplayLink() + + manager.iconOpacity = nil + XCTAssertNil(manager.iconOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-opacity"] as! Double, defaultValue) + } func testInitialIconTranslate() { let initialValue = manager.iconTranslate XCTAssertNil(initialValue) @@ -681,6 +1363,183 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-translate-anchor"] as! String, defaultValue) } + func testInitialTextColor() { + let initialValue = manager.textColor + XCTAssertNil(initialValue) + } + + func testSetTextColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.textColor = value + XCTAssertEqual(manager.textColor, value) + XCTAssertEqual(manager.impl.layerProperties["text-color"] as? String, value?.rawValue) + } + + func testSetToNilTextColor() { + let newTextColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-color").value as! [Any], options: [])) + manager.textColor = newTextColorProperty + XCTAssertNotNil(manager.impl.layerProperties["text-color"]) + harness.triggerDisplayLink() + + manager.textColor = nil + XCTAssertNil(manager.textColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialTextEmissiveStrength() { + let initialValue = manager.textEmissiveStrength + XCTAssertNil(initialValue) + } + + func testSetTextEmissiveStrength() { + let value = 50000.0 + manager.textEmissiveStrength = value + XCTAssertEqual(manager.textEmissiveStrength, value) + XCTAssertEqual(manager.impl.layerProperties["text-emissive-strength"] as! Double, value) + } + + func testSetToNilTextEmissiveStrength() { + let newTextEmissiveStrengthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-emissive-strength").value as! Double + manager.textEmissiveStrength = newTextEmissiveStrengthProperty + XCTAssertNotNil(manager.impl.layerProperties["text-emissive-strength"]) + harness.triggerDisplayLink() + + manager.textEmissiveStrength = nil + XCTAssertNil(manager.textEmissiveStrength) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-emissive-strength"] as! Double, defaultValue) + } + func testInitialTextHaloBlur() { + let initialValue = manager.textHaloBlur + XCTAssertNil(initialValue) + } + + func testSetTextHaloBlur() { + let value = 50000.0 + manager.textHaloBlur = value + XCTAssertEqual(manager.textHaloBlur, value) + XCTAssertEqual(manager.impl.layerProperties["text-halo-blur"] as! Double, value) + } + + func testSetToNilTextHaloBlur() { + let newTextHaloBlurProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-blur").value as! Double + manager.textHaloBlur = newTextHaloBlurProperty + XCTAssertNotNil(manager.impl.layerProperties["text-halo-blur"]) + harness.triggerDisplayLink() + + manager.textHaloBlur = nil + XCTAssertNil(manager.textHaloBlur) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-halo-blur"] as! Double, defaultValue) + } + func testInitialTextHaloColor() { + let initialValue = manager.textHaloColor + XCTAssertNil(initialValue) + } + + func testSetTextHaloColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.textHaloColor = value + XCTAssertEqual(manager.textHaloColor, value) + XCTAssertEqual(manager.impl.layerProperties["text-halo-color"] as? String, value?.rawValue) + } + + func testSetToNilTextHaloColor() { + let newTextHaloColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-color").value as! [Any], options: [])) + manager.textHaloColor = newTextHaloColorProperty + XCTAssertNotNil(manager.impl.layerProperties["text-halo-color"]) + harness.triggerDisplayLink() + + manager.textHaloColor = nil + XCTAssertNil(manager.textHaloColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-halo-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialTextHaloWidth() { + let initialValue = manager.textHaloWidth + XCTAssertNil(initialValue) + } + + func testSetTextHaloWidth() { + let value = 50000.0 + manager.textHaloWidth = value + XCTAssertEqual(manager.textHaloWidth, value) + XCTAssertEqual(manager.impl.layerProperties["text-halo-width"] as! Double, value) + } + + func testSetToNilTextHaloWidth() { + let newTextHaloWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-halo-width").value as! Double + manager.textHaloWidth = newTextHaloWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["text-halo-width"]) + harness.triggerDisplayLink() + + manager.textHaloWidth = nil + XCTAssertNil(manager.textHaloWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-halo-width"] as! Double, defaultValue) + } + func testInitialTextOcclusionOpacity() { + let initialValue = manager.textOcclusionOpacity + XCTAssertNil(initialValue) + } + + func testSetTextOcclusionOpacity() { + let value = 0.5 + manager.textOcclusionOpacity = value + XCTAssertEqual(manager.textOcclusionOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["text-occlusion-opacity"] as! Double, value) + } + + func testSetToNilTextOcclusionOpacity() { + let newTextOcclusionOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-occlusion-opacity").value as! Double + manager.textOcclusionOpacity = newTextOcclusionOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["text-occlusion-opacity"]) + harness.triggerDisplayLink() + + manager.textOcclusionOpacity = nil + XCTAssertNil(manager.textOcclusionOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-occlusion-opacity"] as! Double, defaultValue) + } + func testInitialTextOpacity() { + let initialValue = manager.textOpacity + XCTAssertNil(initialValue) + } + + func testSetTextOpacity() { + let value = 0.5 + manager.textOpacity = value + XCTAssertEqual(manager.textOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["text-opacity"] as! Double, value) + } + + func testSetToNilTextOpacity() { + let newTextOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-opacity").value as! Double + manager.textOpacity = newTextOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["text-opacity"]) + harness.triggerDisplayLink() + + manager.textOpacity = nil + XCTAssertNil(manager.textOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-opacity"] as! Double, defaultValue) + } func testInitialTextTranslate() { let initialValue = manager.textTranslate XCTAssertNil(initialValue) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift index d9fe73da8191..b50b8813b2c7 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift @@ -53,16 +53,14 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { guard let layer = try? self.mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) else { return false } - return layer.fillOpacity == .expression(Exp(.number) { - Exp(.get) { - "fill-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - }) + let fallbackValue = self.manager.fillOpacity ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? (try? JSONSerialization.data(withJSONObject: fallbackValue)) ?? Data() + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = String(decoding: fallbackValueData, as: UTF8.self) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"fill-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + let currentValueString = (try? layer.fillOpacity.toString()) ?? "" + return currentValueString == expectedString }), evaluatedWith: nil, handler: nil) waitForExpectations(timeout: 2, handler: nil) @@ -216,16 +214,13 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) - XCTAssertEqual(layer.fillSortKey, .expression(Exp(.number) { - Exp(.get) { - "fill-sort-key" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.fillSortKey ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-sort-key").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"fill-sort-key\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.fillSortKey.toString(), expectedString) // Test that the property can be reset to nil annotation.fillSortKey = nil @@ -259,16 +254,13 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) - XCTAssertEqual(layer.fillColor, .expression(Exp(.toColor) { - Exp(.get) { - "fill-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.fillColor ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"fill-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.fillColor.toString(), expectedString) // Test that the property can be reset to nil annotation.fillColor = nil @@ -302,16 +294,13 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) - XCTAssertEqual(layer.fillOpacity, .expression(Exp(.number) { - Exp(.get) { - "fill-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.fillOpacity ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"fill-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.fillOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.fillOpacity = nil @@ -345,16 +334,13 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) - XCTAssertEqual(layer.fillOutlineColor, .expression(Exp(.toColor) { - Exp(.get) { - "fill-outline-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.fillOutlineColor ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-outline-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"fill-outline-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.fillOutlineColor.toString(), expectedString) // Test that the property can be reset to nil annotation.fillOutlineColor = nil @@ -388,16 +374,13 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) - XCTAssertEqual(layer.fillPattern, .expression(Exp(.image) { - Exp(.get) { - "fill-pattern" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.fillPattern ?? StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-pattern").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"image\",[\"coalesce\",[\"get\",\"fill-pattern\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.fillPattern.toString(), expectedString) // Test that the property can be reset to nil annotation.fillPattern = nil diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift index aceb8b4b4a86..a5c4ea0343ad 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift @@ -36,6 +36,31 @@ final class PolygonAnnotationManagerTests: XCTestCase, AnnotationInteractionDele super.tearDown() } + func testInitialFillSortKey() { + let initialValue = manager.fillSortKey + XCTAssertNil(initialValue) + } + + func testSetFillSortKey() { + let value = 0.0 + manager.fillSortKey = value + XCTAssertEqual(manager.fillSortKey, value) + XCTAssertEqual(manager.impl.layerProperties["fill-sort-key"] as! Double, value) + } + + func testSetToNilFillSortKey() { + let newFillSortKeyProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-sort-key").value as! Double + manager.fillSortKey = newFillSortKeyProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-sort-key"]) + harness.triggerDisplayLink() + + manager.fillSortKey = nil + XCTAssertNil(manager.fillSortKey) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-sort-key"] as! Double, defaultValue) + } func testInitialFillAntialias() { let initialValue = manager.fillAntialias XCTAssertNil(initialValue) @@ -61,6 +86,32 @@ final class PolygonAnnotationManagerTests: XCTestCase, AnnotationInteractionDele XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-antialias"] as! Bool, defaultValue) } + func testInitialFillColor() { + let initialValue = manager.fillColor + XCTAssertNil(initialValue) + } + + func testSetFillColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.fillColor = value + XCTAssertEqual(manager.fillColor, value) + XCTAssertEqual(manager.impl.layerProperties["fill-color"] as? String, value?.rawValue) + } + + func testSetToNilFillColor() { + let newFillColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-color").value as! [Any], options: [])) + manager.fillColor = newFillColorProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-color"]) + harness.triggerDisplayLink() + + manager.fillColor = nil + XCTAssertNil(manager.fillColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } func testInitialFillEmissiveStrength() { let initialValue = manager.fillEmissiveStrength XCTAssertNil(initialValue) @@ -86,6 +137,82 @@ final class PolygonAnnotationManagerTests: XCTestCase, AnnotationInteractionDele XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-emissive-strength"] as! Double, defaultValue) } + func testInitialFillOpacity() { + let initialValue = manager.fillOpacity + XCTAssertNil(initialValue) + } + + func testSetFillOpacity() { + let value = 0.5 + manager.fillOpacity = value + XCTAssertEqual(manager.fillOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["fill-opacity"] as! Double, value) + } + + func testSetToNilFillOpacity() { + let newFillOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-opacity").value as! Double + manager.fillOpacity = newFillOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-opacity"]) + harness.triggerDisplayLink() + + manager.fillOpacity = nil + XCTAssertNil(manager.fillOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-opacity"] as! Double, defaultValue) + } + func testInitialFillOutlineColor() { + let initialValue = manager.fillOutlineColor + XCTAssertNil(initialValue) + } + + func testSetFillOutlineColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.fillOutlineColor = value + XCTAssertEqual(manager.fillOutlineColor, value) + XCTAssertEqual(manager.impl.layerProperties["fill-outline-color"] as? String, value?.rawValue) + } + + func testSetToNilFillOutlineColor() { + let newFillOutlineColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-outline-color").value as! [Any], options: [])) + manager.fillOutlineColor = newFillOutlineColorProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-outline-color"]) + harness.triggerDisplayLink() + + manager.fillOutlineColor = nil + XCTAssertNil(manager.fillOutlineColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-outline-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialFillPattern() { + let initialValue = manager.fillPattern + XCTAssertNil(initialValue) + } + + func testSetFillPattern() { + let value = UUID().uuidString + manager.fillPattern = value + XCTAssertEqual(manager.fillPattern, value) + XCTAssertEqual(manager.impl.layerProperties["fill-pattern"] as! String, value) + } + + func testSetToNilFillPattern() { + let newFillPatternProperty = UUID().uuidString + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-pattern").value as! String + manager.fillPattern = newFillPatternProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-pattern"]) + harness.triggerDisplayLink() + + manager.fillPattern = nil + XCTAssertNil(manager.fillPattern) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-pattern"] as! String, defaultValue) + } func testInitialFillTranslate() { let initialValue = manager.fillTranslate XCTAssertNil(initialValue) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift index caca942783f1..7cc202f9acb7 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift @@ -47,16 +47,14 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { guard let layer = try? self.mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) else { return false } - return layer.lineWidth == .expression(Exp(.number) { - Exp(.get) { - "line-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - }) + let fallbackValue = self.manager.lineWidth ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? (try? JSONSerialization.data(withJSONObject: fallbackValue)) ?? Data() + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = String(decoding: fallbackValueData, as: UTF8.self) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + let currentValueString = (try? layer.lineWidth.toString()) ?? "" + return currentValueString == expectedString }), evaluatedWith: nil, handler: nil) waitForExpectations(timeout: 2, handler: nil) @@ -418,16 +416,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineJoin, .expression(Exp(.toString) { - Exp(.get) { - "line-join" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineJoin ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-join").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-string\",[\"coalesce\",[\"get\",\"line-join\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.lineJoin.toString(), expectedString) // Test that the property can be reset to nil annotation.lineJoin = nil @@ -455,16 +450,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineSortKey, .expression(Exp(.number) { - Exp(.get) { - "line-sort-key" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineSortKey ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-sort-key").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-sort-key\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineSortKey.toString(), expectedString) // Test that the property can be reset to nil annotation.lineSortKey = nil @@ -492,16 +484,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineZOffset, .expression(Exp(.number) { - Exp(.get) { - "line-z-offset" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineZOffset ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-z-offset").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-z-offset\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineZOffset.toString(), expectedString) // Test that the property can be reset to nil annotation.lineZOffset = nil @@ -529,16 +518,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineBlur, .expression(Exp(.number) { - Exp(.get) { - "line-blur" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineBlur ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-blur").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-blur\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineBlur.toString(), expectedString) // Test that the property can be reset to nil annotation.lineBlur = nil @@ -566,16 +552,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineBorderColor, .expression(Exp(.toColor) { - Exp(.get) { - "line-border-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineBorderColor ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-border-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"line-border-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineBorderColor.toString(), expectedString) // Test that the property can be reset to nil annotation.lineBorderColor = nil @@ -603,16 +586,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineBorderWidth, .expression(Exp(.number) { - Exp(.get) { - "line-border-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineBorderWidth ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-border-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-border-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineBorderWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.lineBorderWidth = nil @@ -640,16 +620,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineColor, .expression(Exp(.toColor) { - Exp(.get) { - "line-color" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineColor ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-color").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"to-color\",[\"coalesce\",[\"get\",\"line-color\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineColor.toString(), expectedString) // Test that the property can be reset to nil annotation.lineColor = nil @@ -677,16 +654,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineGapWidth, .expression(Exp(.number) { - Exp(.get) { - "line-gap-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineGapWidth ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-gap-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-gap-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineGapWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.lineGapWidth = nil @@ -714,16 +688,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineOffset, .expression(Exp(.number) { - Exp(.get) { - "line-offset" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineOffset ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-offset").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-offset\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineOffset.toString(), expectedString) // Test that the property can be reset to nil annotation.lineOffset = nil @@ -751,16 +722,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineOpacity, .expression(Exp(.number) { - Exp(.get) { - "line-opacity" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineOpacity ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-opacity").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-opacity\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineOpacity.toString(), expectedString) // Test that the property can be reset to nil annotation.lineOpacity = nil @@ -788,16 +756,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.linePattern, .expression(Exp(.image) { - Exp(.get) { - "line-pattern" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.linePattern ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-pattern").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"image\",[\"coalesce\",[\"get\",\"line-pattern\",[\"object\",[\"get\",\"layerProperties\"]]],\"\(fallbackValueString)\"]]" + XCTAssertEqual(try layer.linePattern.toString(), expectedString) // Test that the property can be reset to nil annotation.linePattern = nil @@ -825,16 +790,13 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { // Test that the value is synced to the layer manager.impl.syncSourceAndLayerIfNeeded() var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) - XCTAssertEqual(layer.lineWidth, .expression(Exp(.number) { - Exp(.get) { - "line-width" - Exp(.objectExpression) { - Exp(.get) { - "layerProperties" - } - } - } - })) + let fallbackValue = self.manager.lineWidth ?? StyleManager.layerPropertyDefaultValue(for: .line, property: "line-width").value + let fallbackValueData = JSONSerialization.isValidJSONObject(fallbackValue) + ? try XCTUnwrap(JSONSerialization.data(withJSONObject: fallbackValue)) + : Data(String(describing: fallbackValue).utf8) + let fallbackValueString = try XCTUnwrap(String(decoding: fallbackValueData, as: UTF8.self)) + let expectedString = "[\"number\",[\"coalesce\",[\"get\",\"line-width\",[\"object\",[\"get\",\"layerProperties\"]]],\(fallbackValueString)]]" + XCTAssertEqual(try layer.lineWidth.toString(), expectedString) // Test that the property can be reset to nil annotation.lineWidth = nil diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift index 617ce73ad326..c28257dab606 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift @@ -55,6 +55,31 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-cap"] as! String, defaultValue) } + func testInitialLineJoin() { + let initialValue = manager.lineJoin + XCTAssertNil(initialValue) + } + + func testSetLineJoin() { + let value = LineJoin.testConstantValue() + manager.lineJoin = value + XCTAssertEqual(manager.lineJoin, value) + XCTAssertEqual(manager.impl.layerProperties["line-join"] as! String, value.rawValue) + } + + func testSetToNilLineJoin() { + let newLineJoinProperty = LineJoin.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-join").value as! String + manager.lineJoin = newLineJoinProperty + XCTAssertNotNil(manager.impl.layerProperties["line-join"]) + harness.triggerDisplayLink() + + manager.lineJoin = nil + XCTAssertNil(manager.lineJoin) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-join"] as! String, defaultValue) + } func testInitialLineMiterLimit() { let initialValue = manager.lineMiterLimit XCTAssertNil(initialValue) @@ -105,6 +130,158 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-round-limit"] as! Double, defaultValue) } + func testInitialLineSortKey() { + let initialValue = manager.lineSortKey + XCTAssertNil(initialValue) + } + + func testSetLineSortKey() { + let value = 0.0 + manager.lineSortKey = value + XCTAssertEqual(manager.lineSortKey, value) + XCTAssertEqual(manager.impl.layerProperties["line-sort-key"] as! Double, value) + } + + func testSetToNilLineSortKey() { + let newLineSortKeyProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-sort-key").value as! Double + manager.lineSortKey = newLineSortKeyProperty + XCTAssertNotNil(manager.impl.layerProperties["line-sort-key"]) + harness.triggerDisplayLink() + + manager.lineSortKey = nil + XCTAssertNil(manager.lineSortKey) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-sort-key"] as! Double, defaultValue) + } + func testInitialLineZOffset() { + let initialValue = manager.lineZOffset + XCTAssertNil(initialValue) + } + + func testSetLineZOffset() { + let value = 0.0 + manager.lineZOffset = value + XCTAssertEqual(manager.lineZOffset, value) + XCTAssertEqual(manager.impl.layerProperties["line-z-offset"] as! Double, value) + } + + func testSetToNilLineZOffset() { + let newLineZOffsetProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-z-offset").value as! Double + manager.lineZOffset = newLineZOffsetProperty + XCTAssertNotNil(manager.impl.layerProperties["line-z-offset"]) + harness.triggerDisplayLink() + + manager.lineZOffset = nil + XCTAssertNil(manager.lineZOffset) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-z-offset"] as! Double, defaultValue) + } + func testInitialLineBlur() { + let initialValue = manager.lineBlur + XCTAssertNil(initialValue) + } + + func testSetLineBlur() { + let value = 50000.0 + manager.lineBlur = value + XCTAssertEqual(manager.lineBlur, value) + XCTAssertEqual(manager.impl.layerProperties["line-blur"] as! Double, value) + } + + func testSetToNilLineBlur() { + let newLineBlurProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-blur").value as! Double + manager.lineBlur = newLineBlurProperty + XCTAssertNotNil(manager.impl.layerProperties["line-blur"]) + harness.triggerDisplayLink() + + manager.lineBlur = nil + XCTAssertNil(manager.lineBlur) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-blur"] as! Double, defaultValue) + } + func testInitialLineBorderColor() { + let initialValue = manager.lineBorderColor + XCTAssertNil(initialValue) + } + + func testSetLineBorderColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.lineBorderColor = value + XCTAssertEqual(manager.lineBorderColor, value) + XCTAssertEqual(manager.impl.layerProperties["line-border-color"] as? String, value?.rawValue) + } + + func testSetToNilLineBorderColor() { + let newLineBorderColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .line, property: "line-border-color").value as! [Any], options: [])) + manager.lineBorderColor = newLineBorderColorProperty + XCTAssertNotNil(manager.impl.layerProperties["line-border-color"]) + harness.triggerDisplayLink() + + manager.lineBorderColor = nil + XCTAssertNil(manager.lineBorderColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-border-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } + func testInitialLineBorderWidth() { + let initialValue = manager.lineBorderWidth + XCTAssertNil(initialValue) + } + + func testSetLineBorderWidth() { + let value = 50000.0 + manager.lineBorderWidth = value + XCTAssertEqual(manager.lineBorderWidth, value) + XCTAssertEqual(manager.impl.layerProperties["line-border-width"] as! Double, value) + } + + func testSetToNilLineBorderWidth() { + let newLineBorderWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-border-width").value as! Double + manager.lineBorderWidth = newLineBorderWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["line-border-width"]) + harness.triggerDisplayLink() + + manager.lineBorderWidth = nil + XCTAssertNil(manager.lineBorderWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-border-width"] as! Double, defaultValue) + } + func testInitialLineColor() { + let initialValue = manager.lineColor + XCTAssertNil(initialValue) + } + + func testSetLineColor() { + let value = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + manager.lineColor = value + XCTAssertEqual(manager.lineColor, value) + XCTAssertEqual(manager.impl.layerProperties["line-color"] as? String, value?.rawValue) + } + + func testSetToNilLineColor() { + let newLineColorProperty = StyleColor(red: 255, green: 0, blue: 255, alpha: 1) + let defaultValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: StyleManager.layerPropertyDefaultValue(for: .line, property: "line-color").value as! [Any], options: [])) + manager.lineColor = newLineColorProperty + XCTAssertNotNil(manager.impl.layerProperties["line-color"]) + harness.triggerDisplayLink() + + manager.lineColor = nil + XCTAssertNil(manager.lineColor) + harness.triggerDisplayLink() + + let currentValue = try! JSONDecoder().decode(StyleColor.self, from: JSONSerialization.data(withJSONObject: harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-color"] as! [Any])) + XCTAssertEqual(currentValue, defaultValue) + } func testInitialLineDasharray() { let initialValue = manager.lineDasharray XCTAssertNil(initialValue) @@ -180,6 +357,31 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-emissive-strength"] as! Double, defaultValue) } + func testInitialLineGapWidth() { + let initialValue = manager.lineGapWidth + XCTAssertNil(initialValue) + } + + func testSetLineGapWidth() { + let value = 50000.0 + manager.lineGapWidth = value + XCTAssertEqual(manager.lineGapWidth, value) + XCTAssertEqual(manager.impl.layerProperties["line-gap-width"] as! Double, value) + } + + func testSetToNilLineGapWidth() { + let newLineGapWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-gap-width").value as! Double + manager.lineGapWidth = newLineGapWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["line-gap-width"]) + harness.triggerDisplayLink() + + manager.lineGapWidth = nil + XCTAssertNil(manager.lineGapWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-gap-width"] as! Double, defaultValue) + } func testInitialLineOcclusionOpacity() { let initialValue = manager.lineOcclusionOpacity XCTAssertNil(initialValue) @@ -205,6 +407,81 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-occlusion-opacity"] as! Double, defaultValue) } + func testInitialLineOffset() { + let initialValue = manager.lineOffset + XCTAssertNil(initialValue) + } + + func testSetLineOffset() { + let value = 0.0 + manager.lineOffset = value + XCTAssertEqual(manager.lineOffset, value) + XCTAssertEqual(manager.impl.layerProperties["line-offset"] as! Double, value) + } + + func testSetToNilLineOffset() { + let newLineOffsetProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-offset").value as! Double + manager.lineOffset = newLineOffsetProperty + XCTAssertNotNil(manager.impl.layerProperties["line-offset"]) + harness.triggerDisplayLink() + + manager.lineOffset = nil + XCTAssertNil(manager.lineOffset) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-offset"] as! Double, defaultValue) + } + func testInitialLineOpacity() { + let initialValue = manager.lineOpacity + XCTAssertNil(initialValue) + } + + func testSetLineOpacity() { + let value = 0.5 + manager.lineOpacity = value + XCTAssertEqual(manager.lineOpacity, value) + XCTAssertEqual(manager.impl.layerProperties["line-opacity"] as! Double, value) + } + + func testSetToNilLineOpacity() { + let newLineOpacityProperty = 0.5 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-opacity").value as! Double + manager.lineOpacity = newLineOpacityProperty + XCTAssertNotNil(manager.impl.layerProperties["line-opacity"]) + harness.triggerDisplayLink() + + manager.lineOpacity = nil + XCTAssertNil(manager.lineOpacity) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-opacity"] as! Double, defaultValue) + } + func testInitialLinePattern() { + let initialValue = manager.linePattern + XCTAssertNil(initialValue) + } + + func testSetLinePattern() { + let value = UUID().uuidString + manager.linePattern = value + XCTAssertEqual(manager.linePattern, value) + XCTAssertEqual(manager.impl.layerProperties["line-pattern"] as! String, value) + } + + func testSetToNilLinePattern() { + let newLinePatternProperty = UUID().uuidString + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-pattern").value as! String + manager.linePattern = newLinePatternProperty + XCTAssertNotNil(manager.impl.layerProperties["line-pattern"]) + harness.triggerDisplayLink() + + manager.linePattern = nil + XCTAssertNil(manager.linePattern) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-pattern"] as! String, defaultValue) + } func testInitialLineTranslate() { let initialValue = manager.lineTranslate XCTAssertNil(initialValue) @@ -331,6 +608,31 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-trim-offset"] as! [Double], defaultValue) } + func testInitialLineWidth() { + let initialValue = manager.lineWidth + XCTAssertNil(initialValue) + } + + func testSetLineWidth() { + let value = 50000.0 + manager.lineWidth = value + XCTAssertEqual(manager.lineWidth, value) + XCTAssertEqual(manager.impl.layerProperties["line-width"] as! Double, value) + } + + func testSetToNilLineWidth() { + let newLineWidthProperty = 50000.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-width").value as! Double + manager.lineWidth = newLineWidthProperty + XCTAssertNotNil(manager.impl.layerProperties["line-width"]) + harness.triggerDisplayLink() + + manager.lineWidth = nil + XCTAssertNil(manager.lineWidth) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-width"] as! Double, defaultValue) + } func testInitialSlot() { let initialValue = manager.slot XCTAssertNil(initialValue)