In practice, this allOverlays example displays the terms of service element. In this test, it appears that the google script is hiding it again after we make it visible - perhaps because it is not actually displayed. And this is not always consistent. I can get this test to pass by making the timeout shorter. In any case, a simpler test is to confirm that repositionMapElements is getting called (see #2493).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10477 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-07-09 18:05:42 +00:00
parent 309d198e04
commit 1d8773eab6
+12 -8
View File
@@ -175,13 +175,13 @@
function test_Layer_Google_setGMapVisibility(t) { function test_Layer_Google_setGMapVisibility(t) {
t.plan(4); t.plan(4);
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
var gmap = new OpenLayers.Layer.Google("Google Streets"); var gmap = new OpenLayers.Layer.Google("Google Streets");
var dummy = new OpenLayers.Layer("Dummy", {isBaseLayer: true}); var dummy = new OpenLayers.Layer("Dummy", {isBaseLayer: true});
map.addLayers([dummy, gmap]); map.addLayers([dummy, gmap]);
map.zoomToMaxExtent(); map.zoomToMaxExtent();
// In v3, the terms of use and powered by elements are not available // In v3, the terms of use and powered by elements are not available
// until the layer loads. This can occur before the layer is visible, // until the layer loads. This can occur before the layer is visible,
// but we don't try to access these elements until after the layer is // but we don't try to access these elements until after the layer is
@@ -200,7 +200,7 @@
} }
function test_Layer_Google_setGMapVisibility_allOverlays(t) { function test_Layer_Google_setGMapVisibility_allOverlays(t) {
t.plan(4); t.plan(3);
var map = new OpenLayers.Map('map', {allOverlays: true}); var map = new OpenLayers.Map('map', {allOverlays: true});
var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false}); var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false});
@@ -216,11 +216,15 @@
t.ok(!cache.termsOfUse, "termsOfUse is not yet cached"); t.ok(!cache.termsOfUse, "termsOfUse is not yet cached");
t.ok(!cache.poweredBy, "poweredBy is not yet cached"); t.ok(!cache.poweredBy, "poweredBy is not yet cached");
gmap.setVisibility(true); var called = 0;
t.delay_call(4, function() { var original = gmap.repositionMapElements;
var cache = OpenLayers.Layer.Google.cache[map.id]; gmap.repositionMapElements = function() {
t.eq(cache.termsOfUse.style.display, "", "termsOfUse is visible"); ++called;
t.eq(cache.poweredBy.style.display, "", "poweredBy is visible"); original.apply(gmap, arguments);
}
gmap.setVisibility(true);
t.delay_call(2, function() {
t.ok(called > 1, "repositionMapElements called");
map.destroy(); map.destroy();
}); });
} }