| | 21 | |
|---|
| | 22 | function test_Handler_Drag_activate(t) { |
|---|
| | 23 | t.plan(3); |
|---|
| | 24 | var map = new OpenLayers.Map('map'); |
|---|
| | 25 | var control = new OpenLayers.Control(); |
|---|
| | 26 | map.addControl(control); |
|---|
| | 27 | var drag = new OpenLayers.Handler.Drag(control); |
|---|
| | 28 | drag.active = true; |
|---|
| | 29 | var activated = drag.activate(); |
|---|
| | 30 | t.ok(!activated, |
|---|
| | 31 | "activate returns false if the handler was already active"); |
|---|
| | 32 | drag.active = false; |
|---|
| | 33 | drag.dragging = true; |
|---|
| | 34 | activated = drag.activate(); |
|---|
| | 35 | t.ok(activated, |
|---|
| | 36 | "activate returns true if the handler was not already active"); |
|---|
| | 37 | t.ok(!drag.dragging, |
|---|
| | 38 | "activate sets dragging to false"); |
|---|
| | 39 | |
|---|
| | 40 | } |
|---|
| | 41 | |
|---|
| | 42 | function test_Handler_Drag_deactivate(t) { |
|---|
| | 43 | t.plan(3); |
|---|
| | 44 | var map = new OpenLayers.Map('map'); |
|---|
| | 45 | var control = new OpenLayers.Control(); |
|---|
| | 46 | map.addControl(control); |
|---|
| | 47 | var drag = new OpenLayers.Handler.Drag(control); |
|---|
| | 48 | drag.active = false; |
|---|
| | 49 | var deactivated = drag.deactivate(); |
|---|
| | 50 | t.ok(!deactivated, |
|---|
| | 51 | "deactivate returns false if the handler was not already active"); |
|---|
| | 52 | drag.active = true; |
|---|
| | 53 | drag.dragging = true; |
|---|
| | 54 | deactivated = drag.deactivate(); |
|---|
| | 55 | t.ok(deactivated, |
|---|
| | 56 | "deactivate returns true if the handler was active already"); |
|---|
| | 57 | t.ok(!drag.dragging, |
|---|
| | 58 | "deactivate sets dragging to false"); |
|---|
| | 59 | } |
|---|
| | 60 | |
|---|