[core] use stale glyphs
Updating glyphs is still unsupported, and there's no good use case for doing so. When we're using a stale glyph PBF, and the fresh answer contains changed to that glyph, we will continue to use the old glyph.
This commit is contained in:
BIN
test/fixtures/stale/glyph.pbf
vendored
Normal file
BIN
test/fixtures/stale/glyph.pbf
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/stale/stale_style_and_glyphs/expected.png
vendored
Normal file
BIN
test/fixtures/stale/stale_style_and_glyphs/expected.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
39
test/fixtures/stale/style_and_glyphs.json
vendored
Normal file
39
test/fixtures/stale/style_and_glyphs.json
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"version": 8,
|
||||
"name": "Water",
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"url": "asset://test/fixtures/stale/streets.json"
|
||||
}
|
||||
},
|
||||
"glyphs": "http://127.0.0.1:3000/stale/{fontstack}/{range}.pbf",
|
||||
"layers": [{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
"paint": {
|
||||
"background-color": "red"
|
||||
}
|
||||
}, {
|
||||
"id": "water",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "water",
|
||||
"paint": {
|
||||
"fill-color": "blue"
|
||||
}
|
||||
}, {
|
||||
"id": "admin",
|
||||
"type": "symbol",
|
||||
"source": "mapbox",
|
||||
"source-layer": "admin",
|
||||
"layout": {
|
||||
"text-field": "Text"
|
||||
},
|
||||
"paint": {
|
||||
"text-color": "black",
|
||||
"text-halo-color": "white",
|
||||
"text-halo-width": 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -15,8 +15,13 @@ using namespace std::literals::string_literals;
|
||||
|
||||
namespace {
|
||||
|
||||
void checkRendering(Map& map, const char *name, std::chrono::milliseconds timeout) {
|
||||
test::checkImage("test/fixtures/stale/"s + name, test::render(map, timeout), 0.001, 0.1);
|
||||
void checkRendering(Map& map,
|
||||
const char* name,
|
||||
std::chrono::milliseconds timeout,
|
||||
double imageThreshold = 0.001,
|
||||
double pixelThreshold = 0.1) {
|
||||
test::checkImage("test/fixtures/stale/"s + name, test::render(map, timeout), imageThreshold,
|
||||
pixelThreshold);
|
||||
}
|
||||
|
||||
Response expiredItem(const std::string& path) {
|
||||
@@ -100,3 +105,27 @@ TEST_F(Storage, CacheStaleStyleAndSprite) {
|
||||
|
||||
checkRendering(map, "stale_style_and_sprite", 1000ms);
|
||||
}
|
||||
|
||||
TEST_F(Storage, CacheStaleStyleAndGlyphs) {
|
||||
HeadlessView view(display, 1);
|
||||
|
||||
auto cache = SQLiteCache::getShared(":memory:");
|
||||
|
||||
// Rig the cache with an expired stylesheet.
|
||||
const std::string stylePath = "stale/style_and_glyphs.json";
|
||||
const Resource styleResource{ Resource::Kind::Style, prefix + "/" + stylePath };
|
||||
cache->put(styleResource, expiredItem(stylePath));
|
||||
|
||||
// Rig the cache with an expired glyph PBF.
|
||||
const std::string glyphPath = "stale/glyph.pbf";
|
||||
const Resource glyphResource{ Resource::Kind::Glyphs, prefix + "/stale/Open%20Sans%20Regular%2c%20Arial%20Unicode%20MS%20Regular/0-255.pbf" };
|
||||
cache->put(glyphResource, expiredItem(glyphPath));
|
||||
|
||||
DefaultFileSource fileSource(":memory:", ".");
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleURL(styleResource.url);
|
||||
|
||||
// TODO: this shouldn't take > 1 second
|
||||
checkRendering(map, "stale_style_and_glyphs", 2000ms, 0.0015);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ TEST(GlyphStore, LoadingSuccess) {
|
||||
return;
|
||||
|
||||
auto fontStack = test.glyphStore.getFontStack("Test Stack");
|
||||
ASSERT_FALSE(fontStack->getMetrics().empty());
|
||||
ASSERT_FALSE(fontStack->getSDFs().empty());
|
||||
|
||||
test.end();
|
||||
@@ -73,7 +72,6 @@ TEST(GlyphStore, LoadingFail) {
|
||||
ASSERT_EQ(glyphRange, GlyphRange(0, 255));
|
||||
|
||||
auto stack = test.glyphStore.getFontStack("Test Stack");
|
||||
ASSERT_TRUE(stack->getMetrics().empty());
|
||||
ASSERT_TRUE(stack->getSDFs().empty());
|
||||
ASSERT_FALSE(test.glyphStore.hasGlyphRanges("Test Stack", {{0, 255}}));
|
||||
|
||||
@@ -95,7 +93,6 @@ TEST(GlyphStore, LoadingCorrupted) {
|
||||
ASSERT_EQ(glyphRange, GlyphRange(0, 255));
|
||||
|
||||
auto stack = test.glyphStore.getFontStack("Test Stack");
|
||||
ASSERT_TRUE(stack->getMetrics().empty());
|
||||
ASSERT_TRUE(stack->getSDFs().empty());
|
||||
ASSERT_FALSE(test.glyphStore.hasGlyphRanges("Test Stack", {{0, 255}}));
|
||||
|
||||
@@ -132,7 +129,6 @@ TEST(GlyphStore, InvalidURL) {
|
||||
ASSERT_TRUE(error != nullptr);
|
||||
|
||||
auto stack = test.glyphStore.getFontStack("Test Stack");
|
||||
ASSERT_TRUE(stack->getMetrics().empty());
|
||||
ASSERT_TRUE(stack->getSDFs().empty());
|
||||
|
||||
test.end();
|
||||
|
||||
Reference in New Issue
Block a user