OpenLayers OpenLayers

Changeset 5292

Show
Ignore:
Timestamp:
11/28/07 07:24:09 (1 year ago)
Author:
elemoine
Message:

add tests for #1150

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/elemoine/regular-polygon/tests/Control/test_ModifyFeature.html

    r5099 r5292  
    191191        control.onModificationEnd = function (feature) { t.eq(feature.id, fakeFeature.id, "onModificationEnd got feature.") } 
    192192        layer.removeFeatures = function(verts) { 
    193             t.ok(verts == 'a' || verts == 'b', "Verts removed correctly") 
     193            t.ok(verts == 'a', "Normal verts removed correctly"); 
     194        } 
     195        layer.destroyFeatures = function(verts) { 
     196            t.ok(verts == 'b', "Virtual verts destroyed correctly"); 
    194197        } 
    195198        control.unselectFeature(fakeFeature); 
     
    215218         
    216219        control.collectVertices = function() {  
     220          t.ok(true, "collectVertices called");  
    217221          this.vertices = 'a'; 
    218222          this.virtualVertices = 'd'; 
    219           t.ok(true, "collectVertices called");  
     223          layer.addFeatures(this.vertices); 
     224          layer.addFeatures(this.virtualVertices); 
    220225        } 
    221226         
     
    243248 
    244249    function test_ModifyFeature_resetVertices(t) { 
    245         t.plan(9); 
     250        t.plan(15); 
    246251        var layer = new OpenLayers.Layer.Vector(); 
    247252        var control = new OpenLayers.Control.ModifyFeature(layer); 
     
    254259        t.eq(control.vertices.length, 0, "Correct vertices length"); 
    255260        t.eq(control.virtualVertices.length, 0, "Correct virtual vertices length."); 
    256          
     261 
    257262        var multiPoint = new OpenLayers.Geometry.MultiPoint([point, point2]); 
    258263        control.feature = new OpenLayers.Feature.Vector(multiPoint); 
     
    274279        t.eq(control.virtualVertices.length, 3, "Correct virtual vertices length (polygon)."); 
    275280 
     281        control.drag = true; 
     282        control.resetVertices(); 
     283        t.ok(control.dragHandle != null, "Drag handle is set"); 
     284        t.eq(control.vertices.length, 4, "Correct vertices length with polygon (drag)"); 
     285 
     286        control.rotate = true; 
     287        control.resetVertices(); 
     288        t.ok(control.radiusHandle != null, "Radius handle is set"); 
     289        t.eq(control.vertices.length, 0, "Correct vertices length with polygon (rotate)"); 
     290 
     291        control.rotate = false; 
     292        control.resize = true; 
     293        t.ok(control.radiusHandle != null, "Radius handle is set"); 
     294        t.eq(control.vertices.length, 0, "Correct vertices length with polygon (resize)"); 
    276295    }     
    277296         
     
    290309         'id': 'fakeFeature' 
    291310        }; 
    292         control.collectVertices = function(geom) { 
    293             t.eq(geom.id, 'myGeom', "collect geom called"); 
     311        layer.addFeatures = function (verts) { 
     312            t.ok(verts == 'virtual' || verts == 'normal', verts + " verts correct"); 
     313        } 
     314        layer.removeFeatures = function (verts) { 
     315            t.ok(verts == 'previous virtual' || verts == 'previous normal', verts + " verts correct"); 
     316        } 
     317        control.onModification = function(feat) { 
     318            t.eq(feat.id, fakeFeature.id, "onModification gets correct feat"); 
     319        } 
     320        control.collectVertices = function() { 
     321            t.ok(true, "collectVertices called"); 
    294322            this.vertices = 'normal'; 
    295323            this.virtualVertices = 'virtual'; 
    296         } 
    297         layer.addFeatures = function (verts) { 
    298             t.ok(verts == 'virtual' || verts == 'normal', verts + " verts correct"); 
    299         } 
    300         layer.removeFeatures = function (verts) { 
    301             t.ok(verts == 'previous virtual' || verts == 'previous normal', verts + " verts correct"); 
    302         } 
    303         control.onModification = function(feat) { 
    304             t.eq(feat.id, fakeFeature.id, "onModification gets correct feat"); 
     324            layer.addFeatures(this.vertices); 
     325            layer.addFeatures(this.virtualVertices); 
    305326        } 
    306327        control.feature = fakeFeature; 
  • sandbox/elemoine/regular-polygon/tests/Layer/test_Vector.html

    r4356 r5292  
    131131 
    132132    function test_Layer_Vector_destroyFeatures (t) { 
    133         t.plan(3);  
     133        t.plan(5);  
    134134        layer = new OpenLayers.Layer.Vector(name); 
    135135        var map = new OpenLayers.Map('map'); 
     
    146146        t.eq(layer.features.length, 0, "destroyFeatures triggers removal"); 
    147147        t.eq(layer.selectedFeatures, [], "Destroy features removes selected features"); 
     148        features = []; 
     149        for (var i = 0; i < 5; i++) { 
     150            features.push(new OpenLayers.Feature.Vector( 
     151                          new OpenLayers.Geometry.Point(0,0))); 
     152        } 
     153        layer.addFeatures(features); 
     154        layer.selectedFeatures.push(features[0]); 
     155        layer.selectedFeatures.push(features[1]); 
     156        layer.destroyFeatures([features[0], features[1]]); 
     157        t.eq(layer.features.length, 3, "destroyFeatures removes appropriate features"); 
     158        t.eq(layer.selectedFeatures, [], "destroyFeatures removes appropriate selected features"); 
    148159    } 
    149160