From a5ca639c5b7e9f6d24bc3ab16e82373f90a1fbf4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 9 Jul 2010 20:21:30 +0000 Subject: [PATCH] As with r10477, this change simplifies the setGMapVisibility tests to make sure that repositionMapElements is getting called. These tests were periodically failing depending upon the order in which they run. This likely indicates we've got to do some more cleaning up in map.destroy or elsewhere (see #2493). git-svn-id: http://svn.openlayers.org/trunk/openlayers@10478 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tests/Layer/Google/v3.html | 68 +++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/tests/Layer/Google/v3.html b/tests/Layer/Google/v3.html index b0c8771d05..e29c74aef0 100644 --- a/tests/Layer/Google/v3.html +++ b/tests/Layer/Google/v3.html @@ -174,7 +174,7 @@ } function test_Layer_Google_setGMapVisibility(t) { - t.plan(4); + t.plan(3); var map = new OpenLayers.Map('map'); var gmap = new OpenLayers.Layer.Google("Google Streets"); @@ -189,49 +189,55 @@ var cache = OpenLayers.Layer.Google.cache[map.id]; t.ok(!cache.termsOfUse, "termsOfUse is not yet cached"); t.ok(!cache.poweredBy, "poweredBy is not yet cached"); - - map.setBaseLayer(gmap); - t.delay_call(4, function() { - var cache = OpenLayers.Layer.Google.cache[map.id]; - t.eq(cache.termsOfUse.style.display, "", "termsOfUse is visible"); - t.eq(cache.poweredBy.style.display, "", "poweredBy is visible"); - map.destroy(); - }); - } - function test_Layer_Google_setGMapVisibility_allOverlays(t) { - t.plan(3); - - var map = new OpenLayers.Map('map', {allOverlays: true}); - var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false}); - var dummy = new OpenLayers.Layer("Dummy"); - map.addLayers([gmap, dummy]); - map.zoomToMaxExtent(); - - // 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, - // but we don't try to access these elements until after the layer is - // made visible for the first time. - var cache = OpenLayers.Layer.Google.cache[map.id]; - t.ok(!cache.termsOfUse, "termsOfUse is not yet cached"); - t.ok(!cache.poweredBy, "poweredBy is not yet cached"); - var called = 0; var original = gmap.repositionMapElements; gmap.repositionMapElements = function() { ++called; original.apply(gmap, arguments); } - gmap.setVisibility(true); - t.delay_call(2, function() { - t.ok(called > 1, "repositionMapElements called"); + + map.setBaseLayer(gmap); + t.delay_call(4, function() { + t.ok(called > 0, "repositionMapElements called"); map.destroy(); }); } + function test_Layer_Google_setGMapVisibility_allOverlays(t) { + t.plan(3); + + var map = new OpenLayers.Map('map', {allOverlays: true}); + var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false}); + var dummy = new OpenLayers.Layer("Dummy"); + map.addLayers([gmap, dummy]); + map.zoomToMaxExtent(); + + // 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, + // but we don't try to access these elements until after the layer is + // made visible for the first time. + var cache = OpenLayers.Layer.Google.cache[map.id]; + t.ok(!cache.termsOfUse, "termsOfUse is not yet cached"); + t.ok(!cache.poweredBy, "poweredBy is not yet cached"); + + var called = 0; + var original = gmap.repositionMapElements; + gmap.repositionMapElements = function() { + ++called; + original.apply(gmap, arguments); + } + + gmap.setVisibility(true); + t.delay_call(2, function() { + t.ok(called > 0, "repositionMapElements called"); + map.destroy(); + }); + } + -
+
\ No newline at end of file