OpenLayers OpenLayers

Changeset 5340

Show
Ignore:
Timestamp:
12/04/07 08:36:02 (1 year ago)
Author:
elemoine
Message:

applies latest patch to the renderers tests, special thanks to pgiraud for his great work! (hopefully closes #1128 this time)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/tests/Renderer/test_Elements.html

    r5329 r5340  
    66    function test_Elements_constructor(t) { 
    77        t.plan(5); 
    8         var el = document.body; 
     8        var el = document.createElement('div'); 
     9        document.body.appendChild(el); 
    910        el.id = "foo"; 
    1011         
     
    1516        OpenLayers.Renderer.Elements.prototype.createRenderRoot = function() { 
    1617            return rendererRoot; 
    17         } 
     18        }; 
    1819         
    1920        OpenLayers.Renderer.Elements.prototype._createRoot = 
     
    2324        OpenLayers.Renderer.Elements.prototype.createRoot = function() { 
    2425            return root; 
    25         } 
     26        }; 
    2627         
    2728        var r = new OpenLayers.Renderer.Elements("foo"); 
     
    3233         
    3334        t.ok(r.root.parentNode == rendererRoot, "elements root is correctly appended to rendererRoot"); 
    34         t.ok(r.rendererRoot.parentNode == document.body, "elements rendererRoot is correctly appended to container"); 
     35        t.ok(r.rendererRoot.parentNode == el, "elements rendererRoot is correctly appended to container"); 
    3536         
    3637        OpenLayers.Renderer.Elements.prototype.createRenderRoot = 
     
    5556        OpenLayers.Renderer.prototype.destroy = function() { 
    5657            g_Destroy = true; 
    57         } 
     58        }; 
    5859         
    5960        var r = new OpenLayers.Renderer.SVG(document.body); 
    6061        r.clear = function() { 
    6162            g_Clear = true; 
    62         } 
     63        }; 
    6364        r.rendererRoot = 'foo'; 
    6465        r.root = 'bar'; 
     
    118119            var element = document.createElement("div"); 
    119120            return element; 
    120         } 
     121        }; 
    121122        var g_Node = null; 
    122123        r.drawGeometryNode = function(node, geometry, style) { 
    123124            g_Node = node; 
    124125            return node; 
    125         } 
     126        }; 
    126127        r.getNodeType = function(geometry, style) { 
    127128            return "div"; 
    128         } 
     129        }; 
    129130        geometry = { 
    130131            id: 'foo', 
     
    159160            var element = document.createElement("div"); 
    160161            return element; 
    161         } 
     162        }; 
    162163        r.setStyle = function(node, style, options, geometry) { 
    163164            return node; 
     
    169170            properDraw = true; 
    170171            return {}; 
    171         } 
     172        }; 
    172173        geometry = {CLASS_NAME: 'OpenLayers.Geometry.Point'}; 
    173174        style = true; 
     
    180181            properDraw = true; 
    181182            return {}; 
    182         } 
     183        }; 
    183184        geometry = {CLASS_NAME: 'OpenLayers.Geometry.LineString'}; 
    184185        style = true; 
     
    191192            properDraw = true; 
    192193            return {}; 
    193         } 
     194        }; 
    194195        geometry = {CLASS_NAME: 'OpenLayers.Geometry.LinearRing'}; 
    195196        style = true; 
     
    202203            properDraw = true; 
    203204            return {}; 
    204         } 
     205        }; 
    205206        geometry = {CLASS_NAME: 'OpenLayers.Geometry.Polygon'}; 
    206207        style = true; 
     
    224225            properDraw = true; 
    225226            return {}; 
    226         } 
     227        }; 
    227228        geometry = {CLASS_NAME: 'OpenLayers.Geometry.Rectangle'}; 
    228229        style = true; 
     
    235236            properDraw = true; 
    236237            return {}; 
    237         } 
     238        }; 
    238239        geometry = { 
    239240            CLASS_NAME: 'OpenLayers.Geometry.MultiPoint', 
     
    249250            properDraw = true; 
    250251            return {}; 
    251         } 
     252        }; 
    252253        geometry = { 
    253254            CLASS_NAME: 'OpenLayers.Geometry.MultiLineString', 
     
    263264            properDraw = true; 
    264265            return {}; 
    265         } 
     266        }; 
    266267        geometry = { 
    267268            CLASS_NAME: 'OpenLayers.Geometry.MultiPolygon', 
     
    281282        var node = { 
    282283            _featureId: 'foo' 
    283         } 
     284        }; 
    284285        var event = { 
    285286            target: node 
    286         } 
     287        }; 
    287288         
    288289        var id = OpenLayers.Renderer.Elements.prototype.getFeatureIdFromEvent(event); 
     
    291292        var event = { 
    292293            srcElement: node 
    293         } 
     294        }; 
    294295         
    295296        var id = OpenLayers.Renderer.Elements.prototype.getFeatureIdFromEvent(event); 
     
    302303        var el = document.createElement('div'); 
    303304        document.body.appendChild(el); 
    304         el.id = 'foo'; 
     305        el.id = 'bar'; 
    305306        var geometry = { 
    306             id: 'foo
     307            id: 'bar
    307308        }; 
    308309         
     
    310311        t.ok(el.parentNode != document.body, "element correctly removed"); 
    311312 
    312  
    313         var el = document.createElement('div'); 
    314         document.body.appendChild(el); 
    315         el.id = 'foo'; 
     313        var el = document.createElement('div'); 
     314        document.body.appendChild(el); 
     315        el.id = 'bar'; 
    316316        var geometry = { 
    317317            CLASS_NAME: "OpenLayers.Geometry.MultiPoint", 
    318318            components: [{ 
    319                 id: 'foo
     319                id: 'bar
    320320            }] 
    321321        }; 
     
    326326        var el = document.createElement('div'); 
    327327        document.body.appendChild(el); 
    328         el.id = 'foo'; 
     328        el.id = 'bar'; 
    329329        var geometry = { 
    330330            CLASS_NAME: "OpenLayers.Geometry.MultiLineString", 
    331331            components: [{ 
    332                 id: 'foo
     332                id: 'bar
    333333            }] 
    334334        }; 
     
    339339        var el = document.createElement('div'); 
    340340        document.body.appendChild(el); 
    341         el.id = 'foo'; 
     341        el.id = 'bar'; 
    342342        var geometry = { 
    343343            CLASS_NAME: "OpenLayers.Geometry.MultiPolygon", 
    344344            components: [{ 
    345                 id: 'foo
     345                id: 'bar
    346346            }] 
    347347        }; 
  • trunk/openlayers/tests/Renderer/test_SVG.html

    r5320 r5340  
    367367</body> 
    368368</html> 
    369 <html> 
    370 <head> 
    371 <script src="../../lib/OpenLayers.js"></script> 
    372   <script type="text/javascript"> 
    373  
    374     var geometry = null, node = null; 
    375      
    376     function test_SVG_constructor(t) { 
    377         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    378             t.plan(0); 
    379             return; 
    380         } 
    381          
    382         t.plan(1); 
    383         var r = new OpenLayers.Renderer.SVG(document.body); 
    384         t.ok(r instanceof OpenLayers.Renderer.SVG, "new OpenLayers.Renderer.SVG returns SVG object" ); 
    385     } 
    386      
    387     function test_SVG_destroy(t) { 
    388         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    389             t.plan(0); 
    390             return; 
    391         } 
    392          
    393         t.plan(1); 
    394          
    395         var g_Destroy = false; 
    396          
    397         OpenLayers.Renderer.Elements.prototype._destroy =  
    398             OpenLayers.Renderer.Elements.prototype.destroy; 
    399              
    400         OpenLayers.Renderer.prototype.destroy = function() { 
    401             g_Destroy = true; 
    402         } 
    403          
    404         var r = new OpenLayers.Renderer.SVG(document.body); 
    405         r.destroy(); 
    406          
    407         t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called"); 
    408          
    409         OpenLayers.Renderer.prototype.destroy =  
    410             OpenLayers.Renderer.prototype._destroy; 
    411     } 
    412      
    413     function test_SVG_setextent(t) { 
    414         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    415             t.plan(0); 
    416             return; 
    417         } 
    418          
    419         t.plan(5); 
    420          
    421         OpenLayers.Renderer.Elements.prototype._setExtent = 
    422             OpenLayers.Renderer.Elements.prototype.setExtent; 
    423          
    424         var g_SetExtent = false; 
    425         OpenLayers.Renderer.Elements.prototype.setExtent = function() { 
    426             g_SetExtent = true; 
    427         } 
    428                  
    429         var r = new OpenLayers.Renderer.SVG(document.body); 
    430         r.map = { 
    431             getResolution: function() { 
    432                 return 0.5; 
    433             } 
    434         } 
    435          
    436         var extent = new OpenLayers.Bounds(1,2,3,4); 
    437         r.setExtent(extent); 
    438          
    439         t.eq(g_SetExtent, true, "Elements.setExtent() called"); 
    440          
    441         t.eq(r.left, -2, "left is correct"); 
    442         t.eq(r.top, 8, "top is correct"); 
    443          
    444         t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "0 0 4 4", "rendererRoot viewBox is correct"); 
    445          
    446         // test extent changes 
    447         var extent = new OpenLayers.Bounds(4,3,2,1); 
    448         r.setExtent(extent); 
    449         t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "6 6 -4 -4", "rendererRoot viewBox is correct after a new setExtent"); 
    450  
    451         OpenLayers.Renderer.Elements.prototype.setExtent = 
    452             OpenLayers.Renderer.Elements.prototype._setExtent; 
    453     } 
    454      
    455     function test_SVG_setsize(t) { 
    456         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    457             t.plan(0); 
    458             return; 
    459         } 
    460          
    461         t.plan(2); 
    462                  
    463         var r = new OpenLayers.Renderer.SVG(document.body); 
    464          
    465         var size = new OpenLayers.Size(1,2); 
    466         r.setSize(size); 
    467         t.eq(r.rendererRoot.getAttributeNS(null, "width"), size.w.toString(), "width is correct"); 
    468         t.eq(r.rendererRoot.getAttributeNS(null, "height"), size.h.toString(), "height is correct"); 
    469     } 
    470      
    471     function test_SVG_drawpoint(t) { 
    472         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    473             t.plan(0); 
    474             return; 
    475         } 
    476      
    477         t.plan(1); 
    478  
    479         var r = new OpenLayers.Renderer.SVG(document.body); 
    480          
    481         var properDraw = false; 
    482         var g_Radius = null; 
    483         r.drawCircle = function(n, g, r) { 
    484             properDraw = true; 
    485             g_Radius = 1; 
    486         } 
    487         r.drawPoint(); 
    488          
    489         t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1"); 
    490     } 
    491      
    492     function test_SVG_drawcircle(t) { 
    493         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    494             t.plan(0); 
    495             return; 
    496         } 
    497          
    498         t.plan(3); 
    499          
    500         var r = new OpenLayers.Renderer.SVG(document.body); 
    501         r.resolution = 0.5; 
    502         r.left = 0; 
    503         r.top = 0; 
    504          
    505         var node = document.createElement('div'); 
    506          
    507         var geometry = { 
    508             x: 1, 
    509             y: 2 
    510         } 
    511          
    512         r.drawCircle(node, geometry, 3); 
    513          
    514         t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct"); 
    515         t.eq(node.getAttributeNS(null, 'cy'), '4', "cy is correct"); 
    516         t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct"); 
    517     } 
    518      
    519     function test_SVG_drawlinestring(t) { 
    520         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    521             t.plan(0); 
    522             return; 
    523         } 
    524          
    525         t.plan(2); 
    526          
    527         var r = new OpenLayers.Renderer.SVG(document.body); 
    528          
    529         var node = document.createElement('div'); 
    530          
    531         var geometry = { 
    532             components: "foo" 
    533         } 
    534         g_GetString = false; 
    535         g_Components = null; 
    536         r.getComponentsString = function(c) { 
    537             g_GetString = true; 
    538             g_Components = c; 
    539             return "bar"; 
    540         } 
    541          
    542         r.drawLineString(node, geometry); 
    543          
    544         t.ok(g_GetString && g_Components == "foo", "getComponentString is called with valid arguments"); 
    545         t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct"); 
    546     } 
    547      
    548     function test_SVG_drawlinearring(t) { 
    549         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    550             t.plan(0); 
    551             return; 
    552         } 
    553          
    554         t.plan(2); 
    555          
    556         var r = new OpenLayers.Renderer.SVG(document.body); 
    557          
    558         var node = document.createElement('div'); 
    559          
    560         var geometry = { 
    561             components: "foo" 
    562         } 
    563         g_GetString = false; 
    564         g_Components = null; 
    565         r.getComponentsString = function(c) { 
    566             g_GetString = true; 
    567             g_Components = c; 
    568             return "bar"; 
    569         } 
    570          
    571         r.drawLinearRing(node, geometry); 
    572          
    573         t.ok(g_GetString, "getComponentString is called with valid arguments"); 
    574         t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct"); 
    575     } 
    576  
    577     function test_SVG_drawpolygon(t) { 
    578         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    579             t.plan(0); 
    580             return; 
    581         } 
    582          
    583         t.plan(4); 
    584          
    585         var r = new OpenLayers.Renderer.SVG(document.body); 
    586          
    587         var node = document.createElement('div'); 
    588          
    589         var linearRings = [{ 
    590             components: ["foo"] 
    591         },{ 
    592             components: ["bar"] 
    593         }] 
    594          
    595         var geometry = { 
    596             components: linearRings 
    597         } 
    598         g_GetString = false; 
    599         r.getShortString = function(c) { 
    600             g_GetString = true; 
    601             return c; 
    602         } 
    603          
    604         r.drawPolygon(node, geometry); 
    605          
    606         t.ok(g_GetString, "getShortString is called"); 
    607         t.eq(node.getAttributeNS(null, "d"), " M foo M bar z", "d attribute is correctly set"); 
    608         t.eq(node.getAttributeNS(null, "fill-rule"), "evenodd", "fill-rule attribute is correctly set"); 
    609          
    610         r.getShortString = function(c) { 
    611             return false; 
    612         } 
    613         r.drawPolygon(node, geometry); 
    614         t.eq(node.getAttributeNS(null, "d"), "", "d attribute is empty if one linearRing cannot be drawn"); 
    615     } 
    616  
    617     function test_SVG_drawrectangle(t) { 
    618         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    619             t.plan(0); 
    620             return; 
    621         } 
    622          
    623         t.plan(4); 
    624          
    625         var r = new OpenLayers.Renderer.SVG(document.body); 
    626         r.resolution = 0.5; 
    627         r.left = 0; 
    628         r.top = 0; 
    629          
    630         var node = document.createElement('div'); 
    631          
    632         var geometry = { 
    633             x: 1, 
    634             y: 2, 
    635             width: 3, 
    636             height: 4 
    637         } 
    638          
    639         r.drawRectangle(node, geometry); 
    640          
    641         t.eq(node.getAttributeNS(null, "x"), "2", "x attribute is correctly set"); 
    642         t.eq(node.getAttributeNS(null, "y"), "4", "y attribute is correctly set"); 
    643         t.eq(node.getAttributeNS(null, "width"), "6", "width attribute is correctly set"); 
    644         t.eq(node.getAttributeNS(null, "height"), "8", "height attribute is correctly set"); 
    645     } 
    646      
    647     function test_SVG_drawsurface(t) { 
    648         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    649             t.plan(0); 
    650             return; 
    651         } 
    652          
    653         t.plan(3); 
    654          
    655         var r = new OpenLayers.Renderer.SVG(document.body); 
    656          
    657         var node = document.createElement('div'); 
    658          
    659         var geometry = { 
    660             components: ['foo', 'bar', 'dude'] 
    661         } 
    662         g_GetString = false; 
    663         r.getShortString = function(c) { 
    664             g_GetString = true; 
    665             return c; 
    666         } 
    667          
    668         r.drawSurface(node, geometry); 
    669          
    670         t.ok(g_GetString, "getShortString is called"); 
    671          
    672         t.eq(node.getAttributeNS(null, "d"), "M foo C bar dude Z", "d attribute is correctly set"); 
    673          
    674         r.getShortString = function(c) { 
    675             return false; 
    676         } 
    677         r.drawSurface(node, geometry); 
    678         t.eq(node.getAttributeNS(null, "d"), "", "d attribute is empty if one linearRing cannot be drawn"); 
    679     } 
    680      
    681     function test_SVG_getcomponentsstring(t) { 
    682         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    683             t.plan(0); 
    684             return; 
    685         } 
    686          
    687         t.plan(1); 
    688          
    689         var components = ['foo', 'bar']; 
    690          
    691         OpenLayers.Renderer.SVG.prototype._getShortString =  
    692             OpenLayers.Renderer.SVG.prototype.getShortString; 
    693              
    694         OpenLayers.Renderer.SVG.prototype.getShortString = function(p) { 
    695             return p; 
    696         }; 
    697          
    698         var string = OpenLayers.Renderer.SVG.prototype.getComponentsString(components); 
    699         t.eq(string, "foo,bar", "returned string is correct"); 
    700          
    701         OpenLayers.Renderer.SVG.prototype.getShortString =  
    702             OpenLayers.Renderer.SVG.prototype._getShortString; 
    703     } 
    704      
    705      
    706      
    707     function test_SVG_getshortstring(t) { 
    708         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    709             t.plan(0); 
    710             return; 
    711         } 
    712          
    713         t.plan(1); 
    714          
    715         var r = new OpenLayers.Renderer.SVG(document.body); 
    716         r.resolution = 0.5; 
    717         r.left = 0; 
    718         r.top = 0; 
    719          
    720         var point = { 
    721             x: 1, 
    722             y: 2 
    723         }; 
    724          
    725         var string = r.getShortString(point); 
    726         t.eq(string, "2,4", "returned string is correct"); 
    727     } 
    728      
    729      
    730  
    731   </script> 
    732 </head> 
    733 <body> 
    734 <div id="map" style="width:500px;height:550px"></div> 
    735 </body> 
    736 </html> 
    737 <html> 
    738 <head> 
    739 <script src="../../lib/OpenLayers.js"></script> 
    740   <script type="text/javascript"> 
    741  
    742     var geometry = null, node = null; 
    743      
    744     function test_SVG_constructor(t) { 
    745         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    746             t.plan(0); 
    747             return; 
    748         } 
    749          
    750         t.plan(1); 
    751         var r = new OpenLayers.Renderer.SVG(document.body); 
    752         t.ok(r instanceof OpenLayers.Renderer.SVG, "new OpenLayers.Renderer.SVG returns SVG object" ); 
    753     } 
    754      
    755     function test_SVG_destroy(t) { 
    756         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    757             t.plan(0); 
    758             return; 
    759         } 
    760          
    761         t.plan(1); 
    762          
    763         var g_Destroy = false; 
    764          
    765         OpenLayers.Renderer.Elements.prototype._destroy =  
    766             OpenLayers.Renderer.Elements.prototype.destroy; 
    767              
    768         OpenLayers.Renderer.prototype.destroy = function() { 
    769             g_Destroy = true; 
    770         } 
    771          
    772         var r = new OpenLayers.Renderer.SVG(document.body); 
    773         r.destroy(); 
    774          
    775         t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called"); 
    776          
    777         OpenLayers.Renderer.prototype.destroy =  
    778             OpenLayers.Renderer.prototype._destroy; 
    779     } 
    780      
    781     function test_SVG_setextent(t) { 
    782         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    783             t.plan(0); 
    784             return; 
    785         } 
    786          
    787         t.plan(5); 
    788          
    789         OpenLayers.Renderer.Elements.prototype._setExtent = 
    790             OpenLayers.Renderer.Elements.prototype.setExtent; 
    791          
    792         var g_SetExtent = false; 
    793         OpenLayers.Renderer.Elements.prototype.setExtent = function() { 
    794             g_SetExtent = true; 
    795         } 
    796                  
    797         var r = new OpenLayers.Renderer.SVG(document.body); 
    798         r.map = { 
    799             getResolution: function() { 
    800                 return 0.5; 
    801             } 
    802         } 
    803          
    804         var extent = new OpenLayers.Bounds(1,2,3,4); 
    805         r.setExtent(extent); 
    806          
    807         t.eq(g_SetExtent, true, "Elements.setExtent() called"); 
    808          
    809         t.eq(r.left, -2, "left is correct"); 
    810         t.eq(r.top, 8, "top is correct"); 
    811          
    812         t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "0 0 4 4", "rendererRoot viewBox is correct"); 
    813          
    814         // test extent changes 
    815         var extent = new OpenLayers.Bounds(4,3,2,1); 
    816         r.setExtent(extent); 
    817         t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "6 6 -4 -4", "rendererRoot viewBox is correct after a new setExtent"); 
    818  
    819         OpenLayers.Renderer.Elements.prototype.setExtent = 
    820             OpenLayers.Renderer.Elements.prototype._setExtent; 
    821     } 
    822      
    823     function test_SVG_setsize(t) { 
    824         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    825             t.plan(0); 
    826             return; 
    827         } 
    828          
    829         t.plan(2); 
    830                  
    831         var r = new OpenLayers.Renderer.SVG(document.body); 
    832          
    833         var size = new OpenLayers.Size(1,2); 
    834         r.setSize(size); 
    835         t.eq(r.rendererRoot.getAttributeNS(null, "width"), size.w.toString(), "width is correct"); 
    836         t.eq(r.rendererRoot.getAttributeNS(null, "height"), size.h.toString(), "height is correct"); 
    837     } 
    838      
    839     function test_SVG_drawpoint(t) { 
    840         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    841             t.plan(0); 
    842             return; 
    843         } 
    844      
    845         t.plan(1); 
    846  
    847         var r = new OpenLayers.Renderer.SVG(document.body); 
    848          
    849         var properDraw = false; 
    850         var g_Radius = null; 
    851         r.drawCircle = function(n, g, r) { 
    852             properDraw = true; 
    853             g_Radius = 1; 
    854         } 
    855         r.drawPoint(); 
    856          
    857         t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1"); 
    858     } 
    859      
    860     function test_SVG_drawcircle(t) { 
    861         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    862             t.plan(0); 
    863             return; 
    864         } 
    865          
    866         t.plan(3); 
    867          
    868         var r = new OpenLayers.Renderer.SVG(document.body); 
    869         r.resolution = 0.5; 
    870         r.left = 0; 
    871         r.top = 0; 
    872          
    873         var node = document.createElement('div'); 
    874          
    875         var geometry = { 
    876             x: 1, 
    877             y: 2 
    878         } 
    879          
    880         r.drawCircle(node, geometry, 3); 
    881          
    882         t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct"); 
    883         t.eq(node.getAttributeNS(null, 'cy'), '4', "cy is correct"); 
    884         t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct"); 
    885     } 
    886      
    887     function test_SVG_drawlinestring(t) { 
    888         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    889             t.plan(0); 
    890             return; 
    891         } 
    892          
    893         t.plan(2); 
    894          
    895         var r = new OpenLayers.Renderer.SVG(document.body); 
    896          
    897         var node = document.createElement('div'); 
    898          
    899         var geometry = { 
    900             components: "foo" 
    901         } 
    902         g_GetString = false; 
    903         g_Components = null; 
    904         r.getComponentsString = function(c) { 
    905             g_GetString = true; 
    906             g_Components = c; 
    907             return "bar"; 
    908         } 
    909          
    910         r.drawLineString(node, geometry); 
    911          
    912         t.ok(g_GetString && g_Components == "foo", "getComponentString is called with valid arguments"); 
    913         t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct"); 
    914     } 
    915      
    916     function test_SVG_drawlinearring(t) { 
    917         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    918             t.plan(0); 
    919             return; 
    920         } 
    921          
    922         t.plan(2); 
    923          
    924         var r = new OpenLayers.Renderer.SVG(document.body); 
    925          
    926         var node = document.createElement('div'); 
    927          
    928         var geometry = { 
    929             components: "foo" 
    930         } 
    931         g_GetString = false; 
    932         g_Components = null; 
    933         r.getComponentsString = function(c) { 
    934             g_GetString = true; 
    935             g_Components = c; 
    936             return "bar"; 
    937         } 
    938          
    939         r.drawLinearRing(node, geometry); 
    940          
    941         t.ok(g_GetString, "getComponentString is called with valid arguments"); 
    942         t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct"); 
    943     } 
    944  
    945     function test_SVG_drawpolygon(t) { 
    946         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    947             t.plan(0); 
    948             return; 
    949         } 
    950          
    951         t.plan(4); 
    952          
    953         var r = new OpenLayers.Renderer.SVG(document.body); 
    954          
    955         var node = document.createElement('div'); 
    956          
    957         var linearRings = [{ 
    958             components: ["foo"] 
    959         },{ 
    960             components: ["bar"] 
    961         }] 
    962          
    963         var geometry = { 
    964             components: linearRings 
    965         } 
    966         g_GetString = false; 
    967         r.getShortString = function(c) { 
    968             g_GetString = true; 
    969             return c; 
    970         } 
    971          
    972         r.drawPolygon(node, geometry); 
    973          
    974         t.ok(g_GetString, "getShortString is called"); 
    975         t.eq(node.getAttributeNS(null, "d"), " M foo M bar z", "d attribute is correctly set"); 
    976         t.eq(node.getAttributeNS(null, "fill-rule"), "evenodd", "fill-rule attribute is correctly set"); 
    977          
    978         r.getShortString = function(c) { 
    979             return false; 
    980         } 
    981         r.drawPolygon(node, geometry); 
    982         t.eq(node.getAttributeNS(null, "d"), "", "d attribute is empty if one linearRing cannot be drawn"); 
    983     } 
    984  
    985     function test_SVG_drawrectangle(t) { 
    986         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    987             t.plan(0); 
    988             return; 
    989         } 
    990          
    991         t.plan(4); 
    992          
    993         var r = new OpenLayers.Renderer.SVG(document.body); 
    994         r.resolution = 0.5; 
    995         r.left = 0; 
    996         r.top = 0; 
    997          
    998         var node = document.createElement('div'); 
    999          
    1000         var geometry = { 
    1001             x: 1, 
    1002             y: 2, 
    1003             width: 3, 
    1004             height: 4 
    1005         } 
    1006          
    1007         r.drawRectangle(node, geometry); 
    1008          
    1009         t.eq(node.getAttributeNS(null, "x"), "2", "x attribute is correctly set"); 
    1010         t.eq(node.getAttributeNS(null, "y"), "4", "y attribute is correctly set"); 
    1011         t.eq(node.getAttributeNS(null, "width"), "6", "width attribute is correctly set"); 
    1012         t.eq(node.getAttributeNS(null, "height"), "8", "height attribute is correctly set"); 
    1013     } 
    1014      
    1015     function test_SVG_drawsurface(t) { 
    1016         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1017             t.plan(0); 
    1018             return; 
    1019         } 
    1020          
    1021         t.plan(3); 
    1022          
    1023         var r = new OpenLayers.Renderer.SVG(document.body); 
    1024          
    1025         var node = document.createElement('div'); 
    1026          
    1027         var geometry = { 
    1028             components: ['foo', 'bar', 'dude'] 
    1029         } 
    1030         g_GetString = false; 
    1031         r.getShortString = function(c) { 
    1032             g_GetString = true; 
    1033             return c; 
    1034         } 
    1035          
    1036         r.drawSurface(node, geometry); 
    1037          
    1038         t.ok(g_GetString, "getShortString is called"); 
    1039          
    1040         t.eq(node.getAttributeNS(null, "d"), "M foo C bar dude Z", "d attribute is correctly set"); 
    1041          
    1042         r.getShortString = function(c) { 
    1043             return false; 
    1044         } 
    1045         r.drawSurface(node, geometry); 
    1046         t.eq(node.getAttributeNS(null, "d"), "", "d attribute is empty if one linearRing cannot be drawn"); 
    1047     } 
    1048      
    1049     function test_SVG_getcomponentsstring(t) { 
    1050         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1051             t.plan(0); 
    1052             return; 
    1053         } 
    1054          
    1055         t.plan(1); 
    1056          
    1057         var components = ['foo', 'bar']; 
    1058          
    1059         OpenLayers.Renderer.SVG.prototype._getShortString =  
    1060             OpenLayers.Renderer.SVG.prototype.getShortString; 
    1061              
    1062         OpenLayers.Renderer.SVG.prototype.getShortString = function(p) { 
    1063             return p; 
    1064         }; 
    1065          
    1066         var string = OpenLayers.Renderer.SVG.prototype.getComponentsString(components); 
    1067         t.eq(string, "foo,bar", "returned string is correct"); 
    1068          
    1069         OpenLayers.Renderer.SVG.prototype.getShortString =  
    1070             OpenLayers.Renderer.SVG.prototype._getShortString; 
    1071     } 
    1072      
    1073      
    1074      
    1075     function test_SVG_getshortstring(t) { 
    1076         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1077             t.plan(0); 
    1078             return; 
    1079         } 
    1080          
    1081         t.plan(1); 
    1082          
    1083         var r = new OpenLayers.Renderer.SVG(document.body); 
    1084         r.resolution = 0.5; 
    1085         r.left = 0; 
    1086         r.top = 0; 
    1087          
    1088         var point = { 
    1089             x: 1, 
    1090             y: 2 
    1091         }; 
    1092          
    1093         var string = r.getShortString(point); 
    1094         t.eq(string, "2,4", "returned string is correct"); 
    1095     } 
    1096      
    1097      
    1098  
    1099   </script> 
    1100 </head> 
    1101 <body> 
    1102 <div id="map" style="width:500px;height:550px"></div> 
    1103 </body> 
    1104 </html> 
    1105 <html> 
    1106 <head> 
    1107 <script src="../../lib/OpenLayers.js"></script> 
    1108   <script type="text/javascript"> 
    1109  
    1110     var geometry = null, node = null; 
    1111      
    1112     function test_SVG_constructor(t) { 
    1113         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1114             t.plan(0); 
    1115             return; 
    1116         } 
    1117          
    1118         t.plan(1); 
    1119         var r = new OpenLayers.Renderer.SVG(document.body); 
    1120         t.ok(r instanceof OpenLayers.Renderer.SVG, "new OpenLayers.Renderer.SVG returns SVG object" ); 
    1121     } 
    1122      
    1123     function test_SVG_destroy(t) { 
    1124         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1125             t.plan(0); 
    1126             return; 
    1127         } 
    1128          
    1129         t.plan(1); 
    1130          
    1131         var g_Destroy = false; 
    1132          
    1133         OpenLayers.Renderer.Elements.prototype._destroy =  
    1134             OpenLayers.Renderer.Elements.prototype.destroy; 
    1135              
    1136         OpenLayers.Renderer.prototype.destroy = function() { 
    1137             g_Destroy = true; 
    1138         } 
    1139          
    1140         var r = new OpenLayers.Renderer.SVG(document.body); 
    1141         r.destroy(); 
    1142          
    1143         t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called"); 
    1144          
    1145         OpenLayers.Renderer.prototype.destroy =  
    1146             OpenLayers.Renderer.prototype._destroy; 
    1147     } 
    1148      
    1149     function test_SVG_setextent(t) { 
    1150         if (!OpenLayers.Renderer.SVG.prototype.supported()) { 
    1151             t.plan(0); 
    1152             return; 
    1153         } 
    1154          
    1155         t.plan(5); 
    1156          
    1157         OpenLayers.Renderer.Elements.prototype._setExtent = 
    1158             OpenLayers.Renderer.Elements.prototype.setExtent; 
    1159          
    1160         var g_SetExtent = false; 
    1161         OpenLayers.Renderer.Elements.prototype.setExtent = function() { 
    1162             g_SetExtent = true; 
    1163         } 
    1164                  
    1165         var r = new OpenLayers.Renderer.SVG(document.body); 
    1166         r.map = { 
    1167             getResolution: function() { 
    1168                 return 0.5; 
    1169             } 
    1170         } 
    1171          
    1172         var extent = new OpenLayers.Bounds(1,2,3,4); 
    1173         r.setExtent(extent); 
    1174   &nb