OpenLayers OpenLayers

Changeset 3389

Show
Ignore:
Timestamp:
06/20/07 19:53:51 (1 year ago)
Author:
crschmidt
Message:

Commit fix for #726 from andreas, with proper tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/Panel.js

    r3347 r3389  
    117117                control.activate(); 
    118118            } else { 
    119                 this.controls[i].deactivate(); 
     119                if (this.controls[i].type != OpenLayers.Control.TYPE_TOGGLE) { 
     120                    this.controls[i].deactivate(); 
     121                } 
    120122            } 
    121123        } 
  • trunk/openlayers/tests/Control/test_Panel.html

    r3370 r3389  
    33  <script src="../../lib/OpenLayers.js"></script> 
    44  <script type="text/javascript"><!-- 
    5     var map;  
    65    function test_Control_Panel_constructor (t) { 
    76        t.plan( 1 ); 
     
    109        t.ok( control instanceof OpenLayers.Control.Panel, "new OpenLayers.Control returns object" ); 
    1110    } 
     11    function test_01_Control_Panel_constructor (t) { 
     12            t.plan(5); 
     13            var map = new OpenLayers.Map('map'); 
     14            var panel = new OpenLayers.Control.Panel(); 
     15            var toolControl = new OpenLayers.Control.ZoomBox(); 
     16            var AnotherToolControl = OpenLayers.Class.create(); 
     17            AnotherToolControl.prototype = OpenLayers.Class.inherit(OpenLayers.Control, { 
     18                        CLASS_NAME: 'mbControl.TestTool', 
     19                        type: OpenLayers.Control.TYPE_TOOL 
     20            }); 
     21            var anotherToolControl = new AnotherToolControl(); 
     22                var ToggleControl = OpenLayers.Class.create(); 
     23                ToggleControl.prototype = OpenLayers.Class.inherit(OpenLayers.Control, { 
     24                            CLASS_NAME: 'mbControl.TestToggle', 
     25                            type: OpenLayers.Control.TYPE_TOGGLE, 
     26                }); 
     27                var toggleControl = new ToggleControl(); 
     28 
     29        t.ok(panel instanceof OpenLayers.Control.Panel,  
     30                    "new OpenLayers.Control.Panel returns object"); 
     31 
     32                panel.addControls([toolControl, anotherToolControl, toggleControl]); 
     33 
     34        t.eq(panel.controls.length, 3, 
     35                    "added three controls to the panel"); 
     36        map.addControl(panel); 
     37 
     38                panel.activateControl(toolControl); 
     39                t.ok(toolControl.active && !anotherToolControl.active && !toggleControl.active, 
     40                            "activated one tool control, the other one is inactive and the toggle control also."); 
     41                             
     42                panel.activateControl(toggleControl); 
     43                t.ok(toolControl.active && !anotherToolControl.active && toggleControl.active, 
     44                            "activated the toggle control, which has no influence on the tool controls."); 
     45                             
     46                panel.activateControl(anotherToolControl); 
     47                t.ok(!toolControl.active && anotherToolControl.active && toggleControl.active, 
     48                            "activated the other tool control, the first one is inactive and the toggle control still active."); 
     49        } 
    1250  // --> 
    1351  </script> 
  • trunk/openlayers/tests/list-tests.html

    r3323 r3389  
    5858    <li>Control/test_MouseToolbar.html</li> 
    5959    <li>Control/test_LayerSwitcher.html</li> 
     60    <li>Control/test_Panel.html</li> 
    6061    <li>Control/test_PanZoom.html</li> 
    6162    <li>Control/test_PanZoomBar.html</li>