Added tests for ZoomIn control.

This commit is contained in:
Marc Jansen
2012-04-17 20:04:49 +02:00
parent 3dfa3fd157
commit 4af41b41f5
2 changed files with 86 additions and 0 deletions

85
tests/Control/ZoomIn.html Normal file
View File

@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_ZoomIn_constructor (t) {
t.plan( 2 );
// setup
var control = new OpenLayers.Control.ZoomIn();
// tests
//
t.ok(
control instanceof OpenLayers.Control.ZoomIn,
"new OpenLayers.Control.ZoomOut returns object"
);
t.eq(
control.displayClass, "olControlZoomIn",
"displayClass is correct"
);
// tear down
control.destroy();
}
function test_ZoomIn_trigger (t) {
t.plan( 2 );
// set up
var control = new OpenLayers.Control.ZoomIn(),
zoomlevel = 5,
map = new OpenLayers.Map("map", {
allOverlays: true,
layers: [
new OpenLayers.Layer.Vector()
],
center: new OpenLayers.LonLat(1,1),
zoom: zoomlevel
}),
oldZoom;
alert(map.getZoom());
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>

View File

@@ -49,6 +49,7 @@
<li>Control/PanPanel.html</li>
<li>Control/SLDSelect.html</li>
<li>Control/Zoom.html</li>
<li>Control/ZoomIn.html</li>
<li>Control/ZoomOut.html</li>
<li>Control/ZoomToMaxExtent.html</li>
<li>Events.html</li>