Merge bugfixes and test improvements for rc4 release.

git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1513 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-09-28 13:05:36 +00:00
parent c7c21ea08a
commit 6edb290f1b
10 changed files with 163 additions and 12 deletions
+8 -1
View File
@@ -53,12 +53,19 @@
}
function test_04_Bounds_contains(t) {
t.plan( 4 );
t.plan( 6 );
bounds = new OpenLayers.Bounds(10,10,40,40);
t.eq( bounds.contains(20,20), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" );
t.eq( bounds.contains(0,0), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" );
t.eq( bounds.contains(40,40), true, "bounds(10,10,40,40) correctly contains LonLat(40,40) with inclusive set to true" );
t.eq( bounds.contains(40,40, false), false, "bounds(10,10,40,40) correctly does not contain LonLat(40,40) with inclusive set to false" );
var px = new OpenLayers.Pixel(15,30);
t.eq( bounds.containsPixel(px), bounds.contains(px.x, px.y), "containsPixel works");
var ll = new OpenLayers.LonLat(15,30);
t.eq( bounds.containsLonLat(ll), bounds.contains(ll.lon, ll.lat), "containsLonLat works");
}
function test_05_Bounds_fromString(t) {
+26
View File
@@ -76,6 +76,32 @@
"Layer div img contains correct url" );
*/
}
function test_03_Feature_onScreen(t) {
t.plan( 2 );
var map = new OpenLayers.Map("map");
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
var wms = new OpenLayers.Layer.WMS(name, url);
map.addLayer(wms);
var layer = new OpenLayers.Layer("foo");
map.addLayer(layer);
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
//onscreen feature
var feature1 = new OpenLayers.Feature(layer,
new OpenLayers.LonLat(0,0));
t.ok( feature1.onScreen(), "feature knows it's onscreen" );
//onscreen feature
var feature2 = new OpenLayers.Feature(layer,
new OpenLayers.LonLat(100,100));
t.ok( !feature2.onScreen(), "feature knows it's offscreen" );
}
// -->
</script>
+17
View File
@@ -126,6 +126,23 @@
}
function test_06_Layer_getZoomForResolution(t) {
t.plan(4);
var layer = new OpenLayers.Layer('Test Layer');
//make some dummy resolutions
layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
t.eq(layer.getZoomForResolution(200), 0, "zoom all the way out");
t.eq(layer.getZoomForResolution(25), 2, "zoom in middle");
t.eq(layer.getZoomForResolution(3), 5, "zoom allmost all the way in");
t.eq(layer.getZoomForResolution(1), 6, "zoom all the way in");
}
/******
*
*
-2
View File
@@ -14,8 +14,6 @@
function test_01_Layer_WMS_constructor (t) {
t.plan( 4 );
layer = new OpenLayers.Layer.WMS();
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url, params);
t.ok( layer instanceof OpenLayers.Layer.WMS, "new OpenLayers.Layer.WMS returns object" );
+32
View File
@@ -14,10 +14,42 @@
t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" );
}
function test_02_Marker_onScreen(t) {
t.plan( 2 );
var map = new OpenLayers.Map("map");
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url);
map.addLayer(layer);
mlayer = new OpenLayers.Layer.Markers('Test Layer');
map.addLayer(mlayer);
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
//onscreen marker
var ll = new OpenLayers.LonLat(0,0);
var marker = new OpenLayers.Marker(ll);
mlayer.addMarker(marker);
t.ok( marker.onScreen(), "marker knows it's onscreen" );
//offscreen marker
var ll = new OpenLayers.LonLat(100,100);
var marker2 = new OpenLayers.Marker(ll);
mlayer.addMarker(marker2);
t.ok( !marker2.onScreen(), "marker knows it's offscreen" );
}
// -->
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>