Ignore user provided tile cache size when too small

This commit is contained in:
Andreas Hocevar
2020-02-27 13:39:00 +01:00
parent df1d0ac4a0
commit a072e3acea
16 changed files with 41 additions and 30 deletions

View File

@@ -63,13 +63,19 @@ describe('ol.source.Tile', function() {
const source = new TileSource({});
expect(source.tileCache.highWaterMark).to.be(4 * Math.ceil(screen.availWidth / 256) * Math.ceil(screen.availHeight / 256));
});
it('ignores a cache size that is too small', function() {
const source = new TileSource({
cacheSize: 1
});
expect(source.tileCache.highWaterMark).to.be(4 * Math.ceil(screen.availWidth / 256) * Math.ceil(screen.availHeight / 256));
});
it('sets a custom cache size', function() {
const projection = getProjection('EPSG:4326');
const source = new TileSource({
projection: projection,
cacheSize: 42
cacheSize: 442
});
expect(source.getTileCacheForProjection(projection).highWaterMark).to.be(42);
expect(source.getTileCacheForProjection(projection).highWaterMark).to.be(442);
});
});

View File

@@ -26,9 +26,9 @@ describe('ol.source.TileImage', function() {
describe('#getTileCacheForProjection', function() {
it('uses the cacheSize for reprojected tile caches', function() {
const source = createSource(undefined, undefined, 42);
const source = createSource(undefined, undefined, 442);
const tileCache = source.getTileCacheForProjection(getProjection('EPSG:4326'));
expect(tileCache.highWaterMark).to.be(42);
expect(tileCache.highWaterMark).to.be(442);
expect(tileCache).to.not.equal(source.getTileCacheForProjection(source.getProjection()));
});
});