Changeset 5292
- Timestamp:
- 11/28/07 07:24:09 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/elemoine/regular-polygon/tests/Control/test_ModifyFeature.html
r5099 r5292 191 191 control.onModificationEnd = function (feature) { t.eq(feature.id, fakeFeature.id, "onModificationEnd got feature.") } 192 192 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"); 194 197 } 195 198 control.unselectFeature(fakeFeature); … … 215 218 216 219 control.collectVertices = function() { 220 t.ok(true, "collectVertices called"); 217 221 this.vertices = 'a'; 218 222 this.virtualVertices = 'd'; 219 t.ok(true, "collectVertices called"); 223 layer.addFeatures(this.vertices); 224 layer.addFeatures(this.virtualVertices); 220 225 } 221 226 … … 243 248 244 249 function test_ModifyFeature_resetVertices(t) { 245 t.plan( 9);250 t.plan(15); 246 251 var layer = new OpenLayers.Layer.Vector(); 247 252 var control = new OpenLayers.Control.ModifyFeature(layer); … … 254 259 t.eq(control.vertices.length, 0, "Correct vertices length"); 255 260 t.eq(control.virtualVertices.length, 0, "Correct virtual vertices length."); 256 261 257 262 var multiPoint = new OpenLayers.Geometry.MultiPoint([point, point2]); 258 263 control.feature = new OpenLayers.Feature.Vector(multiPoint); … … 274 279 t.eq(control.virtualVertices.length, 3, "Correct virtual vertices length (polygon)."); 275 280 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)"); 276 295 } 277 296 … … 290 309 'id': 'fakeFeature' 291 310 }; 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"); 294 322 this.vertices = 'normal'; 295 323 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); 305 326 } 306 327 control.feature = fakeFeature; sandbox/elemoine/regular-polygon/tests/Layer/test_Vector.html
r4356 r5292 131 131 132 132 function test_Layer_Vector_destroyFeatures (t) { 133 t.plan( 3);133 t.plan(5); 134 134 layer = new OpenLayers.Layer.Vector(name); 135 135 var map = new OpenLayers.Map('map'); … … 146 146 t.eq(layer.features.length, 0, "destroyFeatures triggers removal"); 147 147 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"); 148 159 } 149 160
