From e4e08aca7910d1a8d75791db61de39fa03673fde Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 26 May 2017 10:23:12 -0700 Subject: [PATCH] [tests] Add test for calling addAnnotationImage with an existing ID --- test/api/annotations.test.cpp | 20 ++++++++++++++++-- .../annotations/readd_image/expected.png | Bin 0 -> 1031 bytes 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/annotations/readd_image/expected.png diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 9e85a74c5..4c27c871a 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -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 namedMarker(const std::string& name) { - PremultipliedImage image = decodeImage(util::read_file("test/fixtures/sprites/" + name + ".png")); - return std::make_unique(name, std::move(image), 1.0); + return std::make_unique(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 { 0, 0 }, "default_marker" }); + + test::render(test.map, test.view); + + test.map.addAnnotationImage(std::make_unique("default_marker", namedImage("flipped_marker"), 1.0)); + test.checkRendering("readd_image"); +} + TEST(Annotations, QueryRenderedFeatures) { AnnotationTest test; diff --git a/test/fixtures/annotations/readd_image/expected.png b/test/fixtures/annotations/readd_image/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4847f3a70408ee864435e2a4f5c72181f0c6bc GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJFdbDl1aAr*7p-r3(Rk}kuZ zpg7@BR(|>Bqhdw(oE+8#Dsgx|RJ_5_v^KWu597+UK})?R2)xf>@l-Byy|jEI*AmW5 zrb#AIk(%sbFU>w%mZjW0^Tx88J-_U;&4<+Xncr(G??0OR{rH(TJBxu<4ixwxzj62O z-w#uaB;USyQxo&I?vlvn?8QrTW8)v>)NF{&eElVNqRq+ZU7rqg9ee!o=PLR5cej2% z&tsZ?mMy_oclNve`Ad2(y=4e12zvf6&7fkMg=Xx_G6wC4Yb*E5@y)l{TaY;G#71d` zoEh6x5A418Vzs+`@3Qsz_iXxPp3hNb$eEDyKsS%6&QR`t?S=RIYb*c$`tttv_WsA~ z{q1Kzi&+PhOH0cZ#B=3?R)orznk#k`TFp6dtU!3eG;=ywfA_#hD0OjA7vIb zUmhRr{{QMvX^OoQr-p_vvc7(70eLIigYn{WTY3uY0+}?e!+WWWe|Iz&L_1nt+ zSxr*QoV>hbZ=-R+h4=U4&A!I>Eb*Op=_{Mx%f$8DV|!nCFaPK3-T1`w-lebXeh(9} zUq@bE_ums79RCh!-_g