summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-05-06 18:06:55 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2020-05-26 20:35:04 +0300
commit524cab8dd030d3c5735222f9f355d8d0997e12a7 (patch)
treed854e60aef710bfc7297f99af48e6512728c2a67
parent670c4a34b12ffd37ce1aa2dcfdff0f65930fd759 (diff)
downloadqtlocation-mapboxgl-524cab8dd030d3c5735222f9f355d8d0997e12a7.tar.gz
[test] Update Map.UniversalStyleGetter unit test
-rw-r--r--test/map/map.test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 80118f41ec..780479c463 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -1027,6 +1027,24 @@ TEST(Map, Issue15342) {
test.runLoop.run();
}
+namespace {
+
+void checkConstProperty(Layer* layer, const std::string& propertyName, const std::string& expected) {
+ StyleProperty property = layer->getProperty(propertyName);
+ ASSERT_TRUE(property.getValue());
+ EXPECT_EQ(StyleProperty::Kind::Constant, property.getKind());
+ EXPECT_EQ(expected, *property.getValue().getString());
+}
+
+void checkConstProperty(Layer* layer, const std::string& propertyName, double expected) {
+ StyleProperty property = layer->getProperty(propertyName);
+ ASSERT_TRUE(property.getValue());
+ EXPECT_EQ(StyleProperty::Kind::Constant, property.getKind());
+ EXPECT_EQ(expected, *property.getValue().getDouble());
+}
+
+} // namespace
+
TEST(Map, UniversalStyleGetter) {
MapTest<> test;
@@ -1041,6 +1059,12 @@ TEST(Map, UniversalStyleGetter) {
"id": "line",
"type": "line",
"source": "mapbox",
+ "source-layer": "road",
+ "minzoom": 11,
+ "maxzoom": 16,
+ "filter": [
+ "all", [ "==", "class", "street" ], [ "==", "structure", "tunnel" ]
+ ],
"paint": {
"line-color": "red",
"line-opacity": 0.5,
@@ -1063,6 +1087,22 @@ TEST(Map, UniversalStyleGetter) {
ASSERT_FALSE(nonexistent.getValue());
EXPECT_EQ(StyleProperty::Kind::Undefined, nonexistent.getKind());
+ checkConstProperty(lineLayer, "visibility", "visible");
+ checkConstProperty(lineLayer, "source", "mapbox");
+ checkConstProperty(lineLayer, "source-layer", "road");
+ checkConstProperty(lineLayer, "type", "line");
+ checkConstProperty(lineLayer, "minzoom", 11);
+ checkConstProperty(lineLayer, "maxzoom", 16);
+
+ StyleProperty filter = lineLayer->getProperty("filter");
+ ASSERT_TRUE(filter.getValue());
+ EXPECT_EQ(StyleProperty::Kind::Expression, filter.getKind());
+ ASSERT_TRUE(filter.getValue().getArray());
+ const auto& filterExpression = *filter.getValue().getArray();
+ EXPECT_EQ(3u, filterExpression.size());
+ ASSERT_TRUE(filterExpression[0].getString());
+ EXPECT_EQ("all", *filterExpression[0].getString());
+
StyleProperty undefined = lineLayer->getProperty("line-blur");
ASSERT_FALSE(undefined.getValue());
EXPECT_EQ(StyleProperty::Kind::Undefined, undefined.getKind());