summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-08-15 16:16:45 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-08-19 17:34:10 +0200
commitcb33c861b4cfa82d7afcb5b9ec85d7797679a7d8 (patch)
tree8ad68018af87fd9e41e58a19f5d0286698f203e7 /test
parentdfd40b27a54115cdf769abdda3ec4d3a1329758c (diff)
downloadqtlocation-mapboxgl-cb33c861b4cfa82d7afcb5b9ec85d7797679a7d8.tar.gz
[core] parse more Style JSON properties
We're now parsing "name", "center", "zoom", "bearing", and "pitch" from the stylesheet.
Diffstat (limited to 'test')
-rw-r--r--test/style/style.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/style/style.cpp b/test/style/style.cpp
index 1681bac1c9..b1c7d50baf 100644
--- a/test/style/style.cpp
+++ b/test/style/style.cpp
@@ -61,3 +61,37 @@ TEST(Style, UnusedSourceActiveViaClassUpdate) {
EXPECT_TRUE(unusedSource);
EXPECT_FALSE(unusedSource->baseImpl->isLoaded());
}
+
+TEST(Style, Properties) {
+ util::RunLoop loop;
+
+ StubFileSource fileSource;
+ Style style { fileSource, 1.0 };
+
+ style.setJSON(R"STYLE({"name": "Test"})STYLE");
+ ASSERT_EQ("Test", style.getName());
+
+ style.setJSON(R"STYLE({"center": [10, 20]})STYLE");
+ ASSERT_EQ("", style.getName());
+ ASSERT_EQ((LatLng{20, 10}), style.getDefaultLatLng());
+
+ style.setJSON(R"STYLE({"bearing": 24})STYLE");
+ ASSERT_EQ("", style.getName());
+ ASSERT_EQ((LatLng{0, 0}), style.getDefaultLatLng());
+ ASSERT_EQ(24, style.getDefaultBearing());
+
+ style.setJSON(R"STYLE({"zoom": 13.3})STYLE");
+ ASSERT_EQ("", style.getName());
+ ASSERT_EQ(13.3, style.getDefaultZoom());
+
+ style.setJSON(R"STYLE({"pitch": 60})STYLE");
+ ASSERT_EQ("", style.getName());
+ ASSERT_EQ(60, style.getDefaultPitch());
+
+ style.setJSON(R"STYLE({"name": 23, "center": {}, "bearing": "north", "zoom": null, "pitch": "wide"})STYLE");
+ ASSERT_EQ("", style.getName());
+ ASSERT_EQ((LatLng{0, 0}), style.getDefaultLatLng());
+ ASSERT_EQ(0, style.getDefaultBearing());
+ ASSERT_EQ(0, style.getDefaultZoom());
+ ASSERT_EQ(0, style.getDefaultPitch());
+}