From a744e35f44213584574b2e5377076d4b6d99ac7b Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 30 Jun 2017 14:56:51 +0300 Subject: [test] Added API.ZoomHistory --- test/api/repeated_render.test.cpp | 62 ++++++++++++++++++++++++++++++++++++++ test/fixtures/api/z0/expected.png | Bin 0 -> 5042 bytes test/fixtures/api/z1/expected.png | Bin 0 -> 5648 bytes 3 files changed, 62 insertions(+) create mode 100644 test/fixtures/api/z0/expected.png create mode 100644 test/fixtures/api/z1/expected.png (limited to 'test') 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 #include #include +#include +#include #include @@ -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()); + + 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("testSource"); + source->setGeoJSON(std::move(geojson)); + map.getStyle().addSource(std::move(source)); + + auto layer = std::make_unique("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(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 new file mode 100644 index 0000000000..0867a8cbf6 Binary files /dev/null and b/test/fixtures/api/z0/expected.png differ diff --git a/test/fixtures/api/z1/expected.png b/test/fixtures/api/z1/expected.png new file mode 100644 index 0000000000..897dc196cc Binary files /dev/null and b/test/fixtures/api/z1/expected.png differ -- cgit v1.2.1