Add 'loadstart' and 'loadend' events to some of our exciting layers like WFS, GML, GeoRSS, and Text. tests to back it up. (Closes #808)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4252 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
|
||||
var name = "GML Layer";
|
||||
|
||||
var gml = "./owls.xml";
|
||||
|
||||
// if this test is running online, different rules apply
|
||||
var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1);
|
||||
if (isMSIE) {
|
||||
gml = "." + gml;
|
||||
}
|
||||
|
||||
function test_01_Layer_GML_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
@@ -14,6 +22,24 @@
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
}
|
||||
function test_Layer_GML_events(t) {
|
||||
t.plan(3);
|
||||
|
||||
var layer = new OpenLayers.Layer.GML(name, gml, {isBaseLayer: true});
|
||||
layer.events.register("loadstart", layer, function() {
|
||||
t.ok(true, "loadstart called.")
|
||||
});
|
||||
layer.events.register("loadend", layer, function() {
|
||||
t.ok(true, "loadend called.")
|
||||
});
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
t.delay_call(1, function() {
|
||||
t.ok(true, "waited for 1s");
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0),0);
|
||||
var event = {};
|
||||
t.delay_call( 1, function() {
|
||||
t.delay_call( 2, function() {
|
||||
t.ok(layer.markers[0].events, "First marker has an events object");
|
||||
t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
|
||||
layer.markers[0].events.triggerEvent('click', event);
|
||||
@@ -159,7 +159,26 @@
|
||||
t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon.");
|
||||
});
|
||||
}
|
||||
|
||||
function test_Layer_GeoRSS_loadend_Event(t) {
|
||||
var browserCode = OpenLayers.Util.getBrowserName();
|
||||
if (browserCode == "msie") {
|
||||
t.plan(1);
|
||||
t.ok(true, "IE fails the GeoRSS test. This could probably be fixed by someone with enough energy to fix it.");
|
||||
} else {
|
||||
t.plan(2);
|
||||
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
|
||||
t.delay_call(2, function() {
|
||||
layer.events.register('loadend', layer, function() {
|
||||
t.ok(true, "Loadend event fired");
|
||||
});
|
||||
layer.parseData({
|
||||
'responseText': '<xml xmlns="http://example.com"><title> </title></xml>'
|
||||
});
|
||||
t.ok(true, "Parsing data didn't fail");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function test_99_Layer_GeoRSS_destroy (t) {
|
||||
t.plan( 1 );
|
||||
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
|
||||
|
||||
@@ -118,6 +118,19 @@
|
||||
t.eq(map.popups.length, 0, "no popup on second marker");
|
||||
});
|
||||
}
|
||||
function test_Layer_Text_loadend_Event(t) {
|
||||
t.plan(2);
|
||||
layer = new OpenLayers.Layer.Text('Test Layer', {location:datafile});
|
||||
t.delay_call(2, function() {
|
||||
layer.events.register('loadend', layer, function() {
|
||||
t.ok(true, "Loadend event fired");
|
||||
});
|
||||
layer.parseData({
|
||||
'responseText':''
|
||||
});
|
||||
t.ok(true, "Parsing data didn't fail");
|
||||
});
|
||||
}
|
||||
|
||||
function test_99_Layer_Text_destroy (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
156
tests/owls.xml
Normal file
156
tests/owls.xml
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version='1.0' encoding="ISO-8859-1" ?>
|
||||
<wfs:FeatureCollection
|
||||
xmlns:bsc="http://www.bsc-eoc.org/bsc"
|
||||
xmlns:wfs="http://www.opengis.net/wfs"
|
||||
xmlns:gml="http://www.opengis.net/gml"
|
||||
xmlns:ogc="http://www.opengis.net/ogc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd
|
||||
http://www.bsc-eoc.org/bsc http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=OWLS&OUTPUTFORMAT=XMLSCHEMA">
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-89.817223,45.005555 -74.755001,51.701388</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<gml:featureMember><bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-79.771668,45.891110 -79.771668,45.891110</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-79.771668,45.891110</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.755834,46.365277 -83.755834,46.365277</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:owlname>owl</bsc:owlname>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.755834,46.365277</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.808612,46.175277 -83.808612,46.175277</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.808612,46.175277</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-84.111112,46.309166 -84.111112,46.309166</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-84.111112,46.309166</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.678612,46.821110 -83.678612,46.821110</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.678612,46.821110</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.664445,46.518888 -83.664445,46.518888</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.664445,46.518888</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-80.613334,46.730277 -80.613334,46.730277</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-80.613334,46.730277</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-79.676946,45.428054 -79.676946,45.428054</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-79.676946,45.428054</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.853056,46.236944 -83.853056,46.236944</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-83.853056,46.236944</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
<gml:featureMember>
|
||||
<bsc:OWLS>
|
||||
<gml:boundedBy>
|
||||
<gml:Box srsName="EPSG:4326">
|
||||
<gml:coordinates>-82.289167,45.896388 -82.289167,45.896388</gml:coordinates>
|
||||
</gml:Box>
|
||||
</gml:boundedBy>
|
||||
<bsc:msGeometry>
|
||||
<gml:Point srsName="EPSG:4326">
|
||||
<gml:coordinates>-82.289167,45.896388</gml:coordinates>
|
||||
</gml:Point>
|
||||
</bsc:msGeometry>
|
||||
</bsc:OWLS>
|
||||
</gml:featureMember>
|
||||
</wfs:FeatureCollection>
|
||||
|
||||
Reference in New Issue
Block a user