diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-01 14:49:15 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-01 18:20:21 +0300 |
commit | 187962e4259c3a9d3c29fefe29533358face4ed0 (patch) | |
tree | a2fb310a0df60ffd0c22a5ab950c5f5db6b08256 /test | |
parent | 9cf1746e350048177487406328ff7815287ede61 (diff) | |
download | qtlocation-mapboxgl-187962e4259c3a9d3c29fefe29533358face4ed0.tar.gz |
[core] Fix render tile set source update
Before this change, the `RenderTileSetSource` implementation
ignored update calls for the sources whose description was not yet
loaded and it lead to missing of relayout requests.
Diffstat (limited to 'test')
-rw-r--r-- | test/style/source.test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index 09c433b6a4..ca0e79f46a 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -42,6 +42,7 @@ #include <mbgl/text/glyph_manager.hpp> #include <cstdint> +#include <gmock/gmock.h> using namespace mbgl; using SourceType = mbgl::style::SourceType; @@ -793,3 +794,41 @@ TEST(Source, CustomGeometrySourceSetTileData) { test.run(); } +TEST(Source, RenderTileSetSourceUpdate) { + SourceTest test; + + class FakeRenderTileSetSource : public RenderTileSetSource { + public: + explicit FakeRenderTileSetSource(Immutable<style::Source::Impl> impl_) + : RenderTileSetSource(std::move(impl_)) {} + + MOCK_METHOD0(mockedUpdateInternal, void()); + + void updateInternal(const Tileset&, + const std::vector<Immutable<style::LayerProperties>>&, + const bool, const bool, const TileParameters&) override { + mockedUpdateInternal(); + } + + const optional<Tileset>& getTileset() const override { + return static_cast<const style::VectorSource::Impl&>(*baseImpl).tileset; + } + }; + + VectorSource initialized("source", Tileset{ {"tiles"} }); + initialized.loadDescription(*test.fileSource); + + FakeRenderTileSetSource renderTilesetSource { initialized.baseImpl }; + + LineLayer layer("id", "source"); + Immutable<LayerProperties> layerProperties = makeMutable<LineLayerProperties>(staticImmutableCast<LineLayer::Impl>(layer.baseImpl)); + std::vector<Immutable<LayerProperties>> layers { layerProperties }; + + // Check that `updateInternal()` is called even if the updated source has not yet loaded description. + EXPECT_CALL(renderTilesetSource, mockedUpdateInternal()).Times(2); + RenderSource* renderSource = &renderTilesetSource; + renderSource->update(initialized.baseImpl, layers, true, true, test.tileParameters); + + VectorSource uninitialized("source", "http://url"); + renderSource->update(uninitialized.baseImpl, layers, true, true, test.tileParameters); +} |