summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-05-14 01:17:25 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2020-05-26 20:35:05 +0300
commitab7f1d355bdf437bfcf3d1ad39028f9dc80d7ff5 (patch)
tree3165ac0c6cb7599f49eb78c477fe42094ff5897a
parent1bc45e9022e4b04b53dad189da1fc1bdd30d1e6a (diff)
downloadqtlocation-mapboxgl-ab7f1d355bdf437bfcf3d1ad39028f9dc80d7ff5.tar.gz
[core][tests] Add StyleConversion.GetLayerGenericPropertyDefaultValues unit test
-rw-r--r--test/style/conversion/layer.test.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp
index 9d04c48d28..4016307373 100644
--- a/test/style/conversion/layer.test.cpp
+++ b/test/style/conversion/layer.test.cpp
@@ -1,11 +1,11 @@
#include <mbgl/test/util.hpp>
+#include <rapidjson/prettywriter.h>
#include <mbgl/style/conversion/filter.hpp>
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
-
-#include <rapidjson/prettywriter.h>
+#include <mbgl/style/layers/symbol_layer_properties.hpp>
using namespace mbgl;
using namespace mbgl::style;
@@ -164,4 +164,33 @@ TEST(StyleConversion, SetLayerGenericProperties) {
const JSValue newMaxZoom(22.0f);
layer->setProperty("maxzoom", Convertible(&newMaxZoom));
EXPECT_EQ(22.0f, layer->getMaxZoom());
+}
+
+TEST(StyleConversion, GetLayerGenericPropertyDefaultValues) {
+ auto layer = parseLayer(R"JSON({
+ "type": "symbol",
+ "id": "symbol",
+ "source": "composite"
+ })JSON");
+
+ ASSERT_NE(nullptr, layer);
+ StyleProperty maxzoom = layer->getPropertyDefaultValue("maxzoom");
+ EXPECT_EQ(StyleProperty::Kind::Constant, maxzoom.getKind());
+ EXPECT_EQ(Value(std::numeric_limits<double>::infinity()), maxzoom.getValue());
+
+ StyleProperty minzoom = layer->getPropertyDefaultValue("minzoom");
+ EXPECT_EQ(StyleProperty::Kind::Constant, minzoom.getKind());
+ EXPECT_EQ(Value(-std::numeric_limits<double>::infinity()), minzoom.getValue());
+
+ StyleProperty visibility = layer->getPropertyDefaultValue("visibility");
+ EXPECT_EQ(StyleProperty::Kind::Constant, visibility.getKind());
+ EXPECT_EQ(Value("visible"), visibility.getValue());
+
+ StyleProperty symbolSpacing = layer->getPropertyDefaultValue("symbol-spacing");
+ EXPECT_EQ(StyleProperty::Kind::Constant, symbolSpacing.getKind());
+ EXPECT_EQ(Value(SymbolSpacing::defaultValue()), symbolSpacing.getValue());
+
+ StyleProperty nonexistent = layer->getPropertyDefaultValue("nonexistent");
+ EXPECT_EQ(StyleProperty::Kind::Undefined, nonexistent.getKind());
+ EXPECT_EQ(Value(), nonexistent.getValue());
} \ No newline at end of file