From 5d62028ed2c4029a4c6bff0140594cad94b557c4 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 9 Aug 2017 19:54:04 +0300 Subject: [PATCH] [test] Added API.RecycleMapUpdateImages test --- cmake/test-files.cmake | 1 + test/api/recycle_map.cpp | 58 ++++++++++++++++++ .../recycle_map/default_marker/expected.png | Bin 0 -> 1043 bytes .../recycle_map/flipped_marker/expected.png | Bin 0 -> 1031 bytes 4 files changed, 59 insertions(+) create mode 100644 test/api/recycle_map.cpp create mode 100644 test/fixtures/recycle_map/default_marker/expected.png create mode 100644 test/fixtures/recycle_map/flipped_marker/expected.png diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake index 19412e613..aaf0271bd 100644 --- a/cmake/test-files.cmake +++ b/cmake/test-files.cmake @@ -17,6 +17,7 @@ set(MBGL_TEST_FILES test/api/api_misuse.test.cpp test/api/custom_layer.test.cpp test/api/query.test.cpp + test/api/recycle_map.cpp # gl test/gl/bucket.test.cpp diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp new file mode 100644 index 000000000..8cd622fe7 --- /dev/null +++ b/test/api/recycle_map.cpp @@ -0,0 +1,58 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace mbgl; +using namespace mbgl::style; + + +TEST(API, RecycleMapUpdateImages) { + util::RunLoop loop; + + StubFileSource fileSource; + ThreadPool threadPool(4); + float pixelRatio { 1 }; + + HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; + auto map = std::make_unique(frontend, MapObserver::nullObserver(), frontend.getSize(), + pixelRatio, fileSource, threadPool, MapMode::Still); + + EXPECT_TRUE(map); + + auto loadStyle = [&](auto markerName, auto markerPath) { + auto source = std::make_unique("geometry"); + source->setGeoJSON({ Point { 0, 0 } }); + + auto layer = std::make_unique("geometry", "geometry"); + layer->setIconImage({ markerName }); + + map->getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + map->getStyle().addSource(std::move(source)); + map->getStyle().addLayer(std::move(layer)); + map->getStyle().addImage(std::make_unique(markerName, decodeImage(util::read_file(markerPath)), 1.0)); + }; + + // default marker + + loadStyle("default_marker", "test/fixtures/sprites/default_marker.png"); + test::checkImage("test/fixtures/recycle_map/default_marker", frontend.render(*map), 0.0006, 0.1); + + // flipped marker + + loadStyle("flipped_marker", "test/fixtures/sprites/flipped_marker.png"); + test::checkImage("test/fixtures/recycle_map/flipped_marker", frontend.render(*map), 0.0006, 0.1); +} diff --git a/test/fixtures/recycle_map/default_marker/expected.png b/test/fixtures/recycle_map/default_marker/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..a23b79f8d8d3584c1f472e1fbc1533f4e82e7dd5 GIT binary patch literal 1043 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJFdTb?eCAr*7p-r3(Rk}kpi zfmzXY)!w_M-MT4zTN`480|k5@7A6!cEZOQk(O#i+Rme&qmoMksI5JgYCVnvsV>eUu zb(r)lC{mRp?4{Y~snU^Vn^zmp+jH~ub7p-WaUOd;(BN5_Lk*-t0^!4_I+*idarGp z^^XUsmwM0FFYsEm|W`2OU>YWQ>VmwMZ3v(>4; zKRmgS^!LaH1&-`xUbo`^?I?U4zx}V|+vk((|0zvK?!Mf3#AD5+zl>2Qxb3_r>ggl9`Dx+Zh$JaxN)cE(wArPw_OiFMRweOU;pvP zrKRO{JToLZLwDIbaPwE~^?dg3blj)P+2W0x>q2R$gpJ>-3Jt{Qs)| Y87h=SY>cxmoB%2FboFyt=akR{0AH|}jQ{`u literal 0 HcmV?d00001 diff --git a/test/fixtures/recycle_map/flipped_marker/expected.png b/test/fixtures/recycle_map/flipped_marker/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