summaryrefslogtreecommitdiff
path: root/test/util
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-05 16:31:03 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-08 13:48:57 -0700
commitbaaae99a03202641ae5b8024e57b691fe61a6688 (patch)
tree459045e56197696aa1312594f1e452b03931775d /test/util
parente34d8b5c802186008e49364668e4a7bd5668d0fd (diff)
downloadqtlocation-mapboxgl-baaae99a03202641ae5b8024e57b691fe61a6688.tar.gz
[core, android] Factor JSON string conversions
This adds a `convertJSON` template, to be used like: Error error optional<Foo> foo = convertJSON<Foo>(string, error); Internally, it parses the string with RapidJSON and then calls `convert<Foo>(parsed, error)`. While here, rationalize GeoJSON converters and fix error handling for Tileset conversion in OfflineDownload.
Diffstat (limited to 'test/util')
-rw-r--r--test/util/mapbox.test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/util/mapbox.test.cpp b/test/util/mapbox.test.cpp
index 299f0df833..ba867ccb5c 100644
--- a/test/util/mapbox.test.cpp
+++ b/test/util/mapbox.test.cpp
@@ -3,6 +3,7 @@
#include <mbgl/util/logging.hpp>
#include <mbgl/util/mapbox.hpp>
#include <mbgl/util/constants.hpp>
+#include <mbgl/util/tileset.hpp>
#include <stdexcept>
using namespace mbgl;
@@ -210,3 +211,29 @@ TEST(Mapbox, CanonicalURL) {
"http://api.mapbox.com/v4/a.b/{z}/{x}/{y}/.",
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}/.", SourceType::Raster, 256));
}
+
+TEST(Mapbox, CanonicalizeRasterTileset) {
+ mbgl::Tileset tileset;
+ tileset.tiles = {
+ "http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=key"
+ };
+
+ mbgl::util::mapbox::canonicalizeTileset(tileset, "mapbox://mapbox.satellite", SourceType::Raster, 256);
+
+#if !defined(__ANDROID__) && !defined(__APPLE__)
+ EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.webp", tileset.tiles[0]);
+#else
+ EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", tileset.tiles[0]);
+#endif
+}
+
+TEST(Mapbox, CanonicalizeVectorTileset) {
+ mbgl::Tileset tileset;
+ tileset.tiles = {
+ "http://a.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.vector.pbf?access_token=key"
+ };
+
+ mbgl::util::mapbox::canonicalizeTileset(tileset, "mapbox://mapbox.streets", SourceType::Vector, 512);
+
+ EXPECT_EQ("mapbox://tiles/mapbox.streets/{z}/{x}/{y}.vector.pbf", tileset.tiles[0]);
+}