Merge branch 'master' of github.com:openlayers/openlayers into transform
Conflicts: theme/default/style.css
This commit is contained in:
@@ -278,6 +278,17 @@
|
||||
OpenLayers.Number.decimalSeparator = ",";
|
||||
t.eq(format(num, 3), "12.345,679", "changing thousands/decimal separator globally works");
|
||||
}
|
||||
|
||||
function test_Number_zeroPad(t) {
|
||||
t.plan(6);
|
||||
var pad = OpenLayers.Number.zeroPad;
|
||||
t.eq(pad(15, 4), "0015", "left padding works");
|
||||
t.eq(pad(15, 2), "15", "no left padding when equal to number of digits");
|
||||
t.eq(pad(15, 1), "15", "no left padding when less than number of digits");
|
||||
t.eq(pad(10, 5, 2), "01010", "radix modified and padding works");
|
||||
t.eq(pad(10, 5, 8), "00012", "radix modified and padding works");
|
||||
t.eq(pad(10, 5, 36), "0000a", "radix modified and padding works");
|
||||
}
|
||||
|
||||
function test_Function_bind(t) {
|
||||
t.plan(12);
|
||||
|
||||
@@ -545,6 +545,31 @@
|
||||
t.eq((control.layers === null), true, "When using setLayer with a single layer, the layers property is removed if present before");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_setLayerWithRemoving(t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer1 = new OpenLayers.Layer.Vector();
|
||||
var layer2 = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer1, layer2);
|
||||
// initialize it with a single layer
|
||||
var control = new OpenLayers.Control.SelectFeature(layer1);
|
||||
map.addControl(control);
|
||||
control.activate();
|
||||
var noError = null;
|
||||
map.events.register("preremovelayer", this, function(e) {
|
||||
try {
|
||||
control.setLayer(layer2);
|
||||
} catch (e) {
|
||||
noError = e;
|
||||
}
|
||||
});
|
||||
layer1.destroy();
|
||||
t.eq(layer2.id, control.layer.id, "Layer is set correctly without error");
|
||||
t.eq(noError, null,"No error occured during setLayer. Error is: '"+noError+"'");
|
||||
control.destroy();
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
133
tests/Format/EncodedPolyline.html
Normal file
133
tests/Format/EncodedPolyline.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var basePoints = new Array(
|
||||
new Array(3850000, -12020000),
|
||||
new Array(4070000, -12095000),
|
||||
new Array(4325200, -12645300)
|
||||
);
|
||||
|
||||
var points = [
|
||||
new OpenLayers.Geometry.Point(basePoints[0][1] * 1e-5,
|
||||
basePoints[0][0] * 1e-5),
|
||||
new OpenLayers.Geometry.Point(basePoints[1][1] * 1e-5,
|
||||
basePoints[1][0] * 1e-5),
|
||||
new OpenLayers.Geometry.Point(basePoints[2][1] * 1e-5,
|
||||
basePoints[2][0] * 1e-5)
|
||||
];
|
||||
|
||||
var singlePoint = new OpenLayers.Feature.Vector(points[0]);
|
||||
|
||||
var linestring = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(points)
|
||||
);
|
||||
|
||||
var multipoint = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPoint(points)
|
||||
);
|
||||
|
||||
var linearring = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LinearRing(points)
|
||||
);
|
||||
|
||||
var polygon = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon([
|
||||
new OpenLayers.Geometry.LinearRing(points)
|
||||
])
|
||||
);
|
||||
|
||||
var encoded = "_p~iF~ps|U_ulLnnqC_mqNvxq`@";
|
||||
|
||||
function test_Format_EncodedPolyline_constructor(t) {
|
||||
t.plan(4);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var format = new OpenLayers.Format.EncodedPolyline(options);
|
||||
t.ok(format instanceof OpenLayers.Format.EncodedPolyline,
|
||||
"new OpenLayers.Format.EncodedPolyline returns object" );
|
||||
t.eq(format.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof format.read, "function", "format has a read function");
|
||||
t.eq(typeof format.write, "function", "format has a write function");
|
||||
}
|
||||
|
||||
function test_Format_EncodedPolyline_read(t) {
|
||||
t.plan(5);
|
||||
|
||||
var format = new OpenLayers.Format.EncodedPolyline();
|
||||
|
||||
t.ok(linestring.geometry.equals(format.read(encoded).geometry),
|
||||
"format correctly reads encoded polyline");
|
||||
|
||||
format = new OpenLayers.Format.EncodedPolyline({
|
||||
geometryType: "multipoint"
|
||||
});
|
||||
t.ok(multipoint.geometry.equals(format.read(encoded).geometry),
|
||||
"format correctly reads encoded multipoint");
|
||||
|
||||
format.geometryType = "linearring";
|
||||
t.ok(linearring.geometry.equals(format.read(encoded).geometry),
|
||||
"format correctly reads encoded linearring");
|
||||
|
||||
format.geometryType = "polygon";
|
||||
t.ok(polygon.geometry.equals(format.read(encoded).geometry),
|
||||
"format correctly reads encoded polygon");
|
||||
|
||||
format.geometryType = "point";
|
||||
t.ok(points[0].equals(format.read(encoded).geometry),
|
||||
"format correctly reads encoded point");
|
||||
}
|
||||
|
||||
function test_Format_EncodedPolyline_decode(t) {
|
||||
t.plan(6);
|
||||
|
||||
var format = new OpenLayers.Format.EncodedPolyline();
|
||||
|
||||
var decodedPoints = format.decode(encoded, 2);
|
||||
for (i in decodedPoints) {
|
||||
var point = basePoints[i];
|
||||
var decodedPoint = decodedPoints[i];
|
||||
t.eq(point[0], decodedPoint[0]);
|
||||
t.eq(point[1], decodedPoint[1]);
|
||||
}
|
||||
}
|
||||
|
||||
function test_Format_EncodedPolyline_write(t) {
|
||||
t.plan(5);
|
||||
|
||||
var format = new OpenLayers.Format.EncodedPolyline();
|
||||
|
||||
t.eq(format.write(linestring), encoded,
|
||||
"format correctly writes encoded polyline");
|
||||
|
||||
t.eq(format.write(multipoint), encoded,
|
||||
"format correctly writes encoded multipoint");
|
||||
|
||||
// Different output than encoded,
|
||||
// because polygon closing point is included
|
||||
t.eq(format.write(linearring),
|
||||
"_p~iF~ps|U_ulLnnqC_mqNvxq`@~b_\\ghde@",
|
||||
"format correctly writes encoded linearring");
|
||||
|
||||
t.eq(format.write(polygon),
|
||||
"_p~iF~ps|U_ulLnnqC_mqNvxq`@~b_\\ghde@",
|
||||
"format correctly writes encoded polygon");
|
||||
|
||||
t.eq(format.write(singlePoint), "_p~iF~ps|U",
|
||||
"format correctly writes encoded point");
|
||||
}
|
||||
|
||||
function test_Format_EncodedPolyline_encode(t) {
|
||||
t.plan(1);
|
||||
|
||||
var format = new OpenLayers.Format.EncodedPolyline();
|
||||
|
||||
t.eq(format.encode(basePoints, 2), encoded);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
43
tests/Format/WCSCapabilities.html
Normal file
43
tests/Format/WCSCapabilities.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_read(t) {
|
||||
t.plan(4);
|
||||
|
||||
var _v1_0_0 = OpenLayers.Format.WCSCapabilities.v1_0_0.prototype.read;
|
||||
var _v1_1_0 = OpenLayers.Format.WCSCapabilities.v1_1_0.prototype.read;
|
||||
|
||||
var parser = new OpenLayers.Format.WCSCapabilities();
|
||||
|
||||
// version 1.0.0
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<wcs:WCS_Capabilities version="1.0.0" xmlns:wcs="http://www.opengis.net/wcs"></wcs:WCS_Capabilities>';
|
||||
OpenLayers.Format.WCSCapabilities.v1_0_0.prototype.read = function() {
|
||||
t.ok(true, "Version 1.0.0 detected");
|
||||
return {};
|
||||
}
|
||||
var res = parser.read(text);
|
||||
t.eq(res.version, "1.0.0", "version 1.0.0 written to result object");
|
||||
OpenLayers.Format.WCSCapabilities.v1_1_0.prototype.read = _v1_1_0;
|
||||
|
||||
// version 1.1.0
|
||||
var text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<wcs:WCS_Capabilities version="1.1.0" xmlns:wcs="http://www.opengis.net/wcs/1.1"></wcs:WCS_Capabilities>';
|
||||
OpenLayers.Format.WCSCapabilities.v1_1_0.prototype.read = function() {
|
||||
t.ok(true, "Version 1.1.0 detected");
|
||||
return {};
|
||||
}
|
||||
var res = parser.read(text);
|
||||
t.eq(res.version, "1.1.0", "version 1.1.0 written to result object");
|
||||
OpenLayers.Format.WCSCapabilities.v1_1_0.prototype.read = _v1_1_0;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
87
tests/Format/WCSCapabilities/v1.html
Normal file
87
tests/Format/WCSCapabilities/v1.html
Normal file
File diff suppressed because one or more lines are too long
@@ -40,4 +40,4 @@
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -150,7 +150,7 @@
|
||||
}
|
||||
|
||||
function test_createLayer(t) {
|
||||
t.plan(42);
|
||||
t.plan(43);
|
||||
|
||||
var format = new OpenLayers.Format.WMTSCapabilities();
|
||||
|
||||
@@ -308,6 +308,15 @@
|
||||
requestEncoding: 'KVP'
|
||||
});
|
||||
t.eq(layer.url[0], "http://wmts.geo.admin.ch/kvp", "correct kvp url 2");
|
||||
|
||||
// test RESTfull
|
||||
xml = document.getElementById("arcgis").firstChild.nodeValue;
|
||||
doc = new OpenLayers.Format.XML().read(xml);
|
||||
caps = format.read(doc);
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "WorldTimeZones"
|
||||
});
|
||||
t.eq(layer.requestEncoding, "REST", "correct requestEncoding (in RESTfull)");
|
||||
}
|
||||
|
||||
function test_parse_projection(t) {
|
||||
@@ -875,6 +884,78 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml
|
||||
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
|
||||
</Capabilities>
|
||||
--></div>
|
||||
<div id="arcgis"><!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
|
||||
<ows:ServiceIdentification>
|
||||
<ows:Title>WorldTimeZones</ows:Title>
|
||||
<ows:ServiceType>OGC WMTS</ows:ServiceType>
|
||||
<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
|
||||
</ows:ServiceIdentification>
|
||||
<ows:OperationsMetadata>
|
||||
<ows:Operation name="GetTile">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS/tile/1.0.0/">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>RESTful</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
<ows:Get xlink:href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS?">
|
||||
<ows:Constraint name="GetEncoding">
|
||||
<ows:AllowedValues>
|
||||
<ows:Value>KVP</ows:Value>
|
||||
</ows:AllowedValues>
|
||||
</ows:Constraint>
|
||||
</ows:Get>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
</ows:OperationsMetadata>
|
||||
<Contents>
|
||||
<Layer>
|
||||
<ows:Title>WorldTimeZones</ows:Title>
|
||||
<ows:Identifier>WorldTimeZones</ows:Identifier>
|
||||
<ows:BoundingBox crs="urn:ogc:def:crs:EPSG::102100">
|
||||
<ows:LowerCorner>-2.0037507067161843E7 -3.024097195838617E7</ows:LowerCorner>
|
||||
<ows:UpperCorner>2.0037507067161843E7 3.0240971458386205E7</ows:UpperCorner>
|
||||
</ows:BoundingBox>
|
||||
<ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">
|
||||
<ows:LowerCorner>-179.99999550841463 -88.99999992161119</ows:LowerCorner>
|
||||
<ows:UpperCorner>179.99999550841463 88.99999992161118</ows:UpperCorner>
|
||||
</ows:WGS84BoundingBox>
|
||||
<Style isDefault="true">
|
||||
<ows:Title>Default Style</ows:Title>
|
||||
<ows:Identifier>default</ows:Identifier>
|
||||
</Style>
|
||||
<Format>image/png</Format>
|
||||
<TileMatrixSetLink>
|
||||
<TileMatrixSet>GoogleMapsCompatible</TileMatrixSet>
|
||||
</TileMatrixSetLink>
|
||||
<ResourceURL format="image/png" resourceType="tile" template="http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS/tile/1.0.0/WorldTimeZones/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" />
|
||||
</Layer>
|
||||
<TileMatrixSet>
|
||||
<ows:Title>GoogleMapsCompatible</ows:Title>
|
||||
<ows:Abstract>the wellknown 'GoogleMapsCompatible' tile matrix set defined by OGC WMTS specification</ows:Abstract>
|
||||
<ows:Identifier>GoogleMapsCompatible</ows:Identifier>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:6.18:3:3857</ows:SupportedCRS>
|
||||
<WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible</WellKnownScaleSet>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>5</ows:Identifier>
|
||||
<ScaleDenominator>17471320.75089743</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>32</MatrixWidth>
|
||||
<MatrixHeight>32</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
</Contents>
|
||||
<ServiceMetadataURL xlink:href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS/1.0.0/WMTSCapabilities.xml" />
|
||||
</Capabilities>
|
||||
--></div>
|
||||
|
||||
<div id="multi-getile-2"><!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
<script type="text/javascript">window.alert = oldAlert;</script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
// turn off animation frame handling, so we can check img urls in tests
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
|
||||
|
||||
@@ -187,7 +187,9 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Check our utility function for generating tile indexes against a file cache
|
||||
* Check the utility function for generating tile indexes against a file cache
|
||||
* This is already tested in BaseTypes test, but these are specific,
|
||||
* common conversions that this class will rely on, so the tests are retained
|
||||
*/
|
||||
function test_Layer_ARCGISCACHE_zeroPad(t) {
|
||||
t.plan(4);
|
||||
@@ -195,10 +197,10 @@
|
||||
var layer = new OpenLayers.Layer.ArcGISCache('test', null, { });
|
||||
|
||||
//some tile examples
|
||||
t.ok('00000001' == layer.zeroPad(1, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00000020' == layer.zeroPad(32, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00000100' == layer.zeroPad(256, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00001000' == layer.zeroPad(4096, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00000001' == OpenLayers.Number.zeroPad(1, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00000020' == OpenLayers.Number.zeroPad(32, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00000100' == OpenLayers.Number.zeroPad(256, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
t.ok('00001000' == OpenLayers.Number.zeroPad(4096, 8, 16), 'zeroPad should generate tile indexes properly ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
/**
|
||||
* Because browsers that implement requestAnimationFrame may not execute
|
||||
* animation functions while a window is not displayed (e.g. in a hidden
|
||||
* iframe as in these tests), we mask the native implementations here. The
|
||||
* native requestAnimationFrame functionality is tested in Util.html and
|
||||
* in PanZoom.html (where a popup is opened before panning).
|
||||
*/
|
||||
window.requestAnimationFrame =
|
||||
window.webkitRequestAnimationFrame =
|
||||
window.mozRequestAnimationFrame =
|
||||
window.oRequestAnimationFrame =
|
||||
window.msRequestAnimationFrame = null;
|
||||
</script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, layer;
|
||||
@@ -108,10 +94,9 @@
|
||||
isBaseLayer: false
|
||||
}, options));
|
||||
map.addLayer(layer);
|
||||
var tile = layer.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(tile.url, "Tile not empty");
|
||||
t.ok(layer.grid[0][0].url, "Tile not empty");
|
||||
map.destroy();
|
||||
});
|
||||
}
|
||||
@@ -186,12 +171,11 @@
|
||||
layer = new OpenLayers.Layer.Bing(options);
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
var tile = layer.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(OpenLayers.Util.indexOf(layer.attribution, '<img src="//') != -1, "Attribution contains a logo with protocol //");
|
||||
t.ok(OpenLayers.Util.indexOf(layer.attribution, '<img src="http://') == -1, "Attribution logo does not have http:// protocol");
|
||||
t.ok(tile.url.indexOf('http:') == -1, "Tile url does not contain http:");
|
||||
t.ok(layer.grid[1][1].url.indexOf('http:') == -1, "Tile url does not contain http:");
|
||||
|
||||
map.destroy();
|
||||
});
|
||||
@@ -200,11 +184,10 @@
|
||||
layer_https = new OpenLayers.Layer.Bing(OpenLayers.Util.applyDefaults({protocol: 'https:'}, options));
|
||||
map2.addLayer(layer_https);
|
||||
map2.zoomToMaxExtent();
|
||||
var tile = layer_https.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(OpenLayers.Util.indexOf(layer_https.attribution, '<img src="https://') != -1, "Attribution logo has https:// protocol");
|
||||
t.ok(tile.url.indexOf('https:') == 0, "Tile url contains https:");
|
||||
t.ok(layer_https.grid[1][1].url.indexOf('https:') == 0, "Tile url contains https:");
|
||||
map2.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
// turn off animation frame handling, so we can check img urls in tests
|
||||
var origQueueTileDraw = OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -99,26 +96,6 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_queueTileDraw(t) {
|
||||
t.plan(3);
|
||||
OpenLayers.Layer.Grid.prototype.queueTileDraw = origQueueTileDraw;
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
map.addLayer(layer);
|
||||
map.setCenter([0, 0], 3);
|
||||
var queued = layer.tileQueue.length;
|
||||
t.ok(layer.tileQueue.length, "Tiles queued for drawing");
|
||||
map.zoomIn();
|
||||
t.eq(layer.tileQueue.length, queued, "Tile queue has same length after immediate zoom change");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(layer.tileQueue.length, 0, "Tiles from queue processed");
|
||||
});
|
||||
|
||||
map.destroy();
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
}
|
||||
|
||||
function test_Layer_Grid_clearTiles (t) {
|
||||
t.plan(4);
|
||||
|
||||
@@ -257,10 +234,7 @@
|
||||
|
||||
function test_Layer_Grid_moveTo(t) {
|
||||
|
||||
t.plan(17);
|
||||
|
||||
var origIsNative = OpenLayers.Animation.isNative;
|
||||
OpenLayers.Animation.isNative = false;
|
||||
t.plan(13);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
@@ -270,23 +244,6 @@
|
||||
map.setCenter([-10, 0], 5);
|
||||
|
||||
var log = [];
|
||||
var origDeferMoveGriddedTiles = layer.deferMoveGriddedTiles;
|
||||
layer.deferMoveGriddedTiles = function() {
|
||||
log.push("deferMoveGriddedTiles");
|
||||
origDeferMoveGriddedTiles.apply(this, arguments);
|
||||
};
|
||||
layer.moveGriddedTiles = function() {
|
||||
log.push("moveGriddedTiles");
|
||||
OpenLayers.Layer.WMS.prototype.moveGriddedTiles.apply(this, arguments);
|
||||
};
|
||||
map.moveTo([5, 0]);
|
||||
t.eq(log[0], "moveGriddedTiles", "deferred after moveTo");
|
||||
map.moveTo([0, 0]);
|
||||
t.eq(log[1], "moveGriddedTiles", "deferred again after another moveTo");
|
||||
t.eq(log.length, 2, "no tiles loaded yet");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(log[2], "deferMoveGriddedTiles", "tiles moved after tileLoadingDelay");
|
||||
});
|
||||
|
||||
//make sure null bounds doesnt cause script error.
|
||||
// no test necessary, just action
|
||||
@@ -308,9 +265,6 @@
|
||||
g_WhichFunc = "MoveGridded";
|
||||
g_Bounds = layer.map.getExtent();
|
||||
};
|
||||
layer.deferMoveGriddedTiles = function() {
|
||||
g_WhichFunc = "DeferMoveGridded";
|
||||
}
|
||||
var clearTestBounds = function() {
|
||||
g_WhichFunc = null;
|
||||
g_Bounds = null;
|
||||
@@ -417,8 +371,6 @@
|
||||
layer.moveTo(null, zoomChanged);
|
||||
t.ok(g_WhichFunc == "InitGridded", "if tiles drastically out of bounds, we call initGriddedTile()");
|
||||
t.ok(g_Bounds.equals(b), "if tiles drastically out of bounds, we call initGriddedTile() with correct bounds");
|
||||
|
||||
OpenLayers.Animation.isNative = origIsNative;
|
||||
}
|
||||
|
||||
/** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
|
||||
@@ -437,7 +389,7 @@
|
||||
*/
|
||||
|
||||
function test_Layer_Grid_clone(t) {
|
||||
t.plan(7);
|
||||
t.plan(6);
|
||||
|
||||
var options = {tileSize: new OpenLayers.Size(500,50)};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
@@ -452,7 +404,6 @@
|
||||
t.ok( clone.grid != layer.grid, "clone does not copy grid");
|
||||
t.ok( clone.grid.length == 0, "clone creates a new array instead");
|
||||
|
||||
t.ok(clone.tileQueue !== layer.tileQueue, "new tileQueue for clone");
|
||||
t.eq(clone.backBuffer, null, "no backbuffer from original");
|
||||
|
||||
t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
|
||||
@@ -574,7 +525,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
imgDiv: {className: ''}
|
||||
}
|
||||
|
||||
g_registered = {};
|
||||
@@ -1146,6 +1098,36 @@
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_backbuffer_replace(t) {
|
||||
t.plan(6);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS('', '../../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
t.delay_call(1, function() {
|
||||
layer.mergeNewParams({foo: 'bar'});
|
||||
var tile = layer.grid[1][1];
|
||||
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olTileReplacing'), 'tile is marked for being replaced');
|
||||
t.ok(document.getElementById(tile.id + '_bb'), 'backbuffer created for tile');
|
||||
// simulate a css declaration where '.olTileReplacing' sets display
|
||||
// to none.
|
||||
tile.imgDiv.style.display = 'none';
|
||||
tile.onImageLoad();
|
||||
t.ok(!OpenLayers.Element.hasClass(tile.imgDiv, 'olTileReplacing'), 'tile replaced, no longer marked');
|
||||
t.ok(!document.getElementById(tile.id + '_bb'), 'backbuffer removed for tile');
|
||||
|
||||
layer.mergeNewParams({foo: 'baz'});
|
||||
tile = layer.grid[1][1];
|
||||
// simulate a css declaration where '.olTileReplacing' does not set
|
||||
// display to none.
|
||||
tile.imgDiv.style.display = 'block';
|
||||
tile.onImageLoad();
|
||||
t.ok(!OpenLayers.Element.hasClass(tile.imgDiv, 'olTileReplacing'), 'tile replaced, no longer marked');
|
||||
t.ok(document.getElementById(tile.id + '_bb'), 'backbuffer not removed for visible tile');
|
||||
});
|
||||
}
|
||||
|
||||
function test_singleTile_move_and_zoom(t) {
|
||||
|
||||
@@ -1475,6 +1457,32 @@
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_addOptions(t) {
|
||||
t.plan(15);
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {buffer:2});
|
||||
map.addLayer(layer);
|
||||
t.eq(layer.tileSize, map.getTileSize(), "layer's tile size is equal to the map's tile size");
|
||||
t.ok(layer.removeBackBufferDelay !== 0, "removeBackBufferDelay should not be 0 since we are not singleTile");
|
||||
t.eq(layer.className, "olLayerGrid", "className correct for gridded mode");
|
||||
map.setCenter(new OpenLayers.LonLat(0,0),5);
|
||||
t.eq(layer.grid.length, 8, "Grid rows is correct.");
|
||||
t.eq(layer.grid[0].length, 7, "Grid cols is correct.");
|
||||
t.eq(layer.singleTile, false, "singleTile is false by default");
|
||||
layer.addOptions({singleTile: true});
|
||||
t.eq(layer.removeBackBufferDelay, 0, "removeBackBufferDelay set to 0 since singleTile is true");
|
||||
t.eq(layer.singleTile, true, "singleTile set to true");
|
||||
t.eq(layer.className, "olLayerGridSingleTile", "className correct for singleTile mode");
|
||||
t.eq(layer.grid.length, 1, "Grid rows is correct.");
|
||||
t.eq(layer.grid[0].length, 1, "Grid cols is correct.");
|
||||
t.eq(layer.tileSize, new OpenLayers.Size(748, 823), "tile size changed");
|
||||
layer.addOptions({singleTile: false});
|
||||
t.eq(layer.grid.length, 8, "Grid rows is correct.");
|
||||
t.eq(layer.grid[0].length, 7, "Grid cols is correct.");
|
||||
t.eq(layer.tileSize, map.getTileSize(), "layer's tile size is equal to the map's tile size");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -555,9 +555,6 @@
|
||||
}
|
||||
|
||||
function test_tileBounds(t) {
|
||||
// do not defer moveGriddedTiles
|
||||
var isNative = OpenLayers.Animation.isNative;
|
||||
OpenLayers.Animation.isNative = true;
|
||||
t.plan(3);
|
||||
|
||||
var map = new OpenLayers.Map("map", {projection: "EPSG:3857"});
|
||||
@@ -575,7 +572,6 @@
|
||||
t.eq(bounds.right, 0, "0 is 0, and not some super small number");
|
||||
|
||||
map.destroy();
|
||||
OpenLayers.Animation.isNative = isNative;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
var drawn = tile.draw();
|
||||
t.eq(log[0], "clear", "tile cleared");
|
||||
t.eq(log[1], "beforedraw", "beforedraw event fired");
|
||||
t.eq(drawn, false, "tile not drawn when beforedraw listener returns false");
|
||||
t.eq(drawn, null, "tile not drawn when beforedraw listener returns false");
|
||||
drawn = tile.draw(true);
|
||||
t.eq(log.length, 2, "no beforedraw event fired and tile not cleared when draw called with 'deferred' argument set to true");
|
||||
t.eq(drawn, true, "tile drawn when draw called with 'deferred' argument set to true");
|
||||
|
||||
125
tests/TileManager.html
Normal file
125
tests/TileManager.html
Normal file
@@ -0,0 +1,125 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan(4);
|
||||
|
||||
var tileManager = new OpenLayers.TileManager();
|
||||
var map = new OpenLayers.Map('map', {
|
||||
tileManager: tileManager
|
||||
});
|
||||
var layer = new OpenLayers.Layer.WMS('WMS1', '../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.setCenter([16, 48], 9);
|
||||
t.ok(tileManager.tileQueue[map.id].length, "Tiles queued from layer");
|
||||
map.removeLayer(layer);
|
||||
t.eq(tileManager.tileQueue[map.id].length, 0, "Tiles unqueued when layer is removed");
|
||||
map.addLayer(new OpenLayers.Layer.WMS('WMS2', '../img/blank.gif'));
|
||||
map.zoomIn();
|
||||
t.ok(tileManager.tileQueue[map.id].length, "Tiles queued from added layer");
|
||||
map.destroy();
|
||||
t.eq(tileManager.tileQueue[map.id], undefined, "Tile queue removed when map was destroyed");
|
||||
}
|
||||
|
||||
function test_destroy(t) {
|
||||
t.plan(3);
|
||||
|
||||
var tileManager = new OpenLayers.TileManager();
|
||||
var map = new OpenLayers.Map('map', {tileManager: tileManager});
|
||||
var layer = new OpenLayers.Layer.WMS('WMS', '../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.setCenter([16, 48], 9);
|
||||
var numTileListeners = layer.grid[0][0].events.listeners.beforeload.length;
|
||||
var numLayerListeners = layer.events.listeners.retile.length;
|
||||
var numMapListeners = map.events.listeners.preremovelayer.length;
|
||||
tileManager.destroy();
|
||||
t.eq(layer.grid[0][0].events.listeners.beforeload.length, numTileListeners - 1, "no listener on tile after destroy");
|
||||
t.eq(layer.events.listeners.retile.length, numLayerListeners - 1, "no listeners on layer after destroy");
|
||||
t.eq(map.events.listeners.preremovelayer.length, numMapListeners - 1, "no listeners on map after destroy");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_manageTileCache(t) {
|
||||
t.plan(10);
|
||||
|
||||
var tileManager = new OpenLayers.TileManager({
|
||||
cacheSize: 12
|
||||
});
|
||||
var map = new OpenLayers.Map('map', {tileManager: tileManager});
|
||||
layer = new OpenLayers.Layer.WMS('WMS', '../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.setCenter([16, 48], 9);
|
||||
var gridSize;
|
||||
|
||||
var firstInCache, sharedTile;
|
||||
t.delay_call(2, function() {
|
||||
t.eq(tileManager.tileCacheIndex.length, 12, "tiles cached");
|
||||
t.ok(~OpenLayers.Util.indexOf(tileManager.tileCacheIndex, layer.grid[1][2].url), "tile found in cache");
|
||||
t.ok(tileManager.tileCache[layer.grid[1][2].url] === layer.grid[1][2].imgDiv, "correct object cached");
|
||||
firstInCache = tileManager.tileCache[tileManager.tileCacheIndex[0]];
|
||||
sharedTile = tileManager.tileCache[tileManager.tileCacheIndex[11]];
|
||||
gridSize = layer.div.childNodes.length;
|
||||
map.setCenter([17, 47]);
|
||||
});
|
||||
t.delay_call(4, function() {
|
||||
t.eq(tileManager.tileCacheIndex.length, 12, "tiles cached");
|
||||
t.ok(tileManager.tileCache[layer.grid[1][2].url] === layer.grid[1][2].imgDiv, "correct object cached");
|
||||
t.ok(!(firstInCache.getAttribute("src") in tileManager.tileCache), "old tile discarded");
|
||||
t.ok(sharedTile.getAttribute("src") in tileManager.tileCache, "shared tile still in cache");
|
||||
firstInCache = tileManager.tileCache[tileManager.tileCacheIndex[0]];
|
||||
map.setCenter([16, 48]);
|
||||
});
|
||||
t.delay_call(6, function() {
|
||||
t.ok(!(firstInCache.getAttribute("src") in tileManager.tileCache), "old tile discarded");
|
||||
t.ok(sharedTile.getAttribute("src") in tileManager.tileCache, "shared tile still in cache");
|
||||
t.eq(layer.div.childNodes.length, gridSize, 'no unused images left in dom');
|
||||
map.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function test_queueTileDraw(t) {
|
||||
t.plan(3);
|
||||
|
||||
var tileManager = new OpenLayers.TileManager();
|
||||
var map = new OpenLayers.Map('map', {tileManager: tileManager});
|
||||
layer = new OpenLayers.Layer.WMS('WMS', '../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.setCenter([0, 0], 3);
|
||||
var queued = tileManager.tileQueue[map.id].length;
|
||||
t.ok(tileManager.tileQueue[map.id].length, "Tiles queued for drawing");
|
||||
map.zoomIn();
|
||||
t.eq(tileManager.tileQueue[map.id].length, queued, "Tile queue has same length after immediate zoom change");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(tileManager.tileQueue[map.id].length, 0, "Tiles from queue processed");
|
||||
map.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function test_deferTileDraw(t) {
|
||||
|
||||
t.plan(3);
|
||||
|
||||
var tileManager = new OpenLayers.TileManager();
|
||||
var map = new OpenLayers.Map('map', {tileManager: tileManager});
|
||||
layer = new OpenLayers.Layer.WMS('WMS', '../img/blank.gif');
|
||||
layer.destroy = function() {}; //we're going to do funky things with the grid
|
||||
layer.applyBackBuffer = function() {}; // backbuffering isn't under test here
|
||||
map.addLayer(layer);
|
||||
map.setCenter([-10, 0], 5);
|
||||
|
||||
map.moveTo([5, 0]);
|
||||
t.ok(tileManager.tileQueue[map.id].length, "tile loading deferred after moveTo");
|
||||
map.moveTo([0, 0]);
|
||||
t.ok(tileManager.tileQueue[map.id].length, "deferred again after another moveTo");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(tileManager.tileQueue[map.id].length, 0, "tiles loaded after moveDelay");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:499px;height:549px;display:none"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -74,6 +74,39 @@
|
||||
tween.stop();
|
||||
t.ok(tween.animationId != null, "stop method doesn't do anything if tween isn't running");
|
||||
}
|
||||
|
||||
function test_Tween_skip(t) {
|
||||
t.plan(2);
|
||||
|
||||
var tween = new OpenLayers.Tween();
|
||||
var log = 0;
|
||||
tween.start({count: 0}, {count: 10}, 10, {
|
||||
callbacks: {
|
||||
eachStep: function() {
|
||||
log++;
|
||||
}
|
||||
},
|
||||
minFrameRate: 10000
|
||||
});
|
||||
|
||||
t.delay_call(0.8, function() {
|
||||
t.eq(log, 0, 'all frames skipped at a frame rate of 10000');
|
||||
|
||||
log = 0;
|
||||
tween.start({count: 0}, {count: 10}, 10, {
|
||||
callbacks: {
|
||||
eachStep: function() {
|
||||
log++;
|
||||
}
|
||||
},
|
||||
minFrameRate: 1
|
||||
});
|
||||
});
|
||||
|
||||
t.delay_call(1.6, function() {
|
||||
t.eq(log, 11, 'no frames skipped at a frame rate of 1');
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
<script src="../../../../lib/deprecated.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// turn off animation frame handling, so we can check img urls in tests
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<li>Format/XML/VersionedOGC.html</li>
|
||||
<li>Format/ArcXML/Features.html</li>
|
||||
<li>Format/CQL.html</li>
|
||||
<li>Format/EncodedPolyline.html</li>
|
||||
<li>Format/GeoJSON.html</li>
|
||||
<li>Format/GeoRSS.html</li>
|
||||
<li>Format/GML.html</li>
|
||||
@@ -84,6 +85,8 @@
|
||||
<li>Format/Filter/v1_0_0.html</li>
|
||||
<li>Format/Filter/v1_1_0.html</li>
|
||||
<li>Format/QueryStringFilter.html</li>
|
||||
<li>Format/WCSCapabilities.html</li>
|
||||
<li>Format/WCSCapabilities/v1.html</li>
|
||||
<li>Format/WFS.html</li>
|
||||
<li>Format/WFSCapabilities.html</li>
|
||||
<li>Format/WFSCapabilities/v1.html</li>
|
||||
@@ -228,6 +231,7 @@
|
||||
<li>Tile/Image.html</li>
|
||||
<li>Tile/Image/IFrame.html</li>
|
||||
<li>Tile/UTFGrid.html</li>
|
||||
<li>TileManager.html</li>
|
||||
<li>Tween.html</li>
|
||||
<li>Kinetic.html</li>
|
||||
<li>Util.html</li>
|
||||
|
||||
Reference in New Issue
Block a user