diff --git a/tests/Layer/ArcGIS93Rest.html b/tests/Layer/ArcGIS93Rest.html index 4f1a4c618d..4a57b70c12 100644 --- a/tests/Layer/ArcGIS93Rest.html +++ b/tests/Layer/ArcGIS93Rest.html @@ -190,31 +190,6 @@ } - function test_Layer_AGS93_setOpacity (t) { - var params = {layers: "show:0,2"}; - t.plan( 5 ); - - var map = new OpenLayers.Map('map'); - map.projection = "xx"; - tParams = { layers: 'show:0,2', - format: 'png'}; - tOptions = { 'opacity': '0.5' }; - var tLayer = new OpenLayers.Layer.ArcGIS93Rest(name, url, tParams, tOptions); - map.addLayer(tLayer); - map.zoomToMaxExtent(); - t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); - t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); - tLayer.setOpacity("0.6"); - t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); - t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); - var pixel = new OpenLayers.Pixel(5,6); - var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); - tile.draw(); - t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); - - map.destroy(); - } - function test_Layer_AGS93_noGutters (t) { t.plan(2); var map = new OpenLayers.Map('map'); diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 0c5c747559..eae762735c 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -639,6 +639,38 @@ t.eq( layer.grid, null, "layer.grid is null after destroy" ); t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" ); } + + function test_setOpacity(t) { + + t.plan(5); + + var map = new OpenLayers.Map('map'); + var layer = new OpenLayers.Layer.WMS('', '', {}, { + isBaseLayer: true, + opacity: '0.6' + }); + map.addLayer(layer); + // setCenter adds tiles to the layer's grid + map.setCenter(new OpenLayers.LonLat(0, 0), 5); + + var tile = layer.grid[0][0], tileImg = tile.imgDiv; + + tile.onImageLoad(); // simulate an image load event + t.eq(layer.opacity, '0.6', 'layer opacity value is correct'); + t.eq(parseFloat(tileImg.style.opacity), 0.6, 'tile opacity is correct'); + + layer.setOpacity('0.2'); + t.eq(layer.opacity, '0.2', 'layer opacity value is correct'); + t.eq(parseFloat(tileImg.style.opacity), 0.2, 'tile opacity is correct'); + + tile = layer.addTile(new OpenLayers.Bounds(1, 2, 3, 4), + new OpenLayers.Pixel(5, 6)); + tile.draw(); // add tile to the grid + tile.onImageLoad(); // simulate an image load event + t.eq(parseFloat(tile.imgDiv.style.opacity), 0.2, "tile opacity is correc"); + + map.destroy(); + } function test_getServerResolution(t) { diff --git a/tests/Layer/MapServer.html b/tests/Layer/MapServer.html index 11173cb14b..004731db49 100644 --- a/tests/Layer/MapServer.html +++ b/tests/Layer/MapServer.html @@ -190,31 +190,6 @@ } - function test_Layer_MapServer_setOpacity (t) { - t.plan( 5 ); - - var map = new OpenLayers.Map('map'); - map.projection = "xx"; - tUrl = "http://labs.metacarta.com/cgi-bin/mapserv"; - tParams = { layers: 'basic', - format: 'image/png'}; - tOptions = { 'opacity': '0.5' }; - var tLayer = new OpenLayers.Layer.MapServer(name, tUrl, tParams, tOptions); - map.addLayer(tLayer); - map.zoomToMaxExtent(); - t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); - t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); - tLayer.setOpacity("0.6"); - t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); - t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); - var pixel = new OpenLayers.Pixel(5,6); - var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); - tile.draw(); - t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); - map.destroy(); - - } - function test_Layer_MapServer_singleTile (t) { t.plan( 5 ); var map = new OpenLayers.Map('map'); diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index f18a0d7598..757c6b92b2 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -271,38 +271,6 @@ } - function test_Layer_WMS_setOpacity (t) { - t.plan( 5 ); - - var map = new OpenLayers.Map('map'); - tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; - tParams = { layers: 'basic', - format: 'image/png'}; - tOptions = { 'opacity': '0.5' }; - var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions); - map.addLayer(tLayer); - map.setCenter(new OpenLayers.LonLat(0,0), 5); - - var tile = tLayer.grid[0][0], - tileImg = tile.imgDiv; - - t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); - tile.onImageLoad(); // simulate a 'load' image event - t.eq(parseFloat(tileImg.style.opacity), 0.5, "Opacity on tile is correct"); - - tLayer.setOpacity("0.6"); - t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); - t.eq(parseFloat(tileImg.style.opacity), 0.6, "Opacity on tile is changed correctly"); - - var pixel = new OpenLayers.Pixel(5,6); - var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); - tile.draw(); - tile.onImageLoad(); // simulate a 'load' image event - t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); - - map.destroy(); - } - function test_Layer_WMS_noGutters (t) { t.plan(2); var map = new OpenLayers.Map('map');