Do not abort and dispose of tiles
This commit is contained in:
@@ -83,21 +83,4 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('dispose', function() {
|
||||
|
||||
it('sets image src to a blank image data uri', function() {
|
||||
const tileCoord = [0, 0, 0];
|
||||
const state = TileState.IDLE;
|
||||
const src = 'spec/ol/data/osm-0-0-0.png';
|
||||
const tileLoadFunction = defaultImageLoadFunction;
|
||||
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
tile.load();
|
||||
expect(tile.getState()).to.be(TileState.LOADING);
|
||||
tile.dispose();
|
||||
expect(tile.getState()).to.be(TileState.ABORT);
|
||||
expect(tile.getImage().src).to.be(ImageTile.blankImageUrl);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -218,19 +218,6 @@ describe('ol.source.TileImage', function() {
|
||||
const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
tile.load();
|
||||
});
|
||||
|
||||
it('dispatches tileloadend events for aborted tiles', function() {
|
||||
source.setTileLoadFunction(function() {});
|
||||
const startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
const endSpy = sinon.spy();
|
||||
source.on('tileloadend', endSpy);
|
||||
const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
tile.load();
|
||||
tile.dispose();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
expect(endSpy.callCount).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -32,8 +32,6 @@ describe('ol.TileCache', function() {
|
||||
'2/1/0',
|
||||
'2/0/0'
|
||||
]);
|
||||
|
||||
expect(tiles[0].dispose.calledOnce).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,20 +89,6 @@ describe('ol.TileQueue', function() {
|
||||
|
||||
});
|
||||
|
||||
it('calls #tileChangeCallback_ when all wanted tiles are aborted', function() {
|
||||
const tileChangeCallback = sinon.spy();
|
||||
const queue = new TileQueue(noop, tileChangeCallback);
|
||||
const numTiles = 20;
|
||||
for (let i = 0; i < numTiles; ++i) {
|
||||
const tile = createImageTile();
|
||||
tile.state = TileState.ABORT;
|
||||
queue.enqueue([tile]);
|
||||
}
|
||||
const maxLoading = numTiles / 2;
|
||||
queue.loadMoreTiles(maxLoading, maxLoading);
|
||||
expect(tileChangeCallback.callCount).to.be(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('heapify', function() {
|
||||
@@ -144,7 +130,7 @@ describe('ol.TileQueue', function() {
|
||||
describe('tile change event', function() {
|
||||
const noop = function() {};
|
||||
|
||||
it('abort queued tiles', function() {
|
||||
it('loaded tiles', function() {
|
||||
const tq = new TileQueue(noop, noop);
|
||||
const tile = createImageTile();
|
||||
expect(tile.hasListener('change')).to.be(false);
|
||||
@@ -152,12 +138,11 @@ describe('ol.TileQueue', function() {
|
||||
tq.enqueue([tile]);
|
||||
expect(tile.hasListener('change')).to.be(true);
|
||||
|
||||
tile.dispose();
|
||||
tile.setState(TileState.LOADED);
|
||||
expect(tile.hasListener('change')).to.be(false);
|
||||
expect(tile.getState()).to.eql(5); // ABORT
|
||||
});
|
||||
|
||||
it('abort loading tiles', function() {
|
||||
it('error tiles', function() {
|
||||
const tq = new TileQueue(noop, noop);
|
||||
const tile = createImageTile(noop);
|
||||
|
||||
@@ -166,10 +151,9 @@ describe('ol.TileQueue', function() {
|
||||
expect(tq.getTilesLoading()).to.eql(1);
|
||||
expect(tile.getState()).to.eql(1); // LOADING
|
||||
|
||||
tile.dispose();
|
||||
tile.setState(TileState.ERROR);
|
||||
expect(tq.getTilesLoading()).to.eql(0);
|
||||
expect(tile.hasListener('change')).to.be(false);
|
||||
expect(tile.getState()).to.eql(5); // ABORT
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import TileState from '../../../src/ol/TileState.js';
|
||||
import {defaultLoadFunction} from '../../../src/ol/source/VectorTile.js';
|
||||
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
|
||||
import {listen, listenOnce, unlistenByKey} from '../../../src/ol/events.js';
|
||||
import {listen, unlistenByKey} from '../../../src/ol/events.js';
|
||||
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
|
||||
import {createXYZ} from '../../../src/ol/tilegrid.js';
|
||||
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
|
||||
import EventType from '../../../src/ol/events/EventType.js';
|
||||
|
||||
@@ -95,52 +94,4 @@ describe('ol.VectorRenderTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('#dispose() while loading', function() {
|
||||
const source = new VectorTileSource({
|
||||
format: new GeoJSON(),
|
||||
url: 'spec/ol/data/point.json',
|
||||
tileGrid: createXYZ()
|
||||
});
|
||||
source.getTileGridForProjection = function() {
|
||||
return createXYZ({tileSize: 512});
|
||||
};
|
||||
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
|
||||
|
||||
tile.load();
|
||||
expect(tile.getState()).to.be(TileState.LOADING);
|
||||
tile.dispose();
|
||||
expect(source.sourceTilesByTileKey_[tile.getKey()]).to.be(undefined);
|
||||
expect(tile.getState()).to.be(TileState.ABORT);
|
||||
});
|
||||
|
||||
it('#dispose() when source tiles are loaded', function(done) {
|
||||
const source = new VectorTileSource({
|
||||
format: new GeoJSON(),
|
||||
url: 'spec/ol/data/point.json?{z}/{x}/{y}',
|
||||
tileGrid: createXYZ()
|
||||
});
|
||||
source.getTileGridForProjection = function() {
|
||||
return createXYZ({tileSize: 512});
|
||||
};
|
||||
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
|
||||
|
||||
tile.load();
|
||||
listenOnce(tile, 'change', function() {
|
||||
expect(tile.getState()).to.be(TileState.LOADED);
|
||||
expect(tile.loadingSourceTiles).to.be(0);
|
||||
const sourceTiles = source.getSourceTiles(1, source.getProjection(), tile);
|
||||
expect(sourceTiles.length).to.be(4);
|
||||
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
||||
expect(sourceTiles[i].consumers).to.be(1);
|
||||
}
|
||||
tile.dispose();
|
||||
expect(tile.getState()).to.be(TileState.ABORT);
|
||||
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
||||
expect(sourceTiles[i].consumers).to.be(0);
|
||||
expect(sourceTiles[i].getState()).to.be(TileState.ABORT);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user