[OpenLayers-Commits] r11081 -
sandbox/elemoine/draw-feature/tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Feb 10 05:45:49 EST 2011
Author: erilem
Date: 2011-02-10 02:45:49 -0800 (Thu, 10 Feb 2011)
New Revision: 11081
Modified:
sandbox/elemoine/draw-feature/tests/Handler/Path.html
Log:
use logs.shift() in the path handler tests
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-10 10:45:41 UTC (rev 11080)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-10 10:45:49 UTC (rev 11081)
@@ -125,22 +125,22 @@
});
map.addLayer(layer);
var control = new OpenLayers.Control({});
- var log = [];
+ var logs = [], log;
var handler = new OpenLayers.Handler.Path(control, {
create: function() {
- log.push({type: "create", args: arguments});
+ logs.push({type: "create", args: arguments});
},
point: function() {
- log.push({type: "point", args: arguments});
+ logs.push({type: "point", args: arguments});
},
modify: function() {
- log.push({type: "modify", args: arguments});
+ logs.push({type: "modify", args: arguments});
},
done: function() {
- log.push({type: "done", args: arguments});
+ logs.push({type: "done", args: arguments});
},
cancel: function() {
- log.push({type: "cancel", args: arguments});
+ logs.push({type: "cancel", args: arguments});
}
});
control.handler = handler;
@@ -149,93 +149,105 @@
// create line
handler.activate();
- t.eq(log.length, 1, "[activate] called back");
- t.eq(log[0].type, "create", "[activate] create called");
- t.geom_eq(log[0].args[0], new OpenLayers.Geometry.Point(-200, 125),
+ t.eq(logs.length, 1, "[activate] called back");
+ log = logs.shift();
+ t.eq(log.type, "create", "[activate] create called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-200, 125),
"[activate] correct point");
- t.ok(log[0].args[1] == handler.line,
+ t.ok(log.args[1] == handler.line,
"[activate] correct feature");
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- t.eq(log.length, 2, "[mousedown] called back");
- t.eq(log[1].type, "modify", "[mousedown] modify called");
- t.geom_eq(log[1].args[0], new OpenLayers.Geometry.Point(-150, 75),
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
"[mousedown] correct point");
- t.ok(log[1].args[1] == handler.line,
+ t.ok(log.args[1] == handler.line,
"[mousedown] correct feature");
// mouse up
handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
- t.eq(log.length, 4, "[mouseup] called back twice");
- t.eq(log[2].type, "point", "[mouseup] point called");
- t.geom_eq(log[2].args[0], new OpenLayers.Geometry.Point(-150, 75),
+ t.eq(logs.length, 2, "[mouseup] called back twice");
+ log = logs.shift();
+ t.eq(log.type, "point", "[mouseup] point called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
"[mouseup] correct point");
- t.geom_eq(log[2].args[1],
+ t.geom_eq(log.args[1],
new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(-150, 75),
new OpenLayers.Geometry.Point(-150, 75)
]), "[mouseup] correct line");
- t.eq(log[3].type, "modify", "[mouseup] modify called");
- t.geom_eq(log[3].args[0], new OpenLayers.Geometry.Point(-150, 75),
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mouseup] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
"[mouseup] correct point");
- t.ok(log[3].args[1] == handler.line,
+ t.ok(log.args[1] == handler.line,
"[mouseup] correct feature");
// mouse move
handler.mousemove({type: "mousemove",
xy: new OpenLayers.Pixel(1, 1)});
- t.eq(log.length, 5, "[mousemove] called back");
- t.eq(log[4].type, "modify", "[mousemove] modify called");
- t.geom_eq(log[4].args[0], new OpenLayers.Geometry.Point(-149, 74),
+ t.eq(logs.length, 1, "[mousemove] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousemove] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-149, 74),
"[mousemove] correct point");
- t.ok(log[4].args[1] === handler.line,
+ t.ok(log.args[1] === handler.line,
"[mousemove] correct feature");
// mouse move
handler.mousemove({type: "mousemove",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 6, "[mousemove] called back");
- t.eq(log[5].type, "modify", "[mousemove] modify called");
- t.geom_eq(log[5].args[0], new OpenLayers.Geometry.Point(-140, 65),
+ t.eq(logs.length, 1, "[mousemove] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousemove] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-140, 65),
"[mousemove] correct point");
- t.ok(log[5].args[1] === handler.line,
+ t.ok(log.args[1] === handler.line,
"[mousemove] correct feature");
// mouse down ("modify")
handler.mousedown({type: "mousedown",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 7, "[mousedown] called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
// mouse up ("point", "modify")
handler.mouseup({type: "mouseup",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 9, "[mouseup] called back twice");
+ t.eq(logs.length, 2, "[mouseup] called back twice");
+ log = logs.shift();
+ log = logs.shift();
// mouse down ("modify")
handler.mousedown({type: "mousedown",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 9, "[mousedown] not called back");
+ t.eq(logs.length, 0, "[mousedown] not called back");
// mouse up ("point", "modify")
handler.mouseup({type: "mouseup",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 9, "[mouseup] not called back");
+ t.eq(logs.length, 0, "[mouseup] not called back");
// double click
handler.dblclick({type: "dblclick",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.length, 11, "[dblclick] called back twice");
- t.eq(log[9].type, "done", "[dblclick] done called");
- t.geom_eq(log[9].args[0],
+ t.eq(logs.length, 2, "[dblclick] called back twice");
+ log = logs.shift();
+ t.eq(log.type, "done", "[dblclick] done called");
+ t.geom_eq(log.args[0],
new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(-150, 75),
new OpenLayers.Geometry.Point(-140, 65)
]),
"[dblclick] correct linestring"
);
- t.eq(log[10].type, "create", "[dblclick] create called");
- t.geom_eq(log[10].args[0], new OpenLayers.Geometry.Point(-200, 125),
+ log = logs.shift();
+ t.eq(log.type, "create", "[dblclick] create called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-200, 125),
"[dblclick] correct point");
- t.ok(log[10].args[1] == handler.line,
+ t.ok(log.args[1] == handler.line,
"[dblclick] correct feature");
// cancel
handler.cancel();
- t.eq(log.length, 12, "[cancel] called back");
- t.eq(log[11].type, "cancel", "[cancel] canced called");
- t.geom_eq(log[11].args[0],
+ t.eq(logs.length, 1, "[cancel] called back");
+ log = logs.shift();
+ t.eq(log.type, "cancel", "[cancel] canced called");
+ t.geom_eq(log.args[0],
new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(-200, 125)
]),
More information about the Commits
mailing list