fix tests that do double-test to check lonlat or xy or wh instead of using the equals() functions

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1139 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-09 03:56:32 +00:00
parent 31af99c64d
commit 69876208f4
9 changed files with 49 additions and 49 deletions

View File

@@ -4,7 +4,7 @@
<script type="text/javascript"><!--
var bounds;
function test_01_Bounds_constructor (t) {
t.plan( 12 );
t.plan( 11 );
bounds = new OpenLayers.Bounds(0,2,10,4);
t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
@@ -16,8 +16,8 @@
t.eq( bounds.getHeight(), 2, "bounds.getHeight() returns correct value" );
var sz = bounds.getSize();
t.eq( sz.w, 10, "bounds.getSize() has correct width value" );
t.eq( sz.h, 2, "bounds.getSize() has correct height value" );
var size = new OpenLayers.Size(10,2);
t.ok(sz.equals(size),"bounds.getSize() has correct value" );
var center = new OpenLayers.Pixel(5,3);
var boundsCenter = bounds.getCenterPixel();

View File

@@ -5,12 +5,12 @@
var icon;
function test_01_Icon_constructor (t) {
t.plan( 5 );
icon = new OpenLayers.Icon("",new OpenLayers.Size(5,6));
t.plan( 4 );
var size = new OpenLayers.Size(5,6);
icon = new OpenLayers.Icon("", size);
t.ok( icon instanceof OpenLayers.Icon, "new OpenLayers.Icon returns Icon object" );
t.ok( icon.size instanceof OpenLayers.Size, "icon.size returns Size object" );
t.eq( icon.size.w, 5, "icon.size.w returns correct value" );
t.eq( icon.size.h, 6, "icon.size.w returns correct value" );
t.ok( icon.size.equals(size), "icon.size returns correct value" );
t.eq( icon.url, "", "icon.url returns str object" );
}
function test_02_Icon_clone (t) {

View File

@@ -6,15 +6,15 @@
var layer;
function test_01_Layer_GeoRSS_constructor (t) {
t.plan( 6 );
t.plan( 5 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', "./georss.txt" );
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
t.eq( layer.location, "./georss.txt", "layer.location is correct" );
var markers;
t.delay_call( 1, function() {
t.eq( layer.markers.length, 40, "marker length is correct" );
t.eq( layer.markers[0].lonlat.lat, 42.405696, "latitude on first marker is correct" );
t.eq( layer.markers[0].lonlat.lon, -71.142197, "latitude on first marker is correct" );
var ll = new OpenLayers.LonLat(-71.142197, 42.405696);
t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
t.eq( layer.name, "Crschmidt's Places At Platial", "Layer name is correct." );
} );
}

View File

@@ -6,7 +6,7 @@
var layer;
function test_01_Layer_Text_constructor (t) {
t.plan( 6 );
t.plan( 5 );
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
t.ok( layer instanceof OpenLayers.Layer.Text, "new OpenLayers.Layer.Text returns object" );
@@ -14,8 +14,8 @@
var markers;
t.delay_call( 1, function() {
t.eq( layer.markers.length, 2, "marker length is correct" );
t.eq( layer.markers[0].lonlat.lat, 10, "latitude on first marker is correct" );
t.eq( layer.markers[0].lonlat.lon, 20, "latitude on first marker is correct" );
var ll = new OpenLayers.LonLat(20, 10);
t.ok( layer.markers[0].lonlat.equals(ll), "first marker is correct" );
t.eq( layer.markers[0].icon.url, 'http://boston.openguides.org/markers/ORANGE.png', "icon" );
} );
}

View File

@@ -27,28 +27,27 @@
}
function test_03_LonLat_clone(t) {
t.plan( 4 );
t.plan( 3 );
oldLonLat = new OpenLayers.LonLat(5,6);
lonlat = oldLonLat.clone();
t.ok( lonlat instanceof OpenLayers.LonLat, "clone returns new OpenLayers.LonLat object" );
t.eq( lonlat.lon, 5, "lonlat.lon is set correctly");
t.eq( lonlat.lat, 6, "lonlat.lat is set correctly");
t.ok( lonlat.equals(oldLonLat), "lonlat is set correctly");
oldLonLat.lon = 100;
t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon");
}
function test_04_LonLat_add(t) {
t.plan( 4 );
t.plan( 2 );
lonlatA = new OpenLayers.LonLat(10,100);
addpx = lonlatA.add(5, 50);
t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by add operation");
t.eq( lonlatA.lat, 100, "lonlatA.lat is not modified by add operation");
var ll = new OpenLayers.LonLat(10,100);
t.ok( lonlatA.equals(ll), "lonlatA is not modified by add operation");
t.eq( addpx.lon, 15, "addpx.lon is set correctly");
t.eq( addpx.lat, 150, "addpx.lat is set correctly");
var ll = new OpenLayers.LonLat(15,150);
t.ok( addpx.equals(ll), "addpx is set correctly");
}
function test_06_LonLat_equals(t) {
@@ -72,11 +71,12 @@
}
function test_07_LonLat_fromString(t) {
t.plan( 3 );
t.plan( 2 );
lonlat = OpenLayers.LonLat.fromString("6,5");
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
var ll = new OpenLayers.LonLat(6, 5);
t.ok( lonlat.equals(ll), "lonlat is set correctly");
}
// -->

View File

@@ -30,17 +30,17 @@
t.ok( map.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" );
}
function test_02_Map_center(t) {
t.plan(4);
t.plan(3);
map = new OpenLayers.Map($('map'));
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.setCenter(new OpenLayers.LonLat(2,1), 0);
var ll = new OpenLayers.LonLat(2,1);
map.setCenter(ll, 0);
t.ok( map.getCenter() instanceof OpenLayers.LonLat, "map.getCenter returns a LonLat");
t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter");
t.eq( map.getCenter().lon, 2, "map center lon is correct after calling setCenter");
t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter");
t.ok( map.getCenter().equals(ll), "map center is correct after calling setCenter");
}
function test_03_Map_add_layers(t) {
t.plan(5);
@@ -66,17 +66,17 @@
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hash" );
}
function test_05_Map_center(t) {
t.plan(5);
t.plan(4);
map = new OpenLayers.Map($('map'));
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"} );
map.addLayer(baseLayer);
map.setCenter(new OpenLayers.LonLat(2, 1), 0);
var ll = new OpenLayers.LonLat(2,1);
map.setCenter(ll, 0);
map.zoomIn();
t.eq( map.getZoom(), 1, "map.zoom is correct after calling setCenter,zoom in");
t.eq( map.getCenter().lon, 2, "map center lon is correct after calling setCenter, zoom in");
t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter,zoom in");
t.ok( map.getCenter().equals(ll), "map center is correct after calling setCenter, zoom in");
map.zoomOut();
t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter,zoom in, zoom out");

View File

@@ -5,13 +5,13 @@
var marker;
function test_01_Marker_constructor (t) {
t.plan( 5 );
marker = new OpenLayers.Marker(new OpenLayers.LonLat(2,1),new OpenLayers.Icon());
t.plan( 4 );
var ll = new OpenLayers.LonLat(2,1);
marker = new OpenLayers.Marker(ll,new OpenLayers.Icon());
t.ok( marker instanceof OpenLayers.Marker, "new OpenLayers.Marker returns Marker object" );
t.ok( marker.icon instanceof OpenLayers.Icon, "new marker.Icon returns Icon object" );
t.ok( marker.lonlat instanceof OpenLayers.LonLat, "new marker.lonlat returns LonLat object" );
t.eq( marker.lonlat.lon, 2, "marker.lonlat.lon returns correct lon" );
t.eq( marker.lonlat.lat, 1, "marker.lonlat.lat returns correct lat" );
t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" );
}

View File

@@ -5,14 +5,15 @@
var popup;
function test_01_Popup_default_constructor(t) {
t.plan( 9 );
t.plan( 8 );
var size = new OpenLayers.Size(OpenLayers.Popup.WIDTH,
OpenLayers.Popup.HEIGHT);
popup = new OpenLayers.Popup();
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
t.ok(popup.id.startsWith("Popup"), "good default popup.id");
t.eq(popup.size.w, OpenLayers.Popup.WIDTH, "good default popup.size.w");
t.eq(popup.size.h, OpenLayers.Popup.HEIGHT, "good default popup.size.h");
t.ok(popup.size.equals(size), "good default popup.size");
t.eq(popup.contentHTML, "", "good default popup.contentHTML");
t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor");
t.eq(popup.opacity, OpenLayers.Popup.OPACITY, "good default popup.opacity");
@@ -28,26 +29,26 @@
}
function test_02_Popup_constructor (t) {
t.plan( 7 );
t.plan( 5 );
var id = "chicken";
var w = 500;
var h = 400;
var sz = new OpenLayers.Size(w,h);
var lon = 5;
var lat = 40;
var ll = new OpenLayers.LonLat(lon, lat);
var content = "foo";
popup = new OpenLayers.Popup(id,
new OpenLayers.LonLat(lon, lat),
new OpenLayers.Size(w, h),
ll,
sz,
content);
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
t.eq(popup.id, id, "popup.id set correctly");
t.eq(popup.lonlat.lon, lon, "lon of popup.lonlat set correctly");
t.eq(popup.lonlat.lat, lat, "lat of popup.lonlat set correctly");
t.eq(popup.size.w, w, "width of popup.size set correctly");
t.eq(popup.size.h, h, "height of popup.size set correctly");
t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly");
t.ok(popup.size.equals(sz), "popup.size set correctly");
t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly");
}

View File

@@ -20,13 +20,12 @@
}
function test_03_Size_clone(t) {
t.plan( 4 );
t.plan( 3 );
oldSize = new OpenLayers.Size(5,6);
size = oldSize.clone();
t.ok( size instanceof OpenLayers.Size, "clone returns new OpenLayers.Size object" );
t.eq( size.w, 5, "Size.w is set correctly");
t.eq( size.h, 6, "Size.h is set correctly");
t.ok( size.equals(oldSize), "new size is equal to old size correctly");
oldSize.w = 100;
t.eq( size.w, 5, "changing oldSize.w doesn't change size.w");