diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-10-11 15:16:48 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-10-11 16:51:27 -0700 |
commit | fa81ebc2bff3db41c1d12d0be16ea835a666c030 (patch) | |
tree | 87ee50fdb9d642486b06930b7671df58cca8a87e /test/style | |
parent | f381388b1c6bd10deffbc8b83bb9b37c21dda90c (diff) | |
download | qtlocation-mapboxgl-fa81ebc2bff3db41c1d12d0be16ea835a666c030.tar.gz |
[core] Tests for CustomVectorSource and CustomTile
Diffstat (limited to 'test/style')
-rw-r--r-- | test/style/custom_vector_source.test.cpp | 12 | ||||
-rw-r--r-- | test/style/source.test.cpp | 37 |
2 files changed, 37 insertions, 12 deletions
diff --git a/test/style/custom_vector_source.test.cpp b/test/style/custom_vector_source.test.cpp deleted file mode 100644 index 1d9be99a58..0000000000 --- a/test/style/custom_vector_source.test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include <mbgl/test/util.hpp> - -#include <mbgl/style/sources/custom_vector_source.hpp> -#include <mbgl/style/sources/geojson_source.hpp> -#include <mbgl/tile/tile_id.hpp> -#include <mbgl/util/geo.hpp> - -using namespace mbgl; - -//TODO: AHM: Add tests with real expectations -TEST(CustomVectorSource, EmptyTest) { -} diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index 919260ffe9..c9a6c13992 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -9,6 +9,7 @@ #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_vector_source.hpp> #include <mbgl/style/layers/raster_layer.cpp> #include <mbgl/style/layers/line_layer.hpp> @@ -547,3 +548,39 @@ TEST(Source, ImageSourceImageUpdate) { test.run(); } + +TEST(Source, CustomVectorSourceSetTileData) { + SourceTest test; + + CustomVectorSource source("source", CustomVectorSource::Options()); + source.loadDescription(test.fileSource); + + LineLayer layer("id", "source"); + layer.setSourceLayer("water"); + std::vector<Immutable<Layer::Impl>> layers {{ layer.baseImpl }}; + + test.renderSourceObserver.tileChanged = [&] (RenderSource& source_, const OverscaledTileID&) { + EXPECT_EQ("source", source_.baseImpl->id); + test.end(); + }; + + test.renderSourceObserver.tileError = [&] (RenderSource&, const OverscaledTileID&, std::exception_ptr) { + FAIL() << "Should never be called"; + }; + + auto renderSource = RenderSource::create(source.baseImpl); + renderSource->setObserver(&test.renderSourceObserver); + renderSource->update(source.baseImpl, + layers, + true, + true, + test.tileParameters); + + test.loop.invoke([&] () { + // Set Tile Data + source.setTileData(CanonicalTileID(0, 0, 0), GeoJSON{ FeatureCollection{} }); + }); + + test.run(); +} + |