summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjingsam <jingsam@users.noreply.github.com>2016-07-04 15:26:28 +0800
committerMinh Nguyễn <mxn@1ec5.org>2016-07-04 00:26:28 -0700
commite82ecc60acfeb95ec4804ecb0964a2d695416ea1 (patch)
tree5d1f287d486d028c147cd53c188bc5f355895187 /test
parent8446a9bef201cadee8a39f0e1c008768529141c5 (diff)
downloadqtlocation-mapboxgl-e82ecc60acfeb95ec4804ecb0964a2d695416ea1.tar.gz
mapbox: URL containing query string causes infinite loop (#5554)
* correct all EXPECT_EQ(actual, expected) to EXPECT_EQ(expected, actual) * fix getMapboxURLPathname() of URL with querystring * add test for normalizeSourceURL of non-mapbox protocal * Update mapbox.cpp
Diffstat (limited to 'test')
-rw-r--r--test/util/mapbox.cpp65
1 files changed, 48 insertions, 17 deletions
diff --git a/test/util/mapbox.cpp b/test/util/mapbox.cpp
index e5da25991d..7f9e7ef592 100644
--- a/test/util/mapbox.cpp
+++ b/test/util/mapbox.cpp
@@ -7,34 +7,65 @@
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"));
}
TEST(Mapbox, TileURL) {