diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-06-30 14:56:51 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-07-04 15:50:50 +0300 |
commit | a744e35f44213584574b2e5377076d4b6d99ac7b (patch) | |
tree | 6563c67fe27424bf675c61aceb0cf9935a2e0b79 /test | |
parent | 9a0c5b4dfa7fdb6f980d03bbfb93064e9f2ec81d (diff) | |
download | qtlocation-mapboxgl-a744e35f44213584574b2e5377076d4b6d99ac7b.tar.gz |
[test] Added API.ZoomHistory
Diffstat (limited to 'test')
-rw-r--r-- | test/api/repeated_render.test.cpp | 62 | ||||
-rw-r--r-- | test/fixtures/api/z0/expected.png | bin | 0 -> 5042 bytes | |||
-rw-r--r-- | test/fixtures/api/z1/expected.png | bin | 0 -> 5648 bytes |
3 files changed, 62 insertions, 0 deletions
diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index 3da65939cc..dd9085efd7 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -11,6 +11,8 @@ #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/style/style.hpp> +#include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/sources/geojson_source.hpp> #include <future> @@ -70,3 +72,63 @@ TEST(API, RepeatedRender) { auto unchecked = flo->unchecked(); EXPECT_TRUE(unchecked.empty()) << unchecked; } + +TEST(API, ZoomHistory) { + util::RunLoop loop; + + const auto style = util::read_file("test/fixtures/api/empty.json"); + + HeadlessBackend backend { test::sharedDisplay() }; + BackendScope scope { backend }; + OffscreenView view { backend.getContext(), { 512, 512 } }; + DefaultFileSource fileSource(":memory:", "."); + ThreadPool threadPool(4); + + Log::setObserver(std::make_unique<FixtureLogObserver>()); + + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + map.getStyle().loadJSON(style); + + auto geojson = mapbox::geojson::parse(R"t({ "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ -150, -75 ], [ 150, 75 ] ] } } ] })t"); + auto source = std::make_unique<mbgl::style::GeoJSONSource>("testSource"); + source->setGeoJSON(std::move(geojson)); + map.getStyle().addSource(std::move(source)); + + auto layer = std::make_unique<mbgl::style::LineLayer>("testLayer", "testSource"); + layer->setLineDasharray({ { 1.0f, 2.0f } }); + layer->setLineWidth({ 16.0f }); + map.getStyle().addLayer(std::move(layer)); + + { + PremultipliedImage result; + map.renderStill(view, [&](std::exception_ptr) { + result = view.readStillImage(); + }); + + while (!result.valid()) { + loop.runOnce(); + } + + test::checkImage("test/fixtures/api/z0", result, 0.0002, 0.1); + } + + { + map.setZoom(1.0); + + PremultipliedImage result; + map.renderStill(view, [&](std::exception_ptr) { + result = view.readStillImage(); + }); + + while (!result.valid()) { + loop.runOnce(); + } + + test::checkImage("test/fixtures/api/z1", result, 0.0002, 0.1); + } + + auto observer = Log::removeObserver(); + auto flo = dynamic_cast<FixtureLogObserver*>(observer.get()); + auto unchecked = flo->unchecked(); + EXPECT_TRUE(unchecked.empty()) << unchecked; +} diff --git a/test/fixtures/api/z0/expected.png b/test/fixtures/api/z0/expected.png Binary files differnew file mode 100644 index 0000000000..0867a8cbf6 --- /dev/null +++ b/test/fixtures/api/z0/expected.png diff --git a/test/fixtures/api/z1/expected.png b/test/fixtures/api/z1/expected.png Binary files differnew file mode 100644 index 0000000000..897dc196cc --- /dev/null +++ b/test/fixtures/api/z1/expected.png |