diff options
Diffstat (limited to 'misc/openlayers/tests/Control/ZoomOut.html')
-rw-r--r-- | misc/openlayers/tests/Control/ZoomOut.html | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Control/ZoomOut.html b/misc/openlayers/tests/Control/ZoomOut.html new file mode 100644 index 0000000..5345c55 --- /dev/null +++ b/misc/openlayers/tests/Control/ZoomOut.html @@ -0,0 +1,100 @@ +<!DOCTYPE html> +<html> + <head> + <script src="../OLLoader.js"></script> + <script type="text/javascript"> + +function test_ZoomOut_constructor (t) { + t.plan( 2 ); + + // setup + var control = new OpenLayers.Control.ZoomOut(); + + // tests + // + t.ok( + control instanceof OpenLayers.Control.ZoomOut, + "new OpenLayers.Control.ZoomOut returns object" + ); + t.eq( + control.displayClass, "olControlZoomOut", + "displayClass is correct" + ); + + // tear down + control.destroy(); +} + +function test_ZoomOut_type(t){ + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomOut(); + + // check that the type of the control equals OpenLayers.Control.TYPE_BUTTON + t.eq( + control.type, + OpenLayers.Control.TYPE_BUTTON, + 'ZoomOut-control is of type "OpenLayers.Control.TYPE_BUTTON".' + ); + + // tear down + control.destroy(); +} + +function test_ZoomOut_trigger (t) { + t.plan( 2 ); + + // set up + var control = new OpenLayers.Control.ZoomOut(), + zoomlevel = 5, + map = new OpenLayers.Map("map", { + allOverlays: true, + layers: [ + new OpenLayers.Layer.Vector() + ], + center: new OpenLayers.LonLat(1,1), + zoom: zoomlevel + }), + oldZoom; + + oldZoom = map.getZoom(); + + // tests + // + // trigger the control before it is being added, + // nothing should change + control.trigger(); + + t.eq( + oldZoom, + zoomlevel, + 'Calling trigger on a non added control doesn\'t do anything ' + + '(map zoom is ' + oldZoom + ').' + ); + + // now lets add the control + map.addControl(control); + + // trigger it again, now the map should have a different extent + control.trigger(); + + t.eq( + map.getZoom(), + zoomlevel - 1, + 'Calling trigger on a added control changes the map zoom ' + + '(map zoom was ' + zoomlevel + + ' and is now ' + map.getZoom() + ').' + ); + + // tear down + control.destroy(); + map.destroy(); +} + + </script> + </head> + <body> + <div id="map" style="width: 1000px; height: 1000px;"></div> + </body> +</html> |