diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/style/source.test.cpp | 106 | ||||
-rw-r--r-- | test/tile/annotation_tile.test.cpp | 7 | ||||
-rw-r--r-- | test/tile/geojson_tile.test.cpp | 14 | ||||
-rw-r--r-- | test/tile/raster_tile.test.cpp | 9 | ||||
-rw-r--r-- | test/tile/vector_tile.test.cpp | 9 |
5 files changed, 114 insertions, 31 deletions
diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index 84929178d0..0ab98a63b1 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -8,6 +8,8 @@ #include <mbgl/style/sources/vector_source.hpp> #include <mbgl/style/sources/geojson_source.hpp> #include <mbgl/style/sources/image_source.hpp> +#include <mbgl/style/layers/raster_layer.cpp> +#include <mbgl/style/layers/line_layer.hpp> #include <mbgl/renderer/sources/render_raster_source.hpp> #include <mbgl/renderer/sources/render_vector_source.hpp> @@ -27,12 +29,10 @@ #include <mbgl/util/range.hpp> #include <mbgl/map/transform.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/style/layers/line_layer.hpp> #include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/annotation/annotation_source.hpp> - -#include <mapbox/geojsonvt.hpp> +#include <mbgl/sprite/sprite_atlas.hpp> +#include <mbgl/text/glyph_atlas.hpp> #include <cstdint> @@ -48,7 +48,8 @@ public: TransformState transformState; ThreadPool threadPool { 1 }; AnnotationManager annotationManager; - style::Style style { threadPool, fileSource, 1.0 }; + SpriteAtlas spriteAtlas; + GlyphAtlas glyphAtlas { { 512, 512, }, fileSource }; TileParameters tileParameters { 1.0, @@ -58,7 +59,8 @@ public: fileSource, MapMode::Continuous, annotationManager, - style + spriteAtlas, + glyphAtlas }; SourceTest() { @@ -137,6 +139,9 @@ TEST(Source, RasterTileEmpty) { return response; }; + RasterLayer layer("id", "source"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -154,7 +159,11 @@ TEST(Source, RasterTileEmpty) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -168,6 +177,11 @@ TEST(Source, VectorTileEmpty) { return response; }; + LineLayer layer("id", "source"); + layer.setSourceLayer("water"); + + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -185,7 +199,11 @@ TEST(Source, VectorTileEmpty) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -201,6 +219,9 @@ TEST(Source, RasterTileFail) { return response; }; + RasterLayer layer("id", "source"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -216,7 +237,11 @@ TEST(Source, RasterTileFail) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -232,6 +257,11 @@ TEST(Source, VectorTileFail) { return response; }; + LineLayer layer("id", "source"); + layer.setSourceLayer("water"); + + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -247,7 +277,11 @@ TEST(Source, VectorTileFail) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -261,6 +295,9 @@ TEST(Source, RasterTileCorrupt) { return response; }; + RasterLayer layer("id", "source"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -277,7 +314,11 @@ TEST(Source, RasterTileCorrupt) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -291,10 +332,10 @@ TEST(Source, VectorTileCorrupt) { return response; }; - // Need to have at least one layer that uses the source. - auto layer = std::make_unique<LineLayer>("id", "source"); - layer->setSourceLayer("water"); - test.style.addLayer(std::move(layer)); + LineLayer layer("id", "source"); + layer.setSourceLayer("water"); + + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; Tileset tileset; tileset.tiles = { "tiles" }; @@ -311,7 +352,11 @@ TEST(Source, VectorTileCorrupt) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -324,6 +369,9 @@ TEST(Source, RasterTileCancel) { return optional<Response>(); }; + RasterLayer layer("id", "source"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -340,7 +388,11 @@ TEST(Source, RasterTileCancel) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -353,6 +405,11 @@ TEST(Source, VectorTileCancel) { return optional<Response>(); }; + LineLayer layer("id", "source"); + layer.setSourceLayer("water"); + + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + Tileset tileset; tileset.tiles = { "tiles" }; @@ -369,7 +426,11 @@ TEST(Source, VectorTileCancel) { auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } @@ -377,6 +438,9 @@ TEST(Source, VectorTileCancel) { TEST(Source, RasterTileAttribution) { SourceTest test; + RasterLayer layer("id", "source"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + std::string mapboxOSM = ("<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox</a> " "<a href='http://www.openstreetmap.org/about/' target='_blank'>©️ OpenStreetMap</a>"); @@ -406,7 +470,11 @@ TEST(Source, RasterTileAttribution) { source.loadDescription(test.fileSource); auto renderSource = RenderSource::create(source.baseImpl); - renderSource->updateTiles(test.tileParameters); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); test.run(); } diff --git a/test/tile/annotation_tile.test.cpp b/test/tile/annotation_tile.test.cpp index 205a315db7..bfd991c504 100644 --- a/test/tile/annotation_tile.test.cpp +++ b/test/tile/annotation_tile.test.cpp @@ -12,6 +12,8 @@ #include <mbgl/geometry/feature_index.hpp> #include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/annotation/annotation_tile.hpp> +#include <mbgl/sprite/sprite_atlas.hpp> +#include <mbgl/text/glyph_atlas.hpp> #include <memory> @@ -25,6 +27,8 @@ public: ThreadPool threadPool { 1 }; AnnotationManager annotationManager; style::Style style { threadPool, fileSource, 1.0 }; + SpriteAtlas spriteAtlas; + GlyphAtlas glyphAtlas { { 512, 512, }, fileSource }; TileParameters tileParameters { 1.0, @@ -34,7 +38,8 @@ public: fileSource, MapMode::Continuous, annotationManager, - style + spriteAtlas, + glyphAtlas }; }; diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp index dad4aef2ee..92068d5e43 100644 --- a/test/tile/geojson_tile.test.cpp +++ b/test/tile/geojson_tile.test.cpp @@ -7,10 +7,11 @@ #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/map/transform.hpp> -#include <mbgl/style/style.hpp> #include <mbgl/renderer/tile_parameters.hpp> #include <mbgl/style/layers/circle_layer.hpp> #include <mbgl/annotation/annotation_manager.hpp> +#include <mbgl/sprite/sprite_atlas.hpp> +#include <mbgl/text/glyph_atlas.hpp> #include <memory> @@ -24,7 +25,8 @@ public: util::RunLoop loop; ThreadPool threadPool { 1 }; AnnotationManager annotationManager; - style::Style style { threadPool, fileSource, 1.0 }; + SpriteAtlas spriteAtlas; + GlyphAtlas glyphAtlas { { 512, 512, }, fileSource }; Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" }; TileParameters tileParameters { @@ -35,14 +37,15 @@ public: fileSource, MapMode::Continuous, annotationManager, - style + spriteAtlas, + glyphAtlas }; }; TEST(GeoJSONTile, Issue7648) { GeoJSONTileTest test; - test.style.addLayer(std::make_unique<CircleLayer>("circle", "source")); + CircleLayer layer("circle", "source"); mapbox::geometry::feature_collection<int16_t> features; features.push_back(mapbox::geometry::feature<int16_t> { @@ -55,9 +58,10 @@ TEST(GeoJSONTile, Issue7648) { observer.tileChanged = [&] (const Tile&) { // Once present, the bucket should never "disappear", which would cause // flickering. - ASSERT_NE(nullptr, tile.getBucket(*test.style.getLayer("circle")->baseImpl)); + ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl)); }; + tile.setLayers({{ layer.baseImpl }}); tile.setObserver(&observer); tile.setPlacementConfig({}); diff --git a/test/tile/raster_tile.test.cpp b/test/tile/raster_tile.test.cpp index ee6e31d845..1bd35700b3 100644 --- a/test/tile/raster_tile.test.cpp +++ b/test/tile/raster_tile.test.cpp @@ -6,10 +6,11 @@ #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/map/transform.hpp> -#include <mbgl/style/style.hpp> #include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/renderer/tile_parameters.hpp> #include <mbgl/renderer/buckets/raster_bucket.hpp> +#include <mbgl/sprite/sprite_atlas.hpp> +#include <mbgl/text/glyph_atlas.hpp> using namespace mbgl; @@ -20,7 +21,8 @@ public: util::RunLoop loop; ThreadPool threadPool { 1 }; AnnotationManager annotationManager; - style::Style style { threadPool, fileSource, 1.0 }; + SpriteAtlas spriteAtlas; + GlyphAtlas glyphAtlas { { 512, 512, }, fileSource }; Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" }; TileParameters tileParameters { @@ -31,7 +33,8 @@ public: fileSource, MapMode::Continuous, annotationManager, - style + spriteAtlas, + glyphAtlas }; }; diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index 205d001f72..a44eeb9001 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -7,13 +7,14 @@ #include <mbgl/util/run_loop.hpp> #include <mbgl/map/transform.hpp> #include <mbgl/map/query.hpp> -#include <mbgl/style/style.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/renderer/tile_parameters.hpp> #include <mbgl/renderer/buckets/symbol_bucket.hpp> #include <mbgl/text/collision_tile.hpp> #include <mbgl/geometry/feature_index.hpp> #include <mbgl/annotation/annotation_manager.hpp> +#include <mbgl/sprite/sprite_atlas.hpp> +#include <mbgl/text/glyph_atlas.hpp> #include <memory> @@ -26,7 +27,8 @@ public: util::RunLoop loop; ThreadPool threadPool { 1 }; AnnotationManager annotationManager; - style::Style style { threadPool, fileSource, 1.0 }; + SpriteAtlas spriteAtlas; + GlyphAtlas glyphAtlas { { 512, 512, }, fileSource }; Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" }; TileParameters tileParameters { @@ -37,7 +39,8 @@ public: fileSource, MapMode::Continuous, annotationManager, - style + spriteAtlas, + glyphAtlas }; }; |