diff options
Diffstat (limited to 'test/style')
-rw-r--r-- | test/style/conversion/geojson_options.test.cpp | 12 | ||||
-rw-r--r-- | test/style/conversion/light.test.cpp | 23 | ||||
-rw-r--r-- | test/style/expression/expression.test.cpp | 3 |
3 files changed, 35 insertions, 3 deletions
diff --git a/test/style/conversion/geojson_options.test.cpp b/test/style/conversion/geojson_options.test.cpp index 181189775b..aa84686dce 100644 --- a/test/style/conversion/geojson_options.test.cpp +++ b/test/style/conversion/geojson_options.test.cpp @@ -38,6 +38,7 @@ TEST(GeoJSONOptions, RetainsDefaults) { ASSERT_EQ(converted.cluster, defaults.cluster); ASSERT_EQ(converted.clusterRadius, defaults.clusterRadius); ASSERT_EQ(converted.clusterMaxZoom, defaults.clusterMaxZoom); + ASSERT_TRUE(converted.clusterProperties.empty()); } TEST(GeoJSONOptions, FullConversion) { @@ -49,7 +50,12 @@ TEST(GeoJSONOptions, FullConversion) { "cluster": true, "clusterRadius": 4, "clusterMaxZoom": 5, - "lineMetrics": true + "lineMetrics": true, + "clusterProperties": { + "max": ["max", ["get", "scalerank"]], + "sum": [["+", ["accumulated"], ["get", "sum"]], ["get", "scalerank"]], + "has_island": ["any", ["==", ["get", "featureclass"], "island"]] + } })JSON", error); // GeoJSON-VT @@ -63,4 +69,8 @@ TEST(GeoJSONOptions, FullConversion) { ASSERT_EQ(converted.cluster, true); ASSERT_EQ(converted.clusterRadius, 4); ASSERT_EQ(converted.clusterMaxZoom, 5); + ASSERT_EQ(converted.clusterProperties.size(), 3); + ASSERT_EQ(converted.clusterProperties.count("max"), 1); + ASSERT_EQ(converted.clusterProperties.count("sum"), 1); + ASSERT_EQ(converted.clusterProperties.count("has_island"), 1); } diff --git a/test/style/conversion/light.test.cpp b/test/style/conversion/light.test.cpp index 092c476277..e49667f319 100644 --- a/test/style/conversion/light.test.cpp +++ b/test/style/conversion/light.test.cpp @@ -5,8 +5,10 @@ #include <mbgl/style/conversion/light.hpp> #include <mbgl/style/conversion_impl.hpp> #include <mbgl/style/position.hpp> +#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/util/color.hpp> #include <mbgl/util/chrono.hpp> +#include <mbgl/util/rapidjson.hpp> #include <array> @@ -24,6 +26,27 @@ TEST(StyleConversion, Light) { { auto light = parseLight("{}"); ASSERT_TRUE((bool) light); + + const mbgl::JSValue colorValue("blue"); + light->setProperty("color", &colorValue); + + ASSERT_FALSE(light->getColor().isUndefined()); + ASSERT_TRUE(light->getColor().isConstant()); + ASSERT_EQ(light->getColor().asConstant(), mbgl::Color::blue()); + + const mbgl::JSValue intensityValue(0.5); + light->setProperty("intensity", &intensityValue); + ASSERT_FALSE(light->getIntensity().isUndefined()); + ASSERT_TRUE(light->getIntensity().isConstant()); + ASSERT_EQ(light->getIntensity().asConstant(), 0.5); + + mbgl::JSValue::AllocatorType allocator; + const mbgl::JSValue positionValue(std::move(mbgl::JSValue(rapidjson::kArrayType).PushBack(1.f, allocator).PushBack(2.f, allocator).PushBack(3.f, allocator).Move())); + light->setProperty("position", &positionValue); + ASSERT_FALSE(light->getPosition().isUndefined()); + ASSERT_TRUE(light->getPosition().isConstant()); + std::array<float, 3> expected{{ 1.f, 2.f, 3.f }}; + ASSERT_EQ(light->getPosition().asConstant(), mbgl::style::Position({ expected })); } { diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index 8e2acfcd32..dd986c98f5 100644 --- a/test/style/expression/expression.test.cpp +++ b/test/style/expression/expression.test.cpp @@ -36,8 +36,7 @@ TEST(Expression, IsExpression) { // TODO: "feature-state": https://github.com/mapbox/mapbox-gl-native/issues/12613 // TODO: "interpolate-hcl": https://github.com/mapbox/mapbox-gl-native/issues/8720 // TODO: "interpolate-lab": https://github.com/mapbox/mapbox-gl-native/issues/8720 - // TODO: "accumulated": https://github.com/mapbox/mapbox-gl-native/issues/14043 - if (name == "feature-state" || name == "interpolate-hcl" || name == "interpolate-lab" || name == "accumulated") { + if (name == "feature-state" || name == "interpolate-hcl" || name == "interpolate-lab") { if (expression::isExpression(conversion::Convertible(expression))) { ASSERT_TRUE(false) << "Expression name" << name << "is implemented - please update Expression.IsExpression test."; } |