Replaces tilewms.tests.js with new tests
Transforms the old rendering tests for the TileWMSSource to the new rendering test approach.
BIN
rendering/cases/source-tilewms-gutter0/expected.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
26
rendering/cases/source-tilewms-gutter0/main.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
|
import TileWMS from '../../../src/ol/source/TileWMS.js';
|
||||||
|
|
||||||
|
const tileWms = new TileWMS({
|
||||||
|
params: {
|
||||||
|
'LAYERS': 'layer'
|
||||||
|
},
|
||||||
|
gutter: 0,
|
||||||
|
url: '/data/tiles/wms/wms0.png',
|
||||||
|
transition: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
pixelRatio: 1,
|
||||||
|
layers: [new TileLayer({source: tileWms})],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 5
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
|
|
||||||
BIN
rendering/cases/source-tilewms-gutter20/expected.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
26
rendering/cases/source-tilewms-gutter20/main.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
|
import TileWMS from '../../../src/ol/source/TileWMS.js';
|
||||||
|
|
||||||
|
const tileWms = new TileWMS({
|
||||||
|
params: {
|
||||||
|
'LAYERS': 'layer'
|
||||||
|
},
|
||||||
|
gutter: 20,
|
||||||
|
url: '/data/tiles/wms/wms20.png',
|
||||||
|
transition: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
pixelRatio: 1,
|
||||||
|
layers: [new TileLayer({source: tileWms})],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 5
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
|
|
||||||
BIN
rendering/data/tiles/wms/wms0.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
rendering/data/tiles/wms/wms20.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 21 KiB |
@@ -1,112 +0,0 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
|
||||||
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
|
||||||
import TileWMS from '../../../../src/ol/source/TileWMS.js';
|
|
||||||
|
|
||||||
describe('ol.rendering.source.TileWMS', function() {
|
|
||||||
|
|
||||||
function tilesLoaded(source, callback) {
|
|
||||||
let loading = 0;
|
|
||||||
|
|
||||||
source.on('tileloadstart', function(event) {
|
|
||||||
loading++;
|
|
||||||
});
|
|
||||||
source.on('tileloadend', function(event) {
|
|
||||||
loading--;
|
|
||||||
if (loading == 0) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
source.on('tileloaderror', function(event) {
|
|
||||||
expect().fail('Tile failed to load');
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
let map;
|
|
||||||
function createMap(renderer, pixelRatio) {
|
|
||||||
const MapConstructor = Map;
|
|
||||||
|
|
||||||
map = new MapConstructor({
|
|
||||||
target: createMapDiv(200, 200),
|
|
||||||
pixelRatio: pixelRatio,
|
|
||||||
view: new View({
|
|
||||||
center: [0, 0],
|
|
||||||
zoom: 5
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
if (map) {
|
|
||||||
disposeMap(map);
|
|
||||||
}
|
|
||||||
map = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
function createSource(gutter) {
|
|
||||||
return new TileWMS({
|
|
||||||
params: {
|
|
||||||
'LAYERS': 'layer'
|
|
||||||
},
|
|
||||||
gutter: gutter,
|
|
||||||
url: 'rendering/ol/data/tiles/wms/wms' + gutter + '.png',
|
|
||||||
transition: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
describe('0px gutter, 1 pixel ratio', function() {
|
|
||||||
it('tests the canvas renderer', function(done) {
|
|
||||||
createMap('canvas', 1);
|
|
||||||
const source = createSource(0);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/0_1.canvas.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new TileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('0px gutter, 2 pixel ratio', function() {
|
|
||||||
it('tests the canvas renderer', function(done) {
|
|
||||||
createMap('canvas', 2);
|
|
||||||
const source = createSource(0);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/0_2.canvas.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new TileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('20px gutter, 1 pixel ratio', function() {
|
|
||||||
it('tests the canvas renderer', function(done) {
|
|
||||||
createMap('canvas', 1);
|
|
||||||
const source = createSource(20);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/20_1.canvas.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new TileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('20px gutter, 2 pixel ratio', function() {
|
|
||||||
it('tests the canvas renderer', function(done) {
|
|
||||||
createMap('canvas', 2);
|
|
||||||
const source = createSource(20);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/20_2.canvas.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new TileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||