Merge pull request #5991 from openlayers/Array.isView_tests

Only test ol.format.MVT if ArrayBuffer.isView is supported
This commit is contained in:
Frédéric Junod
2016-10-20 13:40:45 +02:00
committed by GitHub
3 changed files with 26 additions and 15 deletions
+24 -14
View File
@@ -2,9 +2,10 @@ goog.provide('ol.test.featureloader');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.VectorTile'); goog.require('ol.VectorTile');
goog.require('ol.Feature');
goog.require('ol.featureloader'); goog.require('ol.featureloader');
goog.require('ol.format.GeoJSON'); goog.require('ol.format.GeoJSON');
goog.require('ol.format.MVT'); goog.require('ol.format.TextFeature');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
@@ -70,8 +71,7 @@ describe('ol.featureloader', function() {
var tile; var tile;
beforeEach(function() { beforeEach(function() {
tile = new ol.VectorTile([0, 0, 0], undefined, undefined, undefined, tile = new ol.VectorTile([0, 0, 0]);
undefined, ol.proj.get('EPSG:3857'));
}); });
it('sets features on the tile', function(done) { it('sets features on the tile', function(done) {
@@ -85,18 +85,28 @@ describe('ol.featureloader', function() {
loader.call(tile, [], 1, ol.proj.get('EPSG:3857')); loader.call(tile, [], 1, ol.proj.get('EPSG:3857'));
}); });
(typeof ArrayBuffer == 'function' ? it : xit)( it('sets features on the tile and updates proj units', function(done) {
'sets features on the tile and updates proj units', function(done) { // mock format that return a tile-pixels feature
var url = 'spec/ol/data/14-8938-5680.vector.pbf'; var format = new ol.format.TextFeature();
var format = new ol.format.MVT(); format.readProjection = function(source) {
loader = ol.featureloader.tile(url, format); return new ol.proj.Projection({
ol.events.listen(tile, 'change', function(e) { code: '',
expect(tile.getFeatures().length).to.be.greaterThan(0); units: 'tile-pixels'
expect(tile.getProjection().getUnits()).to.be('tile-pixels');
done();
});
loader.call(tile, [], 1, ol.proj.get('EPSG:3857'));
}); });
};
format.readFeatures = function(source, options) {
return [new ol.Feature()];
};
var url = 'spec/ol/data/point.json';
loader = ol.featureloader.tile(url, format);
ol.events.listen(tile, 'change', function(e) {
expect(tile.getFeatures().length).to.be.greaterThan(0);
expect(tile.getProjection().getUnits()).to.be('tile-pixels');
done();
});
loader.call(tile, [], 1, ol.proj.get('EPSG:3857'));
});
}); });
+1 -1
View File
@@ -6,7 +6,7 @@ goog.require('ol.ext.vectortile');
goog.require('ol.format.MVT'); goog.require('ol.format.MVT');
goog.require('ol.render.Feature'); goog.require('ol.render.Feature');
where('ArrayBuffer').describe('ol.format.MVT', function() { where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
var data; var data;
beforeEach(function(done) { beforeEach(function(done) {
+1
View File
@@ -466,6 +466,7 @@
var features = { var features = {
ArrayBuffer: typeof ArrayBuffer === 'function', ArrayBuffer: typeof ArrayBuffer === 'function',
'ArrayBuffer.isView': typeof ArrayBuffer === 'function' && ArrayBuffer.isView,
Uint8ClampedArray: ('Uint8ClampedArray' in global) Uint8ClampedArray: ('Uint8ClampedArray' in global)
}; };