summaryrefslogtreecommitdiff
path: root/platform/node/test/suite_implementation.js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/node/test/suite_implementation.js')
-rw-r--r--platform/node/test/suite_implementation.js44
1 files changed, 32 insertions, 12 deletions
diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js
index bde8acde18..6648757a98 100644
--- a/platform/node/test/suite_implementation.js
+++ b/platform/node/test/suite_implementation.js
@@ -2,6 +2,9 @@
var mbgl = require('../index');
var request = require('request');
+var PNG = require('pngjs').PNG;
+var fs = require('fs');
+var path = require('path');
mbgl.on('message', function(msg) {
console.log('%s (%s): %s', msg.severity, msg.class, msg.text);
@@ -30,16 +33,17 @@ module.exports = function (style, options, callback) {
callback(new Error('timed out after 20 seconds'));
}, 20000);
- options.center = style.center;
- options.zoom = style.zoom;
- options.bearing = style.bearing;
- options.pitch = style.pitch;
options.debug = {
tileBorders: options.debug,
collision: options.collisionDebug,
overdraw: options.showOverdrawInspector,
};
+ options.center = style.center || [0, 0];
+ options.zoom = style.zoom || 0;
+ options.bearing = style.bearing || 0;
+ options.pitch = style.pitch || 0;
+
map.load(style);
applyOperations(options.operations, function() {
@@ -60,16 +64,32 @@ module.exports = function (style, options, callback) {
callback();
} else if (operation[0] === 'wait') {
- var wait = function() {
- if (map.loaded()) {
- applyOperations(operations.slice(1), callback);
- } else {
- map.render(options, wait);
- }
- };
- wait();
+ map.render(options, function () {
+ applyOperations(operations.slice(1), callback);
+ });
+
+ } else if (operation[0] === 'addImage') {
+ var img = PNG.sync.read(fs.readFileSync(path.join(__dirname, '../../../mapbox-gl-js/test/integration', operation[2])));
+ map.addImage(operation[1], img.data, {
+ height: img.height,
+ width: img.width,
+ pixelRatio: 1
+ });
+
+ applyOperations(operations.slice(1), callback);
} else {
+ // Ensure that the next `map.render(options)` does not overwrite this change.
+ if (operation[0] === 'setCenter') {
+ options.center = operation[1];
+ } else if (operation[0] === 'setZoom') {
+ options.zoom = operation[1];
+ } else if (operation[0] === 'setBearing') {
+ options.bearing = operation[1];
+ } else if (operation[0] === 'setPitch') {
+ options.pitch = operation[1];
+ }
+
map[operation[0]].apply(map, operation.slice(1));
applyOperations(operations.slice(1), callback);
}