3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 var test_content = '<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><sld:NamedLayer><sld:Name>TestLayer</sld:Name><sld:UserStyle><sld:Name>foo</sld:Name><sld:FeatureTypeStyle><sld:Rule><sld:Name>bar</sld:Name><ogc:Filter></ogc:Filter><sld:PolygonSymbolizer><sld:Fill><sld:CssParameter name="fill"><ogc:Literal>blue</ogc:Literal></sld:CssParameter></sld:Fill></sld:PolygonSymbolizer></sld:Rule></sld:FeatureTypeStyle></sld:UserStyle></sld:NamedLayer></sld:StyledLayerDescriptor>';
8 function test_Format_SLD_constructor(t) {
11 var options = {'foo': 'bar'};
12 var format = new OpenLayers.Format.SLD(options);
13 t.ok(format instanceof OpenLayers.Format.SLD,
14 "new OpenLayers.Format.SLD returns object" );
15 t.eq(format.foo, "bar", "constructor sets options correctly");
16 t.eq(typeof format.read, "function", "format has a read function");
19 function test_Format_SLD_read(t) {
21 var sld = new OpenLayers.Format.SLD().read(this.test_content);
23 var testLayer = sld.namedLayers["TestLayer"];
24 var userStyles = testLayer.userStyles;
26 t.eq(userStyles[0].name, "foo", "SLD correctly reads a UserStyle named 'foo'");
27 t.eq(userStyles[0].rules.length, 1, "The number of rules for the UserStyle is correct");
28 t.eq(userStyles[0].rules[0].name, "bar", "The first rule's name is 'bar'");
29 t.eq(userStyles[0].rules[0].symbolizer.Polygon.fillColor, "blue", "The fillColor for the Polygon symbolizer is correct");