diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-09 19:54:04 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-14 18:23:03 +0300 |
commit | 5d62028ed2c4029a4c6bff0140594cad94b557c4 (patch) | |
tree | 2318c3060a5602fccf004e1124d9ebfb0f2aad0b /test | |
parent | cd8eb13ba2d8b65f6cac12a36e0586abc56fcb9f (diff) | |
download | qtlocation-mapboxgl-5d62028ed2c4029a4c6bff0140594cad94b557c4.tar.gz |
[test] Added API.RecycleMapUpdateImages test
Diffstat (limited to 'test')
-rw-r--r-- | test/api/recycle_map.cpp | 58 | ||||
-rw-r--r-- | test/fixtures/recycle_map/default_marker/expected.png | bin | 0 -> 1043 bytes | |||
-rw-r--r-- | test/fixtures/recycle_map/flipped_marker/expected.png | bin | 0 -> 1031 bytes |
3 files changed, 58 insertions, 0 deletions
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 <mbgl/test/util.hpp> +#include <mbgl/test/stub_file_source.hpp> + +#include <mbgl/gl/headless_frontend.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/renderer/backend_scope.hpp> +#include <mbgl/storage/online_file_source.hpp> +#include <mbgl/style/layers/symbol_layer.hpp> +#include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/image.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/util/default_thread_pool.hpp> +#include <mbgl/util/exception.hpp> +#include <mbgl/util/geometry.hpp> +#include <mbgl/util/geojson.hpp> +#include <mbgl/util/io.hpp> +#include <mbgl/util/run_loop.hpp> + +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<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(), + pixelRatio, fileSource, threadPool, MapMode::Still); + + EXPECT_TRUE(map); + + auto loadStyle = [&](auto markerName, auto markerPath) { + auto source = std::make_unique<GeoJSONSource>("geometry"); + source->setGeoJSON({ Point<double> { 0, 0 } }); + + auto layer = std::make_unique<SymbolLayer>("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<style::Image>(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 Binary files differnew file mode 100644 index 0000000000..a23b79f8d8 --- /dev/null +++ b/test/fixtures/recycle_map/default_marker/expected.png diff --git a/test/fixtures/recycle_map/flipped_marker/expected.png b/test/fixtures/recycle_map/flipped_marker/expected.png Binary files differnew file mode 100644 index 0000000000..3c4847f3a7 --- /dev/null +++ b/test/fixtures/recycle_map/flipped_marker/expected.png |