summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-09-30 17:37:20 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-11 12:10:32 +0300
commitccef4be9959562bdb6cbb06dde79367109486b1c (patch)
treeb171ca28f5d68010a53250a2427d1475be162fb8 /test
parent623a124e01a9f3812aad3f8cda866992bb61a567 (diff)
downloadqtlocation-mapboxgl-ccef4be9959562bdb6cbb06dde79367109486b1c.tar.gz
[test] Added Annotations.VisibleFeatures test
This provides a means of testing cases where an updated geometry tile would return wrong results for `queryRenderedFeatures`.
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index b82a7adaca..dbe538024f 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -366,3 +366,35 @@ TEST(Annotations, QueryFractionalZoomLevels) {
EXPECT_EQ(features.size(), ids.size());
}
}
+
+TEST(Annotations, VisibleFeatures) {
+ AnnotationTest test;
+
+ auto viewSize = test.view.getSize();
+ auto box = ScreenBox { {}, { double(viewSize[0]), double(viewSize[1]) } };
+
+ test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
+ test.map.setZoom(3);
+
+ std::vector<mbgl::AnnotationID> ids;
+ for (int longitude = -5; longitude <= 5; ++longitude) {
+ for (int latitude = -5; latitude <= 5; ++latitude) {
+ ids.push_back(test.map.addAnnotation(SymbolAnnotation { { double(latitude), double(longitude) }, "default_marker" }));
+ }
+ }
+
+ // Change bearing *after* adding annotations cause them to be reordered,
+ // and some annotations become occluded by others.
+ test.map.setBearing(45);
+ test::render(test.map);
+
+ auto features = test.map.queryRenderedFeatures(box);
+ EXPECT_EQ(features.size(), ids.size());
+
+ test.map.setBearing(0);
+ test.map.setZoom(4);
+ test::render(test.map);
+ features = test.map.queryRenderedFeatures(box);
+ EXPECT_EQ(features.size(), ids.size());
+}