summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-08-15 18:34:45 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-08-16 11:04:30 +0200
commit18176605f65ce90c973e0b61a1a2b563471b0ba5 (patch)
tree4570f3dd8d213c96e4591c5d989d427120f16fb6 /test
parentc34130ac6d968a3ff636af71e19893d22c2faa99 (diff)
downloadqtlocation-mapboxgl-18176605f65ce90c973e0b61a1a2b563471b0ba5.tar.gz
[core] support "scheme": "tms" in TileJSON files
Diffstat (limited to 'test')
-rw-r--r--test/map/map.cpp2
-rw-r--r--test/storage/offline_database.cpp10
-rw-r--r--test/storage/offline_download.cpp4
-rw-r--r--test/storage/resource.cpp27
4 files changed, 26 insertions, 17 deletions
diff --git a/test/map/map.cpp b/test/map/map.cpp
index b304712e1f..d60c7e945c 100644
--- a/test/map/map.cpp
+++ b/test/map/map.cpp
@@ -38,7 +38,7 @@ TEST(Map, Offline) {
fileSource.put(Resource::source(prefix + "streets.json"), expiredItem("streets.json"));
fileSource.put(Resource::spriteJSON(prefix + "sprite", 1.0), expiredItem("sprite.json"));
fileSource.put(Resource::spriteImage(prefix + "sprite", 1.0), expiredItem("sprite.png"));
- fileSource.put(Resource::tile(prefix + "{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0), expiredItem("0-0-0.vector.pbf"));
+ fileSource.put(Resource::tile(prefix + "{z}-{x}-{y}.vector.pbf", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), expiredItem("0-0-0.vector.pbf"));
fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf"));
NetworkStatus::Set(NetworkStatus::Status::Offline);
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index 6a3262abf6..81da46bc78 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -323,7 +323,7 @@ TEST(OfflineDatabase, DeleteRegion) {
response.noContent = true;
db.putRegionResource(region.getID(), Resource::style("http://example.com/"), response);
- db.putRegionResource(region.getID(), Resource::tile("http://example.com/", 1.0, 0, 0, 0), response);
+ db.putRegionResource(region.getID(), Resource::tile("http://example.com/", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
db.deleteRegion(std::move(region));
@@ -474,7 +474,7 @@ TEST(OfflineDatabase, GetRegionCompletedStatus) {
EXPECT_EQ(0u, status2.completedTileCount);
EXPECT_EQ(0u, status2.completedTileSize);
- uint64_t tileSize = db.putRegionResource(region.getID(), Resource::tile("http://example.com/", 1.0, 0, 0, 0), response);
+ uint64_t tileSize = db.putRegionResource(region.getID(), Resource::tile("http://example.com/", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
OfflineRegionStatus status3 = db.getRegionCompletedStatus(region.getID());
EXPECT_EQ(2u, status3.completedResourceCount);
@@ -493,9 +493,9 @@ TEST(OfflineDatabase, OfflineMapboxTileCount) {
OfflineRegion region1 = db.createRegion(definition, metadata);
OfflineRegion region2 = db.createRegion(definition, metadata);
- Resource nonMapboxTile = Resource::tile("http://example.com/", 1.0, 0, 0, 0);
- Resource mapboxTile1 = Resource::tile("mapbox://tiles/1", 1.0, 0, 0, 0);
- Resource mapboxTile2 = Resource::tile("mapbox://tiles/2", 1.0, 0, 0, 1);
+ Resource nonMapboxTile = Resource::tile("http://example.com/", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
+ Resource mapboxTile1 = Resource::tile("mapbox://tiles/1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
+ Resource mapboxTile2 = Resource::tile("mapbox://tiles/2", 1.0, 0, 0, 1, Tileset::Scheme::XYZ);
Response response;
response.data = std::make_shared<std::string>("data");
diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp
index eb676e3b8d..76a772dd1b 100644
--- a/test/storage/offline_download.cpp
+++ b/test/storage/offline_download.cpp
@@ -476,7 +476,7 @@ TEST(OfflineDownload, WithPreviouslyExistingTile) {
};
test.db.put(
- Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
+ Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0, Tileset::Scheme::XYZ),
test.response("0-0-0.vector.pbf"));
auto observer = std::make_unique<MockObserver>();
@@ -510,7 +510,7 @@ TEST(OfflineDownload, ReactivatePreviouslyCompletedDownload) {
};
test.db.put(
- Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
+ Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0, Tileset::Scheme::XYZ),
test.response("0-0-0.vector.pbf"));
auto observer = std::make_unique<MockObserver>();
diff --git a/test/storage/resource.cpp b/test/storage/resource.cpp
index 02559f3e84..1c15fe6503 100644
--- a/test/storage/resource.cpp
+++ b/test/storage/resource.cpp
@@ -19,7 +19,7 @@ TEST(Resource, Source) {
TEST(Resource, Tile) {
using namespace mbgl;
- Resource rasterTile = Resource::tile("http://example.com/{z}/{x}/{y}{ratio}.png", 2.0, 1, 2, 3);
+ Resource rasterTile = Resource::tile("http://example.com/{z}/{x}/{y}{ratio}.png", 2.0, 1, 2, 3, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, rasterTile.kind);
EXPECT_EQ("http://example.com/3/1/2@2x.png", rasterTile.url);
EXPECT_EQ("http://example.com/{z}/{x}/{y}{ratio}.png", rasterTile.tileData->urlTemplate);
@@ -28,7 +28,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(2, rasterTile.tileData->y);
EXPECT_EQ(3, rasterTile.tileData->z);
- Resource vectorTile = Resource::tile("http://example.com/{z}/{x}/{y}.mvt", 2.0, 1, 2, 3);
+ Resource vectorTile = Resource::tile("http://example.com/{z}/{x}/{y}.mvt", 2.0, 1, 2, 3, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, vectorTile.kind);
EXPECT_EQ("http://example.com/3/1/2.mvt", vectorTile.url);
EXPECT_EQ("http://example.com/{z}/{x}/{y}.mvt", vectorTile.tileData->urlTemplate);
@@ -37,7 +37,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(2, vectorTile.tileData->y);
EXPECT_EQ(3, vectorTile.tileData->z);
- Resource quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 0, 0, 1);
+ Resource quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 0, 0, 1, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, quadTile.kind);
EXPECT_EQ("http://example.com/0.png", quadTile.url);
EXPECT_EQ("http://example.com/{quadkey}.png", quadTile.tileData->urlTemplate);
@@ -46,7 +46,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(0, quadTile.tileData->y);
EXPECT_EQ(1, quadTile.tileData->z);
- quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 0, 0, 2);
+ quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 0, 0, 2, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, quadTile.kind);
EXPECT_EQ("http://example.com/00.png", quadTile.url);
EXPECT_EQ("http://example.com/{quadkey}.png", quadTile.tileData->urlTemplate);
@@ -55,7 +55,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(0, quadTile.tileData->y);
EXPECT_EQ(2, quadTile.tileData->z);
- quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 1, 1, 2);
+ quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 1, 1, 2, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, quadTile.kind);
EXPECT_EQ("http://example.com/03.png", quadTile.url);
EXPECT_EQ("http://example.com/{quadkey}.png", quadTile.tileData->urlTemplate);
@@ -64,7 +64,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(1, quadTile.tileData->y);
EXPECT_EQ(2, quadTile.tileData->z);
- quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 22914, 52870, 17);
+ quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 22914, 52870, 17, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, quadTile.kind);
EXPECT_EQ("http://example.com/02301322130000230.png", quadTile.url);
EXPECT_EQ("http://example.com/{quadkey}.png", quadTile.tileData->urlTemplate);
@@ -72,10 +72,10 @@ TEST(Resource, Tile) {
EXPECT_EQ(22914, quadTile.tileData->x);
EXPECT_EQ(52870, quadTile.tileData->y);
EXPECT_EQ(17, quadTile.tileData->z);
-
+
// Test case confirmed by quadkeytools package
// https://bitbucket.org/steele/quadkeytools/src/master/test/quadkey.js?fileviewer=file-view-default#quadkey.js-57
- quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 29, 3, 6);
+ quadTile = Resource::tile("http://example.com/{quadkey}.png", 2.0, 29, 3, 6, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, quadTile.kind);
EXPECT_EQ("http://example.com/011123.png", quadTile.url);
EXPECT_EQ("http://example.com/{quadkey}.png", quadTile.tileData->urlTemplate);
@@ -84,7 +84,7 @@ TEST(Resource, Tile) {
EXPECT_EQ(3, quadTile.tileData->y);
EXPECT_EQ(6, quadTile.tileData->z);
- Resource wmsTile = Resource::tile("http://example.com/?bbox={bbox-epsg-3857}", 2.0, 0, 0, 1);
+ Resource wmsTile = Resource::tile("http://example.com/?bbox={bbox-epsg-3857}", 2.0, 0, 0, 1, Tileset::Scheme::XYZ);
EXPECT_EQ(Resource::Kind::Tile, wmsTile.kind);
EXPECT_EQ("http://example.com/?bbox=-20037508.342789245,0,0,20037508.342789245", wmsTile.url);
EXPECT_EQ("http://example.com/?bbox={bbox-epsg-3857}", wmsTile.tileData->urlTemplate);
@@ -92,6 +92,15 @@ TEST(Resource, Tile) {
EXPECT_EQ(0, wmsTile.tileData->x);
EXPECT_EQ(0, wmsTile.tileData->y);
EXPECT_EQ(1, wmsTile.tileData->z);
+
+ Resource tmsTile = Resource::tile("http://example.com/{z}/{x}/{y}{ratio}.png", 1.0, 1, 2, 3, Tileset::Scheme::TMS);
+ EXPECT_EQ(Resource::Kind::Tile, tmsTile.kind);
+ EXPECT_EQ("http://example.com/3/1/5.png", tmsTile.url);
+ EXPECT_EQ("http://example.com/{z}/{x}/{y}{ratio}.png", tmsTile.tileData->urlTemplate);
+ EXPECT_EQ(1, tmsTile.tileData->pixelRatio);
+ EXPECT_EQ(1, tmsTile.tileData->x);
+ EXPECT_EQ(5, tmsTile.tileData->y);
+ EXPECT_EQ(3, tmsTile.tileData->z);
}
TEST(Resource, Glyphs) {