summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-04-16 16:52:39 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-04-16 13:52:54 -0400
commitffea0af9bf0b8cb91a17b58645f9a4c34bc3e8e5 (patch)
tree6484a9065f11dd0b165b72bbbc4c36854b1b4553 /test
parent7f0c13967d7265f9218ee6cec61c28e0ac40fc90 (diff)
downloadqtlocation-mapboxgl-ffea0af9bf0b8cb91a17b58645f9a4c34bc3e8e5.tar.gz
Add generic setter for 'source' property
- Add setter for 'source' property - Test generic setters via setProperty method
Diffstat (limited to 'test')
-rw-r--r--test/style/conversion/layer.test.cpp16
-rw-r--r--test/style/style_layer.test.cpp10
2 files changed, 25 insertions, 1 deletions
diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp
index 742f902168..079d7ce5a5 100644
--- a/test/style/conversion/layer.test.cpp
+++ b/test/style/conversion/layer.test.cpp
@@ -148,4 +148,20 @@ TEST(StyleConversion, SetGenericProperties) {
EXPECT_EQ(12.0f, layer->getMinZoom());
EXPECT_EQ(18.0f, layer->getMaxZoom());
EXPECT_EQ("landmarks", layer->getSourceLayer());
+
+ const JSValue newComposite("composite_2");
+ layer->setProperty("source", Convertible(&newComposite));
+ EXPECT_EQ("composite_2", layer->getSourceID());
+
+ const JSValue newSourceLayer("poi");
+ layer->setProperty("source-layer", Convertible(&newSourceLayer));
+ EXPECT_EQ("poi", layer->getSourceLayer());
+
+ const JSValue newMinZoom(1.0f);
+ layer->setProperty("minzoom", Convertible(&newMinZoom));
+ EXPECT_EQ(1.0f, layer->getMinZoom());
+
+ const JSValue newMaxZoom(22.0f);
+ layer->setProperty("maxzoom", Convertible(&newMaxZoom));
+ EXPECT_EQ(22.0f, layer->getMaxZoom());
} \ No newline at end of file
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 33573636d7..84bad2830b 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -1,5 +1,7 @@
#include <mbgl/gl/custom_layer.hpp>
#include <mbgl/gl/custom_layer_impl.hpp>
+#include <mbgl/style/conversion/filter.hpp>
+#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/expression/dsl.hpp>
#include <mbgl/style/expression/format_expression.hpp>
#include <mbgl/style/expression/image.hpp>
@@ -28,6 +30,7 @@
using namespace mbgl;
using namespace mbgl::style;
+using namespace mbgl::style::conversion;
using namespace expression;
using namespace expression::dsl;
using namespace std::literals::string_literals;
@@ -60,6 +63,11 @@ class MockLayoutProperties : public Properties<TextField> {};
class MockPaintProperties : public Properties<TextColor> {};
using MockOverrides = FormatSectionOverrides<MockPaintProperties::OverridableProperties>;
+mbgl::style::Filter parseFilter(const std::string& expression) {
+ Error error;
+ return *convertJSON<mbgl::style::Filter>(expression, error);
+}
+
} // namespace
TEST(Layer, BackgroundProperties) {
@@ -221,7 +229,7 @@ TEST(Layer, Observer) {
EXPECT_EQ(layer.get(), &layer_);
filterChanged = true;
};
- layer->setFilter(Filter());
+ layer->setFilter(parseFilter(R"(["==", "foo", "bar"])"));
EXPECT_TRUE(filterChanged);
// Notifies observer on visibility change.