| | 1 | <html> |
|---|
| | 2 | <head> |
|---|
| | 3 | <script src="../../lib/OpenLayers.js"></script> |
|---|
| | 4 | <script type="text/javascript"><!-- |
|---|
| | 5 | function test_01_Control_Panel_constructor (t) { |
|---|
| | 6 | t.plan(5); |
|---|
| | 7 | var map = new OpenLayers.Map('map'); |
|---|
| | 8 | var panel = new OpenLayers.Control.Panel(); |
|---|
| | 9 | var toolControl = new OpenLayers.Control.ZoomBox(); |
|---|
| | 10 | var AnotherToolControl = OpenLayers.Class.create(); |
|---|
| | 11 | AnotherToolControl.prototype = OpenLayers.Class.inherit(OpenLayers.Control, { |
|---|
| | 12 | CLASS_NAME: 'mbControl.TestTool', |
|---|
| | 13 | type: OpenLayers.Control.TYPE_TOOL |
|---|
| | 14 | }); |
|---|
| | 15 | var anotherToolControl = new AnotherToolControl(); |
|---|
| | 16 | var ToggleControl = OpenLayers.Class.create(); |
|---|
| | 17 | ToggleControl.prototype = OpenLayers.Class.inherit(OpenLayers.Control, { |
|---|
| | 18 | CLASS_NAME: 'mbControl.TestToggle', |
|---|
| | 19 | type: OpenLayers.Control.TYPE_TOGGLE, |
|---|
| | 20 | }); |
|---|
| | 21 | var toggleControl = new ToggleControl(); |
|---|
| | 22 | |
|---|
| | 23 | t.ok(panel instanceof OpenLayers.Control.Panel, |
|---|
| | 24 | "new OpenLayers.Control.Panel returns object"); |
|---|
| | 25 | |
|---|
| | 26 | panel.addControls([toolControl, anotherToolControl, toggleControl]); |
|---|
| | 27 | |
|---|
| | 28 | t.eq(panel.controls.length, 3, |
|---|
| | 29 | "added three controls to the panel"); |
|---|
| | 30 | map.addControl(panel); |
|---|
| | 31 | |
|---|
| | 32 | panel.activateControl(toolControl); |
|---|
| | 33 | t.ok(toolControl.active && !anotherToolControl.active && !toggleControl.active, |
|---|
| | 34 | "activated one tool control, the other one is inactive and the toggle control also."); |
|---|
| | 35 | |
|---|
| | 36 | panel.activateControl(toggleControl); |
|---|
| | 37 | t.ok(toolControl.active && !anotherToolControl.active && toggleControl.active, |
|---|
| | 38 | "activated the toggle control, which has no influence on the tool controls."); |
|---|
| | 39 | |
|---|
| | 40 | panel.activateControl(anotherToolControl); |
|---|
| | 41 | t.ok(!toolControl.active && anotherToolControl.active && toggleControl.active, |
|---|
| | 42 | "activated the other tool control, the first one is inactive and the toggle control still active."); |
|---|
| | 43 | } |
|---|
| | 44 | // --> |
|---|
| | 45 | </script> |
|---|
| | 46 | </head> |
|---|
| | 47 | <body> |
|---|
| | 48 | <div id="map" style="width: 1024px; height: 512px;"/> |
|---|
| | 49 | </body> |
|---|
| | 50 | </html> |