Files
openlayers/tests/test_Feature.html
Schuyler Erle 0e6b61c352 All tests now pass in IE.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@315 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-05-24 05:46:54 +00:00

79 lines
3.2 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( 5 );
feature = new OpenLayers.Feature("myfeature",
new OpenLayers.LonLat(2,1),
{
iconURL:'http://boston.openguides.org/features/ORANGE.png',
iconW: 12,
iconH: 17
});
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
t.ok( feature.lonlat instanceof OpenLayers.LonLat, "new feature.lonlat returns LonLat object" );
t.eq( feature.lonlat.lon, 2, "feature.lonlat.lon returns correct lon" );
t.eq( feature.lonlat.lat, 1, "feature.lonlat.lat returns correct lat" );
t.eq( feature.data.iconW, 12, "feature.data.iconW set correctly" );
}
function test_02_Feature_createMarker (t) {
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>