diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-01-07 16:21:45 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-01-15 17:04:07 +0100 |
commit | bd1f71cdbd4aa55ffa1beb61ddee1dd6da32412d (patch) | |
tree | 8bdc66df5446353faa2d315654f0f908c9d8098f /test | |
parent | 40e908677e58f186d13ef9a33d2dcde396390ac4 (diff) | |
download | qtlocation-mapboxgl-bd1f71cdbd4aa55ffa1beb61ddee1dd6da32412d.tar.gz |
[core] use stale sprite data
This is a naïve implementation that essentially merges updated data into existing data. It will *not* remove icons from the stale sprite if they aren't present in the fresh sprite (we aren't tracking the source of a sprite, and the user could have changed it as well). Similarly, it will not update icons that have changed in dimension. This is a rare edge case and probably not worth implementing.
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/stale/sprite.json | 10 | ||||
-rw-r--r-- | test/fixtures/stale/sprite.png | bin | 0 -> 3351 bytes | |||
-rw-r--r-- | test/fixtures/stale/stale_style_and_sprite/expected.png | bin | 0 -> 26859 bytes | |||
-rw-r--r-- | test/fixtures/stale/style_and_sprite.json | 26 | ||||
-rw-r--r-- | test/storage/cache_stale.cpp | 28 |
5 files changed, 64 insertions, 0 deletions
diff --git a/test/fixtures/stale/sprite.json b/test/fixtures/stale/sprite.json new file mode 100644 index 0000000000..e640365519 --- /dev/null +++ b/test/fixtures/stale/sprite.json @@ -0,0 +1,10 @@ +{ + "noise": { + "x": 0, + "y": 0, + "width": 32, + "height": 32, + "pixelRatio": 1, + "sdf": false + } +} diff --git a/test/fixtures/stale/sprite.png b/test/fixtures/stale/sprite.png Binary files differnew file mode 100644 index 0000000000..a02d8eb542 --- /dev/null +++ b/test/fixtures/stale/sprite.png diff --git a/test/fixtures/stale/stale_style_and_sprite/expected.png b/test/fixtures/stale/stale_style_and_sprite/expected.png Binary files differnew file mode 100644 index 0000000000..171599bf5c --- /dev/null +++ b/test/fixtures/stale/stale_style_and_sprite/expected.png diff --git a/test/fixtures/stale/style_and_sprite.json b/test/fixtures/stale/style_and_sprite.json new file mode 100644 index 0000000000..61e3214a5e --- /dev/null +++ b/test/fixtures/stale/style_and_sprite.json @@ -0,0 +1,26 @@ +{ + "version": 8, + "name": "Water", + "sources": { + "mapbox": { + "type": "vector", + "url": "asset://test/fixtures/stale/streets.json" + } + }, + "sprite": "http://127.0.0.1:3000/stale/sprite", + "layers": [{ + "id": "background", + "type": "background", + "paint": { + "background-color": "red" + } + }, { + "id": "water", + "type": "fill", + "source": "mapbox", + "source-layer": "water", + "paint": { + "fill-pattern": "noise" + } + }] +} diff --git a/test/storage/cache_stale.cpp b/test/storage/cache_stale.cpp index 7f379b78a2..ab9fe7b202 100644 --- a/test/storage/cache_stale.cpp +++ b/test/storage/cache_stale.cpp @@ -72,3 +72,31 @@ TEST_F(Storage, CacheStaleStyleAndTileJSON) { checkRendering(map, "stale_style_and_tilejson", 1000ms); } + +TEST_F(Storage, CacheStaleStyleAndSprite) { + HeadlessView view(display, 1); + + auto cache = SQLiteCache::getShared(":memory:"); + + // Rig the cache with an expired stylesheet. + const std::string stylePath = "stale/style_and_sprite.json"; + const Resource styleResource{ Resource::Kind::Style, prefix + "/" + stylePath }; + cache->put(styleResource, expiredItem(stylePath)); + + // Rig the cache with an expired sprite JSON. + const std::string spritejsonPath = "stale/sprite.json"; + const Resource spritejsonResource{ Resource::Kind::SpriteJSON, prefix + "/" + spritejsonPath }; + cache->put(spritejsonResource, expiredItem(spritejsonPath)); + + // Rig the cache with an expired sprite JSON. + const std::string spriteimagePath = "stale/sprite.png"; + const Resource spriteimageResource{ Resource::Kind::SpriteImage, prefix + "/" + spriteimagePath }; + cache->put(spriteimageResource, expiredItem(spriteimagePath)); + + DefaultFileSource fileSource(":memory:", "."); + + Map map(view, fileSource, MapMode::Still); + map.setStyleURL(styleResource.url); + + checkRendering(map, "stale_style_and_sprite", 1000ms); +} |