From 48a47b993a6332a12a2b6801912692733b51a852 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 09:38:57 +0100 Subject: [PATCH 1/6] Fix a Format.WKT test that failed due to rounding / precision of values. --- tests/Format/WKT.html | 48 +++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/tests/Format/WKT.html b/tests/Format/WKT.html index 15d2b2cf62..4850925d25 100644 --- a/tests/Format/WKT.html +++ b/tests/Format/WKT.html @@ -254,21 +254,39 @@ t.plan(1); var projections = { - src: new OpenLayers.Projection("EPSG:4326"), - dest: new OpenLayers.Projection("EPSG:900913") - }; - - var points = { - src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)), - dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665)) - }; - - var format = new OpenLayers.Format.WKT({ - externalProjection: projections["src"], - internalProjection: projections["dest"] - }); - var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0]; - t.eq(feature.geometry.toString(), points["dest"].geometry.toString(), + src: new OpenLayers.Projection("EPSG:4326"), + dest: new OpenLayers.Projection("EPSG:900913") + }, + points = { + src: new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(-87.9, 41.9) + ), + dest: new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665) + ) + }, + format = new OpenLayers.Format.WKT({ + externalProjection: projections["src"], + internalProjection: projections["dest"] + }), + gc_wkt_parts = [ + "GEOMETRYCOLLECTION(", + "POINT(", + points["src"].geometry.x, + " ", + points["src"].geometry.y, + ")", + ")" + ], + feature = format.read( gc_wkt_parts.join("") )[0], + gotGeom = feature.geometry, + expectGeom = points["dest"].geometry, + // we don't use geometry::toString because we might run into + // precision issues + got = gotGeom.x.toFixed(7) + ' ' + gotGeom.y.toFixed(7), + expected = expectGeom.x.toFixed(7) + ' ' + expectGeom.y.toFixed(7); + + t.eq(got, expected, "Geometry collections aren't transformed twice when reprojection."); } From 5faea8e083dc6081a23a038dd0e238b3e61b711b Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 09:54:58 +0100 Subject: [PATCH 2/6] Fix Strategy.BBOX test that failed due to mixed precision of coordinates. --- tests/Strategy/BBOX.html | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index c0ff4ff401..f976d04634 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -80,9 +80,26 @@ strategy.update({force: true}); var from = map.getProjectionObject(); var to = layer.projection; - t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed"); - + var strategyBounds = strategy.bounds, + mapExtent = map.getExtent().transform(from, to), + // we don't use bounds::toString because we might run into + // precision issues + precision = 7, + strategyBoundsGot = [ + strategyBounds.left.toFixed( precision ), + strategyBounds.bottom.toFixed( precision ), + strategyBounds.right.toFixed( precision ), + strategyBounds.top.toFixed( precision ) + ].join(','), + mapExtentExpected = [ + mapExtent.left.toFixed( precision ), + mapExtent.bottom.toFixed( precision ), + mapExtent.right.toFixed( precision ), + mapExtent.top.toFixed( precision ) + ].join(','); + t.eq(strategyBoundsGot, mapExtentExpected, + "[force update different proj] bounds transformed"); } function test_events(t) { From c776dac2c26e2420e63cac643a201ea4d3d0ede6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 10:02:33 +0100 Subject: [PATCH 3/6] Make precision in test configurable. --- tests/Format/WKT.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Format/WKT.html b/tests/Format/WKT.html index 4850925d25..bdfc2337bc 100644 --- a/tests/Format/WKT.html +++ b/tests/Format/WKT.html @@ -283,8 +283,9 @@ expectGeom = points["dest"].geometry, // we don't use geometry::toString because we might run into // precision issues - got = gotGeom.x.toFixed(7) + ' ' + gotGeom.y.toFixed(7), - expected = expectGeom.x.toFixed(7) + ' ' + expectGeom.y.toFixed(7); + precision = 7, + got = gotGeom.x.toFixed(precision) + ' ' + gotGeom.y.toFixed(precision), + expected = expectGeom.x.toFixed(precision) + ' ' + expectGeom.y.toFixed(precision); t.eq(got, expected, "Geometry collections aren't transformed twice when reprojection."); From 436301c9ede591c1d336b0ec9d22a1009e4380e6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 10:44:34 +0100 Subject: [PATCH 4/6] Fix Format.XML test where a defined variable wasn't used. This resulted in an "DOM Exception: INVALID_CHARACTER_ERR (5)" in Chrome 17. --- tests/Format/XML.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Format/XML.html b/tests/Format/XML.html index 8da8fbf1e3..ff663c3f5e 100644 --- a/tests/Format/XML.html +++ b/tests/Format/XML.html @@ -147,7 +147,7 @@ var uri = "http://foo.com"; var prefix = "foo"; var localName = "bar"; - var qualifiedName = prefix + ":" + name; + var qualifiedName = prefix + ":" + localName; var node = format.createElementNS(uri, qualifiedName); t.eq(node.nodeType, 1, "node has correct type"); From 79540f346da76697d2dad0585377f68239653919 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 11:09:45 +0100 Subject: [PATCH 5/6] Reformatting of testfile prior to fixing failing test in Firefox 10.0.1. No functional change. --- tests/Control/OverviewMap.html | 141 ++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 53 deletions(-) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index fce7a24d28..d367a4d94b 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -3,19 +3,23 @@ -
+
From 67ea250ccab85952e3fd1882d3db4ce8c598b1ca Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 14:11:54 +0100 Subject: [PATCH 6/6] Fix a Control.OverviewMap test that failed in Firefox 10.0.1 (Linux). --- tests/Control/OverviewMap.html | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index d367a4d94b..30cac5dff0 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -115,33 +115,35 @@ function test_control_events (t) { t.plan( 10 ); - var evt = {which: 1}; // control expects left-click - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("Test Layer", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}); - map.addLayer(layer); + + map = new OpenLayers.Map('map', { + // when we recenter, don't waste time animating the panning + // without this, the test fails in Firefox 10.0.1 on Linux + panMethod: null, + layers: [ new OpenLayers.Layer('Test Layer', {isBaseLayer: true}) ] + }); control = new OpenLayers.Control.OverviewMap(); map.addControl(control, new OpenLayers.Pixel(20,20)); var centerLL = new OpenLayers.LonLat(-71,42); map.setCenter(centerLL, 11); + t.delay_call( - 1, + 0.1, function() { var overviewCenter = control.ovmap.getCenter(); var overviewZoom = control.ovmap.getZoom(); t.eq(overviewCenter.lon, -71, - "Overviewmap center lon correct"); + "OverviewMap center lon correct"); t.eq(overviewCenter.lat, 42, - "Overviewmap center lat correct"); + "OverviewMap center lat correct"); t.eq(overviewZoom, 8, - "Overviewmap zoomcorrect"); + "OverviewMap zoom correct"); control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)}); }, - 2, + 0.1, function() { var cent = map.getCenter(); t.eq(cent.lon, -71.3515625, @@ -156,7 +158,7 @@ control.rectDrag(new OpenLayers.Pixel(15, 15)); control.updateMapToRect(); }, - 2, + 0.1, function() { var cent = map.getCenter(); t.eq(cent.lon, -71.2734375, @@ -168,11 +170,11 @@ var overviewCenter = control.ovmap.getCenter(); var overviewZoom = control.ovmap.getZoom(); t.eq(overviewCenter.lon, 0, - "Overviewmap center lon correct -- second zoom"); + "OverviewMap center lon correct -- second zoom"); t.eq(overviewCenter.lat, 0, - "Overviewmap center lat correct -- second zoom"); + "OverviewMap center lat correct -- second zoom"); t.eq(overviewZoom, 0, - "Overviewmap zoomcorrect -- second zoom"); + "OverviewMap zoomcorrect -- second zoom"); map.destroy(); } );