| | 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 | } |
|---|