[core] reload geojson source on url change

This commit is contained in:
Ivo van Dongen
2016-10-20 12:02:04 +03:00
committed by Ivo van Dongen
parent 5527887c4b
commit ab63a9494f
6 changed files with 57 additions and 0 deletions

View File

@@ -381,3 +381,37 @@ TEST(Source, RasterTileAttribution) {
test.run();
}
TEST(Source, GeoJSonSourceUrlUpdate) {
SourceTest test;
test.fileSource.sourceResponse = [&] (const Resource& resource) {
EXPECT_EQ("url", resource.url);
Response response;
response.data = std::make_unique<std::string>("{\"geometry\": {\"type\": \"Point\", \"coordinates\": [1.1, 1.1]}, \"type\": \"Feature\", \"properties\": {}}");
return response;
};
test.observer.sourceDescriptionChanged = [&] (Source&) {
//Should be called (test will hang if it doesn't)
test.end();
};
test.observer.tileError = [&] (Source&, const OverscaledTileID&, std::exception_ptr) {
FAIL() << "Should never be called";
};
GeoJSONSource source("source");
source.baseImpl->setObserver(&test.observer);
//Load initial, so the source state will be loaded=true
source.baseImpl->loadDescription(test.fileSource);
//Schedule an update
test.loop.invoke([&] () {
//Update the url
source.setURL(std::string("http://source-url.ext"));
});
test.run();
}