From f38b65fe2b1cc2d294789d11af2fa42e5b0b7865 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 9 Aug 2017 19:54:04 +0300 Subject: [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 19412e6133..aaf0271bd4 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 0000000000..8cd622fe79 --- /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 0000000000..a23b79f8d8 Binary files /dev/null and b/test/fixtures/recycle_map/default_marker/expected.png differ 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 0000000000..3c4847f3a7 Binary files /dev/null and b/test/fixtures/recycle_map/flipped_marker/expected.png differ -- cgit v1.2.1