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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 31 16:17:36 EDT 2011


Author: erilem
Date: 2011-08-31 13:17:35 -0700 (Wed, 31 Aug 2011)
New Revision: 12309

Modified:
   sandbox/camptocamp/clientzoom/tests/Layer/Grid.html
Log:
new test for Layer.Grid

Modified: sandbox/camptocamp/clientzoom/tests/Layer/Grid.html
===================================================================
--- sandbox/camptocamp/clientzoom/tests/Layer/Grid.html	2011-08-31 20:17:29 UTC (rev 12308)
+++ sandbox/camptocamp/clientzoom/tests/Layer/Grid.html	2011-08-31 20:17:35 UTC (rev 12309)
@@ -629,7 +629,103 @@
         t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
     }
     
+    function test_getServerSupportedResolution(t) {
 
+        t.plan(4);
+
+        var layer = new OpenLayers.Layer.Grid('', '', {}, {});
+        var res;
+
+        res = layer.getServerSupportedResolution(1);
+        t.eq(res, 1, '[1] getServerSupportedResolution return value is correct');
+
+        layer.serverResolutions = [2, 1];
+        res = layer.getServerSupportedResolution(1);
+        t.eq(res, 1, '[2] getServerSupportedResolution return value is correct');
+
+        layer.serverResolutions = [2];
+        res = layer.getServerSupportedResolution(1);
+        t.eq(res, 2, '[3] getServerSupportedResolution return value is correct');
+
+        var exc;
+        layer.serverResolutions = [0.5];
+        try {
+            res = layer.getServerSupportedResolution(1);
+        } catch(e) {
+            exc = e;
+        }
+        t.ok(exc != undefined, '[4] getServerSupportedResolution generates exception');
+    }
+
+    function test_getServerSupportedZoom(t) {
+
+        t.plan(5);
+
+        var resolution, zoom;
+        var map = new OpenLayers.Map('map', {
+            resolutions: [8, 4, 2, 1, 0.5],
+            getResolution: function() {
+                return resolution;
+            }
+        });
+        var layer = new OpenLayers.Layer.WMS('', '', {}, {isBaseLayer: true});
+        map.addLayer(layer);
+
+        resolution = 8;
+        zoom = layer.getServerSupportedZoom();
+        t.eq(zoom, 0, '[1] getServerSupportedZoom return value is correct');
+
+        resolution = 4;
+        zoom = layer.getServerSupportedZoom();
+        t.eq(zoom, 1, '[2] getServerSupportedZoom return value is correct');
+
+        layer.serverResolutions = [2, 1];
+        resolution = 1;
+        zoom = layer.getServerSupportedZoom();
+        t.eq(zoom, 3, '[3] getServerSupportedZoom return value is correct');
+
+        layer.serverResolutions = [2];
+        resolution = 0.5;
+        zoom = layer.getServerSupportedZoom();
+        t.eq(zoom, 2, '[4] getServerSupportedZoom return value is correct');
+
+        var exc;
+        layer.serverResolutions = [0.5];
+        resolution = 1;
+        try {
+            zoom = layer.getServerSupportedZoom();
+        } catch(e) {
+            exc = e;
+        }
+        t.ok(exc != undefined, '[4] getServerSupportedZoom generates exception');
+
+        map.destroy();
+    }
+
+    function test_transformDiv(t) {
+
+        t.plan(6);
+
+        var map = new OpenLayers.Map('map');
+        var layer = new OpenLayers.Layer.WMS('', '', {}, {
+            isBaseLayer: true
+        });
+        map.addLayer(layer);
+        map.zoomToMaxExtent();
+
+        var tile = layer.grid[1][1];
+        t.eq(tile.frame.style.left, '122%', 'tile (1,1) expected left');
+        t.eq(tile.frame.style.top, '83%', 'tile (1, 1) expected top');
+
+        layer.transformDiv(1.5);
+        t.eq(layer.div.style.width, '150%', 'layer div has correct width');
+        t.eq(layer.div.style.height, '150%', 'layer div has correct height');
+        t.eq(layer.div.style.left, '-124.75%', 'layer div has correct left');
+        t.eq(layer.div.style.top, '-137.25%', 'layer div has correct top');
+
+        map.destroy();
+    }
+
   </script>
 </head>
 <body>



More information about the Commits mailing list