[tests] Add test for calling addAnnotationImage with an existing ID

This commit is contained in:
John Firebaugh
2017-05-26 10:23:12 -07:00
parent 2c8343aa82
commit e4e08aca79
2 changed files with 18 additions and 2 deletions

View File

@@ -16,9 +16,12 @@ using namespace mbgl;
namespace {
PremultipliedImage namedImage(const std::string& name) {
return decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png"));
}
std::unique_ptr<style::Image> namedMarker(const std::string& name) {
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png"));
return std::make_unique<style::Image>(name, std::move(image), 1.0);
return std::make_unique<style::Image>(name, namedImage(name), 1.0);
}
class AnnotationTest {
@@ -319,6 +322,19 @@ TEST(Annotations, SwitchStyle) {
test.checkRendering("switch_style");
}
TEST(Annotations, ReaddImage) {
AnnotationTest test;
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotationImage(namedMarker("default_marker"));
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
test::render(test.map, test.view);
test.map.addAnnotationImage(std::make_unique<style::Image>("default_marker", namedImage("flipped_marker"), 1.0));
test.checkRendering("readd_image");
}
TEST(Annotations, QueryRenderedFeatures) {
AnnotationTest test;