| 1 |
<html> |
|---|
| 2 |
<head> |
|---|
| 3 |
<script src="../../lib/OpenLayers.js"></script> |
|---|
| 4 |
<script type="text/javascript"> |
|---|
| 5 |
|
|---|
| 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>'; |
|---|
| 7 |
|
|---|
| 8 |
function test_Format_SLD_constructor(t) { |
|---|
| 9 |
t.plan(3); |
|---|
| 10 |
|
|---|
| 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"); |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
function test_Format_SLD_read(t) { |
|---|
| 20 |
t.plan(4); |
|---|
| 21 |
var sld = new OpenLayers.Format.SLD().read(this.test_content); |
|---|
| 22 |
|
|---|
| 23 |
var testLayer = sld.namedLayers["TestLayer"]; |
|---|
| 24 |
var userStyles = testLayer.userStyles; |
|---|
| 25 |
|
|---|
| 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"); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
</script> |
|---|
| 33 |
</head> |
|---|
| 34 |
<body> |
|---|
| 35 |
</body> |
|---|
| 36 |
</html> |
|---|