summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-01 16:01:15 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commitf3d4107d19eef20cc2cf30cd347301128b4f9a86 (patch)
treedc66d61846b2a7fb036c87f127d1dd18045a9293 /test
parent7d6c6c00cac53a3864f0dfd399e64fd862d017e1 (diff)
downloadqtlocation-mapboxgl-f3d4107d19eef20cc2cf30cd347301128b4f9a86.tar.gz
[core] Add a method for statically evaluating font stacks used by a style
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/style_parser/font_stacks.json38
-rw-r--r--test/style/style_parser.cpp10
2 files changed, 48 insertions, 0 deletions
diff --git a/test/fixtures/style_parser/font_stacks.json b/test/fixtures/style_parser/font_stacks.json
new file mode 100644
index 0000000000..07fe223d46
--- /dev/null
+++ b/test/fixtures/style_parser/font_stacks.json
@@ -0,0 +1,38 @@
+{
+ "version": 8,
+ "sources": {
+ "source": {
+ "type": "vector",
+ "tiles": []
+ }
+ },
+ "layers": [{
+ "id": "a",
+ "type": "symbol",
+ "source": "source",
+ "source-layer": "source-layer",
+ "layout": {
+ "text-font": ["a"]
+ }
+ }, {
+ "id": "a,b",
+ "type": "symbol",
+ "source": "source",
+ "source-layer": "source-layer",
+ "layout": {
+ "text-font": {
+ "stops": [[0, ["a", "b"]]]
+ }
+ }
+ }, {
+ "id": "a,b;a,b,c",
+ "type": "symbol",
+ "source": "source",
+ "source-layer": "source-layer",
+ "layout": {
+ "text-font": {
+ "stops": [[0, ["a", "b"]], [1, ["a", "b", "c"]]]
+ }
+ }
+ }]
+}
diff --git a/test/style/style_parser.cpp b/test/style/style_parser.cpp
index 22b5acb12b..1554c76a27 100644
--- a/test/style/style_parser.cpp
+++ b/test/style/style_parser.cpp
@@ -113,3 +113,13 @@ TEST(StyleParser, ParseTileJSONVector) {
EXPECT_EQ("attribution", result->attribution);
EXPECT_EQ("http://a.tiles.mapbox.com/mapbox.streets/{z}-{x}-{y}.vector.pbf?access_token=key", result->tiles[0]);
}
+
+TEST(StyleParser, FontStacks) {
+ StyleParser parser;
+ parser.parse(util::read_file("test/fixtures/style_parser/font_stacks.json"));
+ auto result = parser.fontStacks();
+ ASSERT_EQ(3, result.size());
+ ASSERT_EQ("a", result[0]);
+ ASSERT_EQ("a,b", result[1]);
+ ASSERT_EQ("a,b,c", result[2]);
+}