bring back r6710 now that popup changes are in
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6719 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
76
tests/Control.html
Normal file
76
tests/Control.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
function test_Control_constructor(t) {
|
||||
t.plan(2);
|
||||
|
||||
var control = new OpenLayers.Control();
|
||||
|
||||
t.ok(control instanceof OpenLayers.Control, "new OpenLayers.Control returns object");
|
||||
t.eq(control.displayClass, "olControl", "displayClass set correctly");
|
||||
}
|
||||
|
||||
function test_Control_addControl(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
|
||||
t.ok(control.map === map, "Control.map is set to the map object" );
|
||||
t.ok(map.controls[map.controls.length - 1] === control, "map.controls contains control");
|
||||
}
|
||||
|
||||
function test_Control_title(t) {
|
||||
t.plan( 1 );
|
||||
var titleText = 'Title test';
|
||||
control = new OpenLayers.Control({title:titleText});
|
||||
t.eq( control.title, titleText, "control.title set correctly" );
|
||||
}
|
||||
|
||||
function test_eventListeners(t) {
|
||||
t.plan(1);
|
||||
|
||||
var method = OpenLayers.Events.prototype.on;
|
||||
// test that events.on is called at control construction
|
||||
var options = {
|
||||
eventListeners: {foo: "bar"}
|
||||
};
|
||||
OpenLayers.Events.prototype.on = function(obj) {
|
||||
t.eq(obj, options.eventListeners, "events.on called with eventListeners");
|
||||
}
|
||||
var control = new OpenLayers.Control(options);
|
||||
OpenLayers.Events.prototype.on = method;
|
||||
control.destroy();
|
||||
|
||||
// if events.on is called again, this will fail due to an extra test
|
||||
// test control without eventListeners
|
||||
OpenLayers.Events.prototype.on = function(obj) {
|
||||
t.fail("events.on called without eventListeners");
|
||||
}
|
||||
var control2 = new OpenLayers.Control();
|
||||
OpenLayers.Events.prototype.on = method;
|
||||
control2.destroy();
|
||||
}
|
||||
|
||||
function test_Control_destroy(t) {
|
||||
t.plan(3);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
|
||||
control.destroy();
|
||||
t.ok(map.controls[map.controls.length - 1] != control, "map.controls doesn't contains control");
|
||||
|
||||
t.ok(control.map == null, "Control.map is null");
|
||||
t.ok(control.handler == null, "Control.handler is null");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user