remove the Tile.BackBufferable tests

This commit is contained in:
Éric Lemoine
2011-10-20 23:04:17 +02:00
parent 9bab78cde8
commit dc0867e655
2 changed files with 0 additions and 261 deletions

View File

@@ -1,260 +0,0 @@
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
var tile;
var map, layer;
function setUp() {
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer.WMS(
"WMS",
window.location.href + "#",
null,
{transitionEffect: "resize"}
);
map.addLayer(layer)
map.setCenter(new OpenLayers.LonLat(0, 0));
}
function tearDown() {
map.destroy();
map = null;
layer = null;
}
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
function test_initialize (t) {
t.plan(2);
setUp();
tile = new OpenLayers.Tile.Image(layer, position, bounds, null);
t.eq(tile.backBufferData, {}, "back buffer data initialized");
t.eq(tile.size.w, 256, "size object with default width created");
tearDown();
}
function test_backBufferMode(t) {
t.plan(4);
var l;
var map = new OpenLayers.Map("map");
l = new OpenLayers.Layer.WMS('', window.location.href + '#');
map.addLayer(l);
map.zoomToMaxExtent();
tile = new OpenLayers.Tile.Image(l, position, bounds, null);
t.eq(tile.backBufferMode, 0,
'backBufferMode correctly set [tiled]');
l = new OpenLayers.Layer.WMS('', window.location.href + '#',
null, {singleTile: true});
map.addLayer(l);
tile = new OpenLayers.Tile.Image(l, position, bounds, null);
t.eq(tile.backBufferMode, 1,
'backBufferMode correctly set [singleTile]');
l = new OpenLayers.Layer.WMS('', window.location.href + '#',
null, {transitionEffect: 'resize'});
map.addLayer(l);
tile = new OpenLayers.Tile.Image(l, position, bounds, null);
t.eq(tile.backBufferMode, 2,
'backBufferMode correctly set [tiled, transition]');
l = new OpenLayers.Layer.WMS('', window.location.href + '#',
null, {singleTile: true,
transitionEffect: 'resize'});
map.addLayer(l);
tile = new OpenLayers.Tile.Image(l, position, bounds, null);
t.eq(tile.backBufferMode, 3,
'backBufferMode correctly set [singleTile, transition]');
map.destroy();
}
function test_setBackBufferData(t) {
t.plan(2);
setUp();
tile = new OpenLayers.Tile.Image(layer, position, bounds, null);
tile.draw();
// moveTo calls setBackBufferData
tile.moveTo(new OpenLayers.Bounds(1,2,3,4),
new OpenLayers.Pixel(30,40), true);
t.eq(tile.backBufferData.bounds.toString(), bounds.toString(),
"bounds stored correctly");
t.eq(tile.backBufferData.resolution, map.getResolution(),
"resolution stored correctly");
tearDown();
}
function test_updateBackBuffer(t) {
t.plan(1);
setUp();
tile = new OpenLayers.Tile.Image(layer, position, bounds, null);
tile.draw();
tile.isLoading = false;
map.zoomIn();
tile.updateBackBuffer();
t.eq(tile.backBufferData.tile.style.width, (layer.tileSize.w*2)+"%",
"backBuffer frame correctly resized");
tearDown();
}
function test_removeBackBuffer(t) {
t.plan(2);
setUp();
tile = new OpenLayers.Tile.Image(layer, position, bounds, null);
tile.draw();
tile.isLoading = false;
map.zoomIn();
tile.updateBackBuffer();
var backBuffer = tile.backBufferData.tile;
tile.removeBackBuffer();
t.eq(tile.backBufferData.tile, null,
"backBuffer reference removed");
t.ok(backBuffer.parentNode !== layer.div,
"backBuffer removed from layer");
tearDown();
}
function test_updateBackBuffer_scaled_layer(t) {
t.plan(16);
//
// set up
//
var backBuffer;
var map = new OpenLayers.Map('map', {
resolutions: [32, 16, 8, 4, 2, 1]
});
var layer = new OpenLayers.Layer.WMS(
"WMS",
window.location.href + "#",
null,
{transitionEffect: "resize"}
);
var serverResolitions = layer.serverResolutions;
layer.serverResolutions = [32, 16, 8];
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
tile = new OpenLayers.Tile.Image(layer, position, bounds, null);
tile.backBufferMode = 2; // transition effect
// mock createBackBuffer to avoid removing the image
// div from the tile
tile.insertBackBuffer = function() {
return this.frame.cloneNode(false);
};
tile.removeBackBuffer = function() {
};
//
// test
//
tile.draw();
// check initial state
t.eq(tile.backBufferData.resolution, 8,
'resolution 8 is set in the back buffer data');
tile.isLoading = false;
// change resolution from 8 to 4
map.zoomTo(3);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[8->4] updateBackBuffer returns undefined');
// change resolution from 8 to 2
map.zoomTo(2); tile.setBackBufferData(); map.zoomTo(4);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[8->2] updateBackBuffer returns undefined');
// change resolution from 16 to 4
map.zoomTo(1); tile.setBackBufferData(); map.zoomTo(3);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer != undefined,
'[16->4] updateBackBuffer returns a back buffer tile');
t.eq(backBuffer.style.width, '512%',
'[16->4] back buffer width is as expected');
t.eq(backBuffer.style.width, '512%',
'[16->4] back buffer height is as expected');
// change resolution from 32 to 1
map.zoomTo(0); tile.setBackBufferData(); map.zoomTo(5);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer != undefined,
'[32->1] updateBackBuffer returns a back buffer tile');
t.eq(backBuffer.style.width, '1024%',
'[32->1] back buffer width is as expected');
t.eq(backBuffer.style.width, '1024%',
'[32->1] back buffer height is as expected');
// change resolution from 4 to 2
map.zoomTo(3); tile.setBackBufferData(); map.zoomTo(4);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[4->2] updateBackBuffer returns undefined');
// change resolution from 4 to 1
map.zoomTo(3); tile.setBackBufferData(); map.zoomTo(5);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[4->1] updateBackBuffer returns undefined');
// change resolution from 1 to 4
map.zoomTo(5); tile.setBackBufferData(); map.zoomTo(3);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[1->4] updateBackBuffer returns undefined');
// change resolution from 4 to 8
map.zoomTo(3); tile.setBackBufferData(); map.zoomTo(2);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
'[4->8] updateBackBuffer returns undefined');
// change resolution from 4 to 16
map.zoomTo(3); tile.setBackBufferData(); map.zoomTo(1);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer != undefined,
'[4->16] updateBackBuffer returns a back buffer tile');
t.eq(backBuffer.style.width, '128%',
'[4->16] back buffer width is as expected');
t.eq(backBuffer.style.width, '128%',
'[4->16] back buffer height is as expected');
//
// tear down
//
map.removeLayer(layer);
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="height:550px;width:500px"></div>
</body>
</html>

View File

@@ -224,7 +224,6 @@
<li>Symbolizer/Text.html</li>
<li>Tile.html</li>
<li>Tile/Image.html</li>
<li>Tile/BackBufferable.html</li>
<li>Tile/Image/IFrame.html</li>
<li>Tile/WFS.html</li>
<li>Tween.html</li>