diff --git a/tests/Layer/Google.html b/tests/Layer/Google.html
index 9961e2b631..e2fb1fdbaa 100644
--- a/tests/Layer/Google.html
+++ b/tests/Layer/Google.html
@@ -234,7 +234,57 @@
t.debug_print("Google tests can't be run from " +
window.location.host);
}
- }
+ }
+
+ function test_setOpacity(t) {
+
+ t.plan(6);
+
+ var map = new OpenLayers.Map("map");
+ var gmap = new OpenLayers.Layer.Google(
+ "Google Streets", // the default
+ {numZoomLevels: 20}
+ );
+ var ghyb = new OpenLayers.Layer.Google(
+ "Google Hybrid",
+ {type: G_HYBRID_MAP, numZoomLevels: 20}
+ );
+ var gsat = new OpenLayers.Layer.Google(
+ "Google Satellite",
+ {type: G_SATELLITE_MAP, numZoomLevels: 22}
+ );
+ map.addLayers([gmap, ghyb, gsat]);
+ map.zoomToMaxExtent();
+
+ var container = map.baseLayer.mapObject.getContainer();
+ var opacityCheck = function(opacity) {
+ var style = container.style;
+ var current = style.opacity === "" ? 1 : parseFloat(style.opacity);
+ if (style.filter && !style.opacity) {
+ current = Number(style.filter.replace(/alpha\(opacity=(.+?)\)/, "$1"));
+ }
+ return (current === opacity);
+ };
+
+ gmap.setOpacity(0.5);
+ t.ok(opacityCheck(0.5), "container opacity set for visible layer");
+
+ ghyb.setOpacity(0.75);
+ t.ok(opacityCheck(0.5), "container opacity not changed if layer not visible");
+ map.setBaseLayer(ghyb);
+ t.ok(opacityCheck(0.75), "container opacity changed to 0.75 when layer becomes visible");
+
+ map.setBaseLayer(gsat);
+ t.ok(opacityCheck(1), "container opacity set to 1 by default");
+ gsat.setOpacity(0.25);
+ t.ok(opacityCheck(0.25), "container opacity changed to 0.25 for visible layer");
+
+ map.setBaseLayer(gmap);
+ t.ok(opacityCheck(0.5), "container opacity set to layer opacity");
+
+ map.destroy();
+
+ }
function test_Layer_Google_setGMapVisibility(t) {
if(validkey) {
diff --git a/tests/Map.html b/tests/Map.html
index 3b0f435339..e2a2dddc8a 100644
--- a/tests/Map.html
+++ b/tests/Map.html
@@ -1557,19 +1557,19 @@
var map, msg;
- // try setting center without layers, this is not supported
+ // try setting center without layers, this has no effect
var failed = false;
try {
map = new OpenLayers.Map({
div: "map",
center: new OpenLayers.LonLat(1, 2)
});
- msg = "center set with no layers";
+ msg = "center option without layers has no effect";
} catch (err) {
failed = true;
- msg = "center cannot be set without layers";
+ msg = "center option without layers throws error";
}
- t.ok(failed, msg);
+ t.ok(!failed, msg);
if (map) {
map.destroy();