Merge pull request #810 from tschaub/async-tests

Proper async testing
This commit is contained in:
Tim Schaub
2013-06-24 09:02:47 -07:00
10 changed files with 168 additions and 165 deletions

View File

@@ -5,43 +5,46 @@ describe('ol.parser.kml', function() {
var parser = new ol.parser.KML();
describe('Test KML parser', function() {
it('Polygon read / written correctly', function() {
it('Polygon read / written correctly', function(done) {
var url = 'spec/ol/parser/kml/polygon.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var output = parser.write(obj);
expect(xml).to.xmleql(goog.dom.xml.loadXml(output));
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(obj.features.length).to.eql(1);
var geom = obj.features[0].getGeometry();
expect(obj.features[0].getFeatureId()).to.eql('KML.Polygon');
expect(geom instanceof ol.geom.Polygon).to.be.ok();
expect(geom.dimension).to.eql(3);
done();
});
});
it('Linestring read / written correctly', function() {
it('Linestring read / written correctly', function(done) {
var url = 'spec/ol/parser/kml/linestring.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var output = parser.write(obj);
expect(xml).to.xmleql(goog.dom.xml.loadXml(output));
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(obj.features.length).to.eql(2);
var geom = obj.features[0].getGeometry();
expect(geom instanceof ol.geom.LineString).to.be.ok();
expect(geom.dimension).to.eql(3);
geom = obj.features[1].getGeometry();
expect(geom instanceof ol.geom.LineString).to.be.ok();
done();
});
});
it('Point read / written correctly', function() {
it('Point read / written correctly', function(done) {
var url = 'spec/ol/parser/kml/point.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var output = parser.write(obj);
expect(xml).to.xmleql(goog.dom.xml.loadXml(output));
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(obj.features.length).to.eql(1);
var geom = obj.features[0].getGeometry();
expect(geom instanceof ol.geom.Point).to.be.ok();
expect(geom.dimension).to.eql(3);
done();
});
});
it('NetworkLink read correctly', function(done) {
@@ -78,7 +81,7 @@ describe('ol.parser.kml', function() {
});
});
});
it('Extended data read correctly', function() {
it('Extended data read correctly', function(done) {
var url = 'spec/ol/parser/kml/extended_data.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -88,9 +91,10 @@ describe('ol.parser.kml', function() {
expect(obj.features[0].get('description')).to.eql(description);
expect(obj.features[0].get('foo')).to.eql('bar');
expect(obj.features[0].getFeatureId()).to.eql('foobarbaz');
done();
});
});
it('Extended data read correctly [2]', function() {
it('Extended data read correctly [2]', function(done) {
var url = 'spec/ol/parser/kml/extended_data2.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -98,19 +102,21 @@ describe('ol.parser.kml', function() {
expect(feature.get('TrailHeadName')).to.eql('Pi in the sky');
expect(feature.get('TrailLength')).to.eql('3.14159');
expect(feature.get('ElevationGain')).to.eql('10');
done();
});
});
it('Multi geometry read / written correctly', function() {
it('Multi geometry read / written correctly', function(done) {
var url = 'spec/ol/parser/kml/multigeometry.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
var geom = obj.features[0].getGeometry();
var output = parser.write(obj);
expect(xml).to.xmleql(goog.dom.xml.loadXml(output));
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
expect(geom instanceof ol.geom.MultiLineString).to.be.ok();
done();
});
});
it('Discrete multi geometry read correctly', function() {
it('Discrete multi geometry read correctly', function(done) {
var url = 'spec/ol/parser/kml/multigeometry_discrete.kml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -119,9 +125,10 @@ describe('ol.parser.kml', function() {
expect(geom.components.length).to.eql(2);
expect(geom.components[0] instanceof ol.geom.LineString).to.be.ok();
expect(geom.components[1] instanceof ol.geom.Point).to.be.ok();
done();
});
});
it('Test extract tracks', function() {
it('Test extract tracks', function(done) {
var url = 'spec/ol/parser/kml/macnoise.kml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.KML({extractStyles: true,
@@ -145,6 +152,7 @@ describe('ol.parser.kml', function() {
expect(geom.get(0)).to.eql(-93.0753620391713);
expect(geom.get(1)).to.eql(44.9879724110872);
expect(geom.get(2)).to.eql(1006);
done();
});
});
it('Test CDATA attributes', function() {
@@ -214,18 +222,19 @@ describe('ol.parser.kml', function() {
expect(symbolizer1.fillColor).to.eql('#ff0000');
expect(symbolizer2.opacity).to.eql(0);
});
it('Test iconStyle (read / write)', function() {
it('Test iconStyle (read / write)', function(done) {
var url = 'spec/ol/parser/kml/iconstyle.kml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.KML({extractStyles: true});
var obj = p.read(xml);
var output = p.write(obj);
expect(xml).to.xmleql(goog.dom.xml.loadXml(output));
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
var symbolizer = obj.features[0].getSymbolizerLiterals()[0];
var url = 'http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png';
expect(symbolizer.url).to.eql(url);
expect(symbolizer.width).to.eql(32);
expect(symbolizer.height).to.eql(32);
done();
});
});
});

View File

@@ -6,19 +6,13 @@ describe('ol.parser.ogc.exceptionreport', function() {
var parser = new ol.parser.ogc.ExceptionReport();
describe('test read exception', function() {
it('OCG WMS 1.3.0 exceptions', function(done) {
var result, exceptions;
it('OCG WMS 1.3.0 exceptions', function(done) {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
result = parser.read(xhr.getResponseXml());
exceptions = result.exceptionReport.exceptions;
});
waitsFor(function() {
return (result !== undefined);
}, 'XHR timeout', 1000, function() {
var result = parser.read(xhr.getResponseXml());
var exceptions = result.exceptionReport.exceptions;
expect(exceptions.length).to.be(4);
var str = 'Plain text message about an error.';
expect(goog.string.trim(exceptions[0].text)).to.be(str);
@@ -40,20 +34,15 @@ describe('ol.parser.ogc.exceptionreport', function() {
done();
});
});
it('test read exception OWSCommon 1.0.0', function(done) {
var result, report, exception;
it('test read exception OWSCommon 1.0.0', function(done) {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
result = parser.read(xhr.getResponseXml());
report = result.exceptionReport;
exception = report.exceptions[0];
});
var result = parser.read(xhr.getResponseXml());
var report = result.exceptionReport;
var exception = report.exceptions[0];
waitsFor(function() {
return (result !== undefined);
}, 'XHR timeout', 1000, function() {
expect(report.version).to.eql('1.0.0');
expect(report.language).to.eql('en');
expect(exception.code).to.eql('InvalidParameterValue');
@@ -65,20 +54,15 @@ describe('ol.parser.ogc.exceptionreport', function() {
done();
});
});
it('test read exception OWSCommon 1.1.0', function(done) {
var result, report, exception;
it('test read exception OWSCommon 1.1.0', function(done) {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
result = parser.read(xhr.getResponseXml());
report = result.exceptionReport;
exception = report.exceptions[0];
});
var result = parser.read(xhr.getResponseXml());
var report = result.exceptionReport;
var exception = report.exceptions[0];
waitsFor(function() {
return (result !== undefined);
}, 'XHR timeout', 1000, function() {
expect(report.version).to.eql('1.1.0');
expect(report.language).to.eql('en');
expect(exception.code).to.eql('InvalidParameterValue');

View File

@@ -5,15 +5,16 @@ describe('ol.parser.gml_v2', function() {
var parser = new ol.parser.ogc.GML_v2();
describe('Test GML v2 parser', function() {
it('Point read correctly from coord', function() {
it('Point read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
done();
});
});
it('Point read / written correctly from coordinates', function() {
it('Point read / written correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -25,9 +26,10 @@ describe('ol.parser.gml_v2', function() {
delete parser.srsName;
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
done();
});
});
it('MultiPoint read correctly from coord', function() {
it('MultiPoint read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipoint-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -37,9 +39,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
expect(obj.geometry.parts[1].coordinates).to.eql([2, 3]);
expect(obj.geometry.parts[2].coordinates).to.eql([3, 4]);
done();
});
});
it('MultiPoint read / written correctly from coordinates', function() {
it('MultiPoint read / written correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipoint-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -55,18 +58,20 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
expect(obj.geometry.parts[1].coordinates).to.eql([2, 3]);
expect(obj.geometry.parts[2].coordinates).to.eql([3, 4]);
done();
});
});
it('LineString read correctly from coord', function() {
it('LineString read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linestring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates.length).to.eql(2);
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
done();
});
});
it('LineString read / written correctly from coordinates', function() {
it('LineString read / written correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linestring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -79,9 +84,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates.length).to.eql(2);
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
done();
});
});
it('MultiLineString read correctly from coord', function() {
it('MultiLineString read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multilinestring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -90,9 +96,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
expect(obj.geometry.parts[1].coordinates).to.eql([[3, 4], [4, 5]]);
done();
});
});
it('MultiLineString read / written correctly from coordinates', function() {
it('MultiLineString read / written correctly from coords', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multilinestring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -107,9 +114,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
expect(obj.geometry.parts[1].coordinates).to.eql([[3, 4], [4, 5]]);
done();
});
});
it('Polygon read correctly from coord', function() {
it('Polygon read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/polygon-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -122,9 +130,10 @@ describe('ol.parser.gml_v2', function() {
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
done();
});
});
it('Polygon read / written correctly from coordinates', function() {
it('Polygon read / written correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/polygon-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -135,6 +144,7 @@ describe('ol.parser.gml_v2', function() {
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
delete parser.srsName;
expect(obj.geometry.type).to.eql('polygon');
done();
expect(obj.geometry.coordinates.length).to.eql(3);
expect(obj.geometry.coordinates[0].length).to.eql(4);
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
@@ -145,16 +155,17 @@ describe('ol.parser.gml_v2', function() {
[7, 8], [3, 4]]);
});
});
it('MultiPolygon read correctly from coord', function() {
it('MultiPolygon read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipolygon-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('MultiPolygon read / written correctly from coordinates', function() {
it('MultiPolygon read / written from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipolygon-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -167,9 +178,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('GeometryCollection r / w correctly from coordinates', function() {
it('GeometryCollection r / w correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/' +
'geometrycollection-coordinates.xml';
afterLoadXml(url, function(xml) {
@@ -185,32 +197,36 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[1].type).to.eql('linestring');
expect(obj.geometry.parts[2].type).to.eql('polygon');
done();
});
});
it('Box read correctly from coord', function() {
it('Box read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
done();
});
});
it('Box read correctly from coordinates', function() {
it('Box read correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
done();
});
});
it('LinearRing read correctly from coord', function() {
it('LinearRing read correctly from coord', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linearring-coord.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
[1, 2]]);
done();
});
});
it('LinearRing read / written correctly from coordinates', function() {
it('LinearRing read / written correctly from coordinates', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/linearring-coordinates.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -223,9 +239,10 @@ describe('ol.parser.gml_v2', function() {
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
[1, 2]]);
done();
});
});
it('FeatureCollection read / written correctly', function() {
it('FeatureCollection read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/topp-states.xml';
afterLoadXml(url, function(xml) {
var srsName = 'http://www.opengis.net/gml/srs/epsg.xml#4326';
@@ -252,9 +269,10 @@ describe('ol.parser.gml_v2', function() {
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
done();
});
});
it('Auto configure works correctly', function() {
it('Auto configure works correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/topp-states.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v2();
@@ -264,9 +282,10 @@ describe('ol.parser.gml_v2', function() {
ol.geom.MultiPolygon).to.be.ok();
expect(p.featureType).to.eql('states');
expect(p.featureNS).to.eql('http://www.openplans.org/topp');
done();
});
});
it('Test multiple typeNames', function() {
it('Test multiple typeNames', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipletypenames.xml';
afterLoadXml(url, function(xml) {
// we should not go through autoConfig so specify featureNS
@@ -282,9 +301,10 @@ describe('ol.parser.gml_v2', function() {
ol.geom.MultiLineString).to.be.ok();
expect(features[2].getGeometry() instanceof
ol.geom.MultiPoint).to.be.ok();
done();
});
});
it('Test no geometry', function() {
it('Test no geometry', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/nogeom.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -293,14 +313,16 @@ describe('ol.parser.gml_v2', function() {
expect(feature.getGeometry() === null).to.be.ok();
// TODO test bounds on feature
// see https://github.com/openlayers/ol3/issues/566
done();
});
});
it('Test boundedBy', function() {
it('Test boundedBy', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v2/boundedBy.xml';
afterLoadXml(url, function(xml) {
parser.read(xml);
// TODO test bounds on feature
// see https://github.com/openlayers/ol3/issues/566
done();
});
});
});

View File

@@ -5,14 +5,15 @@ describe('ol.parser.gml_v3', function() {
var parser = new ol.parser.ogc.GML_v3();
describe('Test GML v3 parser', function() {
it('Envelope read correctly', function() {
it('Envelope read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.bounds).to.eql([1, 3, 2, 4]);
done();
});
});
it('LinearRing read / written correctly', function() {
it('LinearRing read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linearring.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -25,9 +26,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('linearring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
[1, 2]]);
done();
});
});
it('Linestring read / written correctly', function() {
it('Linestring read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linestring.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -39,18 +41,20 @@ describe('ol.parser.gml_v3', function() {
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
done();
});
});
it('Linestring 3D read correctly', function() {
it('Linestring 3D read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/linestring3d.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
// no write test since simple features only does 2D
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2, 3], [4, 5, 6]]);
done();
});
});
it('Curve read / written correctly', function() {
it('Curve read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/curve.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
@@ -61,9 +65,10 @@ describe('ol.parser.gml_v3', function() {
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('linestring');
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
done();
});
});
it('MultiLineString plural read correctly', function() {
it('MultiLineString plural read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multilinestring-plural.xml';
afterLoadXml(url, function(xml) {
// no write test for plural, we only write singular
@@ -71,9 +76,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
done();
});
});
it('MultiLineString singular read / written correctly', function() {
it('MultiLineString singular read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multilinestring-singular.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({multiCurve: false, srsName: 'foo'});
@@ -85,9 +91,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('multilinestring');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
done();
});
});
it('MultiCurve singular read / written correctly', function() {
it('MultiCurve singular read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -101,9 +108,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
done();
});
});
it('MultiCurve curve read / written correctly', function() {
it('MultiCurve curve read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-curve.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
@@ -116,9 +124,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('linestring');
expect(obj.geometry.parts[0].coordinates).to.eql([[1, 2], [2, 3]]);
done();
});
});
it('MultiPoint plural read correctly', function() {
it('MultiPoint plural read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -126,9 +135,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
done();
});
});
it('MultiPoint singular read / written correctly', function() {
it('MultiPoint singular read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -142,18 +152,20 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.parts.length).to.eql(3);
expect(obj.geometry.parts[0].type).to.eql('point');
expect(obj.geometry.parts[0].coordinates).to.eql([1, 2]);
done();
});
});
it('MultiPolygon plural read correctly', function() {
it('MultiPolygon plural read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipolygon-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('MultiPolygon singular read / written correctly', function() {
it('MultiPolygon singular read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipolygon-singular.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({multiSurface: false, srsName: 'foo'});
@@ -165,18 +177,20 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('MultiSurface plural read correctly', function() {
it('MultiSurface plural read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-plural.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('MultiSurface singular read / written correctly', function() {
it('MultiSurface singular read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-singular.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -189,9 +203,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('MultiSurface surface read / written correctly', function() {
it('MultiSurface surface read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-surface.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
@@ -203,9 +218,10 @@ describe('ol.parser.gml_v3', function() {
expect(obj.geometry.type).to.eql('multipolygon');
expect(obj.geometry.parts.length).to.eql(2);
expect(obj.geometry.parts[0].type).to.eql('polygon');
done();
});
});
it('Point read / written correctly', function() {
it('Point read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/point.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -217,9 +233,10 @@ describe('ol.parser.gml_v3', function() {
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
expect(obj.geometry.type).to.eql('point');
expect(obj.geometry.coordinates).to.eql([1, 2]);
done();
});
});
it('Polygon read / written correctly', function() {
it('Polygon read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/polygon.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -238,9 +255,10 @@ describe('ol.parser.gml_v3', function() {
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
done();
});
});
it('Surface read / written correctly', function() {
it('Surface read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/surface.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
@@ -258,9 +276,10 @@ describe('ol.parser.gml_v3', function() {
[6, 7], [2, 3]]);
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
[7, 8], [3, 4]]);
done();
});
});
it('FeatureCollection from GML read / written correctly', function() {
it('FeatureCollection from GML read / written correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-gml.xml';
afterLoadXml(url, function(xml) {
var srsName = 'urn:x-ogc:def:crs:EPSG:4326';
@@ -286,9 +305,10 @@ describe('ol.parser.gml_v3', function() {
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
done();
});
});
it('FeatureCollection from WFS read correctly', function() {
it('FeatureCollection from WFS read correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -303,9 +323,10 @@ describe('ol.parser.gml_v3', function() {
expect(attributes['SUB_REGION']).to.eql('E N Cen');
expect(attributes['STATE_ABBR']).to.eql('IL');
expect(attributes['LAND_KM']).to.eql('143986.61');
done();
});
});
it('Read autoConfig', function() {
it('Read autoConfig', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
afterLoadXml(url, function(xml) {
parser.read(xml);
@@ -316,9 +337,10 @@ describe('ol.parser.gml_v3', function() {
parser.read(xml);
expect(parser.autoConfig === false).to.be.ok();
parser.autoConfig = true;
done();
});
});
it('Empty attribute', function() {
it('Empty attribute', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/empty-attribute.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
@@ -327,15 +349,17 @@ describe('ol.parser.gml_v3', function() {
expect(attr['name']).to.eql('Aflu');
expect(attr['foo']).to.eql(undefined);
expect(attr['empty']).to.eql('');
done();
});
});
it('Repeated name', function() {
it('Repeated name', function(done) {
var url = 'spec/ol/parser/ogc/xml/gml_v3/repeated-name.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.eql(1);
var atts = obj.features[0].getAttributes();
expect(atts['zoning']).to.eql('I-L');
done();
});
});
});

View File

@@ -11,7 +11,7 @@ describe('ol.parser.ogc.wmscapabilities_v1_0_0', function() {
var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read', function() {
it('Test read', function() {
it('Test read', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_0_0.xml';
afterLoadXml(url, function(xml) {
var obj;
@@ -27,6 +27,7 @@ describe('ol.parser.ogc.wmscapabilities_v1_0_0', function() {
expect(getmap.formats[0]).to.eql('GIF');
expect(obj.capability.layers[64].keywords.length).to.eql(2);
expect(obj.capability.layers[64].keywords[0].value).to.eql('Geometer');
done();
});
});
});

View File

@@ -5,18 +5,19 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read exception', function() {
it('Error reported correctly', function() {
it('Error reported correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
'exceptionsample.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(!!obj.error).to.be.ok();
done();
});
});
});
describe('test read', function() {
it('Test read', function() {
it('Test read', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
afterLoadXml(url, function(xml) {
var obj, capability, getmap, describelayer, getfeatureinfo, layer;
@@ -59,12 +60,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(layer.styles[0].legend.href).to.eql(legend);
expect(layer.styles[0].legend.format).to.eql('image/png');
expect(layer.queryable).to.be.ok();
done();
});
});
});
describe('test layers', function() {
it('Test layers', function() {
it('Test layers', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
afterLoadXml(url, function(xml) {
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
@@ -110,12 +112,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(layers['ozone_image'].fixedHeight).to.eql(256);
expect(layers['ozone_image'].opaque).to.be.ok();
expect(layers['ozone_image'].noSubsets).to.be.ok();
done();
});
});
});
describe('test dimensions', function() {
it('Test dimensions', function() {
it('Test dimensions', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
afterLoadXml(url, function(xml) {
var obj, capability, layers = {}, time, elevation;
@@ -137,12 +140,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(elevation.multipleVal).to.not.be();
expect(elevation.values).to.eql(
['0', '1000', '3000', '5000', '10000']);
done();
});
});
});
describe('test contact info', function() {
it('Test contact info', function() {
it('Test contact info', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
'ogcsample.xml';
afterLoadXml(url, function(xml) {
@@ -168,12 +172,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(contactinfo.phone).to.eql('+1 301 286-1569');
expect(contactinfo.fax).to.eql('+1 301 286-1777');
expect(contactinfo.email).to.eql('delabeau@iniki.gsfc.nasa.gov');
done();
});
});
});
describe('Test fees and constraints', function() {
it('Test fees and constraints', function() {
it('Test fees and constraints', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
afterLoadXml(url, function(xml) {
var obj, service;
@@ -181,12 +186,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
service = obj.service;
expect('fees' in service).to.not.be();
expect('accessConstraints' in service).to.not.be();
done();
});
});
});
describe('Test requests', function() {
it('Test requests', function() {
it('Test requests', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
afterLoadXml(url, function(xml) {
var obj, request, exception, userSymbols;
@@ -208,12 +214,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(userSymbols.userLayer).to.be.ok();
expect(userSymbols.userStyle).to.be.ok();
expect(userSymbols.remoteWFS).to.be.ok();
done();
});
});
});
describe('test ogc', function() {
it('Test ogc', function() {
it('Test ogc', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
afterLoadXml(url, function(xml) {
var obj, capability, attribution, keywords, metadataURLs;
@@ -240,6 +247,7 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(Math.round(capability.layers[0].maxScale)).to.eql(1000);
expect(capability.layers[1].minScale).to.be(undefined);
expect(capability.layers[1].maxScale).to.be(undefined);
done();
});
});
});

View File

@@ -8,7 +8,7 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
});
describe('test read', function() {
it('Test read', function() {
it('Test read', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml';
afterLoadXml(url, function(xml) {
var obj, tilesets, tileset;
@@ -35,18 +35,20 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
0.009330691928043961, 0.004665345964021981];
expect(tileset.resolutions).to.eql(resolutions);
expect(tileset.styles).to.eql('');
done();
});
});
});
describe('test fallback', function() {
it('Test fallback', function() {
it('Test fallback', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/' +
'fallback.xml';
afterLoadXml(url, function(xml) {
var obj;
obj = parser.read(xml);
expect(obj.capability.layers.length).to.eql(2);
done();
});
});
});

View File

@@ -5,19 +5,20 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read exception', function() {
it('Error reported correctly', function() {
it('Error reported correctly', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/' +
'exceptionsample.xml';
afterLoadXml(url, function(xml) {
var result;
result = parser.read(xml);
expect(!!result.error).to.be(true);
done();
});
});
});
describe('test read', function() {
it('Test read', function() {
it('Test read', function(done) {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
afterLoadXml(url, function(xml) {
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
@@ -131,6 +132,7 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
expect(obj.service.layerLimit).to.eql(16);
expect(obj.service.maxHeight).to.eql(2048);
expect(obj.service.maxWidth).to.eql(2048);
done();
});
});
});

View File

@@ -6,23 +6,16 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
describe('test ows', function() {
it('Test ows', function(done) {
var obj, serviceIdentification, serviceProvider, operationsMetadata,
contactInfo;
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
obj = parser.read(xhr.getResponseXml());
serviceIdentification = obj.serviceIdentification;
serviceProvider = obj.serviceProvider;
operationsMetadata = obj.operationsMetadata;
contactInfo = serviceProvider.serviceContact.contactInfo;
});
var obj = parser.read(xhr.getResponseXml());
var serviceIdentification = obj.serviceIdentification;
var serviceProvider = obj.serviceProvider;
var operationsMetadata = obj.operationsMetadata;
var contactInfo = serviceProvider.serviceContact.contactInfo;
waitsFor(function() {
return (obj !== undefined);
}, 'XHR timeout', 1000, function() {
expect(serviceIdentification.title).to.eql('Web Map Tile Service');
expect(serviceIdentification.serviceTypeVersion).to.eql('1.0.0');
expect(serviceIdentification.serviceType.value).to.eql('OGC WMTS');
@@ -62,22 +55,16 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
});
describe('test layers', function() {
it('Test layers', function(done) {
var obj, contents, layer, wgs84Bbox, dimensions;
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
obj = parser.read(xhr.getResponseXml());
contents = obj.contents;
layer = contents.layers[0];
wgs84Bbox = layer.bounds;
dimensions = layer.dimensions;
});
var obj = parser.read(xhr.getResponseXml());
var contents = obj.contents;
var layer = contents.layers[0];
var wgs84Bbox = layer.bounds;
var dimensions = layer.dimensions;
waitsFor(function() {
return (obj !== undefined);
}, 'XHR timeout', 1000, function() {
expect(contents.layers.length).to.eql(1);
expect(layer['abstract']).to.eql('Coastline/shorelines (BA010)');
expect(layer.identifier).to.eql('coastlines');
@@ -136,22 +123,17 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
});
});
});
describe('test tileMatrixSets', function() {
it('Test tileMatrixSets', function(done) {
var obj, tileMatrixSets, bigWorld;
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
obj = parser.read(xhr.getResponseXml());
tileMatrixSets = obj.contents.tileMatrixSets;
bigWorld = tileMatrixSets['BigWorld'];
});
var obj = parser.read(xhr.getResponseXml());
var tileMatrixSets = obj.contents.tileMatrixSets;
var bigWorld = tileMatrixSets['BigWorld'];
waitsFor(function() {
return (obj !== undefined);
}, 'XHR timeout', 1000, function() {
expect(bigWorld).to.not.be(undefined);
expect(bigWorld.identifier).to.eql('BigWorld');
expect(bigWorld.matrixIds.length).to.eql(2);

View File

@@ -1,32 +1,10 @@
function waitsFor(condition, message, timeout, callback) {
var timeWaiting = 0;
function inner() {
if (condition()) {
callback();
return;
}
if (timeWaiting >= timeout) {
throw new Error(message);
}
timeWaiting += 10;
setTimeout(inner, 10);
}
inner();
}
// helper functions for async testing
(function(global) {
function afterLoad(type, path, next) {
var done, error, data;
goog.net.XhrIo.send(path, function(event) {
var xhr = event.target;
var data;
if (xhr.isSuccess()) {
if (type === 'xml') {
data = xhr.getResponseXml();
@@ -36,16 +14,7 @@ function waitsFor(condition, message, timeout, callback) {
data = xhr.getResponseText();
}
} else {
error = new Error(path + ' loading failed: ' + xhr.getStatus());
}
done = true;
});
waitsFor(function() {
return done;
}, 'XHR timeout', 1000, function() {
if (error) {
throw error;
throw new Error(path + ' loading failed: ' + xhr.getStatus());
}
next(data);
});