[OpenLayers-Commits] r12420 - sandbox/camptocamp/clientzoom/tests/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Sep 29 09:21:06 EDT 2011


Author: erilem
Date: 2011-09-29 06:21:05 -0700 (Thu, 29 Sep 2011)
New Revision: 12420

Modified:
   sandbox/camptocamp/clientzoom/tests/Layer/Grid.html
Log:
add tests to verify the layer div is correctly scaled when zooming to/from "client" zoom levels

Modified: sandbox/camptocamp/clientzoom/tests/Layer/Grid.html
===================================================================
--- sandbox/camptocamp/clientzoom/tests/Layer/Grid.html	2011-09-28 07:48:32 UTC (rev 12419)
+++ sandbox/camptocamp/clientzoom/tests/Layer/Grid.html	2011-09-29 13:21:05 UTC (rev 12420)
@@ -697,6 +697,68 @@
         map.destroy();
     }
 
+    function test_moveTo_scale(t) {
+
+        t.plan(11);
+
+        var map = new OpenLayers.Map('map', {
+            resolutions: [32, 16, 8, 4, 2, 1]
+        });
+        var layer = new OpenLayers.Layer.WMS('', '', {}, {
+            isBaseLayer: true,
+            serverResolutions: [32, 16, 8]
+        });
+        map.addLayer(layer);
+
+        // initial resolution is 8
+        map.setCenter(new OpenLayers.LonLat(0, 0), 2);
+
+        // test initial conditions
+        t.eq(layer.div.style.width, '100%', 'layer div scale is 1');
+
+        // change from resolution 8 to 4
+        map.zoomTo(3);
+        t.eq(layer.div.style.width, '200%', '[8->4] layer div scale is 2');
+
+        // change from resolution 8 to 2
+        map.zoomTo(2); map.zoomTo(4);
+        t.eq(layer.div.style.width, '400%', '[8->2] layer div scale is 4');
+
+        // change from resolution 8 to 1
+        map.zoomTo(2); map.zoomTo(5);
+        t.eq(layer.div.style.width, '800%', '[8->1] layer div scale is 8');
+
+        // change from resolution 4 to 2
+        map.zoomTo(3); map.zoomTo(4);
+        t.eq(layer.div.style.width, '400%', '[4->2] layer div scale is 4');
+
+        // change from resolution 4 to 1
+        map.zoomTo(3); map.zoomTo(5);
+        t.eq(layer.div.style.width, '800%', '[4->1] layer div scale is 8');
+
+        // change from resolution 2 to 1
+        map.zoomTo(4); map.zoomTo(5);
+        t.eq(layer.div.style.width, '800%', '[2->1] layer div scale is 8');
+
+        // change from resolution 1 to 2
+        map.zoomTo(5); map.zoomTo(4);
+        t.eq(layer.div.style.width, '400%', '[1->2] layer div scale is 4');
+
+        // change from resolution 1 to 4
+        map.zoomTo(5); map.zoomTo(3);
+        t.eq(layer.div.style.width, '200%', '[1->4] layer div scale is 2');
+
+        // change from resolution 1 to 8
+        map.zoomTo(5); map.zoomTo(2);
+        t.eq(layer.div.style.width, '100%', '[1->8] layer div scale is 1');
+
+        // change from resolution 1 to 16
+        map.zoomTo(5); map.zoomTo(1);
+        t.eq(layer.div.style.width, '100%', '[1->16] layer div scale is 1');
+
+        map.destroy();
+    }
+
     function test_transformDiv(t) {
 
         t.plan(8);



More information about the Commits mailing list