From ccef4be9959562bdb6cbb06dde79367109486b1c Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 30 Sep 2016 17:37:20 +0300 Subject: [test] Added Annotations.VisibleFeatures test This provides a means of testing cases where an updated geometry tile would return wrong results for `queryRenderedFeatures`. --- test/api/annotations.test.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test') 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 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()); +} -- cgit v1.2.1