diff options
Diffstat (limited to 'platform/node/test/suite_implementation.js')
-rw-r--r-- | platform/node/test/suite_implementation.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index 323f429bed..b0be2fa0eb 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -14,21 +14,25 @@ mbgl.on('message', function(msg) { var maps = new Map(); module.exports = function (style, options, callback) { + var tileMode = options.mapMode === 'tile'; if (options.recycleMap) { - if (maps.has(options.pixelRatio)) { - var map = maps.get(options.pixelRatio); + var key = options.pixelRatio + '/' + tileMode; + if (maps.has(key)) { + var map = maps.get(key); map.request = mapRequest; } else { - maps.set(options.pixelRatio, new mbgl.Map({ + maps.set(key, new mbgl.Map({ ratio: options.pixelRatio, - request: mapRequest + request: mapRequest, + mode: options.mapMode })); - var map = maps.get(options.pixelRatio); + var map = maps.get(key); } } else { var map = new mbgl.Map({ ratio: options.pixelRatio, - request: mapRequest + request: mapRequest, + mode: options.mapMode }); } @@ -90,6 +94,12 @@ module.exports = function (style, options, callback) { applyOperations(operations.slice(1), callback); }); + } else if (operation[0] === 'sleep') { + // Prefer "wait", which renders until the map is loaded + // Use "sleep" when you need to test something that sidesteps the "loaded" logic + setTimeout(() => { + applyOperations(operations.slice(1), callback); + }, operation[1]); } else if (operation[0] === 'addImage' || operation[0] === 'updateImage') { var img = PNG.sync.read(fs.readFileSync(path.join(__dirname, '../../../mapbox-gl-js/test/integration', operation[2]))); const testOpts = (operation.length > 3) ? operation[3] : {}; |