OpenLayers OpenLayers

Changeset 3690

Show
Ignore:
Timestamp:
07/10/07 18:57:38 (1 year ago)
Author:
tschaub
Message:

construct, activate, and deactivate tests for the drag handler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/tests/Handler/test_Drag.html

    r3689 r3690  
    55    function test_Handler_Drag_constructor(t) { 
    66        t.plan(3); 
    7         var map = new OpenLayers.Map('map'); 
    87        var control = new OpenLayers.Control(); 
    98        control.id = Math.random(); 
    109        var callbacks = {foo: "bar"}; 
    1110        var options = {bar: "foo"}; 
    12         map.addControl(control); 
    1311        OpenLayers.Handler.prototype.initialize = function(con, call, opt) { 
    1412            t.eq(con.id, control.id, 
     
    2119        var drag = new OpenLayers.Handler.Drag(control, callbacks, options); 
    2220    } 
     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 
    2361  // --> 
    2462  </script>