From 5f2240887aa5772623e0562ffbce64d59fef88e6 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Sun, 13 Aug 2017 12:20:35 +0300 Subject: [test] Re-added API.ZoomHistory --- cmake/test-files.cmake | 1 + test/api/zoom_history.cpp | 65 ++++++++++++++++++++++++++++++++ test/fixtures/zoom_history/expected.png | Bin 0 -> 3894 bytes 3 files changed, 66 insertions(+) create mode 100644 test/api/zoom_history.cpp create mode 100644 test/fixtures/zoom_history/expected.png diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake index aaf0271bd4..027c34f31e 100644 --- a/cmake/test-files.cmake +++ b/cmake/test-files.cmake @@ -18,6 +18,7 @@ set(MBGL_TEST_FILES test/api/custom_layer.test.cpp test/api/query.test.cpp test/api/recycle_map.cpp + test/api/zoom_history.cpp # gl test/gl/bucket.test.cpp diff --git a/test/api/zoom_history.cpp b/test/api/zoom_history.cpp new file mode 100644 index 0000000000..3c60a5e2f2 --- /dev/null +++ b/test/api/zoom_history.cpp @@ -0,0 +1,65 @@ +#include +#include + +#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, ZoomHistory) { + 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); + + map->getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); + + auto source = std::make_unique("source"); + source->setGeoJSON({ LineString { { 45, -45 }, { -45, 45 } } }); + map->getStyle().addSource(std::move(source)); + + auto layer = std::make_unique("layer-1", "source"); + layer->setLineWidth(CameraFunction { ExponentialStops {{ { 0, 8 }, { 1, 16 } }} }); + layer->setLineDasharray({ std::vector { 1, 1 } }); + layer->setLineColor( { Color::black() } ); + map->getStyle().addLayer(std::move(layer)); + + layer = std::make_unique("layer-2", "source"); + layer->setLineWidth(CameraFunction { ExponentialStops {{ { 0, 4 }, { 1, 8 } }} }); + layer->setLineDasharray({ std::vector { 2, 2 } }); + layer->setLineColor( { Color::red() } ); + map->getStyle().addLayer(std::move(layer)); + + // ZoomHistory.lastIntegerZoom is 1. + map->setZoom(1.0); + frontend.render(*map); + + map->setZoom(0.0); + frontend.render(*map); + + // ZoomHistory.lastIntegerZoom should be 0. + map->setZoom(0.5); + test::checkImage("test/fixtures/zoom_history", frontend.render(*map), 0.0002); +} diff --git a/test/fixtures/zoom_history/expected.png b/test/fixtures/zoom_history/expected.png new file mode 100644 index 0000000000..100dc508a4 Binary files /dev/null and b/test/fixtures/zoom_history/expected.png differ -- cgit v1.2.1