Incorporating @elemoine's review comments

This commit is contained in:
ahocevar
2013-02-14 10:11:48 +01:00
parent 774e983631
commit d0249643b3
4 changed files with 74 additions and 15 deletions

View File

@@ -968,7 +968,7 @@
}
function test_applyBackBuffer(t) {
t.plan(9);
t.plan(12);
var map = new OpenLayers.Map('map2');
var layer = new OpenLayers.Layer.WMS('', '', {}, {
@@ -1025,7 +1025,25 @@
t.eq(layer.backBuffer.style.top, '295px',
'back buffer has correct top');
map.destroy();
// test #4
// and a back buffer in the layer and do as if back buffer removal
// has been scheduled, and test that applyBackBuffer removes the
// back buffer and clears the timer
layer.createBackBuffer = function() {
return;
};
backBuffer = document.createElement('div');
map.layerContainerDiv.insertBefore(backBuffer, map.baseLayer.div);
layer.backBuffer = backBuffer;
layer.backBufferTimerId = 'fake';
layer.applyBackBuffer(2);
t.ok(backBuffer !== map.layerContainerDiv.firstChild,
'back buffer is not first child of layer container div');
t.eq(layer.backBuffer, null,
'back buffer not set in layer');
t.eq(layer.backBufferTimerId, null,
'back buffer timer cleared');
map.destroy();
}
function test_createBackBuffer(t) {
@@ -1269,6 +1287,55 @@
OpenLayers.Tile.Image.prototype.createBackBuffer = origCreateBackBuffer
}
function test_delayed_back_buffer_removal(t) {
//
// Test that the delaying of the back buffer removal behaves
// as expected.
//
t.plan(5);
// set up
var map = new OpenLayers.Map('map', {
resolutions: [32, 16, 8, 4, 2, 1],
zoomMethod: null
});
var layer = new OpenLayers.Layer.WMS('', '', {}, {
isBaseLayer: true,
transitionEffect: 'resize'
});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.zoomTo(1);
t.ok(layer.backBuffer === map.layerContainerDiv.firstChild,
'[a] back buffer is first child of layer container div');
// Mark one tile loaded, to see if back buffer removal gets scheduled.
layer.grid[1][1].onImageLoad();
t.ok(layer.backBufferTimerId !== null,
'[a] back buffer scheduled for removal');
var backBuffer = layer.backBuffer;
map.zoomTo(2);
t.ok(layer.backBuffer !== backBuffer,
'[b] a new back buffer was created');
t.ok(layer.backBuffer === map.layerContainerDiv.firstChild,
'[b] back buffer is first child of layer container div');
t.ok(layer.backBufferTimerId === null,
'[b] back buffer no longer scheduled for removal');
// tear down
map.destroy();
}
function test_getGridData(t) {
t.plan(12);