Zoom control tests.
This commit is contained in:
@@ -126,11 +126,11 @@ OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
if (this.zoomInLink) {
|
if (this.zoomInLink) {
|
||||||
delete this.zoomInLink.onclick;
|
this.zoomInLink.onclick = null;
|
||||||
delete this.zoomInLink;
|
delete this.zoomInLink;
|
||||||
}
|
}
|
||||||
if (this.zoomOutLink) {
|
if (this.zoomOutLink) {
|
||||||
delete this.zoomOutLink.onclick;
|
this.zoomOutLink.onclick = null;
|
||||||
delete this.zoomOutLink;
|
delete this.zoomOutLink;
|
||||||
}
|
}
|
||||||
OpenLayers.Control.prototype.destroy.apply(this);
|
OpenLayers.Control.prototype.destroy.apply(this);
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="../OLLoader.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function test_constructor(t) {
|
||||||
|
t.plan(5);
|
||||||
|
|
||||||
|
var control = new OpenLayers.Control.Zoom();
|
||||||
|
t.ok(control instanceof OpenLayers.Control, "instance of Control");
|
||||||
|
t.ok(control instanceof OpenLayers.Control.Zoom, "instance of Zoom");
|
||||||
|
t.eq(control.displayClass, "olControlZoom", "displayClass");
|
||||||
|
control.destroy();
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.Zoom({
|
||||||
|
zoomInText: "zoom in!",
|
||||||
|
zoomOutText: "zoom out!"
|
||||||
|
});
|
||||||
|
t.eq(control.zoomInText, "zoom in!", "zoomInText");
|
||||||
|
t.eq(control.zoomOutText, "zoom out!", "zoomOutText");
|
||||||
|
control.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_addControl(t) {
|
||||||
|
t.plan(2);
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
var control = new OpenLayers.Control.Zoom();
|
||||||
|
map.addControl(control);
|
||||||
|
t.ok(control.map === map, "Control.map set");
|
||||||
|
t.ok(!!~OpenLayers.Util.indexOf(map.controls, control), "map.controls contains control");
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_zoomIn(t) {
|
||||||
|
t.plan(2);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map({
|
||||||
|
div: "map",
|
||||||
|
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||||
|
});
|
||||||
|
var control = new OpenLayers.Control.Zoom();
|
||||||
|
map.addControl(control);
|
||||||
|
map.setCenter([0, 0], 0);
|
||||||
|
|
||||||
|
t.eq(map.getZoom(), 0, "initial center");
|
||||||
|
control.zoomInLink.onclick();
|
||||||
|
t.eq(map.getZoom(), 1, "after zoom in");
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_zoomOut(t) {
|
||||||
|
t.plan(2);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map({
|
||||||
|
div: "map",
|
||||||
|
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||||
|
});
|
||||||
|
var control = new OpenLayers.Control.Zoom();
|
||||||
|
map.addControl(control);
|
||||||
|
map.setCenter([0, 0], 1);
|
||||||
|
|
||||||
|
t.eq(map.getZoom(), 1, "initial center");
|
||||||
|
control.zoomOutLink.onclick();
|
||||||
|
t.eq(map.getZoom(), 0, "after zoom out");
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map" style="width: 512px; height: 256px;"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
<li>Control/WMTSGetFeatureInfo.html</li>
|
<li>Control/WMTSGetFeatureInfo.html</li>
|
||||||
<li>Control/PanPanel.html</li>
|
<li>Control/PanPanel.html</li>
|
||||||
<li>Control/SLDSelect.html</li>
|
<li>Control/SLDSelect.html</li>
|
||||||
|
<li>Control/Zoom.html</li>
|
||||||
<li>Events.html</li>
|
<li>Events.html</li>
|
||||||
<li>Events/buttonclick.html</li>
|
<li>Events/buttonclick.html</li>
|
||||||
<li>Extras.html</li>
|
<li>Extras.html</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user