git-svn-id: http://svn.openlayers.org/trunk/openlayers@11162 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
154 lines
5.3 KiB
HTML
154 lines
5.3 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../OLLoader.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_disableZoomBox(t) {
|
|
t.plan(2);
|
|
var nav = new OpenLayers.Control.Navigation();
|
|
var zb = new OpenLayers.Control.ZoomBox({});
|
|
nav.zoomBox = zb;
|
|
zb.activate();
|
|
nav.disableZoomBox();
|
|
t.eq(nav.zoomBoxEnabled, false, "zoom box deactivated");
|
|
t.eq(zb.active, false, "zoom box control deactivated");
|
|
}
|
|
|
|
function test_Control_Navigation_enableZoomBox(t) {
|
|
t.plan(2);
|
|
var nav = new OpenLayers.Control.Navigation();
|
|
var zb = new OpenLayers.Control.ZoomBox({});
|
|
nav.zoomBox = zb;
|
|
nav.active = true;
|
|
nav.enableZoomBox();
|
|
t.eq(nav.zoomBoxEnabled, true, "zoom box activated");
|
|
t.eq(zb.active, true, "zoom box control activated");
|
|
}
|
|
|
|
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");
|
|
}
|
|
|
|
function test_documentDrag(t) {
|
|
|
|
t.plan(2);
|
|
|
|
/**
|
|
* These tests confirm that the documentDrag property is false by
|
|
* default and is passed on to the DragPan control. Tests of panning
|
|
* while dragging outside the viewport should go in the DragPan tests.
|
|
* Tests of the document events and appropriate callbacks from the
|
|
* handler should go in the Drag handler tests.
|
|
*/
|
|
|
|
var nav = new OpenLayers.Control.Navigation();
|
|
t.eq(nav.documentDrag, false, "documentDrag false by default");
|
|
// nav.destroy(); // fails if called before draw
|
|
|
|
var map = new OpenLayers.Map({
|
|
div: document.body,
|
|
controls: [new OpenLayers.Control.Navigation({documentDrag: true})]
|
|
});
|
|
nav = map.controls[0];
|
|
|
|
t.eq(nav.dragPan.documentDrag, true, "documentDrag set on the DragPan control");
|
|
map.destroy();
|
|
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|