making google tests conditional so invalid keys don't fail tests - debug reporting instead

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4249 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-09-12 20:04:26 +00:00
parent 448f64e019
commit 7eb1dafa71

View File

@@ -128,42 +128,54 @@
window.location.host);
}
}
function test_Layer_Goole_forwardMercator(t){
t.plan(2);
//Just test that the fowardMercator function still exists.
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
layer.forwardMercator = function(evt) {
t.ok( true, "GoogleMercator.forwardMercator was called and executed." );
return;
}
layer.forwardMercator();
//Now test the fowardMercator returns the expected LonLat object
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
var lonlat2 = new OpenLayers.LonLat(Math.random(),Math.random());
var result = layer.forwardMercator(lonlat2.lon, lonlat2.lat);
t.ok( result instanceof OpenLayers.LonLat, "OpenLayers.Google.fowardMercator returns LonLat object" );
}
if(validkey) {
t.plan(2);
//Just test that the fowardMercator function still exists.
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
layer.forwardMercator = function(evt) {
t.ok(true,
"GoogleMercator.forwardMercator was called and executed." );
return;
}
layer.forwardMercator();
//Now test the fowardMercator returns the expected LonLat object
var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true});
var lonlat2 = new OpenLayers.LonLat(Math.random(),Math.random());
var result = layer.forwardMercator(lonlat2.lon, lonlat2.lat);
t.ok(result instanceof OpenLayers.LonLat, "OpenLayers.Google.fowardMercator returns LonLat object" );
} else {
t.plan(0);
t.debug_print("Google tests can't be run from " +
window.location.host);
}
}
function test_Layer_Google_overlay(t) {
// Test for #849.
t.plan(1);
var map = new OpenLayers.Map( 'map' ,
{ controls: [] , 'numZoomLevels':20});
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} );
var layer = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
map.addLayers([satellite, layer]);
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5);
map.zoomIn();
var size = map.getSize();
var px = new OpenLayers.Pixel(size.w, size.h);
var br = map.getLonLatFromPixel(px);
t.ok(layer.grid[0][0].bounds.containsLonLat(br), "Bottom right pixel is covered by untiled WMS layer");
if(validkey) {
t.plan(1);
var map = new OpenLayers.Map( 'map' ,
{ controls: [] , 'numZoomLevels':20});
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} );
var layer = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
map.addLayers([satellite, layer]);
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5);
map.zoomIn();
var size = map.getSize();
var px = new OpenLayers.Pixel(size.w, size.h);
var br = map.getLonLatFromPixel(px);
t.ok(layer.grid[0][0].bounds.containsLonLat(br), "Bottom right pixel is covered by untiled WMS layer");
} else {
t.plan(0);
t.debug_print("Google tests can't be run from " +
window.location.host);
}
}
</script>