[OpenLayers-Commits] r11107 -
sandbox/elemoine/draw-feature/tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Feb 11 15:54:03 EST 2011
Author: erilem
Date: 2011-02-11 12:54:03 -0800 (Fri, 11 Feb 2011)
New Revision: 11107
Modified:
sandbox/elemoine/draw-feature/tests/Handler/Path.html
sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
Log:
factor out code in the path handler and polygon handler tests
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-11 20:53:55 UTC (rev 11106)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-11 20:54:03 UTC (rev 11107)
@@ -283,44 +283,30 @@
handler.activate();
+ function draw() {
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
+ handler.dblclick(
+ {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
+ }
+
handler.persist = false;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
+ draw();
t.eq(handler.layer.features.length, 2,
"feature destroyed on dblclick when persist is false");
handler.persist = true;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
+ draw();
var feature = handler.layer.features[0];
t.eq(handler.layer.features.length, 3,
"feature not destroyed on dblclick when persist is true");
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
+ draw();
t.ok(handler.layer.features[0] !== feature,
"persisted feature destroyed on next dblclick");
@@ -343,46 +329,32 @@
map.addControl(control);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+ function draw() {
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ }
+
handler.activate();
handler.persist = false;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ draw();
t.eq(handler.layer.features.length, 2,
"feature destroyed on mouseup when persist is false");
handler.persist = true;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ draw();
var feature = handler.layer.features[0];
t.eq(handler.layer.features.length, 3,
"feature not destroyed on mouseup when persist is true");
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ draw();
t.ok(handler.layer.features[0] !== feature,
"persisted feature destroyed on next mouseup");
Modified: sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-11 20:53:55 UTC (rev 11106)
+++ sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-11 20:54:03 UTC (rev 11107)
@@ -289,64 +289,38 @@
map.addControl(control);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+ function draw() {
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
+ handler.dblclick(
+ {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
+ }
+
handler.activate();
handler.persist = false;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
+ draw();
t.eq(handler.layer.features.length, 2,
"feature destroyed on dblclick when persist is false");
handler.persist = true;
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
+ draw();
var feature = handler.layer.features[0];
t.eq(handler.layer.features.length, 3,
"feature not destroyed on dblclick when persist is true");
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousedown(
- {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
- handler.mouseup(
- {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
- handler.mousemove(
- {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
- handler.dblclick(
- {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
+ draw();
t.ok(handler.layer.features[0] !== feature,
"persisted feature destroyed on next dblclick");
More information about the Commits
mailing list