From 187962e4259c3a9d3c29fefe29533358face4ed0 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 1 Aug 2019 14:49:15 +0300 Subject: [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. --- test/style/source.test.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test') 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 #include +#include 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 impl_) + : RenderTileSetSource(std::move(impl_)) {} + + MOCK_METHOD0(mockedUpdateInternal, void()); + + void updateInternal(const Tileset&, + const std::vector>&, + const bool, const bool, const TileParameters&) override { + mockedUpdateInternal(); + } + + const optional& getTileset() const override { + return static_cast(*baseImpl).tileset; + } + }; + + VectorSource initialized("source", Tileset{ {"tiles"} }); + initialized.loadDescription(*test.fileSource); + + FakeRenderTileSetSource renderTilesetSource { initialized.baseImpl }; + + LineLayer layer("id", "source"); + Immutable layerProperties = makeMutable(staticImmutableCast(layer.baseImpl)); + std::vector> 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); +} -- cgit v1.2.1