summaryrefslogtreecommitdiff
path: root/test/api/query.test.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-03-04 18:44:33 -0800
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-03-09 13:11:23 -0800
commit0d10d2df1c6d246004e7291511f3aab7a8781d59 (patch)
tree3667c583d44c5237380ad7b79498787caa24a322 /test/api/query.test.cpp
parent548675a196f9e55d87cf8fce837b6e60393cb1b9 (diff)
downloadqtlocation-mapboxgl-0d10d2df1c6d246004e7291511f3aab7a8781d59.tar.gz
[core] query source features
Diffstat (limited to 'test/api/query.test.cpp')
-rw-r--r--test/api/query.test.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index b42046fb48..45e6b19268 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -8,6 +8,7 @@
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
+#include <mbgl/style/source.hpp>
using namespace mbgl;
using namespace mbgl::style;
@@ -81,3 +82,43 @@ TEST(Query, QueryRenderedFeaturesFilter) {
auto features3 = test.map.queryRenderedFeatures(zz, {{ }, { gtFilter }});
EXPECT_EQ(features3.size(), 1u);
}
+
+TEST(Query, QuerySourceFeatures) {
+ QueryTest test;
+
+ auto features1 = test.map.getSource("source3")->querySourceFeatures();
+ EXPECT_EQ(features1.size(), 1u);
+}
+
+TEST(Query, QuerySourceFeaturesOptionValidation) {
+ QueryTest test;
+
+ // GeoJSONSource, doesn't require a layer id
+ auto features = test.map.getSource("source3")->querySourceFeatures();
+ ASSERT_EQ(features.size(), 1u);
+
+ // VectorSource, requires a layer id
+ features = test.map.getSource("source5")->querySourceFeatures();
+ ASSERT_EQ(features.size(), 0u);
+
+ // RasterSource, not supported
+ features = test.map.getSource("source6")->querySourceFeatures();
+ ASSERT_EQ(features.size(), 0u);
+}
+
+TEST(Query, QuerySourceFeaturesFilter) {
+ QueryTest test;
+
+ const EqualsFilter eqFilter = { "key1", std::string("value1") };
+ auto features1 = test.map.getSource("source4")->querySourceFeatures({{}, { eqFilter }});
+ EXPECT_EQ(features1.size(), 1u);
+
+ const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") };
+ auto features2 = test.map.getSource("source4")->querySourceFeatures({{}, { idNotEqFilter }});
+ EXPECT_EQ(features2.size(), 0u);
+
+ const GreaterThanFilter gtFilter = { "key2", 1.0 };
+ auto features3 = test.map.getSource("source4")->querySourceFeatures({{}, { gtFilter }});
+ EXPECT_EQ(features3.size(), 1u);
+}
+