Files
openlayers/tests/test_Feature.html
crschmidt b00e6a7156 r405@creusa: crschmidt | 2006-05-27 12:23:17 -0400
Fix test to re-order arguments per my change earlier today.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@429 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-05-27 19:17:38 +00:00

88 lines
3.4 KiB
HTML

<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var map;
var feature, layer;
function test_01_Feature_constructor (t) {
t.plan( 6 );
var layer = new Object();
var id = "myfeature";
var lonlat = new OpenLayers.LonLat(2,1);
var iconURL = 'http://boston.openguides.org/features/ORANGE.png';
var iconSize = new OpenLayers.Size(12, 17);
var data = { iconURL: iconURL,
iconSize: iconSize
};
feature = new OpenLayers.Feature(layer, lonlat, data, id);
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
t.eq( feature.layer, layer, "feature.layer set correctly" );
t.eq( feature.id, id, "feature.id set correctly" );
t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" );
t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" );
t.ok( feature.data.iconSize.equals(iconSize), "feature.data.iconSize set correctly" );
}
function test_02_Feature_createMarker (t) {
t.plan(1);
t.ok(true);
/*
t.plan( 11 );
feature = new OpenLayers.Feature("myfeature", new OpenLayers.LonLat(2,1),
{
iconURL:'http://boston.openguides.org/features/ORANGE.png',
iconW: 12,
iconH: 17
});
layer = new OpenLayers.Layer.Markers('Marker Layer');
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
t.ok( layer instanceof OpenLayers.Layer.Markers, "Layer is a marker layer" );
feature.createMarker(layer);
t.ok( feature.marker instanceof OpenLayers.Marker,
"createMarker sets a marker property to a marker" );
t.ok( layer.markers[0] === feature.marker,
"First marker in layer is the feature marker" );
t.ok( feature.marker.lonlat instanceof OpenLayers.LonLat,
"createMarker sets a marker lontlat property to a lonlat" );
t.ok( layer.markers[0].lonlat === feature.lonlat,
"First marker in the layer matches feature lonlat" );
t.ok( feature.marker.icon instanceof OpenLayers.Icon,
"createMarker sets a marker icon property to an icon" );
t.eq( feature.marker.icon.url,
"http://boston.openguides.org/features/ORANGE.png",
"createMarker sets marker url correctly" );
var map = new OpenLayers.Map('map');
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),0);
t.ok( map.layers[0] == layer,
"Marker layer added to map okay." );
if (!isMozilla)
t.ok( true, "skipping element test outside of Mozilla");
else
t.ok( map.layers[0].div.firstChild instanceof HTMLImageElement,
"layer div firstChild is an image" );
t.eq( map.layers[0].div.firstChild.src,
"http://boston.openguides.org/features/ORANGE.png",
"Layer div img contains correct url" );
*/
}
// -->
</script>
</head>
<body>
<div id="map" style="width: 500px; height: 300px;"></div>
</body>
</html>