| | 17 | |
|---|
| | 18 | function test_Layer_WFS_destroy(t) { |
|---|
| | 19 | t.plan(13); |
|---|
| | 20 | |
|---|
| | 21 | var tVectorDestroy = OpenLayers.Layer.Vector.prototype.destroy; |
|---|
| | 22 | OpenLayers.Layer.Vector.prototype.destroy = function() { |
|---|
| | 23 | g_VectorDestroyed = true; |
|---|
| | 24 | } |
|---|
| | 25 | |
|---|
| | 26 | var tMarkersDestroy = OpenLayers.Layer.Markers.prototype.destroy; |
|---|
| | 27 | OpenLayers.Layer.Markers.prototype.destroy = function() { |
|---|
| | 28 | g_MarkersDestroyed = true; |
|---|
| | 29 | } |
|---|
| | 30 | |
|---|
| | 31 | var layer = { |
|---|
| | 32 | 'vectorMode': true, |
|---|
| | 33 | 'tile': { |
|---|
| | 34 | 'destroy': function() { |
|---|
| | 35 | t.ok(true, "wfs layer's tile is destroyed"); |
|---|
| | 36 | } |
|---|
| | 37 | }, |
|---|
| | 38 | 'ratio': {}, |
|---|
| | 39 | 'featureClass': {}, |
|---|
| | 40 | 'format': {}, |
|---|
| | 41 | 'formatObject': { |
|---|
| | 42 | 'destroy': function() { |
|---|
| | 43 | t.ok(true, "wfs layer's format object is destroyed"); |
|---|
| | 44 | } |
|---|
| | 45 | }, |
|---|
| | 46 | 'formatOptions': {}, |
|---|
| | 47 | 'encodeBBOX': {}, |
|---|
| | 48 | 'extractAttributes': {} |
|---|
| | 49 | }; |
|---|
| | 50 | |
|---|
| | 51 | //this call should set off two tests (destroys for tile and format object) |
|---|
| | 52 | g_VectorDestroyed = null; |
|---|
| | 53 | g_MarkersDestroyed = null; |
|---|
| | 54 | OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []); |
|---|
| | 55 | |
|---|
| | 56 | t.ok(g_VectorDestroyed && !g_MarkersDestroyed, "when vector mode is set to true, the default vector layer's destroy() method is called"); |
|---|
| | 57 | t.eq(layer.vectorMode, null, "'vectorMode' property nullified"); |
|---|
| | 58 | t.eq(layer.tile, null, "'tile' property nullified"); |
|---|
| | 59 | t.eq(layer.ratio, null, "'ratio' property nullified"); |
|---|
| | 60 | t.eq(layer.featureClass, null, "'featureClass' property nullified"); |
|---|
| | 61 | t.eq(layer.format, null, "'format' property nullified"); |
|---|
| | 62 | t.eq(layer.formatObject, null, "'formatObject' property nullified"); |
|---|
| | 63 | t.eq(layer.formatOptions, null, "'formatOptions' property nullified"); |
|---|
| | 64 | t.eq(layer.encodeBBOX, null, "'encodeBBOX' property nullified"); |
|---|
| | 65 | t.eq(layer.extractAttributes, null, "'extractAttributes' property nullified"); |
|---|
| | 66 | |
|---|
| | 67 | layer.vectorMode = false; |
|---|
| | 68 | |
|---|
| | 69 | //this call will *not* set off two tests (tile and format object are null) |
|---|
| | 70 | g_VectorDestroyed = null; |
|---|
| | 71 | g_MarkersDestroyed = null; |
|---|
| | 72 | OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []); |
|---|
| | 73 | t.ok(!g_VectorDestroyed && g_MarkersDestroyed, "when vector mode is set to false, the default markers layer's destroy() method is called"); |
|---|
| | 74 | |
|---|
| | 75 | OpenLayers.Layer.Vector.prototype.destroy = tVectorDestroy; |
|---|
| | 76 | OpenLayers.Layer.Markers.prototype.destroy = tMarkersDestroy; |
|---|
| | 77 | } |
|---|
| | 78 | |
|---|