summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-19 16:01:24 +0200
committerBrad Leege <bleege@gmail.com>2016-07-19 13:31:11 -0500
commit6e830725de430de6aa573955769916edcb878e33 (patch)
tree0238229ac692e33a0ab422efcf4c93fe78838b0b /test
parenta8cd7ecdfbf9410bf4919238eed40de1767a1225 (diff)
downloadqtlocation-mapboxgl-6e830725de430de6aa573955769916edcb878e33.tar.gz
[android] #5725 - Cherry picking 559f3a654b976d41d0f3db3fa958ebcda3e97b1c
Diffstat (limited to 'test')
-rw-r--r--test/util/mapbox.cpp72
1 files changed, 54 insertions, 18 deletions
diff --git a/test/util/mapbox.cpp b/test/util/mapbox.cpp
index e5da25991d..9341b695f3 100644
--- a/test/util/mapbox.cpp
+++ b/test/util/mapbox.cpp
@@ -7,34 +7,70 @@
using namespace mbgl;
-// TODO: correct all EXPECT_EQ(actual, expected) to EXPECT_EQ(expected, actual)
-
TEST(Mapbox, SourceURL) {
- EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "key"), "https://api.mapbox.com/v4/user.map.json?access_token=key&secure");
- EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "token"), "https://api.mapbox.com/v4/user.map.json?access_token=token&secure");
- EXPECT_THROW(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", ""), std::runtime_error);
+ EXPECT_EQ(
+ "https://api.mapbox.com/v4/user.map.json?access_token=key&secure",
+ mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "key"));
+ EXPECT_EQ(
+ "http://path",
+ mbgl::util::mapbox::normalizeSourceURL("http://path", "key"));
+ EXPECT_THROW(
+ mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", ""),
+ std::runtime_error);
}
TEST(Mapbox, GlyphsURL) {
- EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fonts/boxmap/Comic%20Sans/0-255.pbf", "key"), "https://api.mapbox.com/fonts/v1/boxmap/Comic%20Sans/0-255.pbf?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fonts/boxmap/{fontstack}/{range}.pbf", "key"), "https://api.mapbox.com/fonts/v1/boxmap/{fontstack}/{range}.pbf?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("http://path", "key"), "http://path");
- EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("mapbox://path", "key"), "mapbox://path");
+ EXPECT_EQ(
+ "https://api.mapbox.com/fonts/v1/boxmap/Comic%20Sans/0-255.pbf?access_token=key",
+ mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fonts/boxmap/Comic%20Sans/0-255.pbf", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/fonts/v1/boxmap/{fontstack}/{range}.pbf?access_token=key",
+ mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fonts/boxmap/{fontstack}/{range}.pbf", "key"));
+ EXPECT_EQ(
+ "http://path",
+ mbgl::util::mapbox::normalizeGlyphsURL("http://path", "key"));
+ EXPECT_EQ(
+ "mapbox://path",
+ mbgl::util::mapbox::normalizeGlyphsURL("mapbox://path", "key"));
}
TEST(Mapbox, StyleURL) {
- EXPECT_EQ(mbgl::util::mapbox::normalizeStyleURL("mapbox://foo", "key"), "mapbox://foo");
- EXPECT_EQ(mbgl::util::mapbox::normalizeStyleURL("mapbox://styles/user/style", "key"), "https://api.mapbox.com/styles/v1/user/style?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeStyleURL("mapbox://styles/user/style/draft", "key"), "https://api.mapbox.com/styles/v1/user/style/draft?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeStyleURL("http://path", "key"), "http://path");
+ EXPECT_EQ(
+ "mapbox://foo",
+ mbgl::util::mapbox::normalizeStyleURL("mapbox://foo", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/styles/v1/user/style?access_token=key",
+ mbgl::util::mapbox::normalizeStyleURL("mapbox://styles/user/style", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/styles/v1/user/style/draft?access_token=key",
+ mbgl::util::mapbox::normalizeStyleURL("mapbox://styles/user/style/draft", "key"));
+ EXPECT_EQ(
+ "http://path",
+ mbgl::util::mapbox::normalizeStyleURL("http://path", "key"));
}
TEST(Mapbox, SpriteURL) {
- EXPECT_EQ(mbgl::util::mapbox::normalizeSpriteURL("map/box/sprites@2x.json", "key"), "map/box/sprites@2x.json");
- EXPECT_EQ(mbgl::util::mapbox::normalizeSpriteURL("mapbox://foo", "key"), "mapbox://foo");
- EXPECT_EQ(mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8.json", "key"), "https://api.mapbox.com/styles/v1/mapbox/streets-v8/sprite.json?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8@2x.png", "key"), "https://api.mapbox.com/styles/v1/mapbox/streets-v8/sprite@2x.png?access_token=key");
- EXPECT_EQ(mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8/draft@2x.png", "key"), "https://api.mapbox.com/styles/v1/mapbox/streets-v8/draft/sprite@2x.png?access_token=key");
+ EXPECT_EQ(
+ "map/box/sprites@2x.json",
+ mbgl::util::mapbox::normalizeSpriteURL("map/box/sprites@2x.json", "key"));
+ EXPECT_EQ(
+ "mapbox://foo",
+ mbgl::util::mapbox::normalizeSpriteURL("mapbox://foo", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/styles/v1/mapbox/streets-v8/sprite.json?access_token=key",
+ mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8.json", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/styles/v1/mapbox/streets-v8/sprite@2x.png?access_token=key",
+ mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8@2x.png", "key"));
+ EXPECT_EQ(
+ "https://api.mapbox.com/styles/v1/mapbox/streets-v8/draft/sprite@2x.png?access_token=key",
+ mbgl::util::mapbox::normalizeSpriteURL("mapbox://sprites/mapbox/streets-v8/draft@2x.png", "key"));
+ EXPECT_EQ(
+ "mapbox://sprites/mapbox/streets-v9?fresh=true.png",
+ mbgl::util::mapbox::normalizeSpriteURL(
+ "mapbox://sprites/mapbox/streets-v9?fresh=true.png",
+ "key"));
+ EXPECT_EQ("mapbox://////", mbgl::util::mapbox::normalizeSpriteURL("mapbox://////", "key"));
}
TEST(Mapbox, TileURL) {