summaryrefslogtreecommitdiff
path: root/test/tile/geojson_tile.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/tile/geojson_tile.test.cpp')
-rw-r--r--test/tile/geojson_tile.test.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp
index 2aa85c3860..c05e04bc8d 100644
--- a/test/tile/geojson_tile.test.cpp
+++ b/test/tile/geojson_tile.test.cpp
@@ -8,6 +8,7 @@
#include <mbgl/util/run_loop.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/renderer/image_manager.hpp>
@@ -24,7 +25,8 @@ public:
TransformState transformState;
util::RunLoop loop;
ThreadPool threadPool { 1 };
- AnnotationManager annotationManager;
+ style::Style style { loop, fileSource, 1 };
+ AnnotationManager annotationManager { style };
ImageManager imageManager;
GlyphManager glyphManager { fileSource };
Tileset tileset { { "https://example.com" }, { 0, 22 }, "none" };
@@ -38,7 +40,8 @@ public:
MapMode::Continuous,
annotationManager,
imageManager,
- glyphManager
+ glyphManager,
+ 0
};
};
@@ -63,7 +66,6 @@ TEST(GeoJSONTile, Issue7648) {
tile.setLayers({{ layer.baseImpl }});
tile.setObserver(&observer);
- tile.setPlacementConfig({});
while (!tile.isComplete()) {
test.loop.runOnce();
@@ -74,3 +76,40 @@ TEST(GeoJSONTile, Issue7648) {
test.loop.runOnce();
}
}
+
+// Tests that tiles remain renderable if they have been renderable and then had an error sent to
+// them, e.g. when revalidating/refreshing the request.
+TEST(GeoJSONTile, Issue9927) {
+ GeoJSONTileTest test;
+
+ CircleLayer layer("circle", "source");
+
+ mapbox::geometry::feature_collection<int16_t> features;
+ features.push_back(mapbox::geometry::feature<int16_t> {
+ mapbox::geometry::point<int16_t>(0, 0)
+ });
+
+ GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features);
+
+ tile.setLayers({{ layer.baseImpl }});
+
+ while (!tile.isComplete()) {
+ test.loop.runOnce();
+ }
+
+ ASSERT_TRUE(tile.isRenderable());
+ ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+
+ // Make sure that once we've had a renderable tile and then receive erroneous data, we retain
+ // the previously rendered data and keep the tile renderable.
+ tile.setError(std::make_exception_ptr(std::runtime_error("Connection offline")));
+ ASSERT_TRUE(tile.isRenderable());
+ ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+
+ // Then simulate a parsing failure and make sure that we keep it renderable in this situation
+ // as well. We're using 3 as a correlationID since we've done two three calls that increment
+ // this counter (as part of the GeoJSONTile constructor, setLayers, and setPlacementConfig).
+ tile.onError(std::make_exception_ptr(std::runtime_error("Parse error")), 3);
+ ASSERT_TRUE(tile.isRenderable());
+ ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ }