-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add line, fill, circle, symbol query tests
- Loading branch information
Showing
4 changed files
with
80 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,12 @@ | ||
'use strict'; | ||
|
||
var Map = require('../js/ui/map'); | ||
var browser = require('../js/util/browser'); | ||
var suite = require('mapbox-gl-test-suite').query; | ||
var querySuite = require('mapbox-gl-test-suite').query; | ||
var suiteImplementation = require('./suite_implementation'); | ||
|
||
var tests; | ||
|
||
if (process.argv[1] === __filename && process.argv.length > 2) { | ||
tests = process.argv.slice(2); | ||
} | ||
|
||
suite.run('js', {tests: tests}, function(style, options, callback) { | ||
browser.devicePixelRatio = options.pixelRatio; | ||
|
||
var map = new Map({ | ||
container: { | ||
offsetWidth: options.width, | ||
offsetHeight: options.height, | ||
classList: { | ||
add: function() {} | ||
} | ||
}, | ||
style: style, | ||
classes: options.classes, | ||
interactive: false, | ||
attributionControl: false | ||
}); | ||
|
||
map.painter.prepareBuffers = function() { | ||
var gl = this.gl; | ||
|
||
if (!gl.renderbuffer) { | ||
// Create default renderbuffer | ||
gl.renderbuffer = gl.createRenderbuffer(); | ||
gl.bindRenderbuffer(gl.RENDERBUFFER, gl.renderbuffer); | ||
gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA, gl.drawingBufferWidth, gl.drawingBufferHeight); | ||
} | ||
|
||
if (!gl.stencilbuffer) { | ||
// Create default stencilbuffer | ||
gl.stencilbuffer = gl.createRenderbuffer(); | ||
gl.bindRenderbuffer(gl.RENDERBUFFER, gl.stencilbuffer); | ||
gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, gl.drawingBufferWidth, gl.drawingBufferHeight); | ||
} | ||
|
||
if (!gl.framebuffer) { | ||
// Create frame buffer | ||
gl.framebuffer = gl.createFramebuffer(); | ||
} | ||
|
||
gl.bindFramebuffer(gl.FRAMEBUFFER, gl.framebuffer); | ||
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, gl.renderbuffer); | ||
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, gl.stencilbuffer); | ||
|
||
this.clearColor(); | ||
}; | ||
|
||
map.painter.bindDefaultFramebuffer = function() { | ||
var gl = this.gl; | ||
gl.bindFramebuffer(gl.FRAMEBUFFER, gl.framebuffer); | ||
}; | ||
|
||
map.once('load', function() { | ||
function done(err, results) { | ||
if (err) return callback(err); | ||
callback(null, results.map(function (r) { | ||
delete r.layer; | ||
return r; | ||
})); | ||
} | ||
|
||
if (options.at) { | ||
map.featuresAt(options.at, options, done); | ||
} else { | ||
map.featuresIn(options.in, options, done); | ||
} | ||
}); | ||
}); | ||
querySuite.run('js', {tests: tests}, suiteImplementation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,12 @@ | ||
'use strict'; | ||
|
||
var Map = require('../js/ui/map'); | ||
var browser = require('../js/util/browser'); | ||
var suite = require('mapbox-gl-test-suite').render; | ||
var renderSuite = require('mapbox-gl-test-suite').render; | ||
var suiteImplementation = require('./suite_implementation'); | ||
|
||
var tests; | ||
|
||
if (process.argv[1] === __filename && process.argv.length > 2) { | ||
tests = process.argv.slice(2); | ||
} | ||
|
||
suite.run('js', {tests: tests}, function(style, options, callback) { | ||
browser.devicePixelRatio = options.pixelRatio; | ||
|
||
var map = new Map({ | ||
container: { | ||
offsetWidth: options.width, | ||
offsetHeight: options.height, | ||
classList: { | ||
add: function() {}, | ||
remove: function() {} | ||
} | ||
}, | ||
style: style, | ||
classes: options.classes, | ||
interactive: false, | ||
attributionControl: false | ||
}); | ||
|
||
if (options.debug) map.debug = true; | ||
if (options.collisionDebug) map.collisionDebug = true; | ||
|
||
var gl = map.painter.gl; | ||
|
||
map.once('load', function() { | ||
var w = options.width * browser.devicePixelRatio, | ||
h = options.height * browser.devicePixelRatio; | ||
|
||
var pixels = new Uint8Array(w * h * 4); | ||
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels); | ||
|
||
var data = new Buffer(pixels); | ||
|
||
map.remove(); | ||
gl.destroy(); | ||
|
||
// Flip the scanlines. | ||
var stride = w * 4; | ||
var tmp = new Buffer(stride); | ||
for (var i = 0, j = h - 1; i < j; i++, j--) { | ||
var start = i * stride; | ||
var end = j * stride; | ||
data.copy(tmp, 0, start, start + stride); | ||
data.copy(data, start, end, end + stride); | ||
tmp.copy(data, end); | ||
} | ||
|
||
callback(null, data); | ||
}); | ||
}); | ||
renderSuite.run('js', {tests: tests}, suiteImplementation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
var Map = require('../js/ui/map'); | ||
var browser = require('../js/util/browser'); | ||
|
||
|
||
module.exports = function(style, options, callback) { | ||
browser.devicePixelRatio = options.pixelRatio; | ||
|
||
var map = new Map({ | ||
container: { | ||
offsetWidth: options.width, | ||
offsetHeight: options.height, | ||
classList: { | ||
add: function() {}, | ||
remove: function() {} | ||
} | ||
}, | ||
style: style, | ||
classes: options.classes, | ||
interactive: false, | ||
attributionControl: false | ||
}); | ||
|
||
if (options.debug) map.debug = true; | ||
if (options.collisionDebug) map.collisionDebug = true; | ||
|
||
var gl = map.painter.gl; | ||
|
||
map.once('load', function() { | ||
var w = options.width * browser.devicePixelRatio, | ||
h = options.height * browser.devicePixelRatio; | ||
|
||
var pixels = new Uint8Array(w * h * 4); | ||
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels); | ||
|
||
var data = new Buffer(pixels); | ||
|
||
// Flip the scanlines. | ||
var stride = w * 4; | ||
var tmp = new Buffer(stride); | ||
for (var i = 0, j = h - 1; i < j; i++, j--) { | ||
var start = i * stride; | ||
var end = j * stride; | ||
data.copy(tmp, 0, start, start + stride); | ||
data.copy(data, start, end, end + stride); | ||
tmp.copy(data, end); | ||
} | ||
|
||
if (options.at) { | ||
map.featuresAt(options.at, options, done); | ||
} else if (options.in) { | ||
map.featuresIn(options.in, options, done); | ||
} else { | ||
done(null, []); | ||
} | ||
|
||
function done(err, results) { | ||
map.remove(); | ||
gl.destroy(); | ||
|
||
if (err) return callback(err); | ||
|
||
results = results.map(function (r) { | ||
delete r.layer; | ||
return r; | ||
}); | ||
|
||
callback(null, data, results); | ||
} | ||
|
||
}); | ||
}; |