but it's not working for me at the moment, so I'm going to trust that the rest of our testing process will find this at the moment, since the panzoom is obvious enough that people will see it if it breaks :) git-svn-id: http://svn.openlayers.org/trunk/openlayers@2922 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
92 lines
3.8 KiB
HTML
92 lines
3.8 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript"><!--
|
|
var map;
|
|
function test_01_Control_PanZoom_constructor (t) {
|
|
t.plan( 1 );
|
|
|
|
control = new OpenLayers.Control.PanZoom();
|
|
t.ok( control instanceof OpenLayers.Control.PanZoom, "new OpenLayers.Control.PanZoom returns object" );
|
|
}
|
|
function test_02_Control_PanZoom_addControl (t) {
|
|
t.plan( 8 );
|
|
map = new OpenLayers.Map('map');
|
|
control = new OpenLayers.Control.PanZoom();
|
|
t.ok( control instanceof OpenLayers.Control.PanZoom, "new OpenLayers.Control.PanZoom returns object" );
|
|
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
|
|
map.addControl(control);
|
|
t.ok( control.map === map, "Control.map is set to the map object" );
|
|
t.ok( map.controls[3] === control, "map.controls contains control" );
|
|
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" );
|
|
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" );
|
|
t.eq( control.div.style.top, "4px", "Control div top located correctly by default");
|
|
|
|
var control2 = new OpenLayers.Control.PanZoom();
|
|
map.addControl(control2, new OpenLayers.Pixel(100,100));
|
|
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
|
|
}
|
|
|
|
function test_03_Control_PanZoom_control_events (t) {
|
|
|
|
if ( !window.document.createEvent ) {
|
|
//ie can't simulate mouseclicks
|
|
t.plan(0)
|
|
} else {
|
|
t.plan( 7 );
|
|
t.open_window( "Control/test_PanZoom.html", function( wnd ) {
|
|
t.delay_call( 3, function() {
|
|
simulateClick(wnd, wnd.control.buttons[0]);
|
|
t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[1]);
|
|
t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[2]);
|
|
t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[3]);
|
|
t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[4]);
|
|
t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[6]);
|
|
t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" );
|
|
|
|
simulateClick(wnd, wnd.control.buttons[5]);
|
|
t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" );
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
function simulateClick(wnd, elem) {
|
|
var evt = wnd.document.createEvent("MouseEvents");
|
|
evt.initMouseEvent("mousedown", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
var canceled = !elem.dispatchEvent(evt);
|
|
}
|
|
|
|
function loader() {
|
|
control = new OpenLayers.Control.PanZoom();
|
|
|
|
mapper = new OpenLayers.Map('map', { controls: [control]});
|
|
|
|
|
|
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
|
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
|
mapper.addLayer(layer);
|
|
|
|
centerLL = new OpenLayers.LonLat(0,0);
|
|
mapper.setCenter(centerLL, 5);
|
|
}
|
|
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body onload="loader()">
|
|
<div id="map" style="width: 1024px; height: 512px;"/>
|
|
</body>
|
|
</html>
|