[OpenLayers-Commits] r12421 -
sandbox/camptocamp/clientzoom/tests/Tile
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Sep 29 10:24:25 EDT 2011
Author: erilem
Date: 2011-09-29 07:24:24 -0700 (Thu, 29 Sep 2011)
New Revision: 12421
Modified:
sandbox/camptocamp/clientzoom/tests/Tile/BackBufferable.html
Log:
better (and correct) tests to verify that back buffers are created and scaled as appropriate based on the layer scale
Modified: sandbox/camptocamp/clientzoom/tests/Tile/BackBufferable.html
===================================================================
--- sandbox/camptocamp/clientzoom/tests/Tile/BackBufferable.html 2011-09-29 13:21:05 UTC (rev 12420)
+++ sandbox/camptocamp/clientzoom/tests/Tile/BackBufferable.html 2011-09-29 14:24:24 UTC (rev 12421)
@@ -107,81 +107,116 @@
}
function test_updateBackBuffer_scaled_layer(t) {
- t.plan(11);
+ t.plan(16);
- var resolution, serverSupportedResolution, backBuffer, scale;
+ //
+ // set up
+ //
- var map = new OpenLayers.Map('map');
+ var backBuffer;
+
+ var map = new OpenLayers.Map('map', {
+ resolutions: [32, 16, 8, 4, 2, 1]
+ });
+
+ var serverResolitions = layer.serverResolutions;
+ layer.serverResolutions = [32, 16, 8];
+
map.addLayer(layer);
- map.zoomToMaxExtent();
+ 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.createBackBuffer = function() {
+ tile.insertBackBuffer = function() {
return this.frame.cloneNode(false);
};
-
- map.getResolution = function() {
- return resolution;
+ tile.removeBackBuffer = function() {
};
- layer.getServerSupportedResolution = function() {
- return serverSupportedResolution;
- };
+ //
+ // test
+ //
- layer.getResolutionScale = function() {
- return scale;
- };
-
- resolution = 32, serverSupportedResolution = 32, scale = 1;
tile.draw();
// check initial state
- t.eq(tile.backBufferData.resolution, 32,
- '[0] resolution 2 is set in the back buffer data');
+ t.eq(tile.backBufferData.resolution, 8,
+ 'resolution 8 is set in the back buffer data');
tile.isLoading = false;
- // change to a server-supported resolution
- resolution = 16, serverSupportedResolution = 16, scale = 1;
+ // 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,
- '[1] updateBackBuffer returns a back buffer tile');
+ '[16->4] updateBackBuffer returns a back buffer tile');
t.eq(backBuffer.style.width, '512%',
- '[1] back buffer width is as expected');
+ '[16->4] back buffer width is as expected');
t.eq(backBuffer.style.width, '512%',
- '[1] back buffer height is as expected');
- tile.resetBackBuffer();
+ '[16->4] back buffer height is as expected');
- // change to a server-unsupported resolution
- resolution = 8, serverSupportedResolution = 16, scale = 1;
+ // 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,
- '[2] updateBackBuffer returns undefined');
- t.eq(tile.backBufferData.resolution, 8,
- '[2] updateBackBuffer correctly sets the back buffer data');
+ '[4->2] updateBackBuffer returns undefined');
- // change back to a server-supported resolution
- resolution = 16, serverSupportedResolution = 16, scale = 2;
+ // change resolution from 4 to 1
+ map.zoomTo(3); tile.setBackBufferData(); map.zoomTo(5);
backBuffer = tile.updateBackBuffer();
t.ok(backBuffer == undefined,
- '[3] updateBackBuffer returns undefined');
- t.eq(tile.backBufferData.resolution, 16,
- '[3] updateBackBuffer correctly sets the back buffer data');
+ '[4->1] updateBackBuffer returns undefined');
- // change to a server-supported resolution
- resolution = 32, serverSupportedResolution = 32, scale = 1;
+ // 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,
- '[3] updateBackBuffer returns a back buffer tile');
+ '[4->16] updateBackBuffer returns a back buffer tile');
t.eq(backBuffer.style.width, '128%',
- '[3] back buffer width is as expected');
+ '[4->16] back buffer width is as expected');
t.eq(backBuffer.style.width, '128%',
- '[3] back buffer height is as expected');
- tile.resetBackBuffer();
+ '[4->16] back buffer height is as expected');
- delete layer.getServerSupportedResolution;
+ //
+ // tear down
+ //
+
map.removeLayer(layer);
map.destroy();
}
More information about the Commits
mailing list