summaryrefslogtreecommitdiff
path: root/test/style
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-12-01 11:23:26 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2016-12-12 09:05:23 -0500
commit028db7febacf7d40598aff32653ae89599d0d0d2 (patch)
tree7cd0342ceee82bb3a6861c5ab15ffd6139edc8a4 /test/style
parentc76a933514e4e1514a58ac0e668b13eebab37794 (diff)
downloadqtlocation-mapboxgl-028db7febacf7d40598aff32653ae89599d0d0d2.tar.gz
[core] guard against duplicate layer ids
Diffstat (limited to 'test/style')
-rw-r--r--test/style/style_layer.test.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index f6dcc684c7..8356f3accd 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -1,5 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_layer_observer.hpp>
+#include <mbgl/test/stub_file_source.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
@@ -15,6 +17,10 @@
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/util/color.hpp>
+#include <mbgl/util/run_loop.hpp>
+#include <mbgl/util/io.hpp>
+
+#include <memory>
using namespace mbgl;
using namespace mbgl::style;
@@ -268,3 +274,25 @@ TEST(Layer, Observer) {
layer->setLineCap(lineCap);
EXPECT_FALSE(layoutPropertyChanged);
}
+
+TEST(Layer, DuplicateLayer) {
+ util::RunLoop loop;
+
+ //Setup style
+ StubFileSource fileSource;
+ Style style { fileSource, 1.0 };
+ style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
+
+ //Add initial layer
+ style.addLayer(std::make_unique<LineLayer>("line", "unusedsource"));
+
+ //Try to add duplicate
+ try {
+ style.addLayer(std::make_unique<LineLayer>("line", "unusedsource"));
+ FAIL() << "Should not have been allowed to add a duplicate layer id";
+ } catch (const std::runtime_error e) {
+ //Expected
+ ASSERT_STREQ("Layer line already exists", e.what());
+ }
+}
+