Merge pull request #5991 from openlayers/Array.isView_tests
Only test ol.format.MVT if ArrayBuffer.isView is supported
This commit is contained in:
@@ -2,9 +2,10 @@ goog.provide('ol.test.featureloader');
|
||||
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.VectorTile');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.featureloader');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.format.MVT');
|
||||
goog.require('ol.format.TextFeature');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.Vector');
|
||||
|
||||
@@ -70,8 +71,7 @@ describe('ol.featureloader', function() {
|
||||
var tile;
|
||||
|
||||
beforeEach(function() {
|
||||
tile = new ol.VectorTile([0, 0, 0], undefined, undefined, undefined,
|
||||
undefined, ol.proj.get('EPSG:3857'));
|
||||
tile = new ol.VectorTile([0, 0, 0]);
|
||||
});
|
||||
|
||||
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'));
|
||||
});
|
||||
|
||||
(typeof ArrayBuffer == 'function' ? it : xit)(
|
||||
'sets features on the tile and updates proj units', function(done) {
|
||||
var url = 'spec/ol/data/14-8938-5680.vector.pbf';
|
||||
var format = new ol.format.MVT();
|
||||
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'));
|
||||
it('sets features on the tile and updates proj units', function(done) {
|
||||
// mock format that return a tile-pixels feature
|
||||
var format = new ol.format.TextFeature();
|
||||
format.readProjection = function(source) {
|
||||
return new ol.proj.Projection({
|
||||
code: '',
|
||||
units: 'tile-pixels'
|
||||
});
|
||||
};
|
||||
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'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ goog.require('ol.ext.vectortile');
|
||||
goog.require('ol.format.MVT');
|
||||
goog.require('ol.render.Feature');
|
||||
|
||||
where('ArrayBuffer').describe('ol.format.MVT', function() {
|
||||
where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
|
||||
var data;
|
||||
beforeEach(function(done) {
|
||||
|
||||
@@ -466,6 +466,7 @@
|
||||
|
||||
var features = {
|
||||
ArrayBuffer: typeof ArrayBuffer === 'function',
|
||||
'ArrayBuffer.isView': typeof ArrayBuffer === 'function' && ArrayBuffer.isView,
|
||||
Uint8ClampedArray: ('Uint8ClampedArray' in global)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user