From afc0283c06c13ae45fadab5d225bcc25d8513f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Sat, 31 Dec 2011 00:45:15 +0100 Subject: [PATCH] fix the Layer.WMS setOpacity tests --- tests/Layer/WMS.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index a07b36c1d9..f18a0d7598 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -275,22 +275,29 @@ t.plan( 5 ); var map = new OpenLayers.Map('map'); - map.projection = "xx"; 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.zoomToMaxExtent(); + 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"); - t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); + 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(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); + 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();