3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_Control_Navigation_constructor (t) {
8 var temp = OpenLayers.Control.prototype.initialize;
9 OpenLayers.Control.prototype.initialize = function() {
10 t.ok(true, "OpenLayers.Control's constructor called");
13 var control = new OpenLayers.Control.Navigation();
14 t.ok( control instanceof OpenLayers.Control.Navigation, "new OpenLayers.Control returns object" );
16 t.ok( !control.handleRightClicks, "'handleRightClicks' property is disabled by default");
18 OpenLayers.Control.prototype.initialize = temp;
21 function test_Control_Navigation_destroy (t) {
24 var temp = OpenLayers.Control.prototype.destroy;
25 OpenLayers.Control.prototype.destroy = function() {
26 t.ok(true, "OpenLayers.Control's destroy called");
33 t.ok(true, "events destroyed");
36 'deactivate': function() {
37 t.ok(true, "navigation control deactivated before being destroyed");
40 'destroy': function() {
41 t.ok(true, "dragPan destroyed");
45 'destroy': function() {
46 t.ok(true, "zoomBox destroyed");
51 'destroy': function() {
52 t.ok(true, "wheelHandler destroyed");
56 'destroy': function() {
57 t.ok(true, "clickHandler destroyed");
63 //this will also trigger one test by calling OpenLayers.Control's destroy
64 // and three more for the destruction of dragPan, zoomBox, and wheelHandler
65 OpenLayers.Control.Navigation.prototype.destroy.apply(control, []);
67 t.eq(control.dragPan, null, "'dragPan' set to null");
68 t.eq(control.zoomBox, null, "'zoomBox' set to null");
69 t.eq(control.handlers, null, "handlers set to null");
71 OpenLayers.Control.prototype.destroy = temp;
74 function test_Control_Navigation_disableZoomWheel(t) {
76 var nav = new OpenLayers.Control.Navigation();
77 var wheel = new OpenLayers.Handler.MouseWheel(nav, {});
78 nav.handlers.wheel = wheel;
79 wheel.register = function() {};
80 wheel.unregister = function() {};
82 nav.disableZoomWheel();
83 t.eq(nav.zoomWheelEnabled, false, "mouse wheel deactivated");
84 t.eq(wheel.active, false, "mouse wheel handler deactivated");
87 function test_Control_Navigation_enableZoomWheel(t) {
89 var nav = new OpenLayers.Control.Navigation({zoomWheelEnabled: false});
91 var wheel = new OpenLayers.Handler.MouseWheel(nav, {});
92 wheel.register = function() {};
93 wheel.unregister = function() {};
94 nav.handlers.wheel = wheel;
95 nav.enableZoomWheel();
96 t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
97 t.eq(wheel.active, true, "mouse wheel handler activated");