Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Add Source.GeoJSONSourceTilesRemainAfterDataReset unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Nov 12, 2019
1 parent 2246cf7 commit ee38730
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions test/style/source.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
#include <mbgl/test/stub_style_observer.hpp>
#include <mbgl/test/stub_render_source_observer.hpp>

#include <mbgl/style/style.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/sources/raster_source.hpp>
#include <mbgl/style/sources/raster_dem_source.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/sources/image_source.hpp>
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/circle_layer_impl.hpp>
#include <mbgl/style/layers/hillshade_layer.hpp>
#include <mbgl/style/layers/hillshade_layer_impl.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/line_layer_impl.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/sources/image_source.hpp>
#include <mbgl/style/sources/raster_dem_source.hpp>
#include <mbgl/style/sources/raster_source.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/style.hpp>

#include <mbgl/renderer/sources/render_raster_source.hpp>
#include <mbgl/renderer/sources/render_raster_dem_source.hpp>
Expand Down Expand Up @@ -906,3 +908,25 @@ TEST(Source, RenderTileSetSourceUpdate) {
VectorSource uninitialized("source", "http://url");
renderSource->update(uninitialized.baseImpl, layers, true, true, test.tileParameters);
}

TEST(Source, GeoJSONSourceTilesRemainAfterDataReset) {
SourceTest test;
GeoJSONSource source("source");
source.setGeoJSONData(GeoJSONData::create(
mapbox::geojson::parse(
R"({"geometry": {"type": "Point", "coordinates": [1.1, 1.1]}, "type": "Feature", "properties": {}})"),
{}));
RenderGeoJSONSource renderSource{staticImmutableCast<GeoJSONSource::Impl>(source.baseImpl)};

CircleLayer layer("id", "source");
Immutable<LayerProperties> layerProperties =
makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl));
std::vector<Immutable<LayerProperties>> layers{layerProperties};

static_cast<RenderSource&>(renderSource).update(source.baseImpl, layers, true, true, test.tileParameters);
EXPECT_FALSE(renderSource.isLoaded()); // loaded == false, means that the source contains pending tiles.

source.setGeoJSONData(nullptr);
static_cast<RenderSource&>(renderSource).update(source.baseImpl, layers, true, true, test.tileParameters);
EXPECT_FALSE(renderSource.isLoaded()); // Tiles remain.
}

0 comments on commit ee38730

Please sign in to comment.