Files
openlayers/tests/test_Layer_WMS.html
crschmidt 6c5b85626e Add tests for WMS layer. This is one of the first tests that probably will catch
real errors: addTile is probably relatively thoroughly covered in testing now.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@110 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-05-17 20:14:30 +00:00

42 lines
2.4 KiB
HTML

<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var layer;
function test_01_Layer_WMS_constructor (t) {
t.plan( 4 );
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
t.ok( layer instanceof OpenLayers.Layer.WMS, "new OpenLayers.Layer.WMS returns object" );
t.eq( layer.name, "Test Layer", "layer.name is correct" );
t.eq( layer.url, "http://octo.metacarta.com/cgi-bin/mapserv", "layer.url is correct" );
t.eq( layer.params.map, "/mapdata/vmap_wms.map", "layer.params.map is correct" );
}
function test_02_Layer_WMS_addtile (t) {
t.plan( 6 );
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
var pixel = new OpenLayers.Pixel(5,6);
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
t.eq( tile.img.src, "http://octo.metacarta.com/cgi-bin/mapserv?bbox=1,2,3,4&width=256&height=256&map=/mapdata/vmap_wms.map&layers=basic&format=image/jpeg&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:4326&exceptions=application/vnd.ogc.se_inimage", "image src is created correctly via addtile" );
t.eq( tile.img.style.top, "6px", "image top is set correctly via addtile" );
t.eq( tile.img.style.left, "5px", "image top is set correctly via addtile" );
t.ok( layer.div.firstChild instanceof HTMLImageElement, "div first child is an image object" );
t.eq( layer.div.firstChild.src, "http://octo.metacarta.com/cgi-bin/mapserv?bbox=1,2,3,4&width=256&height=256&map=/mapdata/vmap_wms.map&layers=basic&format=image/jpeg&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:4326&exceptions=application/vnd.ogc.se_inimage", "div first child is correct image object" );
var pos = tile.getPosition();
t.eq( pos.toString(), "x=5,y=6", "Position of tile is set correctly." );
}
function test_99_Layer_WMS_destroy (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
layer.destroy();
t.eq( layer.map, null, "layer.map is null after destroy" );
}
// -->
</script>
</head>
<body>
</body>
</html>