diff options
Diffstat (limited to 'platform')
20 files changed, 277 insertions, 2 deletions
diff --git a/platform/node/test/fixtures/glyphs/0-255.pbf b/platform/node/test/fixtures/glyphs/0-255.pbf Binary files differnew file mode 100644 index 0000000000..cea1c094d6 --- /dev/null +++ b/platform/node/test/fixtures/glyphs/0-255.pbf diff --git a/platform/node/test/fixtures/sprites/1x.json b/platform/node/test/fixtures/sprites/1x.json new file mode 100644 index 0000000000..123abb40d4 --- /dev/null +++ b/platform/node/test/fixtures/sprites/1x.json @@ -0,0 +1,9 @@ +{ + "icon": { + "width": 20, + "height": 56, + "x": 0, + "y": 0, + "pixelRatio": 1 + } +}
\ No newline at end of file diff --git a/platform/node/test/fixtures/sprites/1x.png b/platform/node/test/fixtures/sprites/1x.png Binary files differnew file mode 100644 index 0000000000..b112096c18 --- /dev/null +++ b/platform/node/test/fixtures/sprites/1x.png diff --git a/platform/node/test/fixtures/sprites/satellite-v8.json b/platform/node/test/fixtures/sprites/satellite-v8.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/platform/node/test/fixtures/sprites/satellite-v8.json @@ -0,0 +1 @@ +{}
\ No newline at end of file diff --git a/platform/node/test/fixtures/sprites/satellite-v8.png b/platform/node/test/fixtures/sprites/satellite-v8.png Binary files differnew file mode 100644 index 0000000000..01aa8fd93f --- /dev/null +++ b/platform/node/test/fixtures/sprites/satellite-v8.png diff --git a/platform/node/test/fixtures/sprites/satellite-v9.json b/platform/node/test/fixtures/sprites/satellite-v9.json new file mode 100644 index 0000000000..7bf2d2f78b --- /dev/null +++ b/platform/node/test/fixtures/sprites/satellite-v9.json @@ -0,0 +1 @@ +{"alcohol-shop-15":{"width":23,"height":23,"x":0,"y":0,"pixelRatio":1},"amusement-park-15":{"width":23,"height":23,"x":23,"y":0,"pixelRatio":1},"aquarium-15":{"width":23,"height":23,"x":0,"y":23,"pixelRatio":1},"art-gallery-15":{"width":23,"height":23,"x":23,"y":23,"pixelRatio":1},"attraction-15":{"width":23,"height":23,"x":46,"y":0,"pixelRatio":1},"bank-15":{"width":23,"height":23,"x":69,"y":0,"pixelRatio":1},"bicycle-15":{"width":23,"height":23,"x":46,"y":23,"pixelRatio":1},"bicycle-share-15":{"width":23,"height":23,"x":69,"y":23,"pixelRatio":1},"car-15":{"width":23,"height":23,"x":0,"y":46,"pixelRatio":1},"castle-15":{"width":23,"height":23,"x":23,"y":46,"pixelRatio":1},"cinema-15":{"width":23,"height":23,"x":46,"y":46,"pixelRatio":1},"circle-15":{"width":23,"height":23,"x":69,"y":46,"pixelRatio":1},"circle-stroked-15":{"width":23,"height":23,"x":0,"y":69,"pixelRatio":1},"clothing-store-15":{"width":23,"height":23,"x":23,"y":69,"pixelRatio":1},"drinking-water-15":{"width":23,"height":23,"x":46,"y":69,"pixelRatio":1},"embassy-15":{"width":23,"height":23,"x":69,"y":69,"pixelRatio":1},"fire-station-15":{"width":23,"height":23,"x":92,"y":0,"pixelRatio":1},"fuel-15":{"width":23,"height":23,"x":115,"y":0,"pixelRatio":1},"grocery-15":{"width":23,"height":23,"x":138,"y":0,"pixelRatio":1},"harbor-15":{"width":23,"height":23,"x":161,"y":0,"pixelRatio":1},"information-15":{"width":23,"height":23,"x":92,"y":23,"pixelRatio":1},"laundry-15":{"width":23,"height":23,"x":115,"y":23,"pixelRatio":1},"library-15":{"width":23,"height":23,"x":138,"y":23,"pixelRatio":1},"lodging-15":{"width":23,"height":23,"x":161,"y":23,"pixelRatio":1},"monument-15":{"width":23,"height":23,"x":92,"y":46,"pixelRatio":1},"museum-15":{"width":23,"height":23,"x":115,"y":46,"pixelRatio":1},"music-15":{"width":23,"height":23,"x":138,"y":46,"pixelRatio":1},"place-of-worship-15":{"width":23,"height":23,"x":161,"y":46,"pixelRatio":1},"police-15":{"width":23,"height":23,"x":92,"y":69,"pixelRatio":1},"post-15":{"width":23,"height":23,"x":115,"y":69,"pixelRatio":1},"prison-15":{"width":23,"height":23,"x":138,"y":69,"pixelRatio":1},"religious-christian-15":{"width":23,"height":23,"x":161,"y":69,"pixelRatio":1},"religious-jewish-15":{"width":23,"height":23,"x":0,"y":92,"pixelRatio":1},"religious-muslim-15":{"width":23,"height":23,"x":23,"y":92,"pixelRatio":1},"shop-15":{"width":23,"height":23,"x":46,"y":92,"pixelRatio":1},"stadium-15":{"width":23,"height":23,"x":69,"y":92,"pixelRatio":1},"star-15":{"width":23,"height":23,"x":92,"y":92,"pixelRatio":1},"suitcase-15":{"width":23,"height":23,"x":115,"y":92,"pixelRatio":1},"swimming-15":{"width":23,"height":23,"x":138,"y":92,"pixelRatio":1},"theatre-15":{"width":23,"height":23,"x":161,"y":92,"pixelRatio":1},"toilet-15":{"width":23,"height":23,"x":0,"y":115,"pixelRatio":1},"town-hall-15":{"width":23,"height":23,"x":23,"y":115,"pixelRatio":1},"triangle-15":{"width":23,"height":23,"x":46,"y":115,"pixelRatio":1},"triangle-stroked-15":{"width":23,"height":23,"x":69,"y":115,"pixelRatio":1},"veterinary-15":{"width":23,"height":23,"x":92,"y":115,"pixelRatio":1},"airfield-15":{"width":21,"height":21,"x":115,"y":115,"pixelRatio":1},"airport-15":{"width":21,"height":21,"x":136,"y":115,"pixelRatio":1},"bus-15":{"width":21,"height":21,"x":157,"y":115,"pixelRatio":1},"entrance-15":{"width":21,"height":21,"x":0,"y":138,"pixelRatio":1},"ferry-15":{"width":21,"height":21,"x":21,"y":138,"pixelRatio":1},"heliport-15":{"width":21,"height":21,"x":42,"y":138,"pixelRatio":1},"rail-15":{"width":21,"height":21,"x":63,"y":138,"pixelRatio":1},"rail-light-15":{"width":21,"height":21,"x":84,"y":138,"pixelRatio":1},"rail-metro-15":{"width":21,"height":21,"x":105,"y":138,"pixelRatio":1},"rocket-15":{"width":21,"height":21,"x":126,"y":138,"pixelRatio":1},"alcohol-shop-11":{"width":19,"height":19,"x":147,"y":138,"pixelRatio":1},"amusement-park-11":{"width":19,"height":19,"x":0,"y":159,"pixelRatio":1},"aquarium-11":{"width":19,"height":19,"x":19,"y":159,"pixelRatio":1},"art-gallery-11":{"width":19,"height":19,"x":38,"y":159,"pixelRatio":1},"attraction-11":{"width":19,"height":19,"x":57,"y":159,"pixelRatio":1},"bakery-15":{"width":19,"height":19,"x":76,"y":159,"pixelRatio":1},"bank-11":{"width":19,"height":19,"x":95,"y":159,"pixelRatio":1},"bar-15":{"width":19,"height":19,"x":114,"y":159,"pixelRatio":1},"beer-15":{"width":19,"height":19,"x":133,"y":159,"pixelRatio":1},"bicycle-11":{"width":19,"height":19,"x":152,"y":159,"pixelRatio":1},"bicycle-share-11":{"width":19,"height":19,"x":171,"y":159,"pixelRatio":1},"cafe-15":{"width":19,"height":19,"x":190,"y":159,"pixelRatio":1},"campsite-15":{"width":19,"height":19,"x":209,"y":159,"pixelRatio":1},"car-11":{"width":19,"height":19,"x":228,"y":159,"pixelRatio":1},"castle-11":{"width":19,"height":19,"x":247,"y":159,"pixelRatio":1},"cemetery-15":{"width":19,"height":19,"x":266,"y":159,"pixelRatio":1},"cinema-11":{"width":19,"height":19,"x":285,"y":159,"pixelRatio":1},"circle-11":{"width":19,"height":19,"x":304,"y":159,"pixelRatio":1},"circle-stroked-11":{"width":19,"height":19,"x":323,"y":159,"pixelRatio":1},"clothing-store-11":{"width":19,"height":19,"x":342,"y":159,"pixelRatio":1},"college-15":{"width":19,"height":19,"x":166,"y":138,"pixelRatio":1},"dentist-15":{"width":19,"height":19,"x":185,"y":138,"pixelRatio":1},"doctor-15":{"width":19,"height":19,"x":204,"y":138,"pixelRatio":1},"dog-park-15":{"width":19,"height":19,"x":223,"y":138,"pixelRatio":1},"drinking-water-11":{"width":19,"height":19,"x":242,"y":138,"pixelRatio":1},"embassy-11":{"width":19,"height":19,"x":261,"y":138,"pixelRatio":1},"fast-food-15":{"width":19,"height":19,"x":280,"y":138,"pixelRatio":1},"fire-station-11":{"width":19,"height":19,"x":299,"y":138,"pixelRatio":1},"fuel-11":{"width":19,"height":19,"x":318,"y":138,"pixelRatio":1},"garden-15":{"width":19,"height":19,"x":337,"y":138,"pixelRatio":1},"golf-15":{"width":19,"height":19,"x":184,"y":0,"pixelRatio":1},"grocery-11":{"width":19,"height":19,"x":203,"y":0,"pixelRatio":1},"harbor-11":{"width":19,"height":19,"x":222,"y":0,"pixelRatio":1},"hospital-15":{"width":19,"height":19,"x":241,"y":0,"pixelRatio":1},"ice-cream-15":{"width":19,"height":19,"x":260,"y":0,"pixelRatio":1},"information-11":{"width":19,"height":19,"x":279,"y":0,"pixelRatio":1},"laundry-11":{"width":19,"height":19,"x":298,"y":0,"pixelRatio":1},"library-11":{"width":19,"height":19,"x":317,"y":0,"pixelRatio":1},"lodging-11":{"width":19,"height":19,"x":336,"y":0,"pixelRatio":1},"monument-11":{"width":19,"height":19,"x":184,"y":23,"pixelRatio":1},"mountain-15":{"width":19,"height":19,"x":203,"y":23,"pixelRatio":1},"museum-11":{"width":19,"height":19,"x":222,"y":23,"pixelRatio":1},"music-11":{"width":19,"height":19,"x":241,"y":23,"pixelRatio":1},"park-15":{"width":19,"height":19,"x":260,"y":23,"pixelRatio":1},"pharmacy-15":{"width":19,"height":19,"x":279,"y":23,"pixelRatio":1},"picnic-site-15":{"width":19,"height":19,"x":298,"y":23,"pixelRatio":1},"place-of-worship-11":{"width":19,"height":19,"x":317,"y":23,"pixelRatio":1},"playground-15":{"width":19,"height":19,"x":336,"y":23,"pixelRatio":1},"police-11":{"width":19,"height":19,"x":184,"y":46,"pixelRatio":1},"post-11":{"width":19,"height":19,"x":203,"y":46,"pixelRatio":1},"prison-11":{"width":19,"height":19,"x":222,"y":46,"pixelRatio":1},"religious-christian-11":{"width":19,"height":19,"x":241,"y":46,"pixelRatio":1},"religious-jewish-11":{"width":19,"height":19,"x":260,"y":46,"pixelRatio":1},"religious-muslim-11":{"width":19,"height":19,"x":279,"y":46,"pixelRatio":1},"restaurant-15":{"width":19,"height":19,"x":298,"y":46,"pixelRatio":1},"school-15":{"width":19,"height":19,"x":317,"y":46,"pixelRatio":1},"shop-11":{"width":19,"height":19,"x":336,"y":46,"pixelRatio":1},"stadium-11":{"width":19,"height":19,"x":184,"y":69,"pixelRatio":1},"star-11":{"width":19,"height":19,"x":203,"y":69,"pixelRatio":1},"suitcase-11":{"width":19,"height":19,"x":222,"y":69,"pixelRatio":1},"swimming-11":{"width":19,"height":19,"x":241,"y":69,"pixelRatio":1},"theatre-11":{"width":19,"height":19,"x":260,"y":69,"pixelRatio":1},"toilet-11":{"width":19,"height":19,"x":279,"y":69,"pixelRatio":1},"town-hall-11":{"width":19,"height":19,"x":298,"y":69,"pixelRatio":1},"triangle-11":{"width":19,"height":19,"x":317,"y":69,"pixelRatio":1},"triangle-stroked-11":{"width":19,"height":19,"x":336,"y":69,"pixelRatio":1},"veterinary-11":{"width":19,"height":19,"x":184,"y":92,"pixelRatio":1},"volcano-15":{"width":19,"height":19,"x":203,"y":92,"pixelRatio":1},"zoo-15":{"width":19,"height":19,"x":222,"y":92,"pixelRatio":1},"airfield-11":{"width":17,"height":17,"x":241,"y":92,"pixelRatio":1},"airport-11":{"width":17,"height":17,"x":258,"y":92,"pixelRatio":1},"bus-11":{"width":17,"height":17,"x":275,"y":92,"pixelRatio":1},"entrance-11":{"width":17,"height":17,"x":292,"y":92,"pixelRatio":1},"ferry-11":{"width":17,"height":17,"x":309,"y":92,"pixelRatio":1},"heliport-11":{"width":17,"height":17,"x":326,"y":92,"pixelRatio":1},"rail-11":{"width":17,"height":17,"x":343,"y":92,"pixelRatio":1},"rail-light-11":{"width":17,"height":17,"x":178,"y":115,"pixelRatio":1},"rail-metro-11":{"width":17,"height":17,"x":195,"y":115,"pixelRatio":1},"rocket-11":{"width":17,"height":17,"x":212,"y":115,"pixelRatio":1},"bakery-11":{"width":15,"height":15,"x":229,"y":115,"pixelRatio":1},"bar-11":{"width":15,"height":15,"x":244,"y":115,"pixelRatio":1},"beer-11":{"width":15,"height":15,"x":259,"y":115,"pixelRatio":1},"cafe-11":{"width":15,"height":15,"x":274,"y":115,"pixelRatio":1},"campsite-11":{"width":15,"height":15,"x":289,"y":115,"pixelRatio":1},"cemetery-11":{"width":15,"height":15,"x":304,"y":115,"pixelRatio":1},"college-11":{"width":15,"height":15,"x":319,"y":115,"pixelRatio":1},"dentist-11":{"width":15,"height":15,"x":334,"y":115,"pixelRatio":1},"doctor-11":{"width":15,"height":15,"x":349,"y":115,"pixelRatio":1},"dog-park-11":{"width":15,"height":15,"x":0,"y":178,"pixelRatio":1},"fast-food-11":{"width":15,"height":15,"x":15,"y":178,"pixelRatio":1},"garden-11":{"width":15,"height":15,"x":30,"y":178,"pixelRatio":1},"golf-11":{"width":15,"height":15,"x":45,"y":178,"pixelRatio":1},"hospital-11":{"width":15,"height":15,"x":60,"y":178,"pixelRatio":1},"ice-cream-11":{"width":15,"height":15,"x":75,"y":178,"pixelRatio":1},"mountain-11":{"width":15,"height":15,"x":90,"y":178,"pixelRatio":1},"park-11":{"width":15,"height":15,"x":105,"y":178,"pixelRatio":1},"pharmacy-11":{"width":15,"height":15,"x":120,"y":178,"pixelRatio":1},"picnic-site-11":{"width":15,"height":15,"x":135,"y":178,"pixelRatio":1},"playground-11":{"width":15,"height":15,"x":150,"y":178,"pixelRatio":1},"restaurant-11":{"width":15,"height":15,"x":165,"y":178,"pixelRatio":1},"school-11":{"width":15,"height":15,"x":180,"y":178,"pixelRatio":1},"volcano-11":{"width":15,"height":15,"x":195,"y":178,"pixelRatio":1},"zoo-11":{"width":15,"height":15,"x":210,"y":178,"pixelRatio":1}}
\ No newline at end of file diff --git a/platform/node/test/fixtures/sprites/satellite-v9.png b/platform/node/test/fixtures/sprites/satellite-v9.png Binary files differnew file mode 100644 index 0000000000..00ad93514f --- /dev/null +++ b/platform/node/test/fixtures/sprites/satellite-v9.png diff --git a/platform/node/test/fixtures/styles/glyphs.json b/platform/node/test/fixtures/styles/glyphs.json new file mode 100644 index 0000000000..aef3134de1 --- /dev/null +++ b/platform/node/test/fixtures/styles/glyphs.json @@ -0,0 +1,56 @@ +{ + "version": 8, + "metadata": { + "test": { + "height": 256 + } + }, + "center": [ + 13.418056, + 52.499167 + ], + "zoom": 14, + "sources": { + "mapbox": { + "type": "vector", + "maxzoom": 14, + "tiles": [ + "./fixtures/tiles/{z}-{x}-{y}.mvt" + ] + } + }, + "glyphs": "./fixtures/glyphs/{range}.pbf", + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "white" + } + }, + { + "id": "text", + "type": "symbol", + "source": "mapbox", + "source-layer": "poi_label", + "filter": [ + "==", + "maki", + "restaurant" + ], + "layout": { + "symbol-placement": "point", + "text-allow-overlap": true, + "text-ignore-placement": true, + "text-field": "Test", + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ] + }, + "paint": { + "text-opacity": 1 + } + } + ] +} diff --git a/platform/node/test/fixtures/styles/satellite-v8.json b/platform/node/test/fixtures/styles/satellite-v8.json new file mode 100644 index 0000000000..cd1d6eaae4 --- /dev/null +++ b/platform/node/test/fixtures/styles/satellite-v8.json @@ -0,0 +1,36 @@ +{ + "version":8, + "name":"Satellite", + "metadata":{"mapbox:autocomposite":true}, + "sources":{ + "mapbox":{ + "type":"raster", + "tiles": [ + "http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png" + ], + "tileSize":256 + } + }, + "sprite":"./fixtures/sprites/satellite-v8", + "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-v8", + "draft":false +} diff --git a/platform/node/test/fixtures/styles/satellite-v9.json b/platform/node/test/fixtures/styles/satellite-v9.json new file mode 100644 index 0000000000..f0e971daef --- /dev/null +++ b/platform/node/test/fixtures/styles/satellite-v9.json @@ -0,0 +1 @@ +{"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}
\ No newline at end of file diff --git a/platform/node/test/fixtures/styles/sprite.json b/platform/node/test/fixtures/styles/sprite.json new file mode 100644 index 0000000000..e6264b8ef5 --- /dev/null +++ b/platform/node/test/fixtures/styles/sprite.json @@ -0,0 +1,26 @@ +{ + "version": 8, + "metadata": { + "test": { + "pixelRatio": 1, + "width": 64, + "height": 64 + } + }, + "center": [ + 0, + 0 + ], + "zoom": 0, + "sources": {}, + "sprite": "./fixtures/sprites/1x", + "layers": [ + { + "id": "default", + "type": "background", + "paint": { + "background-pattern": "icon" + } + } + ] +} diff --git a/platform/node/test/fixtures/styles/streets.json b/platform/node/test/fixtures/styles/streets.json new file mode 100644 index 0000000000..bed0a35188 --- /dev/null +++ b/platform/node/test/fixtures/styles/streets.json @@ -0,0 +1,20 @@ +{ + "version":8, + "sources":{ + "mapbox":{ + "type":"raster", + "tiles": [ + "http://a.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.mvt" + ], + "tileSize":256 + } + }, + "sprite":"./fixtures/sprites/1x", + "glyphs": "./fixtures/glyphs/{range}.pbf", + "layers":[ + { + "type":"vector", + "source":"mapbox" + } + ] +} diff --git a/platform/node/test/fixtures/style.json b/platform/node/test/fixtures/styles/style.json index 222ac82bf8..f9c7471ec8 100644 --- a/platform/node/test/fixtures/style.json +++ b/platform/node/test/fixtures/styles/style.json @@ -6,7 +6,7 @@ "type": "vector", "maxzoom": 15, "tiles": [ - "./fixtures/tiles/{z}-{x}-{y}.vector.pbf" + "./fixtures/tiles/{z}-{x}-{y}.mvt" ] } }, diff --git a/platform/node/test/fixtures/tiles/0-0-0.mvt b/platform/node/test/fixtures/tiles/0-0-0.mvt Binary files differnew file mode 100644 index 0000000000..39bcebd012 --- /dev/null +++ b/platform/node/test/fixtures/tiles/0-0-0.mvt diff --git a/platform/node/test/fixtures/tiles/14-8802-5374.mvt b/platform/node/test/fixtures/tiles/14-8802-5374.mvt Binary files differnew file mode 100644 index 0000000000..bbda53d2a3 --- /dev/null +++ b/platform/node/test/fixtures/tiles/14-8802-5374.mvt diff --git a/platform/node/test/fixtures/tiles/14-8802-5375.mvt b/platform/node/test/fixtures/tiles/14-8802-5375.mvt Binary files differnew file mode 100644 index 0000000000..0cbc8867ab --- /dev/null +++ b/platform/node/test/fixtures/tiles/14-8802-5375.mvt diff --git a/platform/node/test/fixtures/tiles/14-8803-5374.mvt b/platform/node/test/fixtures/tiles/14-8803-5374.mvt Binary files differnew file mode 100644 index 0000000000..9fec68c05b --- /dev/null +++ b/platform/node/test/fixtures/tiles/14-8803-5374.mvt diff --git a/platform/node/test/fixtures/tiles/14-8803-5375.mvt b/platform/node/test/fixtures/tiles/14-8803-5375.mvt Binary files differnew file mode 100644 index 0000000000..de58b8b185 --- /dev/null +++ b/platform/node/test/fixtures/tiles/14-8803-5375.mvt diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 6ffbf3eb66..5021569109 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -4,7 +4,7 @@ var test = require('tape'); var mbgl = require('../../../../lib/mapbox-gl-native'); var fs = require('fs'); var path = require('path'); -var style = require('../fixtures/style.json'); +var style = require('../fixtures/styles/style.json'); test('Map', function(t) { t.test('must be constructed with new', function(t) { diff --git a/platform/node/test/js/partial.test.js b/platform/node/test/js/partial.test.js new file mode 100644 index 0000000000..0095cc6051 --- /dev/null +++ b/platform/node/test/js/partial.test.js @@ -0,0 +1,125 @@ +'use strict'; + +var test = require('tape'); +var mbgl = require('../../../../lib/mapbox-gl-native'); +var fs = require('fs'); +var path = require('path'); +var style = require('../fixtures/styles/style.json'); +var glyphs = require('../fixtures/styles/glyphs.json'); +var sprite = require('../fixtures/styles/sprite.json'); +var satellite = require('../fixtures/styles/satellite-v8.json'); +var streets = require('../fixtures/styles/streets.json'); +var request = require('request'); +var zlib = require('zlib'); + +mbgl.on('message', function(msg) { + console.log('%s (%s): %s', msg.severity, msg.class, msg.text); +}); + +function readFile(req, callback) { + if (/^http/.test(req.url)) { + if (!process.env.MAPBOX_ACCESS_TOKEN) throw "Please set MAPBOX_ACCESS_TOKEN environment variable"; + + request({ + url: req.url, + qs: { + 'access_token': process.env.MAPBOX_ACCESS_TOKEN + }, + gzip: true + }, function(err, res) { + if (err) return callback(err); + + // A non-buffer buffer can just be ignored + if (res.body.length === undefined) return callback(); + + callback(null, { data: new Buffer(res.body) }); + }); + } else { + fs.readFile(path.join(__dirname, '..', req.url), function(err, data) { + if (err) return callback(err); + callback(err, { data: data }); + }); + } +} + +test.skip('Slow tiles', function(t) { + var options = { + request: function(req, callback) { + switch (req.kind) { + case 3: + setTimeout(function() { + readFile(req, callback); + }, 1000); + break; + default: + readFile(req, callback); + } + }, + ratio: 1 + }; + + var map = new mbgl.Map(options); + map.load(style); + + map.render({}, function(err, pixels) { + t.error(err); + t.end(); + }); +}); + +test('Partial tiles with slow resources', function(t) { + var options = { + request: function(req, callback) { + switch (req.kind) { + case 4: + case 5: + case 6: + setTimeout(function() { + readFile(req, callback); + }, 1000); + break; + default: + readFile(req, callback); + } + }, + ratio: 1 + }; + + t.skip('Slow glyphs', function(t) { + var map = new mbgl.Map(options); + map.load(glyphs); + + map.render(glyphs, function(err, pixels) { + t.error(err); + t.end(); + }); + }); + + t.skip('Slow sprite', function(t) { + var map = new mbgl.Map(options); + map.load(sprite); + + map.render(sprite, function(err, pixels) { + t.error(err); + t.end(); + }); + }); + + t.test('Many slow resources', function(t) { + var map = new mbgl.Map(options); + map.load(satellite); + + map.render({ + center: [-122.4403, 37.7497], + zoom: 8, + bearing: 20, + width: 700, + height: 700 + }, function(err, pixels) { + t.error(err); + t.end(); + }); + }); + + t.end(); +}); |