diff options
Diffstat (limited to 'test/api/annotations.test.cpp')
-rw-r--r-- | test/api/annotations.test.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index dc4b00170a..6d6734a10f 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -49,10 +49,7 @@ TEST(Annotations, SymbolAnnotation) { EXPECT_EQ(features.size(), 1u); test.map.setZoom(test.map.getMaxZoom()); - // FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5419 - //test.map.setZoom(test.map.getMaxZoom()); - //test.checkRendering("point_annotation"); - test::render(test.map); + test.checkRendering("point_annotation"); features = test.map.queryPointAnnotations(screenBox); EXPECT_EQ(features.size(), 1u); @@ -369,10 +366,17 @@ TEST(Annotations, QueryFractionalZoomLevels) { } test.map.setLatLngZoom({ 5, 5 }, 0); - for (uint16_t zoomSteps = 0; zoomSteps <= 20; ++zoomSteps) { + for (uint16_t zoomSteps = 10; zoomSteps <= 20; ++zoomSteps) { test.map.setZoom(zoomSteps / 10.0); test::render(test.map); auto features = test.map.queryRenderedFeatures(box); + + // Filter out repeated features. + // See 'edge-cases/null-island' query-test for reference. + auto sortID = [](const Feature& lhs, const Feature& rhs) { return lhs.id < rhs.id; }; + auto sameID = [](const Feature& lhs, const Feature& rhs) { return lhs.id == rhs.id; }; + std::sort(features.begin(), features.end(), sortID); + features.erase(std::unique(features.begin(), features.end(), sameID), features.end()); EXPECT_EQ(features.size(), ids.size()); } } @@ -385,26 +389,31 @@ TEST(Annotations, VisibleFeatures) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png")); - test.map.setZoom(3); + test.map.setLatLngZoom({ 5, 5 }, 3); std::vector<mbgl::AnnotationID> ids; - for (int longitude = -5; longitude <= 5; ++longitude) { - for (int latitude = -5; latitude <= 5; ++latitude) { + for (int longitude = 0; longitude < 10; ++longitude) { + for (int latitude = 0; latitude <= 10; ++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. + // Change bearing *after* adding annotations causes them to be reordered. test.map.setBearing(45); test::render(test.map); auto features = test.map.queryRenderedFeatures(box); + auto sortID = [](const Feature& lhs, const Feature& rhs) { return lhs.id < rhs.id; }; + auto sameID = [](const Feature& lhs, const Feature& rhs) { return lhs.id == rhs.id; }; + std::sort(features.begin(), features.end(), sortID); + features.erase(std::unique(features.begin(), features.end(), sameID), features.end()); EXPECT_EQ(features.size(), ids.size()); test.map.setBearing(0); test.map.setZoom(4); test::render(test.map); features = test.map.queryRenderedFeatures(box); + std::sort(features.begin(), features.end(), sortID); + features.erase(std::unique(features.begin(), features.end(), sameID), features.end()); EXPECT_EQ(features.size(), ids.size()); } |