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/storage | |
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/storage')
-rw-r--r-- | test/storage/cache_stale.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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); +} |