Handle tile state of ol.VectorImageTile properly
This commit is contained in:
@@ -9,20 +9,7 @@ goog.require('ol.proj');
|
||||
|
||||
describe('ol.VectorImageTile', function() {
|
||||
|
||||
it('sets the loader function on source tiles', function() {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = 'spec/ol/data/point.json';
|
||||
var tile = new ol.VectorImageTile([0, 0, 0], 0, url, format,
|
||||
ol.VectorImageTile.defaultLoadFunction,
|
||||
[0, 0, 0], function() {}, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {},
|
||||
1, ol.proj.get('EPSG:3857'), ol.VectorTile);
|
||||
|
||||
tile.load();
|
||||
var loader = tile.getSourceTiles()[0].loader_;
|
||||
expect(typeof loader).to.be('function');
|
||||
});
|
||||
|
||||
it('loader sets features on the source tile', function(done) {
|
||||
it('configures loader that sets features on the source tile', function(done) {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = 'spec/ol/data/point.json';
|
||||
var tile = new ol.VectorImageTile([0, 0, 0], 0, url, format,
|
||||
@@ -33,6 +20,8 @@ describe('ol.VectorImageTile', function() {
|
||||
|
||||
tile.load();
|
||||
var sourceTile = tile.getSourceTiles()[0];
|
||||
var loader = sourceTile.loader_;
|
||||
expect(typeof loader).to.be('function');
|
||||
|
||||
ol.events.listen(sourceTile, 'change', function(e) {
|
||||
expect(sourceTile.getFeatures().length).to.be.greaterThan(0);
|
||||
@@ -40,4 +29,37 @@ describe('ol.VectorImageTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('sets ERROR state when source tiles fail to load', function(done) {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = 'spec/ol/data/unavailable.json';
|
||||
var tile = new ol.VectorImageTile([0, 0, 0], 0, url, format,
|
||||
ol.VectorImageTile.defaultLoadFunction, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {},
|
||||
1, ol.proj.get('EPSG:3857'), ol.VectorTile);
|
||||
|
||||
tile.load();
|
||||
|
||||
ol.events.listen(tile, 'change', function(e) {
|
||||
expect(tile.getState()).to.be(ol.TileState.ERROR);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('sets EMPTY state when tile has only empty source tiles', function(done) {
|
||||
var format = new ol.format.GeoJSON();
|
||||
var url = '';
|
||||
var tile = new ol.VectorImageTile([0, 0, 0], 0, url, format,
|
||||
ol.VectorImageTile.defaultLoadFunction, [0, 0, 0], function() {},
|
||||
ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {},
|
||||
1, ol.proj.get('EPSG:3857'), ol.VectorTile);
|
||||
|
||||
tile.load();
|
||||
|
||||
ol.events.listen(tile, 'change', function(e) {
|
||||
expect(tile.getState()).to.be(ol.TileState.EMPTY);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user