From ff3af7284d384facbf47da67109c547e70f11173 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Sat, 26 Oct 2019 12:24:03 +0300 Subject: [core] Add Map.NoHangOnMissingImage unit test --- test/map/map.test.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 3f3145059a..6f4b14a681 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -1009,3 +1009,54 @@ TEST(Map, UniversalStyleGetter) { ASSERT_TRUE(lineCap.getValue().getString()); EXPECT_EQ(std::string("butt"), *lineCap.getValue().getString()); } + +TEST(Map, NoHangOnMissingImage) { + MapTest<> test; + + test.fileSource->tileResponse = [&](const Resource&) { + Response result; + result.data = std::make_shared(util::read_file("test/fixtures/map/issue12432/0-0-0.mvt")); + return result; + }; + + test.fileSource->spriteImageResponse = [&](const Resource&) { + Response result; + result.data = std::make_shared(util::read_file("test/fixtures/resources/sprite.png")); + return result; + }; + + test.fileSource->spriteJSONResponse = [&](const Resource&) { + Response result; + result.data = std::make_shared(util::read_file("test/fixtures/resources/sprite.json")); + return result; + }; + + const std::string style{R"STYLE({ + "version": 8, + "sprite": "http://example.com/sprites/sprite", + "sources": { + "mapbox": { + "type": "vector", + "tiles": ["http://example.com/{z}-{x}-{y}.vector.pbf"] + } + }, + "layers": [{ + "id": "background", + "type": "background", + "paint": {"background-color": "white"} + },{ + "id": "water", + "type": "fill", + "source": "mapbox", + "source-layer": "water", + "paint": {"fill-pattern": "missing"} + }] + })STYLE"}; + test.map.getStyle().loadJSON(style); + test.frontend.render(test.map); + + test.map.getStyle().loadJSON(style); + test.map.jumpTo(test.map.getStyle().getDefaultCamera()); + // The test passes if the following call does not hang. + test.frontend.render(test.map); +} \ No newline at end of file -- cgit v1.2.1