Conflicts:
	tests/list-tests.html
This commit is contained in:
Marc Jansen
2012-08-17 22:46:06 +02:00
78 changed files with 1733 additions and 315 deletions

View File

@@ -6,6 +6,7 @@
// dependencies for tests
var OpenLayers = [
"OpenLayers/Util/vendorPrefix.js",
"OpenLayers/Animation.js"
];

View File

@@ -33,6 +33,31 @@
map.addControl(control2, new OpenLayers.Pixel(100,100));
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
}
function test_draw(t) {
t.plan(3);
map = new OpenLayers.Map('map', {controls:[]});
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.zoomToMaxExtent();
control = new OpenLayers.Control.PanZoomBar();
map.addControl(control);
t.eq(control.zoombarDiv.style.height, '176px', "Bar's height is correct.");
map.baseLayer.wrapDateLine = true;
control.redraw();
t.eq(control.zoombarDiv.style.height, '154px', "Bar's height is correct after minZoom restriction.");
map.div.style.width = "512px";
map.updateSize();
t.eq(control.zoombarDiv.style.height, '165px', "Bar's height is correct after resize and minZoom restriction.");
map.div.style.width = "1024px";
map.destroy();
}
function test_Control_PanZoomBar_clearDiv(t) {
t.plan(2);

View File

@@ -104,13 +104,18 @@
t.plan(7);
var layer = new OpenLayers.Layer.Vector("foo", {
var layer1 = new OpenLayers.Layer.Vector("foo", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: true
});
var control = new OpenLayers.Control.Split({layer: layer});
var layer2 = new OpenLayers.Layer.Vector("bar", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: false
});
var control = new OpenLayers.Control.Split({layer: layer1});
var map = new OpenLayers.Map("map");
map.addLayer(layer);
map.addLayer(layer1);
map.addLayer(layer2);
map.zoomToMaxExtent();
map.addControl(control);
@@ -124,17 +129,17 @@
t.eq(control.handler.active, false, "sketch handler deactivated");
// set a source layer
control.setSource(layer);
control.setSource(layer2);
// activate and check that listeners are registered
control.activate();
t.ok(layer.events.listeners.sketchcomplete, "sketchcomplete listener registered");
t.ok(layer.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered");
t.ok(layer2.events.listeners.sketchcomplete, "sketchcomplete listener registered");
t.ok(layer2.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered");
// deactivate and confirm no draw related events
control.deactivate();
t.eq(layer.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners");
t.eq(layer.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners");
t.eq(layer2.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners");
t.eq(layer2.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners");
map.destroy();
}

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_constructor(t) {
t.plan(4);
var control = new OpenLayers.Control.ZoomBox();
t.ok(control instanceof OpenLayers.Control, "instance of Control");
t.ok(control instanceof OpenLayers.Control.ZoomBox, "instance of ZoomBox");
t.eq(control.displayClass, "olControlZoomBox", "displayClass");
control.destroy();
control = new OpenLayers.Control.ZoomBox({
zoomOnClick: false
});
t.eq(control.zoomOnClick, false, "zoomOnClick");
control.destroy();
}
function test_zoomBox(t) {
t.plan(4);
var map = new OpenLayers.Map("map", {
layers: [new OpenLayers.Layer("", {isBaseLayer: true})],
center: [0, 0],
zoom: 1
});
var control = new OpenLayers.Control.ZoomBox();
map.addControl(control);
control.zoomBox(new OpenLayers.Pixel(50, 60));
t.eq(map.getZoom(), 2, "zoomed on click");
control.zoomOnClick = false;
control.zoomBox(new OpenLayers.Pixel(-50, -60));
t.eq(map.getZoom(), 2, "not zoomed with zoomOnClick set to false");
map.zoomToMaxExtent();
control.zoomBox(new OpenLayers.Bounds(128, 64, 256, 128));
t.eq(map.getCenter().toShortString(), "-45, 22.5", "centered to box center");
t.eq(map.getZoom(), 3, "zoomed to box extent");
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width: 512px; height: 256px;"/>
</body>
</html>

View File

@@ -63,6 +63,40 @@
events.destroy();
}
function test_ignore(t) {
t.plan(5);
// set up
events = new OpenLayers.Events({}, element);
buttonClick = new OpenLayers.Events.buttonclick(events);
var link = document.createElement('a'),
span1 = document.createElement('span'),
span2 = document.createElement('span'),
span3 = document.createElement('span');
link.appendChild(span1);
span1.appendChild(span2);
span2.appendChild(span3);
t.eq(buttonClick.ignore(link), true,
'ignore returns true when element is a link');
t.eq(buttonClick.ignore(span1), true,
'ignore returns true when element is link descendant level 1');
t.eq(buttonClick.ignore(span2), true,
'ignore returns true when element is link descendant level 2');
t.eq(buttonClick.ignore(span3), false,
'ignore returns false when element is link descendant level 3');
t.eq(buttonClick.ignore(element), false,
'ignore returns false when element is not a link');
// tear down
buttonClick.destroy();
events.destroy();
}
function test_ButtonClick_buttonClick(t) {
t.plan(27);
events = new OpenLayers.Events({}, element);

View File

@@ -198,14 +198,19 @@ var cases = {
])
])
]),
"v2/box-coord.xml": new OpenLayers.Bounds(1, 2, 3, 4),
"v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4)
"v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4),
"v3/linestring3d.xml": new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(1, 2, 3),
new OpenLayers.Geometry.Point(4, 5, 6)
])
};
// cases for v3 use the same geometries
// some cases for v3 use the same geometries
OpenLayers.Util.extend(cases, {
"v3/point.xml": cases["v2/point-coordinates.xml"],
"v3/linestring.xml": cases["v2/linestring-coordinates.xml"],

View File

@@ -10,8 +10,8 @@
"v2/linestring-coord.xml", "v2/linestring-coordinates.xml",
"v2/multipoint-coord.xml", "v2/multipoint-coordinates.xml",
"v2/multilinestring-coord.xml", "v2/multilinestring-coordinates.xml",
"v3/point.xml", "v3/linestring.xml", "v3/curve.xml",
"v3/polygon.xml", "v3/surface.xml",
"v3/point.xml", "v3/linestring.xml", "v3/linestring3d.xml",
"v3/curve.xml", "v3/polygon.xml", "v3/surface.xml",
"v3/multipoint-singular.xml", "v3/multipoint-plural.xml",
"v3/multilinestring-singular.xml", "v3/multilinestring-plural.xml",
"v3/multicurve-singular.xml", "v3/multicurve-curve.xml",
@@ -332,6 +332,11 @@
<gml:posList>1 2 3 4</gml:posList>
</gml:LineString>
--></div>
<div id="v3/linestring3d.xml"><!--
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="foo" srsDimension="3">
<gml:posList>1 2 3 4 5 6</gml:posList>
</gml:LineString>
--></div>
<div id="v3/curve.xml"><!--
<gml:Curve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:segments>

View File

@@ -20,6 +20,10 @@
}
function test_Format_GPX_read(t) {
t.plan(7);
var origDefaultPrecision = OpenLayers.Util.DEFAULT_PRECISION;
OpenLayers.Util.DEFAULT_PRECISION = 9;
var expected,
P = OpenLayers.Geometry.Point,
LS = OpenLayers.Geometry.LineString;
@@ -61,6 +65,8 @@
new P(-19493.373203291227, 6684644.845706556)
]);
t.geom_eq(features[1].geometry, expected, "transformed route feature correctly created");
OpenLayers.Util.DEFAULT_PRECISION = origDefaultPrecision;
}
function test_format_GPX_read_attributes(t) {
t.plan(2);

View File

@@ -374,8 +374,24 @@
// GeoServer example above
}
function test_read_exception(t) {
t.plan(1);
var text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<ows:ExceptionReport version="1.0.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">' +
' <ows:Exception exceptionCode="NoApplicableCode">' +
' <ows:ExceptionText>Could not find type: {http://geonode.org/}_map_4_annotations</ows:ExceptionText>' +
' </ows:Exception>' +
'</ows:ExceptionReport>';
var format = new OpenLayers.Format.WFSDescribeFeatureType();
var obj = format.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
</script>
</head>
<body>
</body>
</html>
</html>

View File

@@ -43,15 +43,15 @@
undefined,
"ows:OperationsMetadata GetTile Constraints Get is correct");
}
function test_layers(t) {
t.plan(37);
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
var contents = obj.contents;
var numOfLayers = contents.layers.length;
t.eq(numOfLayers, 1, "correct count of layers");
@@ -89,11 +89,11 @@
t.eq(wgs84Bbox.top, 90.0, "wgs84BoudingBox top is correct");
t.eq(layer.resourceUrl.tile.format, "image/png", "resourceUrl.tile.format is correct");
t.eq(layer.resourceUrl.tile.template, "http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png",
t.eq(layer.resourceUrl.tile.template, "http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png",
"resourceUrl.tile.template is correct");
t.eq(layer.resourceUrl.FeatureInfo.format, "application/gml+xml; version=3.1", "resourceUrl.FeatureInfo.format is correct");
t.eq(layer.resourceUrl.FeatureInfo.template, "http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml",
t.eq(layer.resourceUrl.FeatureInfo.template, "http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml",
"resourceUrl.FeatureInfo.template is correct");
var dimensions = layer.dimensions;
@@ -112,7 +112,7 @@
t.plan(19);
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
var tileMatrixSets = obj.contents.tileMatrixSets;
@@ -138,54 +138,154 @@
t.eq(bigWorld.matrixIds[1].topLeftCorner.lon, -180, "tileMatrix 1 topLeftCorner.lon is correct");
t.eq(bigWorld.matrixIds[1].topLeftCorner.lat, 84, "tileMatrix 1 topLeftCorner.lat is correct");
}
function test_createLayer(t) {
t.plan(7);
t.plan(34);
var format = new OpenLayers.Format.WMTSCapabilities();
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var caps = format.read(doc);
var layer;
var success = true;
try {
// incomplete config (missing matrixSet)
// incomplete config (missing layer)
layer = format.createLayer(caps, {
layer: "coastlines"
});
} catch (err) {
success = false;
}
t.ok(!success, "createLayer throws error if provided incomplete layer config");
// bogus layer identifier
layer = format.createLayer(caps, {
layer: "foo",
matrixSet: "BigWorld"
});
t.eq(layer, undefined, "createLayer returns undefined given bad layer identifier");
try {
layer = format.createLayer(caps, {
layer: "foo",
matrixSet: "BigWorld"
});
} catch (err) {
success = false;
}
t.ok(!success, "createLayer returns undefined given bad layer identifier");
// bogus matrixSet identifier
layer = format.createLayer(caps, {
layer: "coastlines",
matrixSet: "TheWorld"
});
t.eq(layer, undefined, "createLayer returns undefined given bad matrixSet identifier");
try {
layer = format.createLayer(caps, {
layer: "coastlines",
matrixSet: "TheWorld"
});
} catch (err) {
success = false;
}
t.ok(!success, "createLayer returns undefined given bad matrixSet identifier");
layer = format.createLayer(caps, {
layer: "coastlines",
matrixSet: "BigWorld"
});
t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance");
// autodetect matrixSet
layer = format.createLayer(caps, {
layer: "coastlines"
});
t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance, with autodetected matrixSet");
t.eq(layer.matrixIds.length, 2, "correct matrixIds length");
t.eq(layer.name, "Coastlines", "correct layer title");
t.eq(layer.style, "DarkBlue", "correct style identifier");
t.eq(layer.requestEncoding, "KVP", "correct requestEncoding");
xml = document.getElementById("restsample").firstChild.nodeValue;
doc = new OpenLayers.Format.XML().read(xml);
caps = format.read(doc);
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781"
});
t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance");
t.eq(layer.url, "http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte-2000/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png", "correct url");
t.eq(layer.matrixIds.length, 3, "correct matrixIds length");
t.eq(layer.requestEncoding, "REST", "correct requestEncoding");
t.eq(layer.name, "Agglomérations et villes isolées", "correct layer title");
t.eq(layer.style, "ch.are.agglomerationen_isolierte_staedte-2000", "correct style identifier");
t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection");
t.eq(layer.units, "m", "correct untis");
t.eq(layer.resolutions.length, 3, "correct resolutions length");
t.ok((layer.resolutions[0] - 4000) < 1, "correct first resolution");
t.eq(layer.dimensions.length, 1, "correct dimensions length");
t.eq(layer.dimensions[0], "Time", "correct dimensions");
t.eq(layer.params['TIME'], "20090101", "correct params");
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
style: "toto",
params: {"Time": "2012"}
});
t.eq(layer.matrixIds.length, 3, "correct matrixIds length");
t.eq(layer.style, "toto", "correct style identifier");
t.eq(layer.dimensions.length, 1, "correct dimensions length");
t.eq(layer.dimensions[0], "Time", "correct dimensions");
t.eq(layer.params['TIME'], "2012", "correct params");
// test projection and units
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781",
units: 'degrees'
});
t.eq(layer.units, "degrees", "correct units");
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781",
projection: "EPSG:4326"
});
t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection");
t.eq(layer.units, "degrees", "correct units");
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781",
projection: "EPSG:4326",
units: 'm'
});
t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection");
t.eq(layer.units, "m", "correct units");
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781",
projection: "EPSG:900913",
units: 'degrees'
});
t.eq(layer.projection.getCode(), "EPSG:900913", "correct projection");
t.eq(layer.units, "degrees", "correct units");
}
function test_parse_projection(t) {
t.plan(2);
var format = new OpenLayers.Format.WMTSCapabilities();
var xml = document.getElementById("restsample-alternate-proj1").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var caps = format.read(doc);
var layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781"
});
t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection");
xml = document.getElementById("restsample-alternate-proj2").firstChild.nodeValue;
doc = new OpenLayers.Format.XML().read(xml);
caps = format.read(doc);
layer = format.createLayer(caps, {
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
matrixSet: "21781"
});
t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection");
}
</script>
</head>
<body>
@@ -300,15 +400,15 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml
<TileMatrixSet>BigWorld</TileMatrixSet>
</TileMatrixSetLink>
</Layer>
<TileMatrixSet>
<TileMatrixSet>
<ows:Identifier>BigWorld</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>1e6</ows:Identifier>
<ScaleDenominator>1e6</ScaleDenominator>
<TopLeftCorner>-180 84</TopLeftCorner>
<ScaleDenominator>1e6</ScaleDenominator>
<TopLeftCorner>-180 84</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<TileHeight>256</TileHeight>
<MatrixWidth>60000</MatrixWidth>
<MatrixHeight>50000</MatrixHeight>
</TileMatrix>
@@ -354,5 +454,284 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml
</Themes>
</Capabilities>
--></div>
<div id="restsample"><!--
<?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>Federal Geodata Infrastructure of Switzerland</ows:Title>
<ows:Abstract>Some Geodata are subject to license and fees</ows:Abstract>
<ows:Keywords>
<ows:Keyword>FGDI</ows:Keyword>
<ows:Keyword>Pixelkarte</ows:Keyword>
<ows:Keyword>Switzerland</ows:Keyword>
</ows:Keywords>
<ows:ServiceType>OGC WMTS</ows:ServiceType>
<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
<ows:Fees>yes</ows:Fees>
<ows:AccessConstraints>license</ows:AccessConstraints>
</ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName>swisstopo</ows:ProviderName>
<ows:ProviderSite xlink:href="http://www.swisstopo.admin.ch"/>
<ows:ServiceContact>
<ows:IndividualName>David Oesch</ows:IndividualName>
<ows:PositionName></ows:PositionName>
<ows:ContactInfo>
<ows:Phone>
<ows:Voice>+41 (0)31 / 963 21 11</ows:Voice>
<ows:Facsimile>+41 (0)31 / 963 24 59</ows:Facsimile>
</ows:Phone>
<ows:Address>
<ows:DeliveryPoint>swisstopo</ows:DeliveryPoint>
<ows:City>Bern</ows:City>
<ows:AdministrativeArea>BE</ows:AdministrativeArea>
<ows:PostalCode>3084</ows:PostalCode>
<ows:Country>Switzerland</ows:Country>
<ows:ElectronicMailAddress/>
</ows:Address>
</ows:ContactInfo>
</ows:ServiceContact>
</ows:ServiceProvider>
<ows:OperationsMetadata>
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>
<Contents>
<Layer>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Abstract>Les agglomérations et villes isolées (communes non rattachées à une agglomération et comptant au moins 10`000 habitants) font partie des régions danalyse de la statistique suisse. Ce niveau géographique est défini depuis plus de 100 ans, afin de mesurer lurbanisation, phénomène fondamental structurant lorganisation du territoire. Sa fonction principale est de permettre une comparaison spatiale entre des espaces urbains inégalement délimités sur le plan institutionnel. Une version ancienne est appliquée pour la première fois en 1930, puis révisée en 1984 et 1990, toujours sur la base des recensements de la population. La version actuelle classe les 2896 communes de Suisse (état 2000) selon leur appartenance ou pas à une agglomération ou ville isolée en fonction de critères statistiques (Etat et évolution de la population, lien de continuité de la zone bâtie, rapport entre population active occupée et population résidante, structure économique et flux de pendulaires). Les agglomérations et les villes isolées forment l`espace urbain, les territoires restant l`espace rural. La définition des agglomérations de lOFS na pas valeur dobligation légale.</ows:Abstract>
<ows:WGS84BoundingBox>
<ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
<ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<ows:Metadata xlink:href="http://www.swisstopo.admin.ch/SITiled/world/AdminBoundaries/metadata.htm"/>
<Style>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<LegendURL format="image/png" xlink:href="http://api.geo.admin.ch/legend/ch.are.agglomerationen_isolierte_staedte-2000_fr.png" />
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20090101</Default>
<Value>20090101</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>21781</TileMatrixSet>
</TileMatrixSetLink>
<ResourceURL format="image/png" resourceType="tile" template="http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte-2000/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png"/>
</Layer>
<TileMatrixSet>
<ows:Identifier>21781</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:EPSG::21781</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>0</ows:Identifier>
<ScaleDenominator>14285750.5715</ScaleDenominator>
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>8</ows:Identifier>
<ScaleDenominator>7142875.28575</ScaleDenominator>
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>12</ows:Identifier>
<ScaleDenominator>3571437.64288</ScaleDenominator>
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2</MatrixWidth>
<MatrixHeight>2</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
</Capabilities>
--></div>
<div id="restsample-alternate-proj1"><!--
<?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:OperationsMetadata>
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>
<Contents>
<Layer>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Abstract>Les agglomérations et villes isolées (communes non rattachées à une agglomération et comptant au moins 10`000 habitants) font partie des régions danalyse de la statistique suisse. Ce niveau géographique est défini depuis plus de 100 ans, afin de mesurer lurbanisation, phénomène fondamental structurant lorganisation du territoire. Sa fonction principale est de permettre une comparaison spatiale entre des espaces urbains inégalement délimités sur le plan institutionnel. Une version ancienne est appliquée pour la première fois en 1930, puis révisée en 1984 et 1990, toujours sur la base des recensements de la population. La version actuelle classe les 2896 communes de Suisse (état 2000) selon leur appartenance ou pas à une agglomération ou ville isolée en fonction de critères statistiques (Etat et évolution de la population, lien de continuité de la zone bâtie, rapport entre population active occupée et population résidante, structure économique et flux de pendulaires). Les agglomérations et les villes isolées forment l`espace urbain, les territoires restant l`espace rural. La définition des agglomérations de lOFS na pas valeur dobligation légale.</ows:Abstract>
<ows:WGS84BoundingBox>
<ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
<ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<ows:Metadata xlink:href="http://www.swisstopo.admin.ch/SITiled/world/AdminBoundaries/metadata.htm"/>
<Style>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<LegendURL format="image/png" xlink:href="http://api.geo.admin.ch/legend/ch.are.agglomerationen_isolierte_staedte-2000_fr.png" />
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20090101</Default>
<Value>20090101</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>21781</TileMatrixSet>
</TileMatrixSetLink>
<ResourceURL format="image/png" resourceType="tile" template="http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte-2000/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png"/>
</Layer>
<TileMatrixSet>
<ows:Identifier>21781</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:21781</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>0</ows:Identifier>
<ScaleDenominator>14285750.5715</ScaleDenominator>
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
</Capabilities>
--></div>
<div id="restsample-alternate-proj2"><!--
<?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:OperationsMetadata>
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://wmts.geo.admin.ch/">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>REST</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>
<Contents>
<Layer>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Abstract>Les agglomérations et villes isolées (communes non rattachées à une agglomération et comptant au moins 10`000 habitants) font partie des régions danalyse de la statistique suisse. Ce niveau géographique est défini depuis plus de 100 ans, afin de mesurer lurbanisation, phénomène fondamental structurant lorganisation du territoire. Sa fonction principale est de permettre une comparaison spatiale entre des espaces urbains inégalement délimités sur le plan institutionnel. Une version ancienne est appliquée pour la première fois en 1930, puis révisée en 1984 et 1990, toujours sur la base des recensements de la population. La version actuelle classe les 2896 communes de Suisse (état 2000) selon leur appartenance ou pas à une agglomération ou ville isolée en fonction de critères statistiques (Etat et évolution de la population, lien de continuité de la zone bâtie, rapport entre population active occupée et population résidante, structure économique et flux de pendulaires). Les agglomérations et les villes isolées forment l`espace urbain, les territoires restant l`espace rural. La définition des agglomérations de lOFS na pas valeur dobligation légale.</ows:Abstract>
<ows:WGS84BoundingBox>
<ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
<ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<ows:Metadata xlink:href="http://www.swisstopo.admin.ch/SITiled/world/AdminBoundaries/metadata.htm"/>
<Style>
<ows:Title>Agglomérations et villes isolées</ows:Title>
<ows:Identifier>ch.are.agglomerationen_isolierte_staedte-2000</ows:Identifier>
<LegendURL format="image/png" xlink:href="http://api.geo.admin.ch/legend/ch.are.agglomerationen_isolierte_staedte-2000_fr.png" />
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20090101</Default>
<Value>20090101</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>21781</TileMatrixSet>
</TileMatrixSetLink>
<ResourceURL format="image/png" resourceType="tile" template="http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte-2000/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png"/>
</Layer>
<TileMatrixSet>
<ows:Identifier>21781</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:1.0:21781</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>0</ows:Identifier>
<ScaleDenominator>14285750.5715</ScaleDenominator>
<TopLeftCorner>420000.0 350000.0</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
<ServiceMetadataURL xlink:href="http://www.opengis.uab.es/SITiled/world/1.0.0/WMTSCapabilities.xml"/>
</Capabilities>
--></div>
</body>
</html>

View File

@@ -4,7 +4,7 @@
<script type="text/javascript">
function test_read_WPSDescribeProcess(t) {
t.plan(16);
t.plan(17);
var parser = new OpenLayers.Format.WPSDescribeProcess();
var text =
@@ -109,6 +109,13 @@
' </Supported>' +
' </ComplexOutput>' +
' </Output>' +
' <Output>' +
' <ows:Identifier>literal</ows:Identifier>' +
' <ows:Title>literal output</ows:Title>' +
' <LiteralOutput>' +
' <ows:DataType ows:reference="http://www.w3.org/TR/xmlschema-2/#integer">integer</ows:DataType>'+
' </LiteralOutput>' +
' </Output>' +
' </ProcessOutputs>' +
' </ProcessDescription>' +
'</wps:ProcessDescriptions>';
@@ -135,6 +142,9 @@
t.eq(result.complexOutput["supported"].formats["text/xml; subtype=gml/3.1.1"], true, "processOutputs supported format read correctly [1/2]");
t.eq(result.complexOutput["supported"].formats["application/wkt"], true, "processOutputs supported format read correctly [1/2]");
var literalresult = buffer.processOutputs[1];
t.eq(literalresult.literalOutput.dataType, "integer", "processOutputs supported data type read corectly");
text = '<?xml version="1.0" encoding="UTF-8"?>' +
'<wps:ProcessDescriptions service="WPS" version="1.0.0" xmlns:wps="http://www.opengis.net/wps/1.0.0"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en"' +

View File

@@ -309,12 +309,12 @@
responseForm: {
responseDocument: {
storeExecuteResponse: true,
output: {
outputs: [{
asReference: true,
identifier: 'BufferedPolygon',
title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.'
}
}]
}
}
});
@@ -349,6 +349,11 @@
' <ows:Title>Area serviced by playground.</ows:Title>' +
' <ows:Abstract>Area within which most users of this playground will live.</ows:Abstract>' +
' </wps:Output>' +
' <wps:Output>' +
' <ows:Identifier>literal</ows:Identifier>' +
' <ows:Title/>' +
' <ows:Abstract/>' +
' </wps:Output>' +
' </wps:ResponseDocument>' +
' </wps:ResponseForm>' +
'</wps:Execute>';
@@ -381,12 +386,17 @@
storeExecuteResponse: true,
lineage: true,
status: true,
output: {
asReference: true,
identifier: 'BufferedPolygon',
title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.'
}
outputs: [
{
asReference: true,
identifier: 'BufferedPolygon',
title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.'
},
{
identifier: 'literal'
}
]
}
}
});
@@ -461,12 +471,12 @@
responseForm: {
responseDocument: {
storeExecuteResponse: true,
output: {
outputs: [{
asReference: true,
identifier: 'BufferedPolygon',
title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.'
}
}]
}
}
});

View File

@@ -117,7 +117,7 @@
handler.activate();
var oldIsLeftClick = OpenLayers.Event.isLeftClick;
var oldStop = OpenLayers.Event.stop;
var oldPreventDefault = OpenLayers.Event.preventDefault;
var oldCheckModifiers = handler.checkModifiers;
// test mousedown with right click
@@ -163,15 +163,9 @@
"mousedown calls isLeftClick with the proper event");
return true;
}
OpenLayers.Event.stop = function(evt, allowDefault) {
if(!allowDefault) {
t.ok(evt.xy.x == testEvents.down.xy.x &&
evt.xy.y == testEvents.down.xy.y,
"mousedown default action is disabled");
} else {
t.fail(
"mousedown is prevented from falling to other elements");
}
OpenLayers.Event.preventDefault = function(evt) {
t.ok(evt.xy.x == testEvents.down.xy.x && evt.xy.y == testEvents.down.xy.y,
"mousedown default action is disabled");
}
map.events.triggerEvent("mousedown", testEvents.down);
t.ok(handler.started, "mousedown sets the started flag to true");
@@ -183,7 +177,7 @@
handler.last.y == testEvents.down.xy.y,
"mouse down sets handler.last correctly");
OpenLayers.Event.stop = oldStop;
OpenLayers.Event.preventDefault = oldPreventDefault;
OpenLayers.Event.isLeftClick = oldIsLeftClick;
handler.checkModifiers = oldCheckModifiers;
@@ -292,7 +286,7 @@
function test_Handler_Drag_touch(t) {
// In this test we verify that "touchstart", "touchmove", and
// "touchend" events set expected states in the drag handler.
// We also verify that we stop event bubbling as appropriate.
// We also verify that we prevent the default as appropriate.
t.plan(14);
@@ -308,8 +302,8 @@
});
h.activate();
var _stop = OpenLayers.Event.stop;
OpenLayers.Event.stop = function(e) {
var _preventDefault = OpenLayers.Event.preventDefault;
OpenLayers.Event.preventDefault = function(e) {
log.push(e);
};
@@ -343,7 +337,7 @@
// tear down
OpenLayers.Event.stop = _stop;
OpenLayers.Event.preventDefault = _preventDefault;
m.destroy();
}

View File

@@ -126,9 +126,9 @@
map.zoomToMaxExtent();
t.delay_call(2, function() {
t.ok(layer.attribution.indexOf('olBingAttribution aerial') !== -1, "Attribution has the correct css class");
t.ok(layer.attribution.indexOf('<img src="">') == -1, "Attribution contains a logo");
t.ok(layer.attribution.indexOf('</img></div></a><a style=') == -1 , "Attribution contains a copyright");
t.ok(OpenLayers.Util.indexOf(layer.attribution, 'olBingAttribution aerial') !== -1, "Attribution has the correct css class");
t.ok(OpenLayers.Util.indexOf(layer.attribution, '<img src="">') == -1, "Attribution contains a logo");
t.ok(OpenLayers.Util.indexOf(layer.attribution, '</img></div></a><a style=') == -1 , "Attribution contains a copyright");
map.destroy();
});
}

View File

@@ -1362,7 +1362,7 @@
t.plan(5);
// set up
var map = new OpenLayers.Map('map', {
resolutions: [32, 16, 8, 4, 2, 1]
});
@@ -1375,28 +1375,28 @@
map.zoomTo(1);
t.delay_call(1, function() {
// Mark one tile loaded, to see if back buffer removal gets scheduled.
layer.grid[1][1].onImageLoad();
t.ok(layer.backBuffer.parentNode === layer.div,
'[a] back buffer is a child of layer div');
t.ok(layer.backBufferTimerId !== null,
'[a] back buffer scheduled for removal');
t.ok(layer.backBuffer.parentNode === layer.div,
'[a] back buffer is a child of layer div');
t.ok(layer.backBufferTimerId !== null,
'[a] back buffer scheduled for removal');
var backBuffer = layer.backBuffer;
var backBuffer = layer.backBuffer;
map.zoomTo(2);
map.zoomTo(2);
t.ok(layer.backBuffer !== backBuffer,
'[b] a new back buffer was created');
t.ok(layer.backBuffer.parentNode === layer.div,
'[b] back buffer is a child of layer div');
t.ok(layer.backBufferTimerId === null,
'[b] back buffer no longer scheduled for removal');
t.ok(layer.backBuffer !== backBuffer,
'[b] a new back buffer was created');
t.ok(layer.backBuffer.parentNode === layer.div,
'[b] back buffer is a child of layer div');
t.ok(layer.backBufferTimerId === null,
'[b] back buffer no longer scheduled for removal');
// tear down
// tear down
map.destroy();
});
map.destroy();
}
function test_getGridData(t) {

View File

@@ -2047,7 +2047,7 @@
}
function test_adjustZoom(t) {
t.plan(4);
t.plan(5);
var map = new OpenLayers.Map({
div: 'map',
layers: [
@@ -2062,6 +2062,9 @@
t.eq(map.adjustZoom(9), 9, "valid zoom maintained");
t.eq(map.adjustZoom(1), 2, "zoom adjusted to not exceed world width");
map.fractionalZoom = true;
t.eq(map.adjustZoom(1).toPrecision(3), "1.29", "zoom adjusted to match world width");
map.moveTo([16, 48], 0);
t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom");
@@ -2087,6 +2090,34 @@
t.ok(center.equals(new OpenLayers.LonLat(-13.25, 56)), "Center is correct and not equal to maxExtent's center");
}
function test_autoUpdateSize(t) {
t.plan(1);
OpenLayers.Event.unloadCache();
var resizeListener = false;
var map = new OpenLayers.Map({
autoUpdateSize: false,
div: 'map',
layers: [
new OpenLayers.Layer('name', {
isBaseLayer: true,
wrapDateLine: true
})
]
});
map.setCenter(new OpenLayers.LonLat(-1.3, 50.8), 4);
for (var key in OpenLayers.Event.observers) {
var obj = OpenLayers.Event.observers[key];
for (var i=0, ii=obj.length; i<ii; ++i) {
var listener = obj[i];
if (listener.name === 'resize' && listener.element === window) {
resizeListener = true;
}
}
}
t.eq(resizeListener, map.autoUpdateSize, "resize listener not registered when autoUpdateSize is false");
map.destroy();
}
</script>
</head>
<body>

View File

@@ -44,7 +44,7 @@
// conditionally mock up proj4js
var hasProj = !!window.Proj4js;
if (!hasProj) {
window.Proj4js = true;
window.Proj4js = {};
}
proj1.proj = {defData: "+title= WGS84 +foo=bar +x=0"};
proj2.proj = {defData: "+title=FOO +foo=bar +x=0", srsCode: "FOO"};

View File

@@ -112,43 +112,46 @@
function test_events(t) {
t.plan(3);
var log = {
loadstart: 0,
loadend: 0
};
t.plan(6);
var log = [];
var response = new OpenLayers.Protocol.Response();
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol({
read: function(config) {
config.callback.call(config.scope, {});
config.callback.call(config.scope, response);
}
}),
isBaseLayer: true,
eventListeners: {
loadstart: function() {
++log.loadstart;
loadstart: function(event) {
log.push(event);
},
loadend: function() {
++log.loadend;
loadend: function(event) {
log.push(event);
}
}
});
map.addLayer(layer);
map.zoomToMaxExtent();
t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
t.ok(log[1].response == response, "loadend includes response");
t.eq(log.loadstart, 1, "loadstart triggered");
t.eq(log.loadend, 1, "loadend triggered");
log = {};
var calls = [];
layer.protocol.read = function(obj) {
log.obj = obj;
calls.push(obj);
}
layer.refresh({force: true, whee: 'chicken'});
t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly.");
t.eq(calls.length, 1, "1 call to read");
t.eq(calls[0].whee, "chicken", "properties passed to read");
map.destroy();

View File

@@ -62,44 +62,47 @@
function test_events(t) {
t.plan(3);
t.plan(6);
var log = {
loadstart: 0,
loadend: 0
};
var log = [];
var response = new OpenLayers.Protocol.Response();
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol({
read: function(config) {
config.callback.call(config.scope, {});
config.callback.call(config.scope, response);
}
}),
isBaseLayer: true,
eventListeners: {
loadstart: function() {
++log.loadstart;
loadstart: function(event) {
log.push(event);
},
loadend: function() {
++log.loadend;
loadend: function(event) {
log.push(event);
}
}
});
map.addLayer(layer);
map.zoomToMaxExtent();
t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
t.ok(log[1].response == response, "loadend includes response");
t.eq(log.loadstart, 1, "loadstart triggered");
t.eq(log.loadend, 1, "loadend triggered");
var log = {};
var calls = [];
layer.protocol.read = function(obj) {
log.obj = obj;
calls.push(obj);
}
layer.refresh({whee: 'chicken'});
t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly.");
t.eq(calls.length, 1, "1 call to read");
t.eq(calls[0].whee, "chicken", "properties passed to read");
map.destroy();

View File

@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html>
<head>
<title>vendorPrefix.js Tests</title>
<script>
var div = document.createElement("div");
var style = div.style,
orgCreateElement = document.createElement;
// wrap document.createElement to control property values
document.createElement = function(type) {
return div;
};
// dependencies for tests
var OpenLayers = [
"OpenLayers/Util/vendorPrefix.js"
];
</script>
<script src="../OLLoader.js"></script>
<script>
/**
* Test vendor prefixing
*/
function test_vendor_prefixes(t) {
t.plan(20);
var err;
function clearCache(type) {
var cache = OpenLayers.Util.vendorPrefix[type.replace("style", "js") + "Cache"];
for (var key in cache) {
delete cache[key];
}
}
function setStyleMockProp(prop, value) {
if (prop && value === undefined) {
delete style[prop];
} else if (prop) {
style[prop] = value;
}
}
function curryTestPrefix(type) {
return function(standardProp, expectedPrefix, msg) {
var prefixedProp, err;
try {
clearCache(type);
setStyleMockProp(expectedPrefix, "");
prefixedProp = OpenLayers.Util.vendorPrefix[type](standardProp);
} catch(e) {
err = e;
} finally {
setStyleMockProp(expectedPrefix, undefined);
}
if(!err) {
t.eq(prefixedProp, expectedPrefix, msg);
} else {
t.fail("Error when testing " + type.toUpperCase() + " vendor prefix: " + err.message);
}
};
}
var testDomPrefix = curryTestPrefix("style"),
testCssPrefix = curryTestPrefix("css");
testDomPrefix("unsupported", null, "DOM vendor prefix - unsupported");
testCssPrefix("unsupported", null, "CSS vendor prefix - unsupported");
testDomPrefix("test", "test", "DOM vendor prefix - single word");
testCssPrefix("test", "test", "CSS vendor prefix - single word");
testDomPrefix("testMultiWord", "testMultiWord", "DOM vendor prefix - multiple words");
testCssPrefix("test-multi-word", "test-multi-word", "CSS vendor prefix - multiple words");
testDomPrefix("multiWord", "WebkitMultiWord", "DOM vendor prefix - multiple words for WebKit");
testCssPrefix("multi-word", "-webkit-multi-word", "CSS vendor prefix - multiple words for WebKit");
testDomPrefix("multiWord", "MozMultiWord", "DOM vendor prefix - multiple words for Mozilla");
testCssPrefix("multi-word", "-moz-multi-word", "CSS vendor prefix - multiple words for Mozilla");
testDomPrefix("multiWord", "OMultiWord", "DOM vendor prefix - multiple words for Opera");
testCssPrefix("multi-word", "-o-multi-word", "CSS vendor prefix - multiple words for Opera");
testDomPrefix("multiWord", "msMultiWord", "DOM vendor prefix - multiple words for Internet Explorer");
testCssPrefix("multi-word", "-ms-multi-word", "CSS vendor prefix - multiple words for Internet Explorer");
// test vendor prefix on object
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( {}, "unsupported" ), null, "Standard object property - unsupported");
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( { "test": true }, "test" ), "test", "Standard object property");
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( { "oTest": true }, "test" ), "oTest", "Standard object property");
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( { "msTest": true }, "test" ), "msTest", "Standard object property");
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( { "mozTest": true }, "test" ), "mozTest", "Standard object property");
clearCache("js");
t.eq( OpenLayers.Util.vendorPrefix.js( { "webkitTest": true }, "test" ), "webkitTest", "Standard object property");
// unwrap document.createElement
document.createElement = orgCreateElement;
}
</script>
</head>
<body></body>
</html>

View File

@@ -46,13 +46,10 @@
<li>Control/UTFGrid.html</li>
<li>Control/WMSGetFeatureInfo.html</li>
<li>Control/WMTSGetFeatureInfo.html</li>
<li>Control/Pan.html</li>
<li>Control/PanPanel.html</li>
<li>Control/SLDSelect.html</li>
<li>Control/Zoom.html</li>
<li>Control/ZoomIn.html</li>
<li>Control/ZoomOut.html</li>
<li>Control/ZoomToMaxExtent.html</li>
<li>Control/ZoomBox.html</li>
<li>Events.html</li>
<li>Events/buttonclick.html</li>
<li>Extras.html</li>
@@ -234,6 +231,7 @@
<li>Tween.html</li>
<li>Kinetic.html</li>
<li>Util.html</li>
<li>Util/vendorPrefix.html</li>
<li>deprecated/Ajax.html</li>
<li>deprecated/Util.html</li>
<li>deprecated/BaseTypes/Class.html</li>
@@ -251,4 +249,4 @@
<li>deprecated/Renderer/SVG2.html</li>
<li>deprecated/Layer/Yahoo.html</li>
<li>deprecated/Tile/WFS.html</li>
</ul>
</ul>

View File

@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>map.div Events Acceptance Test</title>
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../../examples/style.css" type="text/css">
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer;
function init() {
map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
map.addLayer(layer);
map.setCenter(
new OpenLayers.LonLat(-71.147, 42.472).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 12
);
var element = document.getElementById('map');
element.addEventListener('mousedown', function(evt) {
alert('mousedown on map div');
});
}
</script>
</head>
<body onload="init()">
<h1 id="title">map.div Events Acceptance Test</h1>
<div id="map" class="smallmap"></div>
<p><b>Test 1</b> : mousedown the map; an alert must be displayed.</p>
</body>
</html>

View File

@@ -39,10 +39,64 @@ function run() {
else {
out.innerHTML += "<br/>height Fail: " + size + ", " + height;
}
// To use the same syntax as in "\tests"
var t = {eq: function(a, b, msg) {
if (a == b) {
out.innerHTML += "<br/>ok " + msg;
}
else {
out.innerHTML += "<br/><span style=\"color:red\">Fail (" + a + " not eq " + b + "): " + msg + "<span>";
}
}
};
var text = (new Array(10)).join("foo foo foo <br>"),
content = "<div>" + text + "</div>";
var testName,
finalSize,
initialSize = OpenLayers.Util.getRenderedDimensions(content, null);
// containerElement option on absolute position with width and height
testName = "Absolute with w&h: ";
var optionAbsDiv ={
containerElement: document.getElementById("absoluteDiv")
};
finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv);
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
t.eq(finalSize.h, initialSize.h,
testName + "initial height " + initialSize.h + "px is maintained");
testName = "Absolute with w&h (set height): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv);
t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
testName = "Absolute with w&h (set width): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv);
t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
// containerElement option on absolute position without width and height
testName = "Absolute without w&h: ";
var optionAbsDiv00 ={
containerElement: document.getElementById("absoluteDiv00")
};
finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv00);
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
t.eq(finalSize.h, initialSize.h,
testName + "initial height " + initialSize.h + "px is maintained");
testName = "Absolute without w&h (set height): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv00);
t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
testName = "Absolute without w&h (set width): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv00);
t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
}
</script>
</head>
<body onload="run()">
<div id="out"></div>
<div id="absoluteDiv" style="position:absolute; left:10px; width:500px; height: 500px"></div>
<div id="absoluteDiv00" style="position:absolute; left:10px;"></div>
</body>
</html>