]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Format/WMC/v1_1_0.html
initial commit
[syp.git] / openlayers / tests / Format / WMC / v1_1_0.html
1 <html> 
2 <head> 
3     <script src="../../../lib/OpenLayers.js"></script> 
4     <script type="text/javascript">
5     
6     function test_write_wmc_Layer(t) {
7         if (OpenLayers.Util.getBrowserName() == "safari") {
8             t.plan(0);
9             t.debug_print("Safari has wierd behavior with getElementsByTagNameNS: the result is that we can't run these tests there. Patches welcome.");
10             return;
11         }
12         t.plan(10);
13         
14         // direct construction of a parser for a unit test
15         var wmc = new OpenLayers.Format.WMC.v1_1_0();
16         var sldNS = wmc.namespaces["sld"];
17         
18         // test that Min/MaxScaleDenominator is not written out when no
19         // resolution related options are set
20         var layer = new OpenLayers.Layer.WMS(
21             "test", "http://foo", {},
22             {maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)}
23         );
24         var node = wmc.write_wmc_Layer(layer);
25         var minList = wmc.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator");
26         t.eq(minList.length, 0, "(none) node not written with MinScaleDenominator");
27         var maxList = wmc.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator");
28         t.eq(maxList.length, 0, "(none) node not written with MaxScaleDenominator");
29
30         // test that Min/MaxScaleDenominator is written out for explicit
31         // resolutions array
32         layer = new OpenLayers.Layer.WMS(
33             "test", "http://foo", {},
34             {resolutions: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)}
35         );
36         layer.minScale = Math.random();
37         layer.maxScale = Math.random();
38         sldNS = wmc.namespaces["sld"];
39         node = wmc.write_wmc_Layer(layer);
40         minList = wmc.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator");
41         t.eq(minList.length, 1, "(resolutions) node written with MinScaleDenominator");
42         t.eq(layer.maxScale.toPrecision(10), wmc.getChildValue(minList[0]),
43              "(resolutions) node written with correct MinScaleDenominator value");
44         maxList = wmc.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator");
45         t.eq(maxList.length, 1, "(resolutions) node written with MaxScaleDenominator");
46         t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
47              "(resolutions) node written with correct MaxScaleDenominator value");
48         
49         layer = new OpenLayers.Layer.WMS(
50             "test", "http://foo", {},
51             {scales: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)}
52         );
53         layer.minScale = Math.random();
54         layer.maxScale = Math.random();
55         node = wmc.write_wmc_Layer(layer);
56         minList = wmc.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator");
57         var f = new OpenLayers.Format.XML();
58         t.eq(minList.length, 1, "(scales) node written with MinScaleDenominator");
59         t.eq(layer.maxScale.toPrecision(10), wmc.getChildValue(minList[0]),
60              "(scales) node written with correct MinScaleDenominator value");
61         maxList = wmc.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator");
62         t.eq(maxList.length, 1, "(scales) node written with MaxScaleDenominator");
63         t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
64              "(scales) node written with correct MaxScaleDenominator value");
65         
66     }
67     
68
69     </script> 
70 </head> 
71 <body>
72     <div id="map" style="width: 512px; height: 256px;"></div>
73 </body> 
74 </html>