Replacing hardcoded configuration with configurable API and removing Mapbox assets (#90)
* Refactoring online file source so that tile server configuration is not hardcoded - part 1 * Added default templates * Update from master * Renaming MGLAccountManager to MGLSettings. Passing ResourceOptions and TileServerOptions to relevant classes and method in order to remove mapbox hardocded configuration * Fixing build * Addedm missing theme * Unit tests fixes * Fixing unit tests, adding factory methods for creating predefined configuration. * Fixing mapbox unit tests * Additional unit test fixes * Making MapboxConfiguration default * Making get/set resource options available in all classes that inherits from FileSource * Making get/set resource options available in all classes that inherits from FileSource - part 2 * Fixes for Android * Disable test coverage reports * Disable test coverage reports * Disable test coverage reports * Disable test coverage reports * Removing hardcoded configuration in iOS project - part 1 * Fixing wrong file extension, making use of tile server options. * Use apiKey and MGL_API_KEY everywhere * Just a rename * Re-enabling tests and improving MGLSettings init * Removing mapbox hardcoded configuration, using api key everywhere, implementing JNI conversion for TileServerOptions * Lint issues. * Integrating configurable tile server properties into Android SDK - part 2 * Removing mabox accounts * Exposing multiple configurations to Android SDK - bug fixes * Removing TileServerOptions from public interface - native methods dont work before mapbox-gl library is loaded * Adding support for configurable predefined styles * Migrating predefined styles in test app + cleanup * Parameter fix * Bug fixes * Fixing render test build * Fixing offline tester * Fixing benchmark tool * Fix: typo in method name * Adding code for public access to TileServerOptions * Bug fixes and debug code removal * Fixes for macOS, adding unit tests from MapLibre, removing redundant members from OnlineFileSource * Unit test fixes * MacOS test app - migrating to configurable tile server options, part 1 * Fixing offline maps * Migrating macOS test app to MapTiler * Minor improvements * Putting back apiKey test * Added unit tests for MapTiler configuration * Migrating test resources to MapTiler * minor fix * A few fixes * Fixing macOS tests, removing feedback functionality * Migrating ios test app to MapTiler * Migrating ui tests * UI tests fix * Benchmarking app fix * Cleanup and strings updates * Migrating benchmark app to maptiler * API key injection in benchmark app * Putting back release configuration * Additional tests and fixing issues identified by thread sanitizer. * Removing test filters * Fixes and addressing lint issues * More Maptiler tests + minro fix * Android instrumentation test migration to MapTiler. Exposing missing TileServerOptions in Android SDK. Minor fixes. * No requirements on API key format. * Fixing offline cache test tool * Adding configurable domain name for sources, adding source domain int MapTiler configuration, cleanup * Migrating tests to MapTiler, adding code for canonicalizing URLs, removing mapbox stuff from comments, cleanup * More tests * Updated database size * Lint issues * Fixed test * Updating developer config API key * Fixes for Android, propagaing updated tileServerOptions to native file sources, more tests * Just a few more fixes * Propagating updated settings to file sources + additional unit test * Lint issues * Removing test filter and fixing incorrect uri * Release preparation * macos release notes
This commit is contained in:
@@ -106,6 +106,7 @@ add_library(
|
||||
${PROJECT_SOURCE_DIR}/test/util/timer.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/token.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/url.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/tile_server_options.test.cpp
|
||||
)
|
||||
|
||||
# MapSnapshotter uses headless backend that is rendering image on a background thread. QT / macOS adaptation for headless backend creates
|
||||
|
||||
@@ -24,7 +24,7 @@ TEST(API, RecycleMapUpdateImages) {
|
||||
|
||||
HeadlessFrontend frontend { 1 };
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
|
||||
std::make_shared<StubFileSource>(),
|
||||
std::make_shared<StubFileSource>(ResourceOptions::Default()),
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
|
||||
EXPECT_TRUE(map);
|
||||
|
||||
BIN
test/fixtures/offline_database/offline_sideload.db
vendored
BIN
test/fixtures/offline_database/offline_sideload.db
vendored
Binary file not shown.
BIN
test/fixtures/offline_database/satellite_test.db
vendored
BIN
test/fixtures/offline_database/satellite_test.db
vendored
Binary file not shown.
BIN
test/fixtures/offline_database/sideload_ambient.db
vendored
BIN
test/fixtures/offline_database/sideload_ambient.db
vendored
Binary file not shown.
BIN
test/fixtures/offline_database/sideload_sat.db
vendored
BIN
test/fixtures/offline_database/sideload_sat.db
vendored
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
"type": "vector",
|
||||
"maxzoom": 15,
|
||||
"minzoom": 0,
|
||||
"tiles": [ "mapbox://{z}-{x}-{y}.vector.pbf" ]
|
||||
"tiles": [ "maptiler://{z}-{x}-{y}.vector.pbf" ]
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
|
||||
6
test/fixtures/offline_download/style.json
vendored
6
test/fixtures/offline_download/style.json
vendored
@@ -2,7 +2,7 @@
|
||||
"version": 8,
|
||||
"name": "Water",
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"maptiler": {
|
||||
"type": "vector",
|
||||
"url": "http://127.0.0.1:3000/streets.json"
|
||||
},
|
||||
@@ -28,7 +28,7 @@
|
||||
}, {
|
||||
"id": "water",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source": "maptiler",
|
||||
"source-layer": "water",
|
||||
"paint": {
|
||||
"fill-pattern": "noise"
|
||||
@@ -36,7 +36,7 @@
|
||||
}, {
|
||||
"id": "admin",
|
||||
"type": "symbol",
|
||||
"source": "mapbox",
|
||||
"source": "maptiler",
|
||||
"source-layer": "admin",
|
||||
"layout": {
|
||||
"text-font": ["Helvetica"],
|
||||
|
||||
39
test/fixtures/resources/source_raster.json
vendored
39
test/fixtures/resources/source_raster.json
vendored
@@ -1 +1,38 @@
|
||||
{"attribution":"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">© DigitalGlobe</a>","autoscale":true,"bounds":[-180,-85,180,85],"cacheControl":"max-age=43200,s-maxage=604800","center":[0,0,3],"created":1358310600000,"description":"","id":"mapbox.satellite","maxzoom":22,"minzoom":0,"modified":1446150592060,"name":"Mapbox Satellite","private":false,"scheme":"xyz","tilejson":"2.0.0","tiles":["https://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.accesstoken","https://b.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.accesstoken"],"webpage":"https://a.tiles.mapbox.com/v4/mapbox.satellite/page.html?access_token=pk.accesstoken"}
|
||||
{
|
||||
"tilejson": "2.0.0",
|
||||
"name": "Satellite",
|
||||
"type": "baselayer",
|
||||
"color": "#0C1C2B",
|
||||
"scale": "1.0000",
|
||||
"bounds": [
|
||||
-180,
|
||||
-85.051129,
|
||||
180,
|
||||
85.05112900000002
|
||||
],
|
||||
"format": "jpg",
|
||||
"maxzoom": 20,
|
||||
"minzoom": 0,
|
||||
"profile": "mercator",
|
||||
"version": "2.0",
|
||||
"generator": "MapTiler Desktop Pro 10.0",
|
||||
"attribution": "<a href=\"https://www.maptiler.com/copyright/\" target=\"_blank\">© MapTiler</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">© OpenStreetMap contributors</a>",
|
||||
"format_arguments": "-f jpeg ",
|
||||
"crs": "EPSG:3857",
|
||||
"crs_wkt": "PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs\"],AUTHORITY[\"EPSG\",\"3857\"]]",
|
||||
"extent": [
|
||||
-20037508.342789244,
|
||||
-20037508.6269291,
|
||||
20037508.342789244,
|
||||
20037508.626929108
|
||||
],
|
||||
"tile_grid": "mercator",
|
||||
"center": [
|
||||
0,
|
||||
2.5444437451708134e-14,
|
||||
1
|
||||
],
|
||||
"tiles": [
|
||||
"maptiler://tiles/satellite/{z}/{x}/{y}.jpg"
|
||||
]
|
||||
}
|
||||
861
test/fixtures/resources/source_vector.json
vendored
861
test/fixtures/resources/source_vector.json
vendored
File diff suppressed because one or more lines are too long
2929
test/fixtures/resources/sprite.json
vendored
2929
test/fixtures/resources/sprite.json
vendored
File diff suppressed because one or more lines are too long
BIN
test/fixtures/resources/sprite.png
vendored
BIN
test/fixtures/resources/sprite.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 243 KiB |
767
test/fixtures/resources/style_raster.json
vendored
767
test/fixtures/resources/style_raster.json
vendored
@@ -1 +1,766 @@
|
||||
{"version":8,"name":"Satellite","metadata":{"mapbox:autocomposite":true,"mapbox:type":"default"},"sources":{"mapbox":{"type":"raster","url":"mapbox://mapbox.satellite","tileSize":256}},"sprite":"mapbox://sprites/mapbox/satellite-v9","glyphs":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"rgb(4,7,14)"}},{"id":"satellite","type":"raster","source":"mapbox","source-layer":"mapbox_satellite_full"}],"created":0,"modified":0,"owner":"mapbox","id":"satellite-v9","draft":false}
|
||||
{
|
||||
"id": "hybrid",
|
||||
"name": "Satellite Hybrid",
|
||||
"zoom": 1,
|
||||
"pitch": 0,
|
||||
"center": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"glyphs": "maptiler://fonts/{fontstack}/{range}.pbf",
|
||||
"layers": [
|
||||
{
|
||||
"id": "satellite",
|
||||
"type": "raster",
|
||||
"paint": {
|
||||
"raster-opacity": 1
|
||||
},
|
||||
"filter": [
|
||||
"all"
|
||||
],
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"source": "satellite",
|
||||
"minzoom": 0
|
||||
},
|
||||
{
|
||||
"id": "tunnel",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(255, 255, 255, 0.2)",
|
||||
"line-width": [
|
||||
"interpolate",
|
||||
[
|
||||
"exponential",
|
||||
1.5
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
6,
|
||||
0.5,
|
||||
20,
|
||||
30
|
||||
],
|
||||
"line-dasharray": [
|
||||
0.28,
|
||||
0.14
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
[
|
||||
"==",
|
||||
"brunnel",
|
||||
"tunnel"
|
||||
],
|
||||
[
|
||||
"in",
|
||||
"class",
|
||||
"motorway",
|
||||
"primary",
|
||||
"secondary",
|
||||
"tertiary",
|
||||
"trunk"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"line-cap": "butt",
|
||||
"line-join": "miter"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "transportation"
|
||||
},
|
||||
{
|
||||
"id": "path",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(247, 247, 247, 0.33)",
|
||||
"line-width": [
|
||||
"interpolate",
|
||||
[
|
||||
"exponential",
|
||||
1.5
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
14,
|
||||
0.5,
|
||||
20,
|
||||
4
|
||||
],
|
||||
"line-dasharray": [
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
[
|
||||
"in",
|
||||
"class",
|
||||
"path",
|
||||
"track"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"line-cap": "square",
|
||||
"line-join": "bevel"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "transportation"
|
||||
},
|
||||
{
|
||||
"id": "road",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": [
|
||||
"interpolate",
|
||||
[
|
||||
"linear"
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
8,
|
||||
"rgba(255, 255, 255, 0.2)",
|
||||
14,
|
||||
"rgba(255, 255, 255, 0.3)"
|
||||
],
|
||||
"line-width": [
|
||||
"interpolate",
|
||||
[
|
||||
"linear"
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
5,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"motorway",
|
||||
"motorway_link"
|
||||
],
|
||||
1,
|
||||
0
|
||||
],
|
||||
7,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"motorway",
|
||||
"motorway_link"
|
||||
],
|
||||
1.4,
|
||||
0
|
||||
],
|
||||
8,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"motorway",
|
||||
"motorway_link",
|
||||
"primary",
|
||||
"trunk"
|
||||
],
|
||||
0.75,
|
||||
0
|
||||
],
|
||||
9,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"secondary",
|
||||
"tertiary"
|
||||
],
|
||||
0.7,
|
||||
1
|
||||
],
|
||||
10,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"motorway",
|
||||
"motorway_link"
|
||||
],
|
||||
1.3,
|
||||
1.3
|
||||
],
|
||||
14,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"minor",
|
||||
"service"
|
||||
],
|
||||
0.5,
|
||||
2.4
|
||||
]
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
[
|
||||
"!in",
|
||||
"class",
|
||||
"rail",
|
||||
"ferry",
|
||||
"path",
|
||||
"track"
|
||||
],
|
||||
[
|
||||
"!=",
|
||||
"brunnel",
|
||||
"tunnel"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"line-cap": "butt",
|
||||
"line-join": "round"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"minzoom": 6,
|
||||
"source-layer": "transportation"
|
||||
},
|
||||
{
|
||||
"id": "railway",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(179, 170, 158, 0.2)",
|
||||
"line-opacity": [
|
||||
"interpolate",
|
||||
[
|
||||
"linear"
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
11,
|
||||
0.5,
|
||||
16,
|
||||
1.3
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"==",
|
||||
"class",
|
||||
"rail"
|
||||
],
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"minzoom": 11,
|
||||
"source-layer": "transportation"
|
||||
},
|
||||
{
|
||||
"id": "admin_sub",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(194, 194, 194, 0.5)",
|
||||
"line-dasharray": [
|
||||
2,
|
||||
1
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"in",
|
||||
"admin_level",
|
||||
4,
|
||||
6,
|
||||
8
|
||||
],
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"minzoom": 3,
|
||||
"source-layer": "boundary"
|
||||
},
|
||||
{
|
||||
"id": "admin_country-dark",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(0, 0, 0, 0.51)",
|
||||
"line-width": [
|
||||
"interpolate",
|
||||
[
|
||||
"exponential",
|
||||
1.5
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
3,
|
||||
0.5,
|
||||
21,
|
||||
32
|
||||
],
|
||||
"line-offset": 1
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"<=",
|
||||
"admin_level",
|
||||
2
|
||||
],
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"line-cap": "butt",
|
||||
"line-join": "round",
|
||||
"visibility": "visible"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "boundary"
|
||||
},
|
||||
{
|
||||
"id": "admin_country",
|
||||
"type": "line",
|
||||
"paint": {
|
||||
"line-color": "rgba(226, 226, 226, 1)",
|
||||
"line-width": [
|
||||
"interpolate",
|
||||
[
|
||||
"exponential",
|
||||
1.5
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
3,
|
||||
0.5,
|
||||
21,
|
||||
32
|
||||
]
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"<=",
|
||||
"admin_level",
|
||||
2
|
||||
],
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"line-cap": "round",
|
||||
"line-join": "round",
|
||||
"visibility": "visible"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "boundary"
|
||||
},
|
||||
{
|
||||
"id": "road_label",
|
||||
"type": "symbol",
|
||||
"paint": {
|
||||
"text-color": "rgba(255, 255, 255, 1)",
|
||||
"text-halo-color": "rgba(43, 43, 43, 1)",
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"filter": [
|
||||
"==",
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
"layout": {
|
||||
"text-font": [
|
||||
"Noto Sans Regular"
|
||||
],
|
||||
"text-size": [
|
||||
"interpolate",
|
||||
[
|
||||
"cubic-bezier",
|
||||
0.75,
|
||||
1,
|
||||
0.75,
|
||||
1
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
10,
|
||||
8,
|
||||
15,
|
||||
9
|
||||
],
|
||||
"text-field": "{name:latin} {name:nonlatin}",
|
||||
"text-transform": "none",
|
||||
"symbol-placement": "line",
|
||||
"text-letter-spacing": 0.1,
|
||||
"text-rotation-alignment": "map"
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "transportation_name"
|
||||
},
|
||||
{
|
||||
"id": "place_label",
|
||||
"type": "symbol",
|
||||
"paint": {
|
||||
"text-color": "rgba(255, 255, 255, 1)",
|
||||
"text-halo-blur": 0.5,
|
||||
"text-halo-color": [
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"city"
|
||||
],
|
||||
"rgba(0, 0, 0, 0.75)",
|
||||
"rgba(43, 43, 43, 1)"
|
||||
],
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"Point"
|
||||
],
|
||||
[
|
||||
"!in",
|
||||
"class",
|
||||
"country",
|
||||
"state"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"text-font": [
|
||||
"Noto Sans Regular"
|
||||
],
|
||||
"text-size": [
|
||||
"interpolate",
|
||||
[
|
||||
"cubic-bezier",
|
||||
0.5,
|
||||
1,
|
||||
0.5,
|
||||
1
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
3,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"city",
|
||||
11,
|
||||
10
|
||||
],
|
||||
6,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"city",
|
||||
14.5,
|
||||
11
|
||||
],
|
||||
8,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"city",
|
||||
16,
|
||||
12
|
||||
],
|
||||
10,
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"city",
|
||||
20,
|
||||
13
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}\n{name:nonlatin}",
|
||||
"text-max-width": 10
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"maxzoom": 16,
|
||||
"minzoom": 3,
|
||||
"source-layer": "place"
|
||||
},
|
||||
{
|
||||
"id": "state_label",
|
||||
"type": "symbol",
|
||||
"paint": {
|
||||
"text-color": "rgba(255, 255, 255, 1)",
|
||||
"text-halo-blur": 1,
|
||||
"text-halo-color": "rgba(0, 0, 0, 1)",
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"Point"
|
||||
],
|
||||
[
|
||||
"in",
|
||||
"class",
|
||||
"state"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"text-font": [
|
||||
"Noto Sans Italic"
|
||||
],
|
||||
"text-size": [
|
||||
"interpolate",
|
||||
[
|
||||
"cubic-bezier",
|
||||
0.75,
|
||||
1,
|
||||
0.75,
|
||||
1
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
1,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
13,
|
||||
1,
|
||||
12,
|
||||
2,
|
||||
12
|
||||
],
|
||||
4,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
15,
|
||||
1,
|
||||
14,
|
||||
2,
|
||||
14
|
||||
],
|
||||
6,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
23,
|
||||
1,
|
||||
18,
|
||||
2,
|
||||
18
|
||||
],
|
||||
9,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
27,
|
||||
1,
|
||||
22,
|
||||
2,
|
||||
22
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}",
|
||||
"text-max-width": 10
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"maxzoom": 12,
|
||||
"minzoom": 3,
|
||||
"source-layer": "place"
|
||||
},
|
||||
{
|
||||
"id": "country_label",
|
||||
"type": "symbol",
|
||||
"paint": {
|
||||
"text-color": "rgba(255, 255, 255, 1)",
|
||||
"text-halo-blur": 1,
|
||||
"text-halo-color": "rgba(0, 0, 0, 1)",
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"$type",
|
||||
"Point"
|
||||
],
|
||||
[
|
||||
"in",
|
||||
"class",
|
||||
"country"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"text-font": [
|
||||
"Noto Sans Bold"
|
||||
],
|
||||
"text-size": [
|
||||
"interpolate",
|
||||
[
|
||||
"cubic-bezier",
|
||||
0.75,
|
||||
1,
|
||||
0.75,
|
||||
1
|
||||
],
|
||||
[
|
||||
"zoom"
|
||||
],
|
||||
1,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
13,
|
||||
1,
|
||||
12,
|
||||
2,
|
||||
12
|
||||
],
|
||||
4,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
15,
|
||||
1,
|
||||
14,
|
||||
2,
|
||||
14
|
||||
],
|
||||
6,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
23,
|
||||
1,
|
||||
18,
|
||||
2,
|
||||
18
|
||||
],
|
||||
9,
|
||||
[
|
||||
"step",
|
||||
[
|
||||
"get",
|
||||
"rank"
|
||||
],
|
||||
27,
|
||||
1,
|
||||
22,
|
||||
2,
|
||||
22
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}",
|
||||
"text-max-width": 10
|
||||
},
|
||||
"source": "openmaptiles",
|
||||
"maxzoom": 12,
|
||||
"source-layer": "place"
|
||||
}
|
||||
],
|
||||
"bearing": 0,
|
||||
"sources": {
|
||||
"satellite": {
|
||||
"url": "maptiler://sources/satellite",
|
||||
"type": "raster",
|
||||
"tileSize": 256
|
||||
},
|
||||
"openmaptiles": {
|
||||
"url": "maptiler://sources/v3",
|
||||
"type": "vector"
|
||||
}
|
||||
},
|
||||
"version": 8,
|
||||
"metadata": {
|
||||
"maputnik:renderer": "mbgljs",
|
||||
"openmaptiles:version": "3.x"
|
||||
}
|
||||
}
|
||||
6515
test/fixtures/resources/style_vector.json
vendored
6515
test/fixtures/resources/style_vector.json
vendored
File diff suppressed because one or more lines are too long
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "circle_blur_example",
|
||||
"type": "circle",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"paint": {
|
||||
"circle-blur": "no"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "circle_color_example",
|
||||
"type": "circle",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"paint": {
|
||||
"circle-color": 1
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "circle_opacity_example",
|
||||
"type": "circle",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"paint": {
|
||||
"circle-opacity": "no"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "circle_radius_example",
|
||||
"type": "circle",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"paint": {
|
||||
"circle-radius": "no"
|
||||
}
|
||||
|
||||
12
test/fixtures/style_parser/colors.style.json
vendored
12
test/fixtures/style_parser/colors.style.json
vendored
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
@@ -16,8 +16,8 @@
|
||||
}, {
|
||||
"id": "landcover_snow",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "landcover",
|
||||
"source": "source",
|
||||
"source-layer": "globallandcover",
|
||||
"filter": ["==", "class", "snow"],
|
||||
"paint": {
|
||||
"fill-color": "f4f8foNGbjf#"
|
||||
@@ -25,8 +25,8 @@
|
||||
}, {
|
||||
"id": "landcover_crop",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "landcover",
|
||||
"source": "source",
|
||||
"source-layer": "globallandcover",
|
||||
"filter": ["==", "class", "crop"],
|
||||
"paint": {
|
||||
"fill-color": "#eerLznieed4"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"sources": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-streets-v5"
|
||||
"url": "maptiler://sources/streets"
|
||||
}
|
||||
},
|
||||
"layers": [
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "waterway_river_canal",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"filter": ["in", "type", "river", "canal"],
|
||||
"paint": {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "waterway_river_canal",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"filter": ["in", "type", "river", "canal"],
|
||||
"layout": {
|
||||
@@ -27,7 +27,7 @@
|
||||
{
|
||||
"id": "label",
|
||||
"type": "symbol",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"layout": {
|
||||
"text-font": {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "waterway_river_canal",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"filter": ["in", "type", "river", "canal"],
|
||||
"paint": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "geojson",
|
||||
"data": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [100.0, 0.0] }, "properties": {} }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "geojson",
|
||||
"data": "asset://TEST_DATA/fixtures/geojson/point.json"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "geojson",
|
||||
"data": 24
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "geojson"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "geojson",
|
||||
"data": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [100.0, 0.0] } }
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/outdoor",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "contour_line_loud",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "contour",
|
||||
"filter": ["==", "index", 5],
|
||||
"paint": {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "line_translate_example",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"paint": {
|
||||
"line-translate": "no"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "waterway_river_canal",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"filter": ["in", "type", "river", "canal"],
|
||||
"paint": {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "landcover_grass",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "landcover",
|
||||
"source": "source",
|
||||
"source-layer": "globallandcover",
|
||||
"filter": ["==", "class", "grass"],
|
||||
"paint": {
|
||||
"fill-opacity": {
|
||||
@@ -21,8 +21,8 @@
|
||||
}, {
|
||||
"id": "landcover_scrub",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "landcover",
|
||||
"source": "source",
|
||||
"source-layer": "globallandcover",
|
||||
"filter": ["==", "class", "scrub"],
|
||||
"paint": {
|
||||
"fill-opacity": {
|
||||
@@ -32,8 +32,8 @@
|
||||
}, {
|
||||
"id": "landcover_wood",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "landcover",
|
||||
"source": "source",
|
||||
"source-layer": "globallandcover",
|
||||
"filter": ["==", "class", "wood"],
|
||||
"paint": {
|
||||
"fill-color": "#001100",
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "waterway_river_canal",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source": "source",
|
||||
"source-layer": "waterway",
|
||||
"filter": ["in", "type", "river", "canal"],
|
||||
"paint": {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"sources": {
|
||||
"vector": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-streets-v5"
|
||||
"url": "maptiler://sources/streets"
|
||||
}
|
||||
},
|
||||
"layers": [
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"source": {
|
||||
"type": "vector",
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
|
||||
"url": "maptiler://sources/streets",
|
||||
"maxzoom": 14
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "country_label",
|
||||
"type": "symbol",
|
||||
"source": "mapbox",
|
||||
"source-layer": "country_label",
|
||||
"source": "source",
|
||||
"source-layer": "place",
|
||||
"filter": ["==", "$type", "Point"],
|
||||
"layout": {
|
||||
"text-size": "no"
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
MapAdapter map;
|
||||
|
||||
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
|
||||
: fileSource(std::make_shared<FileSource>())
|
||||
: fileSource(std::make_shared<FileSource>(ResourceOptions::Default()))
|
||||
, frontend(pixelRatio)
|
||||
, map(frontend, observer, fileSource,
|
||||
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
|
||||
@@ -71,6 +71,17 @@ public:
|
||||
observer,
|
||||
fileSource,
|
||||
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
|
||||
|
||||
template <typename T = FileSource>
|
||||
MapTest(const ResourceOptions& options,
|
||||
float pixelRatio = 1,
|
||||
MapMode mode = MapMode::Static)
|
||||
: fileSource(std::make_shared<T>(options)),
|
||||
frontend(pixelRatio),
|
||||
map(frontend,
|
||||
observer,
|
||||
fileSource,
|
||||
MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
|
||||
};
|
||||
|
||||
TEST(Map, RendererState) {
|
||||
@@ -349,7 +360,7 @@ TEST(Map, Offline) {
|
||||
NetworkStatus::Set(NetworkStatus::Status::Offline);
|
||||
const std::string prefix = "http://127.0.0.1:3000/";
|
||||
std::shared_ptr<FileSource> dbfs =
|
||||
FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
|
||||
FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
|
||||
dbfs->forward(Resource::style(prefix + "style.json"), expiredItem("style.json"), [] {});
|
||||
dbfs->forward(Resource::source(prefix + "streets.json"), expiredItem("streets.json"), [] {});
|
||||
dbfs->forward(Resource::spriteJSON(prefix + "sprite", 1.0), expiredItem("sprite.json"), [] {});
|
||||
@@ -495,7 +506,7 @@ TEST(Map, SetStyleInvalidURL) {
|
||||
test.runLoop.stop();
|
||||
};
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://bar");
|
||||
test.map.getStyle().loadURL("maptiler://bar");
|
||||
|
||||
test.runLoop.run();
|
||||
}
|
||||
@@ -512,7 +523,7 @@ TEST(Map, StyleFresh) {
|
||||
|
||||
MapTest<FakeFileSource> test;
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://styles/test");
|
||||
test.map.getStyle().loadURL("maptiler://maps/test");
|
||||
EXPECT_EQ(1u, test.fileSource->requests.size());
|
||||
|
||||
Response response;
|
||||
@@ -530,7 +541,7 @@ TEST(Map, StyleExpired) {
|
||||
|
||||
MapTest<FakeFileSource> test;
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://styles/test");
|
||||
test.map.getStyle().loadURL("maptiler://maps/test");
|
||||
EXPECT_EQ(1u, test.fileSource->requests.size());
|
||||
|
||||
Response response;
|
||||
@@ -566,7 +577,7 @@ TEST(Map, StyleExpiredWithAnnotations) {
|
||||
|
||||
MapTest<FakeFileSource> test;
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://styles/test");
|
||||
test.map.getStyle().loadURL("maptiler://maps/test");
|
||||
EXPECT_EQ(1u, test.fileSource->requests.size());
|
||||
|
||||
Response response;
|
||||
@@ -590,7 +601,7 @@ TEST(Map, StyleExpiredWithRender) {
|
||||
|
||||
MapTest<FakeFileSource> test;
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://styles/test");
|
||||
test.map.getStyle().loadURL("maptiler://maps/test");
|
||||
EXPECT_EQ(1u, test.fileSource->requests.size());
|
||||
|
||||
Response response;
|
||||
@@ -612,7 +623,7 @@ TEST(Map, StyleEarlyMutation) {
|
||||
|
||||
MapTest<FakeFileSource> test;
|
||||
|
||||
test.map.getStyle().loadURL("mapbox://styles/test");
|
||||
test.map.getStyle().loadURL("maptiler://maps/test");
|
||||
test.map.getStyle().addLayer(std::make_unique<style::BackgroundLayer>("bg"));
|
||||
|
||||
Response response;
|
||||
@@ -664,7 +675,7 @@ TEST(Map, StyleLoadedSignal) {
|
||||
|
||||
// Test for https://github.com/mapbox/mapbox-gl-native/issues/7902
|
||||
TEST(Map, TEST_REQUIRES_SERVER(StyleNetworkErrorRetry)) {
|
||||
MapTest<OnlineFileSource> test;
|
||||
MapTest<OnlineFileSource> test(ResourceOptions::Default());
|
||||
|
||||
test.map.getStyle().loadURL("http://127.0.0.1:3000/style-fail-once-500");
|
||||
|
||||
@@ -676,7 +687,7 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNetworkErrorRetry)) {
|
||||
}
|
||||
|
||||
TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) {
|
||||
MapTest<OnlineFileSource> test;
|
||||
MapTest<OnlineFileSource> test(ResourceOptions::Default());
|
||||
|
||||
test.map.getStyle().loadURL("http://127.0.0.1:3000/style-fail-once-404");
|
||||
|
||||
@@ -1432,9 +1443,9 @@ TEST(Map, KeepRenderData) {
|
||||
test.fileSource->spriteImageResponse = makeResponse("sprite.png");
|
||||
|
||||
test.map.jumpTo(CameraOptions().withZoom(10));
|
||||
test.map.getStyle().loadURL("mapbox://streets");
|
||||
test.map.getStyle().loadURL("maptiler://maps/streets");
|
||||
const int iterations = 3;
|
||||
const int resourcesCount = 4 /*tiles*/ + 3 /*fonts*/;
|
||||
const int resourcesCount = 4 /*tiles*/;
|
||||
// Keep render data.
|
||||
for (int i = 1; i <= iterations; ++i) {
|
||||
test.frontend.render(test.map);
|
||||
@@ -1461,7 +1472,8 @@ bool isInsideTile(const mapbox::geometry::box<float>& box, float padding, Size v
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(Map, PlacedSymbolData) {
|
||||
// Disabled intentionally, no symbol placement occurs in MapTiler streets style
|
||||
TEST(Map, DISABLED_PlacedSymbolData) {
|
||||
MapTest<> test{std::move(MapOptions().withMapMode(MapMode::Tile))};
|
||||
|
||||
test.fileSource->tileResponse = makeResponse("vector.tile", true);
|
||||
@@ -1472,8 +1484,9 @@ TEST(Map, PlacedSymbolData) {
|
||||
test.fileSource->spriteImageResponse = makeResponse("sprite.png");
|
||||
|
||||
// Camera options will give exactly one tile (12/1171/1566)
|
||||
test.map.jumpTo(CameraOptions().withZoom(12).withCenter(LatLng{38.917982, -77.037603}));
|
||||
test.map.getStyle().loadURL("mapbox://streets");
|
||||
test.map.jumpTo(CameraOptions().withZoom(16).withCenter(LatLng{50.072317, 14.444827}));
|
||||
|
||||
test.map.getStyle().loadURL("maptiler://maps/streets");
|
||||
Size viewportSize = test.frontend.getSize();
|
||||
test.frontend.getRenderer()->collectPlacedSymbolData(true);
|
||||
test.frontend.render(test.map);
|
||||
@@ -1489,15 +1502,14 @@ TEST(Map, PlacedSymbolData) {
|
||||
|
||||
int placedTotal = 0;
|
||||
|
||||
const std::set<std::string> symbolLayers{"place-city-lg-s",
|
||||
"place-neighbourhood",
|
||||
"place-suburb",
|
||||
"poi-scalerank2",
|
||||
"poi-scalerank3",
|
||||
"poi-parks-scalerank1",
|
||||
"poi-parks-scalerank2",
|
||||
"poi-parks-scalerank3",
|
||||
"rail-label"};
|
||||
std::set<std::string> symbolLayers;
|
||||
auto layers = test.map.getStyle().getLayers();
|
||||
for (auto l : layers) {
|
||||
auto layerType = l->getTypeInfo()->type;
|
||||
if (strcmp(layerType, "symbol") == 0) {
|
||||
symbolLayers.insert(l->getID());
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& placedSymbol : placedSymbols) {
|
||||
EXPECT_NE(0u, symbolLayers.count(placedSymbol.layer));
|
||||
@@ -1561,4 +1573,4 @@ TEST(Map, VolatileSource) {
|
||||
test.observer.didFinishLoadingMapCallback = [&] { test.runLoop.stop(); };
|
||||
test.runLoop.run();
|
||||
EXPECT_EQ(8, requestedTiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST(SpriteLoader, LoadingSuccess) {
|
||||
};
|
||||
|
||||
test.observer.spriteLoaded = [&](std::vector<Immutable<style::Image::Impl>> images) {
|
||||
EXPECT_EQ(images.size(), 367u);
|
||||
EXPECT_EQ(images.size(), 418u);
|
||||
test.end();
|
||||
};
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include <mbgl/storage/online_file_source.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/util/async_request.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
/*
|
||||
@@ -40,6 +42,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
FakeFileSource(const ResourceOptions& options): resourceOptions(options.clone()) {}
|
||||
FakeFileSource(): FakeFileSource(ResourceOptions::Default()) {}
|
||||
|
||||
std::unique_ptr<AsyncRequest> request(const Resource& resource, Callback callback) override {
|
||||
return std::make_unique<FakeFileRequest>(resource, callback, requests);
|
||||
}
|
||||
@@ -62,10 +67,22 @@ public:
|
||||
|
||||
std::list<FakeFileRequest*> requests;
|
||||
|
||||
void setResourceOptions(ResourceOptions options) override {
|
||||
resourceOptions = options;
|
||||
}
|
||||
ResourceOptions getResourceOptions() override {
|
||||
return resourceOptions.clone();
|
||||
}
|
||||
|
||||
private:
|
||||
ResourceOptions resourceOptions;
|
||||
};
|
||||
|
||||
class FakeOnlineFileSource : public FakeFileSource {
|
||||
public:
|
||||
FakeOnlineFileSource(): FakeOnlineFileSource(ResourceOptions::Default()) {}
|
||||
FakeOnlineFileSource(const ResourceOptions& options): FakeFileSource(options) {}
|
||||
|
||||
std::unique_ptr<AsyncRequest> request(const Resource& resource, Callback callback) override {
|
||||
return FakeFileSource::request(resource, callback);
|
||||
}
|
||||
@@ -78,7 +95,7 @@ public:
|
||||
return onlineFs->getProperty(property);
|
||||
}
|
||||
|
||||
std::unique_ptr<FileSource> onlineFs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> onlineFs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/test/stub_file_source.hpp>
|
||||
#include <mbgl/util/async_request.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -18,8 +19,11 @@ public:
|
||||
StubFileSource& fileSource;
|
||||
};
|
||||
|
||||
StubFileSource::StubFileSource(ResponseType type_)
|
||||
: type(type_) {
|
||||
StubFileSource::StubFileSource(ResponseType type_):
|
||||
StubFileSource::StubFileSource(ResourceOptions().withTileServerOptions(TileServerOptions::MapTilerConfiguration()), type_) {}
|
||||
|
||||
StubFileSource::StubFileSource(const ResourceOptions& options, ResponseType type_)
|
||||
: type(type_), resourceOptions(options.clone()) {
|
||||
if (type == ResponseType::Synchronous) {
|
||||
return;
|
||||
}
|
||||
@@ -110,4 +114,12 @@ optional<Response> StubFileSource::defaultResponse(const Resource& resource) {
|
||||
return Response();
|
||||
}
|
||||
|
||||
void StubFileSource::setResourceOptions(ResourceOptions options) {
|
||||
resourceOptions = options;
|
||||
}
|
||||
|
||||
ResourceOptions StubFileSource::getResourceOptions() {
|
||||
return resourceOptions.clone();
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/storage/online_file_source.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/util/timer.hpp>
|
||||
|
||||
#include <map>
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
Synchronous
|
||||
};
|
||||
|
||||
StubFileSource(const ResourceOptions&, ResponseType = ResponseType::Asynchronous);
|
||||
StubFileSource(ResponseType = ResponseType::Asynchronous);
|
||||
~StubFileSource() override;
|
||||
|
||||
@@ -42,6 +44,9 @@ public:
|
||||
ResponseFunction spriteImageResponse;
|
||||
ResponseFunction imageResponse;
|
||||
|
||||
void setResourceOptions(ResourceOptions options) override;
|
||||
ResourceOptions getResourceOptions() override;
|
||||
|
||||
private:
|
||||
friend class StubOnlineFileSource;
|
||||
|
||||
@@ -52,6 +57,8 @@ private:
|
||||
ResponseType type;
|
||||
util::Timer timer;
|
||||
std::map<std::string, mapbox::base::Value> properties;
|
||||
|
||||
ResourceOptions resourceOptions;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -12,6 +12,10 @@ int runTests(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
// In order to run specific tests
|
||||
// testing::GTEST_FLAG(filter) = "TileServerOptions*";
|
||||
// testing::GTEST_FLAG(filter) = "MainResourceLoader.ResourceOptions";
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/actor/actor_ref.hpp>
|
||||
#include <mbgl/storage/asset_file_source.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
@@ -15,7 +16,7 @@ using namespace mbgl;
|
||||
TEST(AssetFileSource, Load) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
// iOS seems to run out of file descriptors...
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -71,7 +72,7 @@ TEST(AssetFileSource, Load) {
|
||||
}
|
||||
|
||||
TEST(AssetFileSource, AcceptsURL) {
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
EXPECT_TRUE(fs.canRequest(Resource::style("asset://empty")));
|
||||
EXPECT_TRUE(fs.canRequest(Resource::style("asset:///test")));
|
||||
EXPECT_FALSE(fs.canRequest(Resource::style("assds://foo")));
|
||||
@@ -83,7 +84,7 @@ TEST(AssetFileSource, AcceptsURL) {
|
||||
TEST(AssetFileSource, EmptyFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://empty" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -99,7 +100,7 @@ TEST(AssetFileSource, EmptyFile) {
|
||||
TEST(AssetFileSource, NonEmptyFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://nonempty" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -115,7 +116,7 @@ TEST(AssetFileSource, NonEmptyFile) {
|
||||
TEST(AssetFileSource, NonExistentFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://does_not_exist" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -132,7 +133,7 @@ TEST(AssetFileSource, NonExistentFile) {
|
||||
TEST(AssetFileSource, InvalidURL) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "test://wrong-scheme" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -149,7 +150,7 @@ TEST(AssetFileSource, InvalidURL) {
|
||||
TEST(AssetFileSource, ReadDirectory) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://directory" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -166,7 +167,7 @@ TEST(AssetFileSource, ReadDirectory) {
|
||||
TEST(AssetFileSource, URLEncoding) {
|
||||
util::RunLoop loop;
|
||||
|
||||
AssetFileSource fs("test/fixtures/storage/assets");
|
||||
AssetFileSource fs(ResourceOptions::Default().withAssetPath("test/fixtures/storage/assets"));
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "asset://%6eonempty" }, [&](Response res) {
|
||||
req.reset();
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(Cancel)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&](Response) {
|
||||
ADD_FAILURE() << "Callback should not be called";
|
||||
@@ -21,7 +22,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(Cancel)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP200)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, [&](Response res) {
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
@@ -39,7 +40,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP200)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP404)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" }, [&](Response res) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
@@ -58,7 +59,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP404)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTPTile404)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Tile, "http://127.0.0.1:3000/doesnotexist" }, [&](Response res) {
|
||||
EXPECT_TRUE(res.noContent);
|
||||
@@ -76,7 +77,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTPTile404)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP200EmptyData)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/empty-data" }, [&](Response res) {
|
||||
EXPECT_FALSE(res.noContent);
|
||||
@@ -94,7 +95,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP200EmptyData)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP204)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/no-content" }, [&](Response res) {
|
||||
EXPECT_TRUE(res.noContent);
|
||||
@@ -112,7 +113,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP204)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP500)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" }, [&](Response res) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
@@ -131,7 +132,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(HTTP500)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(ExpiresParsing)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown,
|
||||
"http://127.0.0.1:3000/test?modified=1420794326&expires=1420797926&etag=foo" }, [&](Response res) {
|
||||
@@ -150,7 +151,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(ExpiresParsing)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(CacheControlParsing)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" }, [&](Response res) {
|
||||
EXPECT_EQ(nullptr, res.error);
|
||||
@@ -168,7 +169,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(CacheControlParsing)) {
|
||||
|
||||
TEST(HTTPFileSource, TEST_REQUIRES_SERVER(Load)) {
|
||||
util::RunLoop loop;
|
||||
HTTPFileSource fs;
|
||||
HTTPFileSource fs(ResourceOptions::Default());
|
||||
|
||||
const int concurrency = 50;
|
||||
const int max = 10000;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/storage/local_file_source.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
@@ -22,7 +23,7 @@ std::string toAbsoluteURL(const std::string& fileName) {
|
||||
using namespace mbgl;
|
||||
|
||||
TEST(LocalFileSource, AcceptsURL) {
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
EXPECT_TRUE(fs.canRequest(Resource::style("file://empty")));
|
||||
EXPECT_TRUE(fs.canRequest(Resource::style("file:///test")));
|
||||
EXPECT_FALSE(fs.canRequest(Resource::style("flie://foo")));
|
||||
@@ -34,7 +35,7 @@ TEST(LocalFileSource, AcceptsURL) {
|
||||
TEST(LocalFileSource, EmptyFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, toAbsoluteURL("empty") }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -50,7 +51,7 @@ TEST(LocalFileSource, EmptyFile) {
|
||||
TEST(LocalFileSource, NonEmptyFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, toAbsoluteURL("nonempty") }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -66,7 +67,7 @@ TEST(LocalFileSource, NonEmptyFile) {
|
||||
TEST(LocalFileSource, NonExistentFile) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, toAbsoluteURL("does_not_exist") }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -83,7 +84,7 @@ TEST(LocalFileSource, NonExistentFile) {
|
||||
TEST(LocalFileSource, InvalidURL) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "test://wrong-scheme" }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -100,7 +101,7 @@ TEST(LocalFileSource, InvalidURL) {
|
||||
TEST(LocalFileSource, ReadDirectory) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, toAbsoluteURL("directory") }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -117,7 +118,7 @@ TEST(LocalFileSource, ReadDirectory) {
|
||||
TEST(LocalFileSource, URLEncoding) {
|
||||
util::RunLoop loop;
|
||||
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
|
||||
std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, toAbsoluteURL("%6eonempty") }, [&](Response res) {
|
||||
req.reset();
|
||||
@@ -134,7 +135,7 @@ TEST(LocalFileSource, URLLimit) {
|
||||
util::RunLoop loop;
|
||||
|
||||
size_t length = PATH_MAX - toAbsoluteURL("").size();
|
||||
LocalFileSource fs;
|
||||
LocalFileSource fs(ResourceOptions::Default());
|
||||
char filename[length];
|
||||
memset(filename, 'x', length);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/timer.hpp>
|
||||
#include <mbgl/util/tile_server_options.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -823,3 +824,26 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoDoubleDispatch)) {
|
||||
|
||||
loop.run();
|
||||
}
|
||||
|
||||
TEST(MainResourceLoader, ResourceOptions) {
|
||||
MainResourceLoader fs(
|
||||
ResourceOptions().withTileServerOptions(
|
||||
TileServerOptions()
|
||||
.withBaseURL("originalBaseURL")
|
||||
.withUriSchemeAlias("originalAlias")
|
||||
)
|
||||
);
|
||||
|
||||
fs.setResourceOptions(ResourceOptions()
|
||||
.withTileServerOptions(
|
||||
TileServerOptions()
|
||||
.withBaseURL("updatedBaseURL")
|
||||
.withUriSchemeAlias("updatedAlias")
|
||||
).clone()
|
||||
);
|
||||
|
||||
auto updatedOptions = fs.getResourceOptions().tileServerOptions();
|
||||
|
||||
EXPECT_EQ(updatedOptions.baseURL(), "updatedBaseURL");
|
||||
EXPECT_EQ(updatedOptions.uriSchemeAlias(), "updatedAlias");
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using SourceType = mbgl::style::SourceType;
|
||||
|
||||
|
||||
TEST(OfflineTilePyramidRegionDefinition, EncodeDecode) {
|
||||
OfflineTilePyramidRegionDefinition region("mapbox://style", LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 }), 0, 20, 1.0, true);
|
||||
OfflineTilePyramidRegionDefinition region("maptiler://style", LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 }), 0, 20, 1.0, true);
|
||||
|
||||
auto encoded = encodeOfflineRegionDefinition(region);
|
||||
auto decoded = decodeOfflineRegionDefinition(encoded).get<OfflineTilePyramidRegionDefinition>();
|
||||
@@ -23,7 +23,7 @@ TEST(OfflineTilePyramidRegionDefinition, EncodeDecode) {
|
||||
}
|
||||
|
||||
TEST(OfflineGeometryRegionDefinition, EncodeDecode) {
|
||||
OfflineGeometryRegionDefinition region("mapbox://style", Point<double>(-122.5744, 37.6609), 0, 2, 1.0, false);
|
||||
OfflineGeometryRegionDefinition region("maptiler://style", Point<double>(-122.5744, 37.6609), 0, 2, 1.0, false);
|
||||
|
||||
auto encoded = encodeOfflineRegionDefinition(region);
|
||||
auto decoded = decodeOfflineRegionDefinition(encoded).get<OfflineGeometryRegionDefinition>();
|
||||
|
||||
@@ -102,21 +102,23 @@ static int databaseAutoVacuum(const std::string& path) {
|
||||
|
||||
namespace fixture {
|
||||
|
||||
const Resource resource{ Resource::Style, "mapbox://test" };
|
||||
const Resource tile = Resource::tile("mapbox://test", 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource resource{ Resource::Style, "maptiler://test" };
|
||||
const Resource tile = Resource::tile("maptiler://test", 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Response response = [] {
|
||||
Response res;
|
||||
res.data = std::make_shared<std::string>("first");
|
||||
return res;
|
||||
}();
|
||||
|
||||
const TileServerOptions& tileServerOptions = TileServerOptions::MapTilerConfiguration();
|
||||
|
||||
} // namespace fixture
|
||||
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) {
|
||||
FixtureLog log;
|
||||
deleteDatabaseFiles();
|
||||
OfflineDatabase db(filename);
|
||||
EXPECT_FALSE(bool(db.get({ Resource::Unknown, "mapbox://test" })));
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
EXPECT_FALSE(bool(db.get({ Resource::Unknown, "maptiler://test" })));
|
||||
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
}
|
||||
@@ -131,7 +133,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(CreateFail)) {
|
||||
// it is not allowed to create the file. The OfflineDatabase object should handle this gracefully
|
||||
// and treat it like an empty cache that can't be written to.
|
||||
fs.allowFileCreate(false);
|
||||
OfflineDatabase db(filename_test_fs);
|
||||
OfflineDatabase db(filename_test_fs, fixture::tileServerOptions);
|
||||
EXPECT_EQ(1u, log.count(warning(ResultCode::CantOpen, "Can't open database: unable to open database file")));
|
||||
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
@@ -224,12 +226,12 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(SchemaVersion)) {
|
||||
}
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
}
|
||||
|
||||
EXPECT_EQ(6, databaseUserVersion(filename));
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
// Now try inserting and reading back to make sure we have a valid database.
|
||||
for (const auto& res : { fixture::resource, fixture::tile }) {
|
||||
EXPECT_EQ(std::make_pair(true, uint64_t(5)), db.put(res, fixture::response));
|
||||
@@ -248,7 +250,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Invalid)) {
|
||||
deleteDatabaseFiles();
|
||||
util::write_file(filename, "this is an invalid file");
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
// Checking two possibilities for the error string because it apparently changes between SQLite versions.
|
||||
EXPECT_EQ(1u, log.count(error(ResultCode::NotADB, "Can't open database: file is encrypted or is not a database"), true) +
|
||||
log.count(error(ResultCode::NotADB, "Can't open database: file is not a database"), true));
|
||||
@@ -267,7 +269,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Invalid)) {
|
||||
|
||||
TEST(OfflineDatabase, PutDoesNotStoreConnectionErrors) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Unknown, "http://example.com/" };
|
||||
Response response;
|
||||
@@ -281,7 +283,7 @@ TEST(OfflineDatabase, PutDoesNotStoreConnectionErrors) {
|
||||
|
||||
TEST(OfflineDatabase, PutDoesNotStoreServerErrors) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Unknown, "http://example.com/" };
|
||||
Response response;
|
||||
@@ -295,7 +297,7 @@ TEST(OfflineDatabase, PutDoesNotStoreServerErrors) {
|
||||
|
||||
TEST(OfflineDatabase, PutResource) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Style, "http://example.com/" };
|
||||
Response response;
|
||||
@@ -326,9 +328,9 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(GetResourceFromOfflineRegion)) {
|
||||
deleteDatabaseFiles();
|
||||
util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db");
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
|
||||
Resource resource = Resource::style("mapbox://styles/mapbox/satellite-v9");
|
||||
Resource resource = Resource::style("maptiler://maps/hybrid");
|
||||
ASSERT_TRUE(db.get(resource));
|
||||
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
@@ -336,12 +338,12 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(GetResourceFromOfflineRegion)) {
|
||||
|
||||
TEST(OfflineDatabase, PutAndGetResource) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Response response1;
|
||||
response1.data = std::make_shared<std::string>("foobar");
|
||||
|
||||
Resource resource = Resource::style("mapbox://example.com/style");
|
||||
Resource resource = Resource::style("maptiler://example.com/style");
|
||||
|
||||
db.put(resource, response1);
|
||||
|
||||
@@ -354,7 +356,7 @@ TEST(OfflineDatabase, PutAndGetResource) {
|
||||
|
||||
TEST(OfflineDatabase, PutTile) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Tile, "http://example.com/" };
|
||||
resource.tileData = Resource::TileData {
|
||||
@@ -389,7 +391,7 @@ TEST(OfflineDatabase, PutTile) {
|
||||
|
||||
TEST(OfflineDatabase, PutResourceNoContent) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Style, "http://example.com/" };
|
||||
Response response;
|
||||
@@ -406,7 +408,7 @@ TEST(OfflineDatabase, PutResourceNoContent) {
|
||||
|
||||
TEST(OfflineDatabase, PutTileNotFound) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource { Resource::Tile, "http://example.com/" };
|
||||
resource.tileData = Resource::TileData {
|
||||
@@ -430,7 +432,7 @@ TEST(OfflineDatabase, PutTileNotFound) {
|
||||
|
||||
TEST(OfflineDatabase, CreateRegion) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
@@ -455,7 +457,7 @@ TEST(OfflineDatabase, CreateRegion) {
|
||||
|
||||
TEST(OfflineDatabase, UpdateMetadata) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
@@ -471,7 +473,7 @@ TEST(OfflineDatabase, UpdateMetadata) {
|
||||
|
||||
TEST(OfflineDatabase, ListRegions) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, false };
|
||||
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
|
||||
|
||||
@@ -501,7 +503,7 @@ TEST(OfflineDatabase, ListRegions) {
|
||||
|
||||
TEST(OfflineDatabase, GetRegionDefinition) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, false };
|
||||
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
|
||||
|
||||
@@ -533,7 +535,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
};
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
}
|
||||
|
||||
size_t initialSize = util::read_file(filename).size();
|
||||
@@ -543,26 +545,26 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
response.data = randomString(100 * 1024);
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize); // 50 MB
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition{ "mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineTilePyramidRegionDefinition definition{ "maptiler://masp/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata{{ 1, 2, 3 }};
|
||||
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
|
||||
// Add 100 MB of resources (50/50 ambient/region)
|
||||
for (unsigned i = 0; i < 250; ++i) {
|
||||
const Resource ambientTile = Resource::tile("mapbox://ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambientTile = Resource::tile("maptiler://tiles/tiles/ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambientTile, response);
|
||||
|
||||
const Resource ambientStyle = Resource::style("mapbox://ambient_style_" + std::to_string(i));
|
||||
const Resource ambientStyle = Resource::style("maptiler://maps/ambient_style_" + std::to_string(i));
|
||||
db.put(ambientStyle, response);
|
||||
|
||||
const Resource regionTile = Resource::tile("mapbox://region_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource regionTile = Resource::tile("maptiler://tiles/tiles/region_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(region->getID(), regionTile, response);
|
||||
|
||||
const Resource regionStyle = Resource::style("mapbox://region_style_" + std::to_string(i));
|
||||
const Resource regionStyle = Resource::style("maptiler://maps/region_style_" + std::to_string(i));
|
||||
db.putRegionResource(region->getID(), regionStyle, response);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +579,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
maximumSize = 30 * 1024 * 1024;
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize); // 30 MB
|
||||
}
|
||||
|
||||
@@ -587,7 +589,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
EXPECT_LE(databaseSize(), 60 * 1024 * 1024);
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize); // 30 MB
|
||||
db.deleteRegion(std::move(db.listRegions().value()[0]));
|
||||
}
|
||||
@@ -598,7 +600,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
EXPECT_GE(databaseSize(), maximumSize / 2);
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize * 2); // 60 MB
|
||||
}
|
||||
|
||||
@@ -609,15 +611,15 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
EXPECT_GE(databaseSize(), maximumSize / 2);
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize); // 30 MB
|
||||
|
||||
// Add ~50 MB in ambient cache data.
|
||||
for (unsigned i = 0; i < 250; ++i) {
|
||||
const Resource ambientTile = Resource::tile("mapbox://ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambientTile = Resource::tile("maptiler://tiles/tiles/ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambientTile, response);
|
||||
|
||||
const Resource ambientStyle = Resource::style("mapbox://ambient_style_" + std::to_string(i));
|
||||
const Resource ambientStyle = Resource::style("maptiler://mas/ambient_style_" + std::to_string(i));
|
||||
db.put(ambientStyle, response);
|
||||
}
|
||||
}
|
||||
@@ -630,7 +632,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
maximumSize = 20 * 1024 * 1024;
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(maximumSize); // 20 MB
|
||||
}
|
||||
|
||||
@@ -639,15 +641,15 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DISABLED_MaximumAmbientCacheSize)) {
|
||||
EXPECT_GE(databaseSize(), initialSize);
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
for (unsigned i = 0; i < 5; ++i) {
|
||||
const Resource ambientTile = Resource::tile("mapbox://ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambientTile = Resource::tile("maptiler://tiles/tiles/ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambientTile, response);
|
||||
ASSERT_FALSE(db.get(ambientTile));
|
||||
|
||||
const Resource ambientStyle = Resource::style("mapbox://ambient_style_" + std::to_string(i));
|
||||
const Resource ambientStyle = Resource::style("maptiler://maps/ambient_style_" + std::to_string(i));
|
||||
db.put(ambientStyle, response);
|
||||
ASSERT_FALSE(db.get(ambientStyle));
|
||||
}
|
||||
@@ -679,7 +681,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) {
|
||||
deleteDatabaseFiles();
|
||||
|
||||
{
|
||||
OfflineDatabase dbCreate(filename);
|
||||
OfflineDatabase dbCreate(filename, fixture::tileServerOptions);
|
||||
}
|
||||
|
||||
size_t initialSize = util::read_file(filename).size();
|
||||
@@ -688,17 +690,17 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) {
|
||||
Response response;
|
||||
response.data = randomString(.5 * 1024 * 1024);
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition{ "mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineTilePyramidRegionDefinition definition{ "maptiler://maps/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata{{ 1, 2, 3 }};
|
||||
|
||||
auto region1 = db.createRegion(definition, metadata);
|
||||
auto region2 = db.createRegion(definition, metadata);
|
||||
|
||||
OfflineRegionStatus status;
|
||||
db.putRegionResources(region1->getID(), generateResources("mapbox://tile_1", "mapbox://style_1"), status);
|
||||
db.putRegionResources(region2->getID(), generateResources("mapbox://tile_2", "mapbox://style_2"), status);
|
||||
db.putRegionResources(region1->getID(), generateResources("maptiler://tiles/tiles/tile_1", "maptiler://maps/style_1"), status);
|
||||
db.putRegionResources(region2->getID(), generateResources("maptiler://tiles/tiles/tile_2", "maptiler://maps/style_2"), status);
|
||||
const size_t sizeWithTwoRegions = util::read_file(filename).size();
|
||||
|
||||
db.runPackDatabaseAutomatically(false);
|
||||
@@ -740,7 +742,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Pack)) {
|
||||
FixtureLog log;
|
||||
deleteDatabaseFiles();
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
size_t initialSize = util::read_file(filename).size();
|
||||
db.runPackDatabaseAutomatically(false);
|
||||
|
||||
@@ -748,10 +750,10 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Pack)) {
|
||||
response.data = randomString(.5 * 1024 * 1024);
|
||||
|
||||
for (unsigned i = 0; i < 50; ++i) {
|
||||
const Resource tile = Resource::tile("mapbox://tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource tile = Resource::tile("maptiler://tiles/tiles/tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(tile, response);
|
||||
|
||||
const Resource style = Resource::style("mapbox://style_" + std::to_string(i));
|
||||
const Resource style = Resource::style("maptiler://maps/style_" + std::to_string(i));
|
||||
db.put(style, response);
|
||||
}
|
||||
size_t populatedSize = util::read_file(filename).size();
|
||||
@@ -771,26 +773,26 @@ TEST(OfflineDatabase, MapboxTileLimitExceeded) {
|
||||
|
||||
uint64_t limit = 60;
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setOfflineMapboxTileCountLimit(limit);
|
||||
|
||||
Response response;
|
||||
response.data = randomString(4096);
|
||||
|
||||
auto insertAmbientTile = [&](unsigned i) {
|
||||
const Resource ambientTile = Resource::tile("mapbox://ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambientTile = Resource::tile("maptiler://tiles/tiles/ambient_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambientTile, response);
|
||||
};
|
||||
|
||||
auto insertRegionTile = [&](int64_t regionID, uint64_t i) {
|
||||
const Resource tile = Resource::tile("mapbox://region_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource tile = Resource::tile("maptiler://tiles/tiles/region_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(regionID, tile, response);
|
||||
};
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition1{ "mapbox://style1", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineTilePyramidRegionDefinition definition1{ "maptiler://maps/style1", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata1{{ 1, 2, 3 }};
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition2{ "mapbox://style2", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineTilePyramidRegionDefinition definition2{ "maptiler://maps/style2", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata2{{ 1, 2, 3 }};
|
||||
|
||||
auto region1 = db.createRegion(definition1, metadata1);
|
||||
@@ -868,34 +870,34 @@ TEST(OfflineDatabase, Invalidate) {
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Response response;
|
||||
response.noContent = true;
|
||||
response.mustRevalidate = false;
|
||||
response.expires = util::now() + 1h;
|
||||
|
||||
const Resource ambientTile = Resource::tile("mapbox://tile_ambient", 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource ambientTile = Resource::tile("maptiler://tiles/tiles/tile_ambient", 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(ambientTile, response);
|
||||
|
||||
const Resource ambientStyle = Resource::style("mapbox://style_ambient");
|
||||
const Resource ambientStyle = Resource::style("maptiler://maps/style_ambient");
|
||||
db.put(ambientStyle, response);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition { "mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineTilePyramidRegionDefinition definition { "maptiler://maps/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
|
||||
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
|
||||
|
||||
auto region1 = db.createRegion(definition, metadata);
|
||||
const Resource region1Tile = Resource::tile("mapbox://tile_offline_region1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource region1Tile = Resource::tile("maptiler://tiles/tiles/tile_offline_region1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(region1->getID(), region1Tile, response);
|
||||
|
||||
const Resource region1Style = Resource::style("mapbox://style_offline_region1");
|
||||
const Resource region1Style = Resource::style("maptiler://maps/style_offline_region1");
|
||||
db.putRegionResource(region1->getID(), region1Style, response);
|
||||
|
||||
auto region2 = db.createRegion(definition, metadata);
|
||||
const Resource region2Tile = Resource::tile("mapbox://tile_offline_region2", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource region2Tile = Resource::tile("maptiler://tiles/tiles/tile_offline_region2", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(region2->getID(), region2Tile, response);
|
||||
|
||||
const Resource region2Style = Resource::style("mapbox://style_offline_region2");
|
||||
const Resource region2Style = Resource::style("maptiler://maps/style_offline_region2");
|
||||
db.putRegionResource(region2->getID(), region2Style, response);
|
||||
|
||||
// Prior to invalidation, all tiles are usable.
|
||||
@@ -960,7 +962,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ClearAmbientCache)) {
|
||||
deleteDatabaseFiles();
|
||||
|
||||
{
|
||||
OfflineDatabase dbCreate(filename);
|
||||
OfflineDatabase dbCreate(filename, fixture::tileServerOptions);
|
||||
}
|
||||
|
||||
size_t initialSize = util::read_file(filename).size();
|
||||
@@ -969,13 +971,13 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ClearAmbientCache)) {
|
||||
Response response;
|
||||
response.data = randomString(.5 * 1024 * 1024);
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
|
||||
for (unsigned i = 0; i < 50; ++i) {
|
||||
const Resource tile = Resource::tile("mapbox://tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource tile = Resource::tile("maptiler://tiles/tiles/tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.put(tile, response);
|
||||
|
||||
const Resource style = Resource::style("mapbox://style_" + std::to_string(i));
|
||||
const Resource style = Resource::style("maptiler://maps/style_" + std::to_string(i));
|
||||
db.put(style, response);
|
||||
}
|
||||
|
||||
@@ -988,7 +990,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ClearAmbientCache)) {
|
||||
|
||||
TEST(OfflineDatabase, CreateRegionInfiniteMaxZoom) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, false };
|
||||
OfflineRegionMetadata metadata;
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
@@ -1006,10 +1008,10 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ConcurrentUse)) {
|
||||
FixtureLog log;
|
||||
deleteDatabaseFiles();
|
||||
|
||||
OfflineDatabase db1(filename);
|
||||
OfflineDatabase db1(filename, fixture::tileServerOptions);
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
OfflineDatabase db2(filename);
|
||||
OfflineDatabase db2(filename, fixture::tileServerOptions);
|
||||
|
||||
std::thread thread1([&] {
|
||||
for (auto i = 0; i < 100; i++) {
|
||||
@@ -1037,7 +1039,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(ConcurrentUse)) {
|
||||
|
||||
TEST(OfflineDatabase, PutReturnsSize) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Response compressible;
|
||||
compressible.data = std::make_shared<std::string>(1024, 0);
|
||||
@@ -1056,7 +1058,7 @@ TEST(OfflineDatabase, PutReturnsSize) {
|
||||
|
||||
TEST(OfflineDatabase, PutEvictsLeastRecentlyUsedResources) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
Response response;
|
||||
@@ -1076,7 +1078,7 @@ TEST(OfflineDatabase, PutEvictsLeastRecentlyUsedResources) {
|
||||
|
||||
TEST(OfflineDatabase, OfflineRegionDoesNotAffectAmbientCacheSize) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
unsigned dataSize = 1024u * 100u;
|
||||
unsigned numberOfCachedResources = 2u;
|
||||
unsigned databasePage = 4096u;
|
||||
@@ -1097,10 +1099,10 @@ TEST(OfflineDatabase, OfflineRegionDoesNotAffectAmbientCacheSize) {
|
||||
|
||||
// 1MB of offline region data.
|
||||
for (std::size_t i = 0; i < 5; ++i) {
|
||||
const Resource tile = Resource::tile("mapbox://tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
const Resource tile = Resource::tile("maptiler://tiles/tiles/tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
db.putRegionResource(region->getID(), tile, response);
|
||||
|
||||
const Resource style = Resource::style("mapbox://style_" + std::to_string(i));
|
||||
const Resource style = Resource::style("maptiler://maps/style_" + std::to_string(i));
|
||||
db.putRegionResource(region->getID(), style, response);
|
||||
}
|
||||
|
||||
@@ -1115,7 +1117,7 @@ TEST(OfflineDatabase, OfflineRegionDoesNotAffectAmbientCacheSize) {
|
||||
|
||||
TEST(OfflineDatabase, PutRegionResourceDoesNotEvict) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
|
||||
@@ -1137,7 +1139,7 @@ TEST(OfflineDatabase, PutRegionResourceDoesNotEvict) {
|
||||
|
||||
TEST(OfflineDatabase, PutFailsWhenEvictionInsuffices) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
Response big;
|
||||
@@ -1156,7 +1158,7 @@ TEST(OfflineDatabase, PutFailsWhenEvictionInsuffices) {
|
||||
|
||||
TEST(OfflineDatabase, GetRegionCompletedStatus) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, false };
|
||||
OfflineRegionMetadata metadata;
|
||||
auto region = db.createRegion(definition, metadata);
|
||||
@@ -1195,7 +1197,7 @@ TEST(OfflineDatabase, GetRegionCompletedStatus) {
|
||||
|
||||
TEST(OfflineDatabase, HasRegionResource) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
|
||||
@@ -1221,7 +1223,7 @@ TEST(OfflineDatabase, HasRegionResource) {
|
||||
|
||||
TEST(OfflineDatabase, HasRegionResourceTile) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, false };
|
||||
@@ -1257,7 +1259,7 @@ TEST(OfflineDatabase, HasRegionResourceTile) {
|
||||
|
||||
TEST(OfflineDatabase, OfflineMapboxTileCount) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
OfflineTilePyramidRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0 , true};
|
||||
OfflineRegionMetadata metadata;
|
||||
|
||||
@@ -1267,8 +1269,8 @@ TEST(OfflineDatabase, OfflineMapboxTileCount) {
|
||||
ASSERT_TRUE(region2);
|
||||
|
||||
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);
|
||||
Resource mapboxTile1 = Resource::tile("maptiler://tiles/tiles/1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
|
||||
Resource mapboxTile2 = Resource::tile("maptiler://tiles/tiles/2", 1.0, 0, 0, 1, Tileset::Scheme::XYZ);
|
||||
|
||||
Response response;
|
||||
response.data = std::make_shared<std::string>("data");
|
||||
@@ -1318,7 +1320,7 @@ TEST(OfflineDatabase, OfflineMapboxTileCount) {
|
||||
|
||||
TEST(OfflineDatabase, BatchInsertion) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
OfflineTilePyramidRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0, true };
|
||||
@@ -1345,7 +1347,7 @@ TEST(OfflineDatabase, BatchInsertion) {
|
||||
|
||||
TEST(OfflineDatabase, BatchInsertionMapboxTileCountExceeded) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setOfflineMapboxTileCountLimit(1);
|
||||
db.setMaximumAmbientCacheSize(1024 * 100);
|
||||
|
||||
@@ -1358,8 +1360,8 @@ TEST(OfflineDatabase, BatchInsertionMapboxTileCountExceeded) {
|
||||
std::list<std::tuple<Resource, Response>> resources;
|
||||
|
||||
resources.emplace_back(Resource::style("http://example.com/"), response);
|
||||
resources.emplace_back(Resource::tile("mapbox://tiles/1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
|
||||
resources.emplace_back(Resource::tile("mapbox://tiles/2", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
|
||||
resources.emplace_back(Resource::tile("maptiler://tiles/1", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
|
||||
resources.emplace_back(Resource::tile("maptiler://tiles/2", 1.0, 0, 0, 0, Tileset::Scheme::XYZ), response);
|
||||
|
||||
OfflineRegionStatus status;
|
||||
try {
|
||||
@@ -1385,7 +1387,7 @@ TEST(OfflineDatabase, MigrateFromV2Schema) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/v2.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
auto regions = db.listRegions();
|
||||
@@ -1409,7 +1411,7 @@ TEST(OfflineDatabase, MigrateFromV3Schema) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/v3.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
@@ -1430,7 +1432,7 @@ TEST(OfflineDatabase, MigrateFromV4Schema) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/v4.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
@@ -1458,7 +1460,7 @@ TEST(OfflineDatabase, MigrateFromV5Schema) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/v5.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
@@ -1498,7 +1500,7 @@ TEST(OfflineDatabase, IncrementalVacuum) {
|
||||
EXPECT_EQ(0, databaseAutoVacuum(filename));
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
|
||||
auto regions = db.listRegions().value();
|
||||
@@ -1520,7 +1522,7 @@ TEST(OfflineDatabase, DowngradeSchema) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/v999.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setMaximumAmbientCacheSize(0);
|
||||
}
|
||||
|
||||
@@ -1544,7 +1546,7 @@ TEST(OfflineDatabase, CorruptDatabaseOnOpen) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/corrupt-immediate.db");
|
||||
|
||||
// This database is corrupt in a way that will prevent opening the database.
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
EXPECT_EQ(1u, log.count(error(ResultCode::Corrupt, "Can't open database: database disk image is malformed"), true));
|
||||
EXPECT_EQ(1u, log.count({ EventSeverity::Warning, Event::Database, -1, "Removing existing incompatible offline database" }));
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
@@ -1567,7 +1569,7 @@ TEST(OfflineDatabase, CorruptDatabaseOnQuery) {
|
||||
|
||||
// This database is corrupt in a way that won't manifest itself until we start querying it,
|
||||
// so just opening it will not cause an error.
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
|
||||
// Just opening this corrupt database should not have produced an error yet, since
|
||||
// PRAGMA user_version still succeeds with this database.
|
||||
@@ -1596,12 +1598,12 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DisallowedIO)) {
|
||||
deleteDatabaseFiles();
|
||||
test::SQLite3TestFS fs;
|
||||
|
||||
OfflineDatabase db(filename_test_fs);
|
||||
OfflineDatabase db(filename_test_fs, fixture::tileServerOptions);
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
|
||||
// First, create a region object so that we can try deleting it later.
|
||||
OfflineTilePyramidRegionDefinition definition(
|
||||
"mapbox://style", LatLngBounds::hull({ 37.66, -122.57 }, { 37.83, -122.32 }), 0, 8, 2, false);
|
||||
"maptiler://maps/style", LatLngBounds::hull({ 37.66, -122.57 }, { 37.83, -122.32 }), 0, 8, 2, false);
|
||||
auto region = db.createRegion(definition, {});
|
||||
ASSERT_TRUE(region);
|
||||
|
||||
@@ -1671,17 +1673,19 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_New) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat.db");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
EXPECT_EQ(0u, db.listRegions()->size());
|
||||
|
||||
|
||||
OfflineDatabase db_sideload(filename_sideload, fixture::tileServerOptions);
|
||||
auto newRegionsCount = db_sideload.listRegions()->size();
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_EQ(1u, result->size());
|
||||
EXPECT_EQ(1u, db.listRegions()->size());
|
||||
EXPECT_EQ(newRegionsCount, db.listRegions()->size());
|
||||
|
||||
auto regionId = result->front().getID();
|
||||
auto status = db.getRegionCompletedStatus(regionId);
|
||||
EXPECT_EQ(2u, status->completedResourceCount);
|
||||
EXPECT_EQ(1u, status->completedTileCount);
|
||||
EXPECT_EQ(398u, status->completedResourceCount);
|
||||
EXPECT_EQ(5u, status->completedTileCount);
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update)) {
|
||||
@@ -1692,69 +1696,77 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update))
|
||||
int64_t regionId;
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
std::string tileURL = "maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg";
|
||||
OfflineDatabase db1(filename_sideload, fixture::tileServerOptions);
|
||||
auto originalTile = db1.getRegionResource(
|
||||
Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
auto originalStamp = originalTile->first.modified;
|
||||
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
auto regions = db.listRegions();
|
||||
EXPECT_EQ(1u, db.listRegions()->size());
|
||||
regionId = regions->front().getID();
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_EQ(1u, result->size());
|
||||
// When updating an identical region, the region id remains unchanged.
|
||||
EXPECT_EQ(regionId, result->front().getID());
|
||||
|
||||
auto status = db.getRegionCompletedStatus(regionId);
|
||||
EXPECT_EQ(5u, status->completedResourceCount);
|
||||
EXPECT_EQ(1u, status->completedTileCount);
|
||||
EXPECT_EQ(395u, status->completedResourceCount);
|
||||
EXPECT_EQ(2u, status->completedTileCount);
|
||||
|
||||
//Verify the modified timestamp matches the tile in the sideloaded db.
|
||||
auto updatedTile = db.getRegionResource(
|
||||
Resource::tile("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.webp",
|
||||
1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
EXPECT_EQ(Timestamp{ Seconds(1520409600) }, *(updatedTile->first.modified));
|
||||
Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
|
||||
auto updatedStamp = updatedTile->first.modified;
|
||||
EXPECT_EQ(*originalStamp, *updatedStamp);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_NoUpdate) {
|
||||
deleteDatabaseFiles();
|
||||
util::deleteFile(filename_sideload);
|
||||
|
||||
|
||||
//Swap sideload/main database from update test and ensure that an older tile is not copied over
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/satellite_test.db");
|
||||
util::copyFile(filename, "test/fixtures/offline_database/sideload_sat.db");
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
|
||||
std::string tileURL = "maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg";
|
||||
auto originalTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
auto originalStamp = originalTile->first.modified;
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_EQ(1u, result->size());
|
||||
EXPECT_EQ(1u, db.listRegions()->size());
|
||||
EXPECT_EQ(2u, db.listRegions()->size());
|
||||
|
||||
auto updatedTile = db.getRegionResource(
|
||||
Resource::tile("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.webp",
|
||||
1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
auto updatedTile = db.getRegionResource(Resource::tile(tileURL,1, 0, 0, 1, Tileset::Scheme::XYZ));
|
||||
|
||||
//Verify the modified timestamp matches the tile in the main db.
|
||||
EXPECT_EQ(Timestamp{ Seconds(1520409600) }, *(updatedTile->first.modified));
|
||||
EXPECT_EQ(originalStamp, updatedTile->first.modified);
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_ambient.db");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
|
||||
EXPECT_TRUE(bool(db.hasRegionResource(Resource::tile("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", 1, 0, 0, 1, Tileset::Scheme::XYZ))));
|
||||
EXPECT_TRUE(bool(db.hasRegionResource(Resource::tile("maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg", 1, 0, 0, 1, Tileset::Scheme::XYZ))));
|
||||
|
||||
//Ambient resources should not be copied
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::style("mapbox://styles/mapbox/streets-v9"))));
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::tile("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", 1, 0, 1, 2, Tileset::Scheme::XYZ))));
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::tile("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", 1, 1, 1, 2, Tileset::Scheme::XYZ))));
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::style("maptiler://maps/streets"))));
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::tile("maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg", 1, 0, 1, 2, Tileset::Scheme::XYZ))));
|
||||
EXPECT_FALSE(bool(db.hasRegionResource(Resource::tile("maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg", 1, 1, 1, 2, Tileset::Scheme::XYZ))));
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, MergeDatabaseWithMultipleRegions_New) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
EXPECT_EQ(0u, db.listRegions()->size());
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
@@ -1763,13 +1775,13 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegions_New) {
|
||||
|
||||
auto region1Id = result->front().getID();
|
||||
auto status = db.getRegionCompletedStatus(region1Id);
|
||||
EXPECT_EQ(4u, status->completedResourceCount);
|
||||
EXPECT_EQ(3u, status->completedTileCount);
|
||||
EXPECT_EQ(398u, status->completedResourceCount);
|
||||
EXPECT_EQ(5u, status->completedTileCount);
|
||||
|
||||
auto region2Id = result->back().getID();
|
||||
status = db.getRegionCompletedStatus(region2Id);
|
||||
EXPECT_EQ(1u, status->completedTileCount);
|
||||
EXPECT_EQ(2u, status->completedResourceCount);
|
||||
EXPECT_EQ(0u, status->completedTileCount);
|
||||
EXPECT_EQ(200u, status->completedResourceCount);
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) {
|
||||
@@ -1779,12 +1791,12 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) {
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db");
|
||||
|
||||
{
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
EXPECT_EQ(1u, db.listRegions()->size());
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_EQ(2u, result->size());
|
||||
EXPECT_EQ(3u, db.listRegions()->size());
|
||||
EXPECT_EQ(2u, db.listRegions()->size());
|
||||
}
|
||||
|
||||
mapbox::sqlite::Database db = mapbox::sqlite::Database::open(filename, mapbox::sqlite::ReadOnly);
|
||||
@@ -1798,7 +1810,7 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) {
|
||||
query.run();
|
||||
|
||||
// Ensure multiple entries for tiles shared between regions
|
||||
EXPECT_EQ(1 + 3 + 1, query.get<int>(0));
|
||||
EXPECT_EQ(5, query.get<int>(0));
|
||||
}
|
||||
{
|
||||
// clang-format off
|
||||
@@ -1810,7 +1822,7 @@ TEST(OfflineDatabase, MergeDatabaseWithMultipleRegionsWithOverlap) {
|
||||
query.run();
|
||||
|
||||
// Ensure multiple entries for resources shared between regions
|
||||
EXPECT_EQ(1 + 1 + 1, query.get<int>(0));
|
||||
EXPECT_EQ(593, query.get<int>(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1819,7 +1831,7 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyNewTiles) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat_multiple.db");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.setOfflineMapboxTileCountLimit(1);
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
@@ -1835,7 +1847,7 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegionTooManyExistingTiles) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/sideload_sat_multiple.db");
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/satellite_test.db");
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.setOfflineMapboxTileCountLimit(2);
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
@@ -1851,7 +1863,7 @@ TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_FALSE(result);
|
||||
@@ -1866,7 +1878,7 @@ TEST(OfflineDatabase, MergeDatabaseWithInvalidDb) {
|
||||
util::deleteFile(filename_sideload);
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/corrupt-immediate.db");
|
||||
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
auto result = db.mergeDatabase(filename_sideload);
|
||||
EXPECT_FALSE(result);
|
||||
@@ -1885,7 +1897,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithDiskFull)) {
|
||||
util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db");
|
||||
util::copyFile(filename_sideload, "test/fixtures/offline_database/sideload_sat.db");
|
||||
|
||||
OfflineDatabase db(filename_test_fs);
|
||||
OfflineDatabase db(filename_test_fs, fixture::tileServerOptions);
|
||||
|
||||
fs.setWriteLimit(0);
|
||||
|
||||
@@ -1899,7 +1911,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithDiskFull)) {
|
||||
|
||||
TEST(OfflineDatabase, ChangePath) {
|
||||
std::string newPath("test/fixtures/offline_database/test.db");
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
db.changePath(newPath);
|
||||
mapbox::sqlite::Database::open(newPath, mapbox::sqlite::ReadOnly);
|
||||
util::deleteFile(newPath);
|
||||
@@ -1910,7 +1922,7 @@ TEST(OfflineDatabase, ResetDatabase) {
|
||||
deleteDatabaseFiles();
|
||||
util::copyFile(filename, "test/fixtures/offline_database/satellite_test.db");
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
auto result = db.resetDatabase();
|
||||
EXPECT_FALSE(result);
|
||||
|
||||
@@ -1922,7 +1934,7 @@ TEST(OfflineDatabase, ResetDatabase) {
|
||||
|
||||
TEST(OfflineDatabase, PutResourceReadOnlyMode) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:");
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Resource resource{Resource::Style, "http://example.com/"};
|
||||
Response response;
|
||||
@@ -1951,7 +1963,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(UpdateDatabaseReadOnlyMode)) {
|
||||
FixtureLog log;
|
||||
deleteDatabaseFiles();
|
||||
|
||||
OfflineDatabase db(filename);
|
||||
OfflineDatabase db(filename, fixture::tileServerOptions);
|
||||
db.reopenDatabaseReadOnly(true /*readOnly*/);
|
||||
db.clearAmbientCache();
|
||||
EXPECT_EQ(1u,
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
class OfflineTest {
|
||||
public:
|
||||
OfflineTest(const std::string& path = ":memory:") : db(path) {
|
||||
OfflineTest(const std::string& path = ":memory:") : db(path, TileServerOptions::MapTilerConfiguration()) {
|
||||
}
|
||||
|
||||
util::RunLoop loop;
|
||||
@@ -542,6 +542,10 @@ TEST(OfflineDownload, TileCountLimitExceededNoTileResponse) {
|
||||
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
|
||||
return test.response("mapbox_source.style.json");
|
||||
};
|
||||
// test.fileSource.tileResponse = [&] (const Resource& resource) {
|
||||
// EXPECT_EQ("maptiler://0-0-0.vector.pbf", resource.url);
|
||||
// return test.response("0-0-0.vector.pbf");
|
||||
// };
|
||||
|
||||
auto observer = std::make_unique<MockObserver>();
|
||||
bool mapboxTileCountLimitExceededCalled = false;
|
||||
@@ -588,7 +592,7 @@ TEST(OfflineDownload, TileCountLimitExceededWithTileResponse) {
|
||||
|
||||
test.fileSource.tileResponse = [&] (const Resource& resource) {
|
||||
const Resource::TileData& tile = *resource.tileData;
|
||||
EXPECT_EQ("mapbox://{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ("maptiler://{z}-{x}-{y}.vector.pbf", tile.urlTemplate);
|
||||
EXPECT_EQ(1, tile.pixelRatio);
|
||||
EXPECT_EQ(0, tile.x);
|
||||
EXPECT_EQ(0, tile.y);
|
||||
@@ -1130,4 +1134,4 @@ TEST(OfflineDownload, NoFreezingOnNotFoundError) {
|
||||
|
||||
test.loop.run();
|
||||
// Passes if does not freeze.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/storage/online_file_source.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/test/util.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
@@ -14,7 +15,7 @@ using namespace mbgl;
|
||||
|
||||
TEST(OnlineFileSource, Cancel) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
fs->request({Resource::Unknown, "http://127.0.0.1:3000/test"},
|
||||
[&](Response) { ADD_FAILURE() << "Callback should not be called"; });
|
||||
@@ -24,7 +25,7 @@ TEST(OnlineFileSource, Cancel) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(CancelMultiple)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
|
||||
|
||||
@@ -48,7 +49,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(CancelMultiple)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(TemporaryError)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const auto start = Clock::now();
|
||||
int counter = 0;
|
||||
@@ -88,7 +89,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(TemporaryError)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(ConnectionError)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const auto start = Clock::now();
|
||||
int counter = 0;
|
||||
@@ -119,7 +120,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(ConnectionError)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Timeout)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
@@ -146,7 +147,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Timeout)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryDelayOnExpiredTile)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
@@ -166,7 +167,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryDelayOnExpiredTile)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryOnClockSkew)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
@@ -195,7 +196,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryOnClockSkew)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
// Very long expiration time, should never arrive.
|
||||
Resource resource1{ Resource::Unknown, "http://127.0.0.1:3000/test" };
|
||||
@@ -219,7 +220,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectMinimumUpdateInterval)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
auto start = util::now();
|
||||
Resource resource{Resource::Unknown, "http://127.0.0.1:3000/test"};
|
||||
@@ -237,7 +238,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectMinimumUpdateInterval)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Load)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const int concurrency = 50;
|
||||
const int max = 10000;
|
||||
@@ -281,7 +282,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Load)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusChange)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/delayed" };
|
||||
|
||||
@@ -311,7 +312,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusChange)) {
|
||||
// reachability issues.
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusChangePreempt)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
fs->pause();
|
||||
|
||||
const auto start = Clock::now();
|
||||
@@ -354,7 +355,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusChangePreempt)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusOnlineOffline)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
|
||||
|
||||
@@ -382,7 +383,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusOnlineOffline)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitStandard)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
auto req = fs->request({Resource::Unknown, "http://127.0.0.1:3000/rate-limit?std=true"}, [&](Response res) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
@@ -397,7 +398,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitStandard)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitMBX)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
auto req = fs->request({Resource::Unknown, "http://127.0.0.1:3000/rate-limit?mbx=true"}, [&](Response res) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
@@ -412,7 +413,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitMBX)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitDefault)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
auto req = fs->request({Resource::Unknown, "http://127.0.0.1:3000/rate-limit"}, [&](Response res) {
|
||||
ASSERT_NE(nullptr, res.error);
|
||||
@@ -424,36 +425,83 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitDefault)) {
|
||||
loop.run();
|
||||
}
|
||||
|
||||
TEST(OnlineFileSource, GetBaseURLAndAccessTokenWhilePaused) {
|
||||
TEST(OnlineFileSource, GetBaseURLAndApiKeyWhilePaused) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
fs->pause();
|
||||
|
||||
auto baseURL = "http://url";
|
||||
auto accessToken = "access_token";
|
||||
auto apiKey = "api_key";
|
||||
|
||||
fs->setProperty(API_BASE_URL_KEY, baseURL);
|
||||
fs->setProperty(ACCESS_TOKEN_KEY, accessToken);
|
||||
fs->setProperty(API_KEY_KEY, apiKey);
|
||||
|
||||
EXPECT_EQ(*fs->getProperty(API_BASE_URL_KEY).getString(), baseURL);
|
||||
EXPECT_EQ(*fs->getProperty(ACCESS_TOKEN_KEY).getString(), accessToken);
|
||||
EXPECT_EQ(*fs->getProperty(API_KEY_KEY).getString(), apiKey);
|
||||
}
|
||||
|
||||
TEST(OnlineFileSource, ChangeAPIBaseURL){
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
|
||||
EXPECT_EQ(mbgl::util::API_BASE_URL, *fs->getProperty(API_BASE_URL_KEY).getString());
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
EXPECT_EQ(ResourceOptions::Default().tileServerOptions().baseURL(), *fs->getProperty(API_BASE_URL_KEY).getString());
|
||||
const std::string customURL = "test.domain";
|
||||
fs->setProperty(API_BASE_URL_KEY, customURL);
|
||||
EXPECT_EQ(customURL, *fs->getProperty(API_BASE_URL_KEY).getString());
|
||||
|
||||
auto updatedTileServerOptions = fs->getResourceOptions().tileServerOptions();
|
||||
EXPECT_EQ(customURL, updatedTileServerOptions.baseURL());
|
||||
}
|
||||
|
||||
TEST(OnlineFileSource, ChangeTileServerOptions){
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
TileServerOptions tileServerOptsChanged;
|
||||
tileServerOptsChanged.withApiKeyParameterName("apiKeyChanged")
|
||||
.withBaseURL("baseURLChanged")
|
||||
.withDefaultStyle("defaultStyleChanged")
|
||||
.withGlyphsTemplate("defaultGlyphsTemplateChanged", "glyphsDomainChanged", {})
|
||||
.withSourceTemplate("sourceTemplateChanged", "sourceDomainChanged", {})
|
||||
.withSpritesTemplate("spritesTemplateChanged", "spritesDomainChanged", {})
|
||||
.withStyleTemplate("styleTemplateChanged", "styleDomainChanged", {})
|
||||
.withTileTemplate("tileTemplateChanged", "tileDomainChanged", {})
|
||||
.withUriSchemeAlias("uriSchemeAliasChanged");
|
||||
ResourceOptions resOpts;
|
||||
resOpts.withApiKey("changedAPIKey")
|
||||
.withTileServerOptions(tileServerOptsChanged);
|
||||
|
||||
fs->setResourceOptions(resOpts.clone());
|
||||
|
||||
auto actualResourceOpts = fs->getResourceOptions();
|
||||
|
||||
EXPECT_EQ(tileServerOptsChanged.baseURL(), *fs->getProperty(API_BASE_URL_KEY).getString());
|
||||
EXPECT_EQ(actualResourceOpts.apiKey(), *fs->getProperty(API_KEY_KEY).getString());
|
||||
|
||||
EXPECT_EQ(resOpts.apiKey(), actualResourceOpts.apiKey());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().defaultStyle(), tileServerOptsChanged.defaultStyle());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().baseURL(), tileServerOptsChanged.baseURL());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().glyphsTemplate(), tileServerOptsChanged.glyphsTemplate());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().glyphsDomainName(), tileServerOptsChanged.glyphsDomainName());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().glyphsVersionPrefix(), tileServerOptsChanged.glyphsVersionPrefix());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().sourceTemplate(), tileServerOptsChanged.sourceTemplate());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().sourceDomainName(), tileServerOptsChanged.sourceDomainName());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().sourceVersionPrefix(), tileServerOptsChanged.sourceVersionPrefix());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().spritesTemplate(), tileServerOptsChanged.spritesTemplate());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().spritesDomainName(), tileServerOptsChanged.spritesDomainName());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().spritesVersionPrefix(), tileServerOptsChanged.spritesVersionPrefix());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().tileTemplate(), tileServerOptsChanged.tileTemplate());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().tileDomainName(), tileServerOptsChanged.tileDomainName());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().tileVersionPrefix(), tileServerOptsChanged.tileVersionPrefix());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().styleTemplate(), tileServerOptsChanged.styleTemplate());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().styleDomainName(), tileServerOptsChanged.styleDomainName());
|
||||
EXPECT_EQ(resOpts.tileServerOptions().styleVersionPrefix(), tileServerOptsChanged.styleVersionPrefix());
|
||||
}
|
||||
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequests)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
std::size_t response_counter = 0;
|
||||
const std::size_t NUM_REQUESTS = 3;
|
||||
|
||||
@@ -495,7 +543,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequests)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
int response_counter = 0;
|
||||
int correct_low = 0;
|
||||
int correct_regular = 0;
|
||||
@@ -550,7 +598,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(MaximumConcurrentRequests)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
ASSERT_EQ(*fs->getProperty(MAX_CONCURRENT_REQUESTS_KEY).getUint(), 20u);
|
||||
|
||||
@@ -560,7 +608,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(MaximumConcurrentRequests)) {
|
||||
|
||||
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RequestSameUrlMultipleTimes)) {
|
||||
util::RunLoop loop;
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
|
||||
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>(ResourceOptions::Default());
|
||||
|
||||
int count = 0;
|
||||
std::vector<std::unique_ptr<AsyncRequest>> requests;
|
||||
|
||||
@@ -41,12 +41,10 @@ private:
|
||||
TEST(SyncFileSource, LoadSyncRender) {
|
||||
util::RunLoop loop;
|
||||
auto fs = std::make_shared<SyncFileSource>();
|
||||
fs->add("mapbox://mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7",
|
||||
fs->add("maptiler://maps/streets",
|
||||
util::read_file("test/fixtures/resources/source_vector.json"));
|
||||
fs->add("mapbox://sprites/mapbox/streets-v9.png",
|
||||
fs->add("maptiler://sprites/streets/sprite",
|
||||
util::read_file("test/fixtures/resources/sprite.png"));
|
||||
fs->add("mapbox://sprites/mapbox/streets-v9.json",
|
||||
util::read_file("test/fixtures/resources/sprite.json"));
|
||||
HeadlessFrontend frontend{ { 512, 512 }, 1.0 };
|
||||
MapAdapter map{ frontend, MapObserver::nullObserver(), fs, MapOptions() };
|
||||
map.getStyle().loadJSON(util::read_file("test/fixtures/resources/style_vector.json"));
|
||||
|
||||
@@ -65,10 +65,10 @@ TEST(Style, DuplicateSource) {
|
||||
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mptiler://tiles/contours"));
|
||||
|
||||
try {
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mptiler://tiles/contours"));
|
||||
FAIL() << "Should not have been allowed to add a duplicate source id";
|
||||
} catch (const std::runtime_error&) {
|
||||
// Expected
|
||||
@@ -86,7 +86,7 @@ TEST(Style, RemoveSourceInUse) {
|
||||
|
||||
style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
style.addSource(std::make_unique<VectorSource>("sourceId", "mptiler://tiles/contours"));
|
||||
style.addLayer(std::make_unique<LineLayer>("layerId", "sourceId"));
|
||||
|
||||
// Should not remove the source
|
||||
@@ -109,9 +109,9 @@ TEST(Style, SourceImplsOrder) {
|
||||
auto fileSource = std::make_shared<StubFileSource>();
|
||||
Style::Impl style{fileSource, 1.0};
|
||||
|
||||
style.addSource(std::make_unique<VectorSource>("c", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
style.addSource(std::make_unique<VectorSource>("b", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
style.addSource(std::make_unique<VectorSource>("a", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
style.addSource(std::make_unique<VectorSource>("c", "mptiler://tiles/contours"));
|
||||
style.addSource(std::make_unique<VectorSource>("b", "mptiler://tiles/contours"));
|
||||
style.addSource(std::make_unique<VectorSource>("a", "mptiler://tiles/contours"));
|
||||
|
||||
auto sources = style.getSources();
|
||||
ASSERT_EQ(3u, sources.size());
|
||||
@@ -158,4 +158,4 @@ TEST(Style, AddRemoveRemoveImage) {
|
||||
EXPECT_TRUE(!!style.getImage("three"));
|
||||
EXPECT_FALSE(!!style.getImage("two"));
|
||||
EXPECT_FALSE(!!style.getImage("four"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/tile/vector_tile.hpp>
|
||||
#include <mbgl/tile/vector_tile_data.hpp>
|
||||
#include <mbgl/tile/tile_loader_impl.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/map/transform.hpp>
|
||||
@@ -22,7 +23,7 @@ using namespace mbgl;
|
||||
|
||||
class VectorTileTest {
|
||||
public:
|
||||
std::shared_ptr<FileSource> fileSource = std::make_shared<FakeFileSource>();
|
||||
std::shared_ptr<FileSource> fileSource = std::make_shared<FakeFileSource>(ResourceOptions::Default());
|
||||
TransformState transformState;
|
||||
util::RunLoop loop;
|
||||
style::Style style{fileSource, 1};
|
||||
|
||||
@@ -4,197 +4,205 @@
|
||||
#include <mbgl/util/mapbox.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/tileset.hpp>
|
||||
#include <mbgl/util/tile_server_options.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace mbgl;
|
||||
using SourceType = mbgl::style::SourceType;
|
||||
|
||||
namespace mapboxFixture {
|
||||
const TileServerOptions mapboxTileServerOptions = TileServerOptions::MapboxConfiguration();
|
||||
const TileServerOptions mapLibreTileServerOptions = TileServerOptions::MapLibreConfiguration();
|
||||
const TileServerOptions mapTilerTileServerOptions = TileServerOptions::MapTilerConfiguration();
|
||||
} // namespace fixture
|
||||
|
||||
TEST(Mapbox, SourceURL) {
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/user.map.json?access_token=key&secure",
|
||||
mbgl::util::mapbox::normalizeSourceURL(util::API_BASE_URL, "mapbox://user.map", "key"));
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapboxTileServerOptions, "mapbox://user.map", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.example.com/v4/user.map.json?access_token=key&secure",
|
||||
mbgl::util::mapbox::normalizeSourceURL("https://api.example.com", "mapbox://user.map", "key"));
|
||||
mbgl::util::mapbox::normalizeSourceURL(TileServerOptions(mapboxFixture::mapboxTileServerOptions).withBaseURL("https://api.example.com"), "mapbox://user.map", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/user.map.json?access_token=key&secure&style=mapbox://styles/mapbox/streets-v9@0",
|
||||
mbgl::util::mapbox::normalizeSourceURL(util::API_BASE_URL, "mapbox://user.map?style=mapbox://styles/mapbox/streets-v9@0", "key"));
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapboxTileServerOptions, "mapbox://user.map?style=mapbox://styles/mapbox/streets-v9@0", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/user.map.json?access_token=key&secure",
|
||||
mbgl::util::mapbox::normalizeSourceURL(util::API_BASE_URL, "mapbox://user.map?", "key"));
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapboxTileServerOptions, "mapbox://user.map?", "key"));
|
||||
EXPECT_EQ(
|
||||
"http://path",
|
||||
mbgl::util::mapbox::normalizeSourceURL(util::API_BASE_URL, "http://path", "key"));
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapboxTileServerOptions, "http://path", "key"));
|
||||
EXPECT_THROW(
|
||||
mbgl::util::mapbox::normalizeSourceURL(util::API_BASE_URL, "mapbox://user.map", ""),
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapboxTileServerOptions, "mapbox://user.map", ""),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(Mapbox, GlyphsURL) {
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/fonts/v1/boxmap/Comic%20Sans/0-255.pbf?access_token=key",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(util::API_BASE_URL, "mapbox://fonts/boxmap/Comic%20Sans/0-255.pbf", "key"));
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapboxTileServerOptions, "mapbox://fonts/boxmap/Comic%20Sans/0-255.pbf", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.example.com/fonts/v1/boxmap/Comic%20Sans/0-255.pbf?access_token=key",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL("https://api.example.com", "mapbox://fonts/boxmap/Comic%20Sans/0-255.pbf", "key"));
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(TileServerOptions(mapboxFixture::mapboxTileServerOptions).withBaseURL("https://api.example.com"), "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(util::API_BASE_URL, "mapbox://fonts/boxmap/{fontstack}/{range}.pbf", "key"));
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapboxTileServerOptions, "mapbox://fonts/boxmap/{fontstack}/{range}.pbf", "key"));
|
||||
EXPECT_EQ(
|
||||
"http://path",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(util::API_BASE_URL, "http://path", "key"));
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapboxTileServerOptions, "http://path", "key"));
|
||||
EXPECT_EQ(
|
||||
"mapbox://path",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(util::API_BASE_URL, "mapbox://path", "key"));
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapboxTileServerOptions, "mapbox://path", "key"));
|
||||
}
|
||||
|
||||
TEST(Mapbox, StyleURL) {
|
||||
EXPECT_EQ(
|
||||
"mapbox://foo",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "mapbox://foo", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "mapbox://foo", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/user/style?access_token=key",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "mapbox://styles/user/style", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "mapbox://styles/user/style", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.example.com/styles/v1/user/style?access_token=key",
|
||||
mbgl::util::mapbox::normalizeStyleURL("https://api.example.com", "mapbox://styles/user/style", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(TileServerOptions(mapboxFixture::mapboxTileServerOptions).withBaseURL("https://api.example.com"), "mapbox://styles/user/style", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/user/style/draft?access_token=key",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "mapbox://styles/user/style/draft", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "mapbox://styles/user/style/draft", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/user/style?access_token=key&shave=true",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "mapbox://styles/user/style?shave=true", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "mapbox://styles/user/style?shave=true", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/user/style?access_token=key",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "mapbox://styles/user/style?", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "mapbox://styles/user/style?", "key"));
|
||||
EXPECT_EQ(
|
||||
"http://path",
|
||||
mbgl::util::mapbox::normalizeStyleURL(util::API_BASE_URL, "http://path", "key"));
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapboxTileServerOptions, "http://path", "key"));
|
||||
}
|
||||
|
||||
TEST(Mapbox, SpriteURL) {
|
||||
EXPECT_EQ(
|
||||
"map/box/sprites@2x.json",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL, "map/box/sprites@2x.json", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "map/box/sprites@2x.json", "key"));
|
||||
EXPECT_EQ(
|
||||
"mapbox://foo",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL, "mapbox://foo", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "mapbox://foo", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/mapbox/streets-v8/sprite.json?access_token=key",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL, "mapbox://sprites/mapbox/streets-v8.json", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "mapbox://sprites/mapbox/streets-v8.json", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.example.com/styles/v1/mapbox/streets-v8/sprite.json?access_token=key",
|
||||
mbgl::util::mapbox::normalizeSpriteURL("https://api.example.com", "mapbox://sprites/mapbox/streets-v8.json", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(TileServerOptions(mapboxFixture::mapboxTileServerOptions).withBaseURL("https://api.example.com"), "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(util::API_BASE_URL, "mapbox://sprites/mapbox/streets-v8@2x.png", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "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(util::API_BASE_URL, "mapbox://sprites/mapbox/streets-v8/draft@2x.png", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "mapbox://sprites/mapbox/streets-v8/draft@2x.png", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/styles/v1/mapbox/streets-v11/sprite?access_token=key&fresh=true.png",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL,
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions,
|
||||
"mapbox://sprites/mapbox/streets-v11?fresh=true.png",
|
||||
"key"));
|
||||
EXPECT_EQ("mapbox://////", mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL, "mapbox://////", "key"));
|
||||
EXPECT_EQ("mapbox://////", mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "mapbox://////", "key"));
|
||||
}
|
||||
|
||||
TEST(Mapbox, TileURL) {
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b/0/0/0.pbf?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0.pbf", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b/0/0/0.pbf", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b/0/0/0.pbf?access_token=key&style=mapbox://styles/mapbox/streets-v9@0",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0.pbf?style=mapbox://styles/mapbox/streets-v9@0", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b/0/0/0.pbf?style=mapbox://styles/mapbox/streets-v9@0", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b/0/0/0.pbf?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0.pbf?", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b/0/0/0.pbf?", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b/0/0/0.png?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0.png", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b/0/0/0.png", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.example.com/v4/a.b/0/0/0.png?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL("https://api.example.com", "mapbox://tiles/a.b/0/0/0.png", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(TileServerOptions(mapboxFixture::mapboxTileServerOptions).withBaseURL("https://api.example.com"), "mapbox://tiles/a.b/0/0/0.png", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b/0/0/0@2x.png?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0@2x.png", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b/0/0/0@2x.png", "key"));
|
||||
EXPECT_EQ(
|
||||
"https://api.mapbox.com/v4/a.b,c.d/0/0/0.pbf?access_token=key",
|
||||
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b,c.d/0/0/0.pbf", "key"));
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapboxTileServerOptions, "mapbox://tiles/a.b,c.d/0/0/0.pbf", "key"));
|
||||
EXPECT_EQ(
|
||||
"http://path",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(util::API_BASE_URL, "http://path", "key"));
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapboxTileServerOptions, "http://path", "key"));
|
||||
}
|
||||
|
||||
TEST(Mapbox, CanonicalURL) {
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://b.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://b.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions,"http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("https://api.mapbox.cn/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions,"https://api.mapbox.cn/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b,c.d/{z}/{x}/{y}.vector.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b,c.d/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions,"http://api.mapbox.com/v4/a.b,c.d/{z}/{x}/{y}.vector.pbf?access_token=key", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key&custom=parameter", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions,"http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?access_token=key&custom=parameter", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter&access_token=key", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter&access_token=key", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter&second=param",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter&access_token=key&second=param", SourceType::Vector, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://a.tiles.mapbox.com/v4/a.b/{z}/{x}/{y}.vector.pbf?custom=parameter&access_token=key&second=param", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.jpg",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg?access_token=key", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg?access_token=key", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.jpg70",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg70?access_token=key", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg70?access_token=key", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.jpg",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg?access_token=key", SourceType::Raster, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg?access_token=key", SourceType::Raster, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.jpg70",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg70?access_token=key", SourceType::Raster, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg70?access_token=key", SourceType::Raster, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.png",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.png",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.png",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 512));
|
||||
EXPECT_EQ(
|
||||
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.png",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 512));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 512));
|
||||
|
||||
// We don't ever expect to see these inputs, but be safe anyway.
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"http://path",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://path", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://path", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"http://api.mapbox.com/v4/",
|
||||
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/", SourceType::Raster, 256));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"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));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.", SourceType::Raster, 256));
|
||||
EXPECT_EQ(
|
||||
"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));
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapboxTileServerOptions, "http://api.mapbox.com/v4/a.b/{z}/{x}/{y}/.", SourceType::Raster, 256));
|
||||
}
|
||||
|
||||
TEST(Mapbox, CanonicalizeRasterTileset) {
|
||||
@@ -203,7 +211,7 @@ TEST(Mapbox, CanonicalizeRasterTileset) {
|
||||
"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);
|
||||
mbgl::util::mapbox::canonicalizeTileset(mapboxFixture::mapboxTileServerOptions, tileset, "mapbox://mapbox.satellite", SourceType::Raster, 256);
|
||||
|
||||
EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", tileset.tiles[0]);
|
||||
}
|
||||
@@ -214,7 +222,211 @@ TEST(Mapbox, CanonicalizeVectorTileset) {
|
||||
"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);
|
||||
mbgl::util::mapbox::canonicalizeTileset(mapboxFixture::mapboxTileServerOptions, tileset, "mapbox://mapbox.streets", SourceType::Vector, 512);
|
||||
|
||||
EXPECT_EQ("mapbox://tiles/mapbox.streets/{z}/{x}/{y}.vector.pbf", tileset.tiles[0]);
|
||||
}
|
||||
|
||||
// MapLibre tests
|
||||
TEST(MapLibre, CanonicalURL) {
|
||||
EXPECT_EQ(
|
||||
"https://demotiles.maplibre.org/style.json",
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapLibreTileServerOptions, "maplibre://maps/style", ""));
|
||||
EXPECT_EQ(
|
||||
"https://demotiles.maplibre.org/tiles/tiles.json",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapLibreTileServerOptions, "maplibre://tiles/tiles", ""));
|
||||
EXPECT_EQ(
|
||||
"https://demotiles.maplibre.org/font/{fontstack}/{start}-{end}.pbf",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapLibreTileServerOptions, "maplibre://fonts/{fontstack}/{start}-{end}.pbf", ""));
|
||||
|
||||
EXPECT_EQ(
|
||||
"maplibre://tiles/tiles/{z}/{x}/{y}.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapLibreTileServerOptions, "https://demotiles.maplibre.org/tiles/{z}/{x}/{y}.pbf", SourceType::Vector, 512));
|
||||
}
|
||||
|
||||
// MapTiler tests
|
||||
TEST(MapTiler, StyleURL) {
|
||||
//Styles
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/maps/basic/style.json",
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://maps/basic", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/maps/basic/style.json?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://maps/basic", "abcdef"));
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::normalizeStyleURL(mapboxFixture::mapTilerTileServerOptions, "", ""));
|
||||
EXPECT_EQ(
|
||||
"https://dummy",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://dummy", ""));
|
||||
}
|
||||
|
||||
// Sources
|
||||
TEST(MapTiler, SourceURL) {
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/tiles/v3/tiles.json?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://sources/v3", "abcdef"));
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/tiles/outdoor/tiles.json?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://sources/outdoor", "abcdef"));
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/tiles/7ac429c7-c96e-46dd-8c3e-13d48988986a/tiles.json?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://sources/7ac429c7-c96e-46dd-8c3e-13d48988986a", "abcdef"));
|
||||
|
||||
EXPECT_EQ(
|
||||
"maptiler://sources/v3",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/tiles/v3/tiles.json?key=abcdef"));
|
||||
EXPECT_EQ(
|
||||
"maptiler://sources/outdoor",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/tiles/outdoor/tiles.json?key=abcdef"));
|
||||
EXPECT_EQ(
|
||||
"maptiler://sources/7ac429c7-c96e-46dd-8c3e-13d48988986a",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/tiles/7ac429c7-c96e-46dd-8c3e-13d48988986a/tiles.json?key=abcdef"));
|
||||
}
|
||||
|
||||
TEST(MapTiler, SourceURLPassThrough) {
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::normalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy"));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234"));
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::canonicalizeSourceURL(mapboxFixture::mapTilerTileServerOptions, ""));
|
||||
}
|
||||
|
||||
TEST(MapTiler, GlyphsURL) {
|
||||
// Glyphs
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/fonts/{fontstack}/{range}.pbf",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://fonts/{fontstack}/{range}.pbf", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://fonts/{fontstack}/{range}.pbf", "abcdef"));
|
||||
|
||||
EXPECT_EQ(
|
||||
"maptiler://fonts/{fontstack}/{range}.pbf",
|
||||
mbgl::util::mapbox::canonicalizeGlyphURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf"));
|
||||
EXPECT_EQ(
|
||||
"maptiler://fonts/{fontstack}/{range}.pbf",
|
||||
mbgl::util::mapbox::canonicalizeGlyphURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=abcdef"));
|
||||
}
|
||||
|
||||
TEST(MapTiler, GlyphsURLPassThrough) {
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapTilerTileServerOptions, "", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::normalizeGlyphsURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::canonicalizeGlyphURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy"));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::canonicalizeGlyphURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234"));
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::canonicalizeGlyphURL(mapboxFixture::mapTilerTileServerOptions, ""));
|
||||
}
|
||||
|
||||
TEST(MapTiler, Sprites) {
|
||||
// Sprites
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/maps/streets/sprite",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://sprites/streets/sprite", ""));
|
||||
// Sprites
|
||||
EXPECT_EQ(
|
||||
"maptiler://sprites/streets/sprite",
|
||||
mbgl::util::mapbox::canonicalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/maps/streets/sprite"));
|
||||
}
|
||||
|
||||
TEST(MapTiler, SpritesURLPassThrough) {
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::normalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::canonicalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy"));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::canonicalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234"));
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::canonicalizeSpriteURL(mapboxFixture::mapTilerTileServerOptions, ""));
|
||||
}
|
||||
|
||||
TEST(MapTiler, Tiles) {
|
||||
// Tiles
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/tiles/contours/{z}/{x}/{y}.pbf?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://tiles/tiles/contours/{z}/{x}/{y}.pbf", "abcdef"));
|
||||
EXPECT_EQ(
|
||||
"https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=abcdef",
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "maptiler://tiles/tiles/v3/{z}/{x}/{y}.pbf", "abcdef"));
|
||||
EXPECT_EQ(
|
||||
"maptiler://tiles/tiles/contours/{z}/{x}/{y}.pbf",
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "https://api.maptiler.com/tiles/contours/{z}/{x}/{y}.pbf?key=abcdef", SourceType::Vector, 512));
|
||||
}
|
||||
|
||||
TEST(MapTiler, TilesURLPassThrough) {
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy", ""));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::normalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234", ""));
|
||||
EXPECT_EQ(
|
||||
"http://dummy",
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "http://dummy", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"https://api.tileserver.com/map?key=1234",
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "https://api.tileserver.com/map?key=1234", SourceType::Vector, 512));
|
||||
EXPECT_EQ(
|
||||
"",
|
||||
mbgl::util::mapbox::canonicalizeTileURL(mapboxFixture::mapTilerTileServerOptions, "", SourceType::Vector, 512));
|
||||
}
|
||||
|
||||
TEST(MapTiler, CanonicalizeRasterTileset) {
|
||||
mbgl::Tileset tileset;
|
||||
tileset.tiles = {
|
||||
"https://api.maptiler.com/tiles/satellite/{z}/{x}/{y}.jpg?key=abcdef"
|
||||
};
|
||||
|
||||
mbgl::util::mapbox::canonicalizeTileset(mapboxFixture::mapTilerTileServerOptions, tileset, "maptiler://tiles/satellite", SourceType::Raster, 256);
|
||||
|
||||
EXPECT_EQ("maptiler://tiles/tiles/satellite/{z}/{x}/{y}{ratio}.jpg", tileset.tiles[0]);
|
||||
}
|
||||
|
||||
TEST(MapTiler, CanonicalizeVectorTileset) {
|
||||
mbgl::Tileset tileset;
|
||||
tileset.tiles = {
|
||||
"https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=abcdef"
|
||||
};
|
||||
|
||||
mbgl::util::mapbox::canonicalizeTileset(mapboxFixture::mapTilerTileServerOptions, tileset, "maptiler://tiles/streets", SourceType::Vector, 512);
|
||||
|
||||
EXPECT_EQ("maptiler://tiles/tiles/v3/{z}/{x}/{y}.pbf", tileset.tiles[0]);
|
||||
}
|
||||
|
||||
@@ -26,9 +26,19 @@ using namespace std::literals::string_literals;
|
||||
class MemoryTest {
|
||||
public:
|
||||
MemoryTest() {
|
||||
fileSource->styleResponse = [&](const Resource& res) { return response("style_" + getType(res) + ".json");};
|
||||
fileSource->tileResponse = [&](const Resource& res) { return response(getType(res) + ".tile"); };
|
||||
fileSource->sourceResponse = [&](const Resource& res) { return response("source_" + getType(res) + ".json"); };
|
||||
fileSource->styleResponse = [&](const Resource& res) {
|
||||
auto resName = "style_" + getType(res) + ".json";
|
||||
return response(resName);
|
||||
};
|
||||
fileSource->tileResponse = [&](const Resource& res) {
|
||||
auto resName = getType(res) + ".tile";
|
||||
return response(resName);
|
||||
};
|
||||
fileSource->sourceResponse = [&](const Resource& res) {
|
||||
auto resName = "source_" + getType(res) + ".json";
|
||||
return response(resName);
|
||||
|
||||
};
|
||||
fileSource->glyphsResponse = [&](const Resource&) { return response("glyphs.pbf"); };
|
||||
fileSource->spriteJSONResponse = [&](const Resource&) { return response("sprite.json"); };
|
||||
fileSource->spriteImageResponse = [&](const Resource&) { return response("sprite.png"); };
|
||||
@@ -56,7 +66,7 @@ private:
|
||||
}
|
||||
|
||||
std::string getType(const Resource& res) {
|
||||
if (res.url.find("satellite") != std::string::npos) {
|
||||
if (res.url.find("hybrid") != std::string::npos || res.url.find("satellite") != std::string::npos) {
|
||||
return "raster";
|
||||
} else {
|
||||
return "vector";
|
||||
@@ -74,7 +84,7 @@ TEST(Memory, Vector) {
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
|
||||
map.jumpTo(CameraOptions().withZoom(16));
|
||||
map.getStyle().loadURL("mapbox://streets");
|
||||
map.getStyle().loadURL("maptiler://maps/streets");
|
||||
|
||||
frontend.render(map);
|
||||
}
|
||||
@@ -86,7 +96,7 @@ TEST(Memory, Raster) {
|
||||
HeadlessFrontend frontend { { 256, 256 }, ratio };
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
|
||||
map.getStyle().loadURL("mapbox://satellite");
|
||||
map.getStyle().loadURL("maptiler://maps/hybrid");
|
||||
|
||||
frontend.render(map);
|
||||
}
|
||||
@@ -135,8 +145,8 @@ TEST(Memory, Footprint) {
|
||||
|
||||
// Warm up buffers and cache.
|
||||
for (unsigned i = 0; i < 10; ++i) {
|
||||
FrontendAndMap(test, "mapbox://streets");
|
||||
FrontendAndMap(test, "mapbox://satellite");
|
||||
FrontendAndMap(test, "maptiler://maps/streets");
|
||||
FrontendAndMap(test, "maptiler://maps/hybrid");
|
||||
}
|
||||
|
||||
// Process close callbacks, mostly needed by
|
||||
@@ -148,14 +158,14 @@ TEST(Memory, Footprint) {
|
||||
|
||||
long vectorInitialRSS = mbgl::test::getCurrentRSS();
|
||||
for (unsigned i = 0; i < runs; ++i) {
|
||||
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "mapbox://streets"));
|
||||
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "maptiler://maps/streets"));
|
||||
}
|
||||
|
||||
double vectorFootprint = (mbgl::test::getCurrentRSS() - vectorInitialRSS) / double(runs);
|
||||
|
||||
long rasterInitialRSS = mbgl::test::getCurrentRSS();
|
||||
for (unsigned i = 0; i < runs; ++i) {
|
||||
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "mapbox://satellite"));
|
||||
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "maptiler://maps/hybrid"));
|
||||
}
|
||||
|
||||
double rasterFootprint = (mbgl::test::getCurrentRSS() - rasterInitialRSS) / double(runs);
|
||||
|
||||
20
test/util/tile_server_options.test.cpp
Normal file
20
test/util/tile_server_options.test.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
#include <mbgl/util/tile_server_options.hpp>
|
||||
|
||||
|
||||
TEST(TileServerOptions, CopyAssignment) {
|
||||
mbgl::TileServerOptions options = mbgl::TileServerOptions::MapboxConfiguration();
|
||||
mbgl::TileServerOptions optionsCopy = options;
|
||||
|
||||
EXPECT_FALSE(&optionsCopy == &options);
|
||||
EXPECT_EQ(optionsCopy.baseURL(), options.baseURL());
|
||||
}
|
||||
|
||||
TEST(TileServerOptions, CopyConstructor) {
|
||||
mbgl::TileServerOptions options = mbgl::TileServerOptions::MapboxConfiguration();
|
||||
mbgl::TileServerOptions optionsCopy = mbgl::TileServerOptions(options);
|
||||
|
||||
EXPECT_FALSE(&optionsCopy == &options);
|
||||
EXPECT_EQ(optionsCopy.baseURL(), options.baseURL());
|
||||
}
|
||||
Reference in New Issue
Block a user