add tests for createAlphaImageDiv function
git-svn-id: http://svn.openlayers.org/trunk/openlayers@365 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -177,6 +177,72 @@
|
||||
t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly");
|
||||
}
|
||||
|
||||
function test_08_Util_createAlphaImageDiv(t) {
|
||||
t.plan( 16 );
|
||||
|
||||
var img = "http://www.openlayers.org/images/OpenLayers.trac.png";
|
||||
var sz = new OpenLayers.Size(10,10);
|
||||
var xy = new OpenLayers.Pixel(5,5);
|
||||
var position = "absolute";
|
||||
var id = "boo";
|
||||
var border = "1";
|
||||
|
||||
var imageDiv = OpenLayers.Util.createAlphaImageDiv(img, sz, xy, position, id, border);
|
||||
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
t.ok( imageDiv instanceof HTMLDivElement, "createDiv creates a valid HTMLDivElement" );
|
||||
|
||||
t.eq( imageDiv.id, id, "image.id set correctly");
|
||||
t.eq( imageDiv.style.left, xy.x + "px", "image.style.left set correctly");
|
||||
t.eq( imageDiv.style.top, xy.y + "px", "image.style.top set correctly");
|
||||
|
||||
t.eq( imageDiv.style.width, sz.w + "px", "image.style.width set correctly");
|
||||
t.eq( imageDiv.style.height, sz.h + "px", "image.style.height set correctly");
|
||||
|
||||
t.eq( imageDiv.style.position, position, "image.style.positionset correctly");
|
||||
|
||||
|
||||
image = imageDiv.firstChild;
|
||||
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
t.ok( image instanceof HTMLImageElement, "createImage creates a valid HTMLImageElement" );
|
||||
t.eq( image.id, id + "_innerImage", "image.id set correctly");
|
||||
|
||||
t.eq( image.style.width, sz.w + "px", "image.style.width set correctly");
|
||||
t.eq( image.style.height, sz.h + "px", "image.style.height set correctly");
|
||||
|
||||
t.ok( image.style.border.startsWith(border + "px"), "image.style.border set correctly");
|
||||
t.eq( image.style.position, "relative", "image.style.positionset correctly");
|
||||
|
||||
var arVersion = navigator.appVersion.split("MSIE");
|
||||
var version = parseFloat(arVersion[1]);
|
||||
|
||||
var alphaHack = ( (document.body.filters) &&
|
||||
(version >= 5.5) && (version < 7) );
|
||||
|
||||
if (alphaHack) {
|
||||
|
||||
t.eq(imageDiv.style.display, "inline-block", "imageDiv.style.display set correctly");
|
||||
|
||||
var filter = "progid:DXImageTransform.Microsoft" +
|
||||
".AlphaImageLoader(src='" + img + "')";
|
||||
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
|
||||
|
||||
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
|
||||
t.eq(image.style.filter, filter, "image filter set correctly");
|
||||
|
||||
} else {
|
||||
t.eq( image.src, img, "image.style.backgroundImage correctly");
|
||||
t.ok(true, "div filter value not set (not in IE)");
|
||||
t.ok(true, "image filter value not set (not in IE)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -->
|
||||
|
||||
Reference in New Issue
Block a user