Files
openlayers/tests/Control/Navigation.html

105 lines
3.5 KiB
HTML

<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Control_Navigation_constructor (t) {
t.plan( 3 );
var temp = OpenLayers.Control.prototype.initialize;
OpenLayers.Control.prototype.initialize = function() {
t.ok(true, "OpenLayers.Control's constructor called");
};
var control = new OpenLayers.Control.Navigation();
t.ok( control instanceof OpenLayers.Control.Navigation, "new OpenLayers.Control returns object" );
t.ok( !control.handleRightClicks, "'handleRightClicks' property is disabled by default");
OpenLayers.Control.prototype.initialize = temp;
}
function test_Control_Navigation_destroy (t) {
t.plan(10);
var temp = OpenLayers.Control.prototype.destroy;
OpenLayers.Control.prototype.destroy = function() {
t.ok(true, "OpenLayers.Control's destroy called");
temp.call(this);
};
var control = {
events: {
destroy: function() {
t.ok(true, "events destroyed");
}
},
'deactivate': function() {
t.ok(true, "navigation control deactivated before being destroyed");
},
'dragPan': {
'destroy': function() {
t.ok(true, "dragPan destroyed");
}
},
'zoomBox': {
'destroy': function() {
t.ok(true, "zoomBox destroyed");
}
},
handlers: {
'wheel': {
'destroy': function() {
t.ok(true, "wheelHandler destroyed");
}
},
'click': {
'destroy': function() {
t.ok(true, "clickHandler destroyed");
}
}
}
};
//this will also trigger one test by calling OpenLayers.Control's destroy
// and three more for the destruction of dragPan, zoomBox, and wheelHandler
OpenLayers.Control.Navigation.prototype.destroy.apply(control, []);
t.eq(control.dragPan, null, "'dragPan' set to null");
t.eq(control.zoomBox, null, "'zoomBox' set to null");
t.eq(control.handlers, null, "handlers set to null");
OpenLayers.Control.prototype.destroy = temp;
}
function test_Control_Navigation_disableZoomWheel(t) {
t.plan(2);
var nav = new OpenLayers.Control.Navigation();
var wheel = new OpenLayers.Handler.MouseWheel(nav, {});
nav.handlers.wheel = wheel;
wheel.register = function() {};
wheel.unregister = function() {};
wheel.activate();
nav.disableZoomWheel();
t.eq(nav.zoomWheelEnabled, false, "mouse wheel deactivated");
t.eq(wheel.active, false, "mouse wheel handler deactivated");
}
function test_Control_Navigation_enableZoomWheel(t) {
t.plan(2);
var nav = new OpenLayers.Control.Navigation({zoomWheelEnabled: false});
nav.active = true;
var wheel = new OpenLayers.Handler.MouseWheel(nav, {});
wheel.register = function() {};
wheel.unregister = function() {};
nav.handlers.wheel = wheel;
nav.enableZoomWheel();
t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
t.eq(wheel.active, true, "mouse wheel handler activated");
}
</script>
</head>
<body>
</body>
</html>