diff options
Diffstat (limited to 'misc/openlayers/tests/Format/WMC')
-rw-r--r-- | misc/openlayers/tests/Format/WMC/v1.html | 266 | ||||
-rw-r--r-- | misc/openlayers/tests/Format/WMC/v1_1_0.html | 86 |
2 files changed, 0 insertions, 352 deletions
diff --git a/misc/openlayers/tests/Format/WMC/v1.html b/misc/openlayers/tests/Format/WMC/v1.html deleted file mode 100644 index 05e6078..0000000 --- a/misc/openlayers/tests/Format/WMC/v1.html +++ /dev/null @@ -1,266 +0,0 @@ -<html> -<head> - <script src="../../OLLoader.js"></script> - <script type="text/javascript"> - - function test_write_wmc_StyleList(t) { - t.plan(4); - - var layer, layerContext, got, expected; - - var format = new OpenLayers.Format.WMC(); - var parser = format.getParser("1"); - var name = "test"; - var url = "http://foo"; - - // test named style - layer = new OpenLayers.Layer.WMS(name, url, { - styles: "mystyle" - }); - layerContext = format.layerToContext(layer); - got = parser.write_wmc_StyleList(layerContext); - expected = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<Name>mystyle</Name><Title>Default</Title>" + - "</Style>" + - "</StyleList>"; - - t.xml_eq(got, expected, "named style correctly written"); - layer.destroy(); - - // test linked style - layer = new OpenLayers.Layer.WMS(name, url, { - sld: "http://linked.sld" - }); - layerContext = format.layerToContext(layer); - got = parser.write_wmc_StyleList(layerContext); - expected = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<SLD>" + - "<Title>Default</Title>" + - "<OnlineResource xmlns:xlink='http://www.w3.org/1999/xlink' "+ - "xlink:type='simple' " + - "xlink:href='http://linked.sld' />" + - "</SLD>" + - "</Style>" + - "</StyleList>"; - - t.xml_eq(got, expected, "linked style correctly written"); - layer.destroy(); - - // test inline style - layer = new OpenLayers.Layer.WMS(name, url, { - sld_body: - "<sld:StyledLayerDescriptor version='1.0.0' " + - "xmlns:ogc='http://www.opengis.net/ogc' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<sld:NamedLayer>" + - "<sld:Name>AAA212</sld:Name>" + - "<sld:UserStyle>" + - "<sld:FeatureTypeStyle>" + - "<sld:Rule>" + - "<sld:TextSymbolizer>" + - "<sld:Label>" + - "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + - "</sld:Label>" + - "<sld:Font>" + - "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + - "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + - "</sld:Font>" + - "<sld:Fill>" + - "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + - "</sld:Fill>" + - "</sld:TextSymbolizer>" + - "</sld:Rule>" + - "</sld:FeatureTypeStyle>" + - "</sld:UserStyle>" + - "</sld:NamedLayer>" + - "</sld:StyledLayerDescriptor>" - }); - - layerContext = format.layerToContext(layer); - got = parser.write_wmc_StyleList(layerContext); - expected = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<SLD>" + - "<Title>Default</Title>" + - "<sld:StyledLayerDescriptor version='1.0.0' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:ogc='http://www.opengis.net/ogc' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<sld:NamedLayer>" + - "<sld:Name>AAA212</sld:Name>" + - "<sld:UserStyle>" + - "<sld:FeatureTypeStyle>" + - "<sld:Rule>" + - "<sld:TextSymbolizer>" + - "<sld:Label>" + - "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + - "</sld:Label>" + - "<sld:Font>" + - "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + - "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + - "</sld:Font>" + - "<sld:Fill>" + - "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + - "</sld:Fill>" + - "</sld:TextSymbolizer>" + - "</sld:Rule>" + - "</sld:FeatureTypeStyle>" + - "</sld:UserStyle>" + - "</sld:NamedLayer>" + - "</sld:StyledLayerDescriptor>" + - "</SLD>" + - "</Style>" + - "</StyleList>"; - - t.xml_eq(got, expected, "inline style correctly written"); - layer.destroy(); - - // test inline FeatureTypeStyle - layer = new OpenLayers.Layer.WMS(name, url, { - sld_body: - "<sld:FeatureTypeStyle version='1.0.0' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:ogc='http://www.opengis.net/ogc' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<sld:Rule>" + - "<sld:TextSymbolizer>" + - "<sld:Label>" + - "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + - "</sld:Label>" + - "<sld:Font>" + - "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + - "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + - "</sld:Font>" + - "<sld:Fill>" + - "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + - "</sld:Fill>" + - "</sld:TextSymbolizer>" + - "</sld:Rule>" + - "</sld:FeatureTypeStyle>" - }); - - layerContext = format.layerToContext(layer); - got = parser.write_wmc_StyleList(layerContext); - expected = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<SLD>" + - "<Title>Default</Title>" + - "<sld:FeatureTypeStyle version='1.0.0' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:ogc='http://www.opengis.net/ogc' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<sld:Rule>" + - "<sld:TextSymbolizer>" + - "<sld:Label>" + - "<ogc:PropertyName>ZONENR</ogc:PropertyName>" + - "</sld:Label>" + - "<sld:Font>" + - "<sld:CssParameter name='font-family'>Arial</sld:CssParameter>" + - "<sld:CssParameter name='font-size'>10</sld:CssParameter>" + - "</sld:Font>" + - "<sld:Fill>" + - "<sld:CssParameter name='fill'>#FF9900</sld:CssParameter>" + - "</sld:Fill>" + - "</sld:TextSymbolizer>" + - "</sld:Rule>" + - "</sld:FeatureTypeStyle>" + - "</SLD>" + - "</Style>" + - "</StyleList>"; - - t.xml_eq(got, expected, "inline FeatureTypeStyle correctly written"); - layer.destroy(); - } - - function test_read_wmc_StyleList(t) { - t.plan(3); - - var xml = new OpenLayers.Format.XML(); - var format = new OpenLayers.Format.WMC(); - var parser = format.getParser("1"); - var node, text, layerContext, layer; - - // test named style - text = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<Name>mystyle</Name><Title>Default</Title>" + - "</Style>" + - "</StyleList>"; - node = xml.read(text).documentElement; - layerContext = { - styles: [] - }; - parser.read_wmc_StyleList(layerContext, node); - layer = format.getLayerFromContext(layerContext); - t.eq(layer.params.STYLES, "mystyle", "named style correctly read"); - - // test linked style - text = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<SLD>" + - "<OnlineResource xmlns:xlink='http://www.w3.org/1999/xlink' "+ - "xlink:type='simple' " + - "xlink:href='http://linked.sld' />" + - "</SLD>" + - "</Style>" + - "</StyleList>"; - node = xml.read(text).documentElement; - layerContext = { - styles: [] - }; - parser.read_wmc_StyleList(layerContext, node); - layer = format.getLayerFromContext(layerContext); - t.eq(layer.params.SLD, "http://linked.sld", "linked style correctly read"); - - // test inline style - // any valid xml under the StyledLayerDescriptor node should make the - // round trip from string to node and back - text = - "<StyleList xmlns='http://www.opengis.net/context'>" + - "<Style current='1'>" + - "<SLD>" + - "<sld:StyledLayerDescriptor version='1.0.0' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<foo>bar<more/></foo>" + - "</sld:StyledLayerDescriptor>" + - "</SLD>" + - "</Style>" + - "</StyleList>"; - node = xml.read(text).documentElement; - layerContext = { - styles: [] - }; - parser.read_wmc_StyleList(layerContext, node); - layer = format.getLayerFromContext(layerContext); - var expected = - "<sld:StyledLayerDescriptor version='1.0.0' " + - "xmlns:sld='http://www.opengis.net/sld' " + - "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + - "xsi:schemaLocation='http://www.opengis.net/sld http://schemas.opengeospatial.net/sld/1.0.0/StyledLayerDescriptor.xsd'>" + - "<foo xmlns='http://www.opengis.net/context'>bar<more/></foo>" + - "</sld:StyledLayerDescriptor>"; - t.xml_eq(layer.params.SLD_BODY, expected, "inline style correctly read"); - - } - - - </script> -</head> -<body> -</body> -</html> diff --git a/misc/openlayers/tests/Format/WMC/v1_1_0.html b/misc/openlayers/tests/Format/WMC/v1_1_0.html deleted file mode 100644 index 815d3bf..0000000 --- a/misc/openlayers/tests/Format/WMC/v1_1_0.html +++ /dev/null @@ -1,86 +0,0 @@ -<html> -<head> - <script src="../../OLLoader.js"></script> - <script type="text/javascript"> - - function test_write_wmc_Layer(t) { - if (OpenLayers.BROWSER_NAME == "safari") { - t.plan(0); - t.debug_print("Safari has wierd behavior with getElementsByTagNameNS: the result is that we can't run these tests there. Patches welcome."); - return; - } - t.plan(12); - - // direct construction of a parser for a unit test - var format = new OpenLayers.Format.WMC(); - var parser = format.getParser("1_1_0"); - var sldNS = parser.namespaces["sld"]; - - // test that Min/MaxScaleDenominator is not written out when no - // resolution related options are set - var layer = new OpenLayers.Layer.WMS( - "test", "http://foo", {}, - {maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)} - ); - var layerContext = format.layerToContext(layer); - var node = parser.write_wmc_Layer(layerContext); - var minList = parser.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator"); - t.eq(minList.length, 0, "(none) node not written with MinScaleDenominator"); - var maxList = parser.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator"); - t.eq(maxList.length, 0, "(none) node not written with MaxScaleDenominator"); - - // test that Min/MaxScaleDenominator is written out for explicit - // resolutions array - layer = new OpenLayers.Layer.WMS( - "test", "http://foo", {}, - {resolutions: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)} - ); - layer.minScale = Math.random(); - layer.maxScale = Math.random(); - sldNS = parser.namespaces["sld"]; - layerContext = format.layerToContext(layer); - node = parser.write_wmc_Layer(layerContext); - minList = parser.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator"); - t.eq(minList.length, 1, "(resolutions) node written with MinScaleDenominator"); - t.eq(layer.maxScale.toPrecision(16), parser.getChildValue(minList[0]), - "(resolutions) node written with correct MinScaleDenominator value"); - maxList = parser.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator"); - t.eq(maxList.length, 1, "(resolutions) node written with MaxScaleDenominator"); - t.eq(layer.minScale.toPrecision(16), parser.getChildValue(maxList[0]), - "(resolutions) node written with correct MaxScaleDenominator value"); - - layer = new OpenLayers.Layer.WMS( - "test", "http://foo", {}, - {scales: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)} - ); - layer.minScale = Math.random(); - layer.maxScale = Math.random(); - layerContext = format.layerToContext(layer); - node = parser.write_wmc_Layer(layerContext); - minList = parser.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator"); - var f = new OpenLayers.Format.XML(); - t.eq(minList.length, 1, "(scales) node written with MinScaleDenominator"); - t.eq(layer.maxScale.toPrecision(16), parser.getChildValue(minList[0]), - "(scales) node written with correct MinScaleDenominator value"); - maxList = parser.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator"); - t.eq(maxList.length, 1, "(scales) node written with MaxScaleDenominator"); - t.eq(layer.minScale.toPrecision(16), parser.getChildValue(maxList[0]), - "(scales) node written with correct MaxScaleDenominator value"); - - layer.metadataURL = 'http://foo'; - layerContext = format.layerToContext(layer); - node = parser.write_wmc_Layer(layerContext); - t.eq(node.childNodes[3].localName || node.childNodes[3].nodeName.split(":").pop(), - 'MetadataURL', "MinScaleDenominator is written after MetadataURL, so third node should be MetadataURL"); - t.eq(node.childNodes[4].localName || node.childNodes[4].nodeName.split(":").pop(), - 'MinScaleDenominator', "MinScaleDenominator is written after MetadataURL, so fourth node should be MinScaleDenominator"); - - } - - - </script> -</head> -<body> - <div id="map" style="width: 512px; height: 256px;"></div> -</body> -</html> |