make sure permalink updates itself when layers change name/visibility or when a baselayer switch is made. (Closes #359)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4228 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-09-12 03:26:35 +00:00
parent 315f20bc9b
commit 7a37ed4423
2 changed files with 26 additions and 2 deletions

View File

@@ -10,18 +10,34 @@
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
t.eq( control.displayClass, "olControlPermalink", "displayClass is correct" );
}
function test_Control_Permalink_uncentered (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink('permalink');
map = new OpenLayers.Map('map');
map.addControl(control);
map.events.triggerEvent("changelayer", {});
t.ok(true, "permalink didn't bomb out.");
}
function test_02_Control_Permalink_updateLinks (t) {
t.plan( 2 );
t.plan( 3 );
control = new OpenLayers.Control.Permalink('permalink');
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
map.addLayer(layer);
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, {'isBaseLayer': false});
map.addLayer(layer);
layer.setVisibility(true);
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
t.eq(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BT"), 'pan sets permalink');
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BF"), 'setVisibility sets permalink');
}
function test_03_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );