adding basic tests for the select feature control

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4149 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-31 00:27:28 +00:00
parent 6c7824cfb0
commit b3e524960b
2 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<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>

View File

@@ -59,6 +59,7 @@
<li>test_Tile.html</li>
<li>Tile/test_Image.html</li>
<li>test_Control.html</li>
<li>Control/test_SelectFeature.html</li>
<li>Control/test_DragFeature.html</li>
<li>Control/test_DragPan.html</li>
<li>Control/test_OverviewMap.html</li>