OpenLayers OpenLayers

Changeset 7703

Show
Ignore:
Timestamp:
08/05/08 00:39:11 (4 months ago)
Author:
fredj
Message:

Fix a typo in Layer.Vector.destroy and add unit tests for protocol and strategies construct/destroy, r=crschmidt (closes #1659)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Layer/Vector.js

    r7675 r7703  
    229229     */ 
    230230    destroy: function() { 
    231         if (this.stategies) { 
     231        if (this.strategies) { 
    232232            for(var i=0, len=this.strategies.length; i<len; i++) { 
    233233                this.strategies[i].destroy(); 
  • trunk/openlayers/tests/Layer/Vector.html

    r7681 r7703  
    77     
    88    function test_Layer_Vector_constructor(t) { 
    9         t.plan(3); 
    10  
    11         var layer = new OpenLayers.Layer.Vector(name); 
     9        t.plan(4); 
     10 
     11        var options = {protocol: new OpenLayers.Protocol(),  
     12                       strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]} 
     13        var layer = new OpenLayers.Layer.Vector(name, options); 
     14 
    1215        t.ok(layer instanceof OpenLayers.Layer.Vector, "new OpenLayers.Layer.Vector returns correct object" ); 
    1316        t.eq(layer.name, name, "layer name is correctly set"); 
    1417        t.ok(layer.renderer.CLASS_NAME, "layer has a renderer"); 
    15  
     18         
     19        t.ok((layer.name == layer.strategies[0].layer.name) && 
     20             (layer.strategies[0].layer.name == layer.strategies[1].layer.name),  
     21             "setLayer was called on strategies"); 
    1622    } 
    1723     
     
    217223 
    218224    function test_Layer_Vector_destroy (t) { 
    219         t.plan(2);     
    220         layer = new OpenLayers.Layer.Vector(name); 
     225        t.plan(4);     
     226 
     227        var options = {protocol: new OpenLayers.Protocol(),  
     228                       strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]} 
     229        var layer = new OpenLayers.Layer.Vector(name, options); 
    221230        var map = new OpenLayers.Map('map'); 
    222231        map.addLayer(layer); 
    223232        layer.destroy(); 
    224233        t.eq(layer.map, null, "layer.map is null after destroy"); 
    225         t.eq(layer.getFeatureFromEvent({'target':'map'}), null, "getFeatureIdFromEvent doesn't cause an error when called on layer which has been destroyed."); 
     234        t.eq(layer.getFeatureFromEvent({'target':'map'}), null,  
     235            "getFeatureIdFromEvent doesn't cause an error when called on layer which has been destroyed."); 
     236 
     237        t.eq(layer.protocol, null, "layer.protocol is null after destroy"); 
     238        t.eq(layer.strategies, null, "layer.strategies is null after destroy"); 
    226239    } 
    227240