summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html')
-rw-r--r--misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html158
1 files changed, 158 insertions, 0 deletions
diff --git a/misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html b/misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html
new file mode 100644
index 0000000..f235492
--- /dev/null
+++ b/misc/openlayers/tests/deprecated/Layer/MapServer/Untiled.html
@@ -0,0 +1,158 @@
+<html>
+<head>
+
+ <script src="../../../OLLoader.js"></script>
+ <script src="../../../../lib/deprecated.js"></script>
+ <script type="text/javascript">
+
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var layer;
+
+ var name = 'Test Layer';
+ var url = "http://labs.metacarta.com/cgi-bin/mapserv";
+ var params = { map: '/mapdata/vmap_wms.map',
+ layers: 'basic'};
+
+ function test_Layer_MapServer_Untiled_constructor (t) {
+ t.plan( 4 );
+
+ var url = "http://labs.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
+ t.ok( layer instanceof OpenLayers.Layer.MapServer.Untiled, "new OpenLayers.Layer.MapServer returns object" );
+ t.eq( layer.url, "http://labs.metacarta.com/cgi-bin/mapserv", "layer.url is correct (HTTPRequest inited)" );
+
+ t.eq( layer.params.mode, "map", "default mode param correctly copied");
+ t.eq( layer.params.map_imagetype, "png", "default imagetype correctly copied");
+
+
+ }
+
+ function test_Layer_MapServer_Untiled_clone (t) {
+ t.plan(3);
+
+ var url = "http://labs.metacarta.com/cgi-bin/mapserv";
+ var map = new OpenLayers.Map('map', {});
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
+ map.addLayer(layer);
+
+ var clone = layer.clone();
+ layer.tile = [[1,2],[3,4]];
+
+ t.ok( clone.tile != layer.tile, "clone does not copy tile");
+
+ layer.ratio += 1;
+
+ t.eq( clone.ratio, 1.5, "changing layer.ratio does not change clone.ratio -- a fresh copy was made, not just copied reference");
+
+ t.eq( clone.alpha, layer.alpha, "alpha copied correctly");
+
+ layer.tile = null;
+ map.destroy();
+ }
+
+ function test_Layer_MapServer_Untiled_isBaseLayer(t) {
+ t.plan(3);
+
+ var url = "http://labs.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
+ t.ok( layer.isBaseLayer, "baselayer is true by default");
+
+ var newParams = OpenLayers.Util.extend({}, params);
+ newParams.transparent = "true";
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, newParams);
+ t.ok( !layer.isBaseLayer, "baselayer is false when transparent is set to true");
+
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params, {isBaseLayer: false});
+ t.ok( !layer.isBaseLayer, "baselayer is false when option is set to false" );
+ }
+
+ function test_Layer_MapServer_Untiled_mergeNewParams (t) {
+ t.plan( 5 );
+
+ var map = new OpenLayers.Map("map", {tileManager: null});
+ var url = "http://labs.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
+
+ var newParams = { layers: 'sooper',
+ chickpeas: 'image/png'};
+
+ map.addLayer(layer);
+ map.zoomToMaxExtent();
+ t.ok( !layer.grid[0][0].url.match("chickpeas"), "chickpeas is not in URL of first tile in grid" );
+
+ layer.mergeNewParams(newParams);
+
+ t.eq( layer.params.layers, "sooper", "mergeNewParams() overwrites well");
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well");
+ t.ok( layer.grid[0][0].url.match("chickpeas"), "chickpeas is in URL of first tile in grid" );
+
+ newParams.chickpeas = 151;
+
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hashtable");
+ map.destroy();
+ }
+
+ function test_Layer_MapServer_Untiled_getFullRequestString (t) {
+
+
+ t.plan( 1 );
+ var map = new OpenLayers.Map('map');
+ tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
+ tParams = { layers: 'basic',
+ format: 'png'};
+ var tLayer = new OpenLayers.Layer.MapServer.Untiled(name, tUrl, tParams);
+ map.addLayer(tLayer);
+ str = tLayer.getFullRequestString();
+ var tParams = {
+ layers: 'basic',
+ format: 'png',
+ mode: 'map',
+ map_imagetype: 'png'
+ };
+
+ var sStr = tUrl + "?" + OpenLayers.Util.getParameterString(tParams);
+ sStr = sStr.replace(/,/g, "+");
+
+ t.eq(str, sStr , "getFullRequestString() works");
+ map.destroy();
+
+ }
+
+ // DEPRECATED -- REMOVE IN 3.0
+ function test_Layer_Untiled_MapServer(t) {
+ t.plan(1);
+
+ var layer = new OpenLayers.Layer.MapServer.Untiled();
+
+ var clone = layer.clone();
+
+ t.ok(clone.singleTile, "regression test: clone works. this is for #1013");
+ }
+
+ function test_Layer_MapServer_Untiled_destroy (t) {
+
+ t.plan( 1 );
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
+ map.addLayer(layer);
+
+ map.setCenter(new OpenLayers.LonLat(0,0), 5);
+
+ //grab a reference to one of the tiles
+ var tile = layer.tile;
+
+ layer.destroy();
+
+ // checks to make sure superclass (grid) destroy() was called
+
+ t.ok( layer.tile == null, "tile set to null");
+ map.destroy();
+ }
+
+ </script>
+</head>
+<body>
+<div id="map" style="width:500px;height:550px"></div>
+</body>
+</html>