Files
openlayers/tests/Control/test_SelectFeature.html
2007-08-31 00:27:28 +00:00

71 lines
2.4 KiB
HTML

<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Control_SelectFeature_constructor(t) {
t.plan(2);
var options = {
// geometryTypes: "foo"
};
var layer = "bar";
var control = new OpenLayers.Control.SelectFeature(layer, options);
t.ok(control instanceof OpenLayers.Control.SelectFeature,
"new OpenLayers.Control.SelectFeature returns an instance");
t.eq(control.layer, "bar",
"constructor sets layer correctly");
// t.eq(control.featureHandler.geometryTypes, "foo",
// "constructor sets options correctly on feature handler");
}
function test_Control_SelectFeature_destroy(t) {
t.plan(1);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector();
map.addLayer(layer);
var control = new OpenLayers.Control.SelectFeature(layer);
control.handler.destroy = function() {
t.ok(true,
"control.destroy calls destroy on feature handler");
}
// should nullify the layer property here
control.destroy();
}
function test_Control_SelectFeature_activate(t) {
t.plan(2);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector();
map.addLayer(layer);
var control = new OpenLayers.Control.SelectFeature(layer);
map.addControl(control);
t.ok(!control.handler.active,
"feature handler is not active prior to activating control");
control.activate();
t.ok(control.handler.active,
"feature handler is active after activating control");
}
function test_Control_SelectFeature_deactivate(t) {
t.plan(1);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector();
map.addLayer(layer);
var control = new OpenLayers.Control.SelectFeature(layer);
map.addControl(control);
control.activate();
control.handler.deactivate = function() {
t.ok(true,
"control.deactivate calls deactivate on feature handler");
}
control.deactivate();
}
</script>
</head>
<body>
<div id="map" style="width: 400px; height: 250px;"/>
</body>
</html>