summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authorLucas Wojciechowski <hello@lucaswoj.com>2018-05-10 12:37:14 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-05-10 12:37:14 -0700
commita4e2c1af1fd83b22ef4ee57ab19a15616224f8b8 (patch)
tree7584634fd01753452d28ea30cdc63e98c8618d43 /test/api
parentee1008870284d2956c4d246bd8751e032ee91898 (diff)
downloadqtlocation-mapboxgl-a4e2c1af1fd83b22ef4ee57ab19a15616224f8b8.tar.gz
[core] Convert "legacy" filters directly into expressions (#11610)
Ports the specialized filter-* expressions from GL JS, adding them to src/mbgl/style/expression/compound_expression.cpp
Diffstat (limited to 'test/api')
-rw-r--r--test/api/query.test.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index c67ff9064c..ffab52692b 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -13,6 +13,7 @@
using namespace mbgl;
using namespace mbgl::style;
+using namespace mbgl::style::expression;
namespace {
@@ -67,18 +68,19 @@ TEST(Query, QueryRenderedFeaturesFilterLayer) {
TEST(Query, QueryRenderedFeaturesFilter) {
QueryTest test;
+ ParsingContext context;
auto zz = test.map.pixelForLatLng({ 0, 0 });
- const EqualsFilter eqFilter = { "key1", std::string("value1") };
+ const Filter eqFilter(createCompoundExpression("filter-==", createLiteral("key1"), createLiteral("value1"), context));
auto features1 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{}, { eqFilter }});
EXPECT_EQ(features1.size(), 1u);
- const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") };
+ const Filter idNotEqFilter(createCompoundExpression("!", std::move(*createCompoundExpression("filter-id-==", createLiteral("feature1"), context)), context));
auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{{ "layer4" }}, { idNotEqFilter }});
EXPECT_EQ(features2.size(), 0u);
- const GreaterThanFilter gtFilter = { "key2", 1.0 };
+ const Filter gtFilter(createCompoundExpression("filter->", createLiteral("key2"), createLiteral(1.0), context));
auto features3 = test.frontend.getRenderer()->queryRenderedFeatures(zz, {{ }, { gtFilter }});
EXPECT_EQ(features3.size(), 1u);
}
@@ -108,16 +110,17 @@ TEST(Query, QuerySourceFeaturesOptionValidation) {
TEST(Query, QuerySourceFeaturesFilter) {
QueryTest test;
+ ParsingContext context;
- const EqualsFilter eqFilter = { "key1", std::string("value1") };
+ const Filter eqFilter(createCompoundExpression("filter-==", createLiteral("key1"), createLiteral("value1"), context));
auto features1 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { eqFilter }});
EXPECT_EQ(features1.size(), 1u);
- const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") };
+ const Filter idNotEqFilter(createCompoundExpression("!", std::move(*createCompoundExpression("filter-id-==", createLiteral("feature1"), context)), context));
auto features2 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { idNotEqFilter }});
EXPECT_EQ(features2.size(), 0u);
- const GreaterThanFilter gtFilter = { "key2", 1.0 };
+ const Filter gtFilter(createCompoundExpression("filter->", createLiteral("key2"), createLiteral(1.0), context));
auto features3 = test.frontend.getRenderer()->querySourceFeatures("source4", {{}, { gtFilter }});
EXPECT_EQ(features3.size(), 1u);
}