diff options
Diffstat (limited to 'test/api')
-rw-r--r-- | test/api/annotations.test.cpp | 40 | ||||
-rw-r--r-- | test/api/api_misuse.test.cpp | 18 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 8 | ||||
-rw-r--r-- | test/api/query.test.cpp | 8 | ||||
-rw-r--r-- | test/api/render_missing.test.cpp | 8 | ||||
-rw-r--r-- | test/api/repeated_render.test.cpp | 14 |
6 files changed, 47 insertions, 49 deletions
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 53c0182ee9..2c875796bd 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -6,7 +6,7 @@ #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/util/color.hpp> @@ -24,14 +24,14 @@ class AnnotationTest { public: util::RunLoop loop; HeadlessBackend backend; - HeadlessView view; + OffscreenView view{ backend.getContext() }; StubFileSource fileSource; ThreadPool threadPool { 4 }; - Map map { backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still }; + Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still }; void checkRendering(const char * name) { test::checkImage(std::string("test/fixtures/annotations/") + name, - test::render(map), 0.0002, 0.1); + test::render(map, view), 0.0002, 0.1); } }; @@ -162,7 +162,7 @@ TEST(Annotations, AddMultiple) { test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png")); test.map.addAnnotation(SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); test.map.addAnnotation(SymbolAnnotation { Point<double> { 10, 0 }, "default_marker" }); test.checkRendering("add_multiple"); @@ -172,7 +172,7 @@ TEST(Annotations, NonImmediateAdd) { AnnotationTest test; test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test::render(test.map); + test::render(test.map, test.view); Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; FillAnnotation annotation { polygon }; @@ -190,7 +190,7 @@ TEST(Annotations, UpdateSymbolAnnotationGeometry) { test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" }); test.checkRendering("update_point"); @@ -204,7 +204,7 @@ TEST(Annotations, UpdateSymbolAnnotationIcon) { test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); test.map.updateAnnotation(point, SymbolAnnotation { Point<double> { 0, 0 }, "flipped_marker" }); test.checkRendering("update_icon"); @@ -220,7 +220,7 @@ TEST(Annotations, UpdateLineAnnotationGeometry) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); - test::render(test.map); + test::render(test.map, test.view); annotation.geometry = LineString<double> {{ { 0, 0 }, { -45, -45 } }}; test.map.updateAnnotation(line, annotation); @@ -237,7 +237,7 @@ TEST(Annotations, UpdateLineAnnotationStyle) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); - test::render(test.map); + test::render(test.map, test.view); annotation.color = { { 0, 255, 0, 1 } }; annotation.width = { 2 }; @@ -254,7 +254,7 @@ TEST(Annotations, UpdateFillAnnotationGeometry) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); - test::render(test.map); + test::render(test.map, test.view); annotation.geometry = Polygon<double> {{ {{ { 0, 0 }, { 0, 45 }, { 45, 0 } }} }}; test.map.updateAnnotation(fill, annotation); @@ -271,7 +271,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); - test::render(test.map); + test::render(test.map, test.view); annotation.color = { { 0, 255, 0, 1 } }; test.map.updateAnnotation(fill, annotation); @@ -285,7 +285,7 @@ TEST(Annotations, RemovePoint) { test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png")); AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); test.map.removeAnnotation(point); test.checkRendering("remove_point"); @@ -302,7 +302,7 @@ TEST(Annotations, RemoveShape) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID shape = test.map.addAnnotation(annotation); - test::render(test.map); + test::render(test.map, test.view); test.map.removeAnnotation(shape); test.checkRendering("remove_shape"); @@ -314,7 +314,7 @@ TEST(Annotations, ImmediateRemoveShape) { test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString<double>() })); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); - test::render(test.map); + test::render(test.map, test.view); } TEST(Annotations, SwitchStyle) { @@ -324,7 +324,7 @@ TEST(Annotations, SwitchStyle) { test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png")); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.checkRendering("switch_style"); @@ -338,7 +338,7 @@ TEST(Annotations, QueryRenderedFeatures) { test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" }); test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 50 }, "default_marker" }); - test::render(test.map); + test::render(test.map, test.view); auto features = test.map.queryRenderedFeatures(test.map.pixelForLatLng({ 0, 0 })); EXPECT_EQ(features.size(), 1u); @@ -370,7 +370,7 @@ TEST(Annotations, QueryFractionalZoomLevels) { test.map.setLatLngZoom({ 5, 5 }, 0); for (uint16_t zoomSteps = 10; zoomSteps <= 20; ++zoomSteps) { test.map.setZoom(zoomSteps / 10.0); - test::render(test.map); + test::render(test.map, test.view); auto features = test.map.queryRenderedFeatures(box); // Filter out repeated features. @@ -402,7 +402,7 @@ TEST(Annotations, VisibleFeatures) { // Change bearing *after* adding annotations causes them to be reordered. test.map.setBearing(45); - test::render(test.map); + test::render(test.map, test.view); auto features = test.map.queryRenderedFeatures(box); auto sortID = [](const Feature& lhs, const Feature& rhs) { return lhs.id < rhs.id; }; @@ -413,7 +413,7 @@ TEST(Annotations, VisibleFeatures) { test.map.setBearing(0); test.map.setZoom(4); - test::render(test.map); + test::render(test.map, test.view); features = test.map.queryRenderedFeatures(box); std::sort(features.begin(), features.end(), sortID); features.erase(std::unique(features.begin(), features.end(), sameID), features.end()); diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp index f11363fa3c..eb271b0258 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -4,7 +4,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/storage/online_file_source.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/util/exception.hpp> @@ -21,14 +21,13 @@ TEST(API, RenderWithoutCallback) { util::RunLoop loop; HeadlessBackend backend; - HeadlessView view; - view.resize(128, 512); + OffscreenView view(backend.getContext(), {{ 128, 512 }}); StubFileSource fileSource; ThreadPool threadPool(4); - std::unique_ptr<Map> map = std::make_unique<Map>(backend, view, view.getPixelRatio(), - fileSource, threadPool, MapMode::Still); - map->renderStill(nullptr); + std::unique_ptr<Map> map = + std::make_unique<Map>(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + map->renderStill(view, nullptr); // Force Map thread to join. map.reset(); @@ -47,15 +46,14 @@ TEST(API, RenderWithoutStyle) { util::RunLoop loop; HeadlessBackend backend; - HeadlessView view; - view.resize(128, 512); + OffscreenView view(backend.getContext(), {{ 128, 512 }}); StubFileSource fileSource; ThreadPool threadPool(4); - Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still); + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); std::exception_ptr error; - map.renderStill([&](std::exception_ptr error_, PremultipliedImage&&) { + map.renderStill(view, [&](std::exception_ptr error_) { error = error_; loop.stop(); }); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 84ae780174..70de102b80 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -3,7 +3,7 @@ #include <mbgl/gl/gl.hpp> #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/style/layers/custom_layer.hpp> @@ -86,7 +86,7 @@ TEST(CustomLayer, Basic) { util::RunLoop loop; HeadlessBackend backend; - HeadlessView view; + OffscreenView view(backend.getContext()); #ifdef MBGL_ASSET_ZIP // Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/` @@ -97,7 +97,7 @@ TEST(CustomLayer, Basic) { ThreadPool threadPool(4); - Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still); + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.addLayer(std::make_unique<CustomLayer>( @@ -117,5 +117,5 @@ TEST(CustomLayer, Basic) { layer->setFillColor(Color{ 1.0, 1.0, 0.0, 1.0 }); map.addLayer(std::move(layer)); - test::checkImage("test/fixtures/custom_layer/basic", test::render(map), 0.0006, 0.1); + test::checkImage("test/fixtures/custom_layer/basic", test::render(map, view), 0.0006, 0.1); } diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index d989d222c5..8e59c19afc 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -1,6 +1,6 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/sprite/sprite_image.hpp> #include <mbgl/test/stub_file_source.hpp> @@ -22,15 +22,15 @@ public: map.setStyleJSON(util::read_file("test/fixtures/api/query_style.json")); map.addImage("test-icon", std::move(image)); - test::render(map); + test::render(map, view); } util::RunLoop loop; HeadlessBackend backend; - HeadlessView view; + OffscreenView view { backend.getContext() }; StubFileSource fileSource; ThreadPool threadPool { 4 }; - Map map { backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still }; + Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still }; }; } // end namespace diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp index 8123070282..366d71e67d 100644 --- a/test/api/render_missing.test.cpp +++ b/test/api/render_missing.test.cpp @@ -3,7 +3,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/image.hpp> @@ -26,7 +26,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { const auto style = util::read_file("test/fixtures/api/water_missing_tiles.json"); HeadlessBackend backend; - HeadlessView view(1, 256, 512); + OffscreenView view(backend.getContext(), {{ 256, 512 }}); #ifdef MBGL_ASSET_ZIP // Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/` DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip"); @@ -38,14 +38,14 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still); + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); std::string message; // This host does not respond (== connection error). // Are you seeing this test fail? Make sure you don't have a server running on port 3001! map.setStyleJSON(style); - map.renderStill([&](std::exception_ptr err, PremultipliedImage&&) { + map.renderStill(view, [&](std::exception_ptr err) { ASSERT_TRUE(err.operator bool()); try { std::rethrow_exception(err); diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index 5bc57198bd..715b49b289 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -3,7 +3,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/util/image.hpp> @@ -20,7 +20,7 @@ TEST(API, RepeatedRender) { const auto style = util::read_file("test/fixtures/api/water.json"); HeadlessBackend backend; - HeadlessView view(1, 256, 512); + OffscreenView view(backend.getContext(), {{ 256, 512 }}); #ifdef MBGL_ASSET_ZIP // Regenerate with `cd test/fixtures/api/ && zip -r assets.zip assets/` DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets.zip"); @@ -32,13 +32,13 @@ TEST(API, RepeatedRender) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still); + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); { map.setStyleJSON(style); PremultipliedImage result; - map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) { - result = std::move(image); + map.renderStill(view, [&](std::exception_ptr) { + result = view.readStillImage(); }); while (!result.size()) { @@ -55,8 +55,8 @@ TEST(API, RepeatedRender) { { map.setStyleJSON(style); PremultipliedImage result; - map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) { - result = std::move(image); + map.renderStill(view, [&](std::exception_ptr) { + result = view.readStillImage(); }); while (!result.size()) { |