Files
openlayers/tests/test_Control_Permalink.html
crschmidt c66f1ce360 Create a function -- OpenLayers.Util.getElement -- which replaces "$". This
should be used in all library code. This patch replaces all uses of "$()" in
existing code. The primary reason for this is to avoid conflicts with libraries
(like Prototype) which might redefine this function differently.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2541 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-03-08 20:14:03 +00:00

62 lines
2.7 KiB
HTML

<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var map;
function test_01_Control_Permalink_constructor (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink();
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
}
function test_02_Control_Permalink_updateLinks (t) {
t.plan( 2 );
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);
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
var pm = OpenLayers.Util.getElement('permalink');
if (/MSIE/.test(navigator.userAgent)) {
t.eq(pm.href, "?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
} else {
t.eq(pm.href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
}
}
function test_03_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );
control = new OpenLayers.Control.Permalink('permalink', "./edit.html" );
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);
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
var edit_pm = OpenLayers.Util.getElement('edit_permalink');
edit_pm.href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, edit_pm.href, "Panning sets permalink with base");
}
function test_04_Control_Permalink_noElement (t) {
t.plan( 2 );
control = new OpenLayers.Control.Permalink( );
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
map = new OpenLayers.Map('map');
map.addControl(control);
t.eq(map.controls[3].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
}
// -->
</script>
</head>
<body>
<a id="permalink" href="">Permalink</a> <br />
<a id="edit_permalink" href="">Edit</a> <br />
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>