[test] Added Annotations.VisibleFeatures test

This provides a means of testing cases where an updated geometry tile
would return wrong results for `queryRenderedFeatures`.
This commit is contained in:
Bruno de Oliveira Abinader
2016-09-30 17:37:20 +03:00
parent 623a124e01
commit ccef4be995

View File

@@ -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());
}