remove duplicated setOpacity tests

This commit is contained in:
Éric Lemoine
2011-12-31 12:23:32 +01:00
parent afc0283c06
commit e7ef3d6c21
4 changed files with 32 additions and 82 deletions

View File

@@ -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');

View File

@@ -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) {

View File

@@ -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');

View File

@@ -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');