Fixed tests. p=jorix, r=me (closes #2506)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10309 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-05-11 21:56:21 +00:00
parent a6cd2d51d5
commit 489d3c47b6

View File

@@ -9,10 +9,9 @@
t.ok( control instanceof OpenLayers.Control.Panel, "new OpenLayers.Control returns object" );
t.eq( control.displayClass, "olControlPanel", "displayClass is correct" );
}
function test_Control_Panel_constructor (t) {
t.plan(6);
function test_Control_Panel_constructor2 (t) {
t.plan(11);
var map = new OpenLayers.Map('map');
var panel = new OpenLayers.Control.Panel();
var toolControl = new OpenLayers.Control.ZoomBox();
var AnotherToolControl = OpenLayers.Class(OpenLayers.Control, {
CLASS_NAME: 'mbControl.TestTool',
@@ -23,30 +22,55 @@
CLASS_NAME: 'mbControl.TestToggle',
type: OpenLayers.Control.TYPE_TOGGLE
});
var toggleControl = new ToggleControl();
var panel = new OpenLayers.Control.Panel(
{defaultControl: anotherToolControl});
t.ok(panel instanceof OpenLayers.Control.Panel,
"new OpenLayers.Control.Panel returns object");
panel.redraw = function(){
panel.redrawsCount++;
};
panel.addControls([toolControl, anotherToolControl, toggleControl]);
t.eq(panel.controls.length, 3,
"added three controls to the panel");
panel.redrawsCount = 0;
map.addControl(panel);
t.ok((panel.redrawsCount > 0), "Redraw called on add panel to map " +
panel.redrawsCount + " times.");
t.ok((panel.active),"Panel is active after add panel to map.");
panel.redrawsCount = 0;
panel.addControls(new AnotherToolControl());
t.ok((panel.redrawsCount > 0),
"Redraw called on add control to panel after add panel to map " +
panel.redrawsCount + " times.");
panel.deactivate();
panel.redrawsCount = 0;
panel.activate();
t.ok((panel.redrawsCount > 0),"Redraw called on activate panel " +
panel.redrawsCount + " times.");
panel.activateControl(toolControl);
t.ok(toolControl.active && !anotherToolControl.active && !toggleControl.active,
"activated one tool control, the other one is inactive and the toggle control also.");
panel.redraw = function(){
t.ok(true,"Redraw called on activated toggle");
}
panel.redrawsCount = 0;
panel.activateControl(toggleControl);
t.ok((panel.redrawsCount > 0),"Redraw called on activated toggle " +
panel.redrawsCount + " times.");
t.ok(toolControl.active && !anotherToolControl.active && toggleControl.active,
"activated the toggle control, which has no influence on the tool controls.");
panel.redrawsCount = 0;
panel.activateControl(anotherToolControl);
t.ok((panel.redrawsCount > 0),
"Redraw called on activated tool control " + panel.redrawsCount +
" times.");
t.ok(!toolControl.active && anotherToolControl.active && toggleControl.active,
"activated the other tool control, the first one is inactive and the toggle control still active.");
}