3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_Control_PanZoomBar_constructor (t) {
9 control = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(100,100)});
10 t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" );
11 t.eq( control.displayClass, "olControlPanZoomBar", "displayClass is correct" );
12 t.eq( control.position.x, 100, "PanZoom X Set correctly.");
13 t.eq( control.position.y, 100, "PanZoom y Set correctly.");
15 function test_Control_PanZoomBar_addControl (t) {
17 map = new OpenLayers.Map('map', {controls:[]});
18 var layer = new OpenLayers.Layer.WMS("Test Layer",
19 "http://octo.metacarta.com/cgi-bin/mapserv?",
20 {map: "/mapdata/vmap_wms.map", layers: "basic"});
22 control = new OpenLayers.Control.PanZoomBar();
23 t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" );
24 t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
25 map.addControl(control);
26 t.ok( control.map === map, "Control.map is set to the map object" );
27 t.ok( map.controls[0] === control, "map.controls contains control" );
28 t.eq( parseInt(control.div.style.zIndex), 1001, "Control div zIndexed properly" );
29 t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), 1001, "Viewport div contains control div" );
30 t.eq( control.div.style.top, "4px", "Control div top located correctly by default");
32 var control2 = new OpenLayers.Control.PanZoomBar();
33 map.addControl(control2, new OpenLayers.Pixel(100,100));
34 t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
37 function test_Control_PanZoomBar_clearDiv(t) {
39 map = new OpenLayers.Map('map', {controls:[]});
40 var layer = new OpenLayers.Layer.WMS("Test Layer",
41 "http://octo.metacarta.com/cgi-bin/mapserv?",
42 {map: "/mapdata/vmap_wms.map", layers: "basic"});
44 control = new OpenLayers.Control.PanZoomBar();
45 map.addControl(control);
46 control.removeButtons();
47 control._removeZoomBar();
48 t.eq(control.div.childNodes.length, 0, "control's div cleared.");
49 t.eq(control.zoombarDiv, null, "zoombar div nullified.")
52 function test_Control_PanZoomBar_divClick (t) {
54 map = new OpenLayers.Map('map', {controls:[]});
55 var layer = new OpenLayers.Layer.WMS("Test Layer",
56 "http://octo.metacarta.com/cgi-bin/mapserv?",
57 {map: "/mapdata/vmap_wms.map", layers: "basic"});
59 control = new OpenLayers.Control.PanZoomBar();
60 map.addControl(control);
61 control.divClick({'xy': {'x': 0, 'y': 50}, which: 1});
62 t.eq(map.zoom, 11, "zoom is correct on standard map");
64 map.fractionalZoom = true;
65 control.divClick({'xy': {'x': 0, 'y': 49}, which: 1});
66 t.eq(map.zoom.toFixed(3), '10.545', "zoom is correct on fractional zoom map");
73 <div id="map" style="width: 1024px; height: 512px;"/>