diff options
author | Tobrun <tobrun@mapbox.com> | 2017-06-09 12:05:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-09 12:05:54 +0200 |
commit | 6ec5e4f8cdb98227db11e5989376c31832ca2048 (patch) | |
tree | 666de95e35b73f4c6f851e9c243c29fe74ce4465 /test | |
parent | fa972fad60e58e5b8f9f9622f508e9732c8c9ffd (diff) | |
download | qtlocation-mapboxgl-6ec5e4f8cdb98227db11e5989376c31832ca2048.tar.gz |
Cherry picks to release branch (#9230)
* [ios][macos] test remove source in use
* [android] test remove source in use
* [core] check source usage before remove
* [core] ensure layer::accept works with non-void return values on gcc
* [android] - remove upgrade runtime exceptions (#9191)
Diffstat (limited to 'test')
-rw-r--r-- | test/style/style.test.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp index b529abad4a..841c7b291b 100644 --- a/test/style/style.test.cpp +++ b/test/style/style.test.cpp @@ -1,10 +1,12 @@ #include <mbgl/test/util.hpp> #include <mbgl/test/stub_file_source.hpp> +#include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/source_impl.hpp> #include <mbgl/style/sources/vector_source.hpp> #include <mbgl/style/layer.hpp> +#include <mbgl/style/layers/line_layer.hpp> #include <mbgl/util/io.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/util/default_thread_pool.hpp> @@ -67,3 +69,33 @@ TEST(Style, DuplicateSource) { // Expected } } + +TEST(Style, RemoveSourceInUse) { + util::RunLoop loop; + + auto log = new FixtureLogObserver(); + Log::setObserver(std::unique_ptr<Log::Observer>(log)); + + ThreadPool threadPool{ 1 }; + StubFileSource fileSource; + Style style { threadPool, fileSource, 1.0 }; + + style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json")); + + style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2")); + style.addLayer(std::make_unique<LineLayer>("layerId", "sourceId")); + + // Should not remove the source + auto removed = style.removeSource("sourceId"); + ASSERT_EQ(nullptr, removed); + ASSERT_NE(nullptr, style.getSource("sourceId")); + + const FixtureLogObserver::LogMessage logMessage { + EventSeverity::Warning, + Event::General, + int64_t(-1), + "Source 'sourceId' is in use, cannot remove", + }; + + EXPECT_EQ(log->count(logMessage), 1u); +} |