summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-18 14:22:17 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-19 08:11:41 +0300
commitc50577d039c67b04a60155f7f7b7c6dc9d2c0d30 (patch)
tree5e83fa9664683413ed8a25bfe7c44e5a3b902852 /test
parentef62b78fce06ad93de87e9a6a6775ae33fff214d (diff)
downloadqtlocation-mapboxgl-c50577d039c67b04a60155f7f7b7c6dc9d2c0d30.tar.gz
[core] Fix SymbolAnnotation coordinate system conversions
Diffstat (limited to 'test')
-rw-r--r--test/api/annotations.test.cpp29
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());
}