summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-01 20:25:55 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-01 20:25:55 -0800
commit52689796dfed796a1e949d39be411ccca3041933 (patch)
tree4cfc320ea66acf9d0fff21b1fa64b2a4a4cf0390 /test
parent8aa3359ff00332ef17157bf3c4452e710cc10b23 (diff)
downloadqtlocation-mapboxgl-52689796dfed796a1e949d39be411ccca3041933.tar.gz
[core] Normalize only raster source tile URLs
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/style_parser/tilejson.raster.json8
-rw-r--r--test/fixtures/style_parser/tilejson.vector.json8
-rw-r--r--test/miscellaneous/style_parser.cpp28
3 files changed, 44 insertions, 0 deletions
diff --git a/test/fixtures/style_parser/tilejson.raster.json b/test/fixtures/style_parser/tilejson.raster.json
new file mode 100644
index 0000000000..2eb0971a03
--- /dev/null
+++ b/test/fixtures/style_parser/tilejson.raster.json
@@ -0,0 +1,8 @@
+{
+ "minzoom": 0,
+ "maxzoom": 15,
+ "center": [ 1, 2, 3 ],
+ "bounds": [ 4, 5, 6, 7 ],
+ "attribution": "attribution",
+ "tiles": [ "http://a.tiles.mapbox.com/mapbox.satellite/{z}-{x}-{y}.png?access_token=key" ]
+}
diff --git a/test/fixtures/style_parser/tilejson.vector.json b/test/fixtures/style_parser/tilejson.vector.json
new file mode 100644
index 0000000000..ea7d4bc352
--- /dev/null
+++ b/test/fixtures/style_parser/tilejson.vector.json
@@ -0,0 +1,8 @@
+{
+ "minzoom": 0,
+ "maxzoom": 15,
+ "center": [ 1, 2, 3 ],
+ "bounds": [ 4, 5, 6, 7 ],
+ "attribution": "attribution",
+ "tiles": [ "http://a.tiles.mapbox.com/mapbox.streets/{z}-{x}-{y}.vector.pbf?access_token=key" ]
+}
diff --git a/test/miscellaneous/style_parser.cpp b/test/miscellaneous/style_parser.cpp
index 46d0dab5d8..22b5acb12b 100644
--- a/test/miscellaneous/style_parser.cpp
+++ b/test/miscellaneous/style_parser.cpp
@@ -85,3 +85,31 @@ INSTANTIATE_TEST_CASE_P(StyleParser, StyleParserTest, ::testing::ValuesIn([] {
EXPECT_GT(names.size(), 0ul);
return names;
}()));
+
+TEST(StyleParser, ParseTileJSONRaster) {
+ auto result = StyleParser::parseTileJSON(
+ util::read_file("test/fixtures/style_parser/tilejson.raster.json"),
+ "mapbox://mapbox.satellite",
+ SourceType::Raster);
+
+ EXPECT_EQ(0, result->minZoom);
+ EXPECT_EQ(15, result->maxZoom);
+ EXPECT_EQ("attribution", result->attribution);
+#if !defined(__ANDROID__) && !defined(__APPLE__)
+ EXPECT_EQ("http://a.tiles.mapbox.com/mapbox.satellite/{z}-{x}-{y}{ratio}.webp?access_token=key", result->tiles[0]);
+#else
+ EXPECT_EQ("http://a.tiles.mapbox.com/mapbox.satellite/{z}-{x}-{y}{ratio}.png?access_token=key", result->tiles[0]);
+#endif
+}
+
+TEST(StyleParser, ParseTileJSONVector) {
+ auto result = StyleParser::parseTileJSON(
+ util::read_file("test/fixtures/style_parser/tilejson.vector.json"),
+ "mapbox://mapbox.streets",
+ SourceType::Vector);
+
+ EXPECT_EQ(0, result->minZoom);
+ EXPECT_EQ(15, result->maxZoom);
+ 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]);
+}