summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-06-28 14:58:52 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-06-29 15:38:11 -0700
commit6dfe56510caa87b3e0fdbb8256d13ec955764d53 (patch)
tree0df4859ec90a88d2fca83c18c2aef28924db25ae /platform/darwin/test/MGLBackgroundStyleLayerTests.mm
parent542a4b4501794653b55fd1ffc60cb01348d8fc88 (diff)
downloadqtlocation-mapboxgl-6dfe56510caa87b3e0fdbb8256d13ec955764d53.tar.gz
[darwin] Replace use of *Stops with expressions DSL
Diffstat (limited to 'platform/darwin/test/MGLBackgroundStyleLayerTests.mm')
-rw-r--r--platform/darwin/test/MGLBackgroundStyleLayerTests.mm40
1 files changed, 22 insertions, 18 deletions
diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
index bf18b2d30e..9f805160d1 100644
--- a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
+++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
@@ -8,6 +8,7 @@
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/transition_options.hpp>
+#include <mbgl/style/expression/dsl.hpp>
@interface MGLBackgroundLayerTests : MGLStyleLayerTests
@end
@@ -45,11 +46,12 @@
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
layer.backgroundColor = functionExpression;
- mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
- { -INFINITY, { 1, 0, 0, 1 } },
- { 18, { 1, 0, 0, 1 } },
- }};
- propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
+ {
+ using namespace mbgl::style::expression::dsl;
+ propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
+ step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
+ );
+ }
XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
@"Setting backgroundColor to a camera expression should update background-color.");
@@ -85,23 +87,24 @@
@"background-opacity should be unset initially.");
NSExpression *defaultExpression = layer.backgroundOpacity;
- NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
+ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
layer.backgroundOpacity = constantExpression;
- mbgl::style::PropertyValue<float> propertyValue = { 0xff };
+ mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
@"Setting backgroundOpacity to a constant value expression should update background-opacity.");
XCTAssertEqualObjects(layer.backgroundOpacity, constantExpression,
@"backgroundOpacity should round-trip constant value expressions.");
- constantExpression = [NSExpression expressionWithFormat:@"0xff"];
+ constantExpression = [NSExpression expressionWithFormat:@"1"];
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
layer.backgroundOpacity = functionExpression;
- mbgl::style::IntervalStops<float> intervalStops = {{
- { -INFINITY, 0xff },
- { 18, 0xff },
- }};
- propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
+ {
+ using namespace mbgl::style::expression::dsl;
+ propertyValue = mbgl::style::CameraFunction<float>(
+ step(zoom(), literal(1.0), 18.0, literal(1.0))
+ );
+ }
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
@"Setting backgroundOpacity to a camera expression should update background-opacity.");
@@ -149,11 +152,12 @@
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
layer.backgroundPattern = functionExpression;
- mbgl::style::IntervalStops<std::string> intervalStops = {{
- { -INFINITY, "Background Pattern" },
- { 18, "Background Pattern" },
- }};
- propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
+ {
+ using namespace mbgl::style::expression::dsl;
+ propertyValue = mbgl::style::CameraFunction<std::string>(
+ step(zoom(), literal("Background Pattern"), 18.0, literal("Background Pattern"))
+ );
+ }
XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
@"Setting backgroundPattern to a camera expression should update background-pattern.");