summaryrefslogtreecommitdiff
path: root/test/api/query.test.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-06-13 10:50:16 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-07-18 10:45:12 +0200
commit3832f8d0d8194b81ea34a045e19b0d5bc7a89e25 (patch)
treebbb4b277e1e74bde457271b9b9a5b6a9ec3ad5fb /test/api/query.test.cpp
parent39a732d7ae3cb1b927d94c4b1154b42d9565356a (diff)
downloadqtlocation-mapboxgl-3832f8d0d8194b81ea34a045e19b0d5bc7a89e25.tar.gz
[core] renderer interface
Diffstat (limited to 'test/api/query.test.cpp')
-rw-r--r--test/api/query.test.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index 0b02e47219..efb31f89c6 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -11,6 +11,8 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/source.hpp>
+#include <mbgl/renderer/renderer.hpp>
+#include <mbgl/test/stub_renderer_frontend.hpp>
using namespace mbgl;
using namespace mbgl::style;
@@ -33,7 +35,11 @@ public:
OffscreenView view { backend.getContext() };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
- Map map { backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still };
+ float pixelRatio { 1 };
+ StubRendererFrontend rendererFrontend {
+ std::make_unique<Renderer>(backend, pixelRatio, fileSource, threadPool), view };
+ Map map { rendererFrontend, MapObserver::nullObserver(), view.getSize(), pixelRatio, fileSource,
+ threadPool, MapMode::Still };
};
} // end namespace
@@ -41,10 +47,10 @@ public:
TEST(Query, QueryRenderedFeatures) {
QueryTest test;
- auto features1 = test.map.queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 }));
+ auto features1 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 }));
EXPECT_EQ(features1.size(), 4u);
- auto features2 = test.map.queryRenderedFeatures(test.map.pixelForLatLng({ 9, 9 }));
+ auto features2 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(test.map.pixelForLatLng({ 9, 9 }));
EXPECT_EQ(features2.size(), 0u);
}
@@ -53,16 +59,16 @@ TEST(Query, QueryRenderedFeaturesFilterLayer) {
auto zz = test.map.pixelForLatLng({ 0, 0 });
- auto features1 = test.map.queryRenderedFeatures(zz, {{{ "layer1"}}, {}});
+ auto features1 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{{ "layer1"}}, {}});
EXPECT_EQ(features1.size(), 1u);
- auto features2 = test.map.queryRenderedFeatures(zz, {{{ "layer1", "layer2" }}, {}});
+ auto features2 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{{ "layer1", "layer2" }}, {}});
EXPECT_EQ(features2.size(), 2u);
- auto features3 = test.map.queryRenderedFeatures(zz, {{{ "foobar" }}, {}});
+ auto features3 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{{ "foobar" }}, {}});
EXPECT_EQ(features3.size(), 0u);
- auto features4 = test.map.queryRenderedFeatures(zz, {{{ "foobar", "layer3" }}, {}});
+ auto features4 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{{ "foobar", "layer3" }}, {}});
EXPECT_EQ(features4.size(), 1u);
}
@@ -72,22 +78,22 @@ TEST(Query, QueryRenderedFeaturesFilter) {
auto zz = test.map.pixelForLatLng({ 0, 0 });
const EqualsFilter eqFilter = { "key1", std::string("value1") };
- auto features1 = test.map.queryRenderedFeatures(zz, {{}, { eqFilter }});
+ auto features1 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{}, { eqFilter }});
EXPECT_EQ(features1.size(), 1u);
const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") };
- auto features2 = test.map.queryRenderedFeatures(zz, {{{ "layer4" }}, { idNotEqFilter }});
+ auto features2 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{{ "layer4" }}, { idNotEqFilter }});
EXPECT_EQ(features2.size(), 0u);
const GreaterThanFilter gtFilter = { "key2", 1.0 };
- auto features3 = test.map.queryRenderedFeatures(zz, {{ }, { gtFilter }});
+ auto features3 = test.rendererFrontend.getRenderer()->queryRenderedFeatures(zz, {{ }, { gtFilter }});
EXPECT_EQ(features3.size(), 1u);
}
TEST(Query, QuerySourceFeatures) {
QueryTest test;
- auto features1 = test.map.querySourceFeatures("source3");
+ auto features1 = test.rendererFrontend.getRenderer()->querySourceFeatures("source3");
EXPECT_EQ(features1.size(), 1u);
}
@@ -95,15 +101,15 @@ TEST(Query, QuerySourceFeaturesOptionValidation) {
QueryTest test;
// GeoJSONSource, doesn't require a layer id
- auto features = test.map.querySourceFeatures("source3");
+ auto features = test.rendererFrontend.getRenderer()->querySourceFeatures("source3");
ASSERT_EQ(features.size(), 1u);
// VectorSource, requires a layer id
- features = test.map.querySourceFeatures("source5");
+ features = test.rendererFrontend.getRenderer()->querySourceFeatures("source5");
ASSERT_EQ(features.size(), 0u);
// RasterSource, not supported
- features = test.map.querySourceFeatures("source6");
+ features = test.rendererFrontend.getRenderer()->querySourceFeatures("source6");
ASSERT_EQ(features.size(), 0u);
}
@@ -111,15 +117,15 @@ TEST(Query, QuerySourceFeaturesFilter) {
QueryTest test;
const EqualsFilter eqFilter = { "key1", std::string("value1") };
- auto features1 = test.map.querySourceFeatures("source4", {{}, { eqFilter }});
+ auto features1 = test.rendererFrontend.getRenderer()->querySourceFeatures("source4", {{}, { eqFilter }});
EXPECT_EQ(features1.size(), 1u);
const IdentifierNotEqualsFilter idNotEqFilter = { std::string("feature1") };
- auto features2 = test.map.querySourceFeatures("source4", {{}, { idNotEqFilter }});
+ auto features2 = test.rendererFrontend.getRenderer()->querySourceFeatures("source4", {{}, { idNotEqFilter }});
EXPECT_EQ(features2.size(), 0u);
const GreaterThanFilter gtFilter = { "key2", 1.0 };
- auto features3 = test.map.querySourceFeatures("source4", {{}, { gtFilter }});
+ auto features3 = test.rendererFrontend.getRenderer()->querySourceFeatures("source4", {{}, { gtFilter }});
EXPECT_EQ(features3.size(), 1u);
}