summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-01-07 10:22:20 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-01-15 12:48:23 +0100
commit8a964fb9313e57b71c64b8c0739ec84f163dc537 (patch)
treee0415a40fd010eb5a8245b7c3e818a4678599641 /test
parent21e4029acf757898da8695474f94642f9858acd8 (diff)
downloadqtlocation-mapboxgl-8a964fb9313e57b71c64b8c0739ec84f163dc537.tar.gz
[core] use stale and refreshing TileJSON/GeoJSON data
We're now supporting using stale TileJSON and GeoJSON data. When we receive a new answer with an updated TileJSON file, we're replacing the Source's metadata with the new one and trigger updates to make sure we're loading the correct tiles. Similarly, GeoJSON data will be reparsed.
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/stale/stale_style_and_tilejson/expected.pngbin0 -> 13447 bytes
-rw-r--r--test/fixtures/stale/style_and_tilejson.json25
-rw-r--r--test/storage/cache_stale.cpp23
3 files changed, 48 insertions, 0 deletions
diff --git a/test/fixtures/stale/stale_style_and_tilejson/expected.png b/test/fixtures/stale/stale_style_and_tilejson/expected.png
new file mode 100644
index 0000000000..d3c6ef3cd5
--- /dev/null
+++ b/test/fixtures/stale/stale_style_and_tilejson/expected.png
Binary files differ
diff --git a/test/fixtures/stale/style_and_tilejson.json b/test/fixtures/stale/style_and_tilejson.json
new file mode 100644
index 0000000000..f2a4fddd0b
--- /dev/null
+++ b/test/fixtures/stale/style_and_tilejson.json
@@ -0,0 +1,25 @@
+{
+ "version": 8,
+ "name": "Water",
+ "sources": {
+ "mapbox": {
+ "type": "vector",
+ "url": "http://127.0.0.1:3000/stale/streets.json"
+ }
+ },
+ "layers": [{
+ "id": "background",
+ "type": "background",
+ "paint": {
+ "background-color": "red"
+ }
+ }, {
+ "id": "water",
+ "type": "fill",
+ "source": "mapbox",
+ "source-layer": "water",
+ "paint": {
+ "fill-color": "blue"
+ }
+ }]
+}
diff --git a/test/storage/cache_stale.cpp b/test/storage/cache_stale.cpp
index cc421f7c34..7f379b78a2 100644
--- a/test/storage/cache_stale.cpp
+++ b/test/storage/cache_stale.cpp
@@ -49,3 +49,26 @@ TEST_F(Storage, CacheStaleStyle) {
checkRendering(map, "stale_style", 1000ms);
}
+
+TEST_F(Storage, CacheStaleStyleAndTileJSON) {
+ HeadlessView view(display, 1);
+
+ auto cache = SQLiteCache::getShared(":memory:");
+
+ // Rig the cache with an expired stylesheet.
+ const std::string stylePath = "stale/style_and_tilejson.json";
+ const Resource styleResource{ Resource::Kind::Style, prefix + "/" + stylePath };
+ cache->put(styleResource, expiredItem(stylePath));
+
+ // Rig the cache with an expired TileJSON.
+ const std::string tilejsonPath = "stale/streets.json";
+ const Resource tilejsonResource{ Resource::Kind::Source, prefix + "/" + tilejsonPath };
+ cache->put(tilejsonResource, expiredItem(tilejsonPath));
+
+ DefaultFileSource fileSource(":memory:", ".");
+
+ Map map(view, fileSource, MapMode::Still);
+ map.setStyleURL(styleResource.url);
+
+ checkRendering(map, "stale_style_and_tilejson", 1000ms);
+}