summaryrefslogtreecommitdiff
path: root/test/style/source.test.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-30 13:40:36 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-05 19:38:08 -0700
commit591af0021bfb8b9fdfd803b55fb6c18a24c46943 (patch)
treeb0952184aca90ddda6ce170c4e2cc287824fbf54 /test/style/source.test.cpp
parent32589c271c6f4885dadb6291c4bf637b72659a9f (diff)
downloadqtlocation-mapboxgl-591af0021bfb8b9fdfd803b55fb6c18a24c46943.tar.gz
[core] Refactor RenderSource updates
* Eliminate updateBatch in favor of diffing layers and detecting changes to properties upon which layout depends. * Replace RenderSource::{update,remove,invalidate,reload}Tiles with a single update method * Replace TilePyramid::{update,remove,invalidate,reload}Tiles with a single update method * Remove Style& dependency TODO from GeometryTile and TileParameters
Diffstat (limited to 'test/style/source.test.cpp')
-rw-r--r--test/style/source.test.cpp106
1 files changed, 87 insertions, 19 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'>&copy; 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();
}