summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-04-16 16:11:40 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-04-17 13:40:42 +0200
commit1c920c433274095af37a3da89207e9ea03df64ae (patch)
treeab5958c8b9a8f862cb30993b80c10393cdcc11fc /test/api
parent46bf2269107b21d20fc84ef46a9ce5c2bfeea519 (diff)
downloadqtlocation-mapboxgl-1c920c433274095af37a3da89207e9ea03df64ae.tar.gz
don't throw an exception in the map thread for bad styles
Diffstat (limited to 'test/api')
-rw-r--r--test/api/set_style.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/api/set_style.cpp b/test/api/set_style.cpp
new file mode 100644
index 0000000000..5a5013accf
--- /dev/null
+++ b/test/api/set_style.cpp
@@ -0,0 +1,32 @@
+#include "../fixtures/util.hpp"
+#include "../fixtures/fixture_log_observer.hpp"
+
+#include <mbgl/map/map.hpp>
+#include <mbgl/platform/default/headless_view.hpp>
+#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/storage/default_file_source.hpp>
+
+
+TEST(API, SetStyle) {
+ using namespace mbgl;
+
+ auto display = std::make_shared<mbgl::HeadlessDisplay>();
+ HeadlessView view(display);
+ DefaultFileSource fileSource(nullptr);
+
+ Log::setObserver(util::make_unique<FixtureLogObserver>());
+
+ Map map(view, fileSource);
+
+ map.start(Map::Mode::Static);
+
+ map.setStyleJSON("invalid", "test/suite");
+
+ map.stop();
+
+ auto observer = Log::removeObserver();
+ auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
+ EXPECT_EQ(1ul, flo->count({ EventSeverity::Error, Event::ParseStyle, -1,
+ "Error parsing style JSON at 0: Expect either an object or array at root" }));
+ EXPECT_TRUE(flo->unchecked().empty());
+}