[OpenLayers-Commits] r11080 - sandbox/elemoine/draw-feature/tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Feb 10 05:45:41 EST 2011


Author: erilem
Date: 2011-02-10 02:45:41 -0800 (Thu, 10 Feb 2011)
New Revision: 11080

Modified:
   sandbox/elemoine/draw-feature/tests/Handler/Point.html
Log:
use logs.shift() in the point handler tests

Modified: sandbox/elemoine/draw-feature/tests/Handler/Point.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Point.html	2011-02-10 10:45:35 UTC (rev 11079)
+++ sandbox/elemoine/draw-feature/tests/Handler/Point.html	2011-02-10 10:45:41 UTC (rev 11080)
@@ -152,19 +152,19 @@
         });
         map.addLayer(layer);
         var control = new OpenLayers.Control({});
-        var log = [];
+        var logs = [], log;
         var handler = new OpenLayers.Handler.Point(control, {
             create: function() {
-                log.push({type: "create", args: arguments});
+                logs.push({type: "create", 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;
@@ -173,60 +173,67 @@
         
         // create point
         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");
         // 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] modified 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] modified called");
+        t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
                   "[mousedown] correct point");
-        t.geom_eq(log[1].args[1].geometry,
+        t.geom_eq(log.args[1].geometry,
                   new OpenLayers.Geometry.Point(-150, 75),
                   "[mousedown] correct feature");
         // mouse move
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(1, 0)});
-        t.eq(log.length, 3, "[mousemove] called back");
-        t.eq(log[2].type, "modify", "[mousemove] modify called");
-        t.geom_eq(log[2].args[0], new OpenLayers.Geometry.Point(-149, 75),
+        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, 75),
                   "[mousemove] correct point");
-        t.geom_eq(log[2].args[1].geometry,
+        t.geom_eq(log.args[1].geometry,
                   new OpenLayers.Geometry.Point(-149, 75),
                   "[mousemove] correct feature");
         // mouse up (no finalize - we moved)
         handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(1, 0)});
-        t.eq(log.length, 3, "[mouseup] not called back");
+        t.eq(logs.length, 0, "[mouseup] not called back");
         // mouse down
         handler.mousedown(
             {type: "mousedown", xy: new OpenLayers.Pixel(2, 0)});
-        t.eq(log.length, 4, "[mousedown] called back");
-        t.eq(log[3].type, "modify", "[mousedown] modified called");
-        t.geom_eq(log[3].args[0], new OpenLayers.Geometry.Point(-148, 75),
+        t.eq(logs.length, 1, "[mousedown] called back");
+        log = logs.shift();
+        t.eq(log.type, "modify", "[mousedown] modified called");
+        t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-148, 75),
                   "[mousedown] correct point");
-        t.geom_eq(log[3].args[1].geometry,
+        t.geom_eq(log.args[1].geometry,
                   new OpenLayers.Geometry.Point(-148, 75),
                   "[mousedown] correct feature");
         // mouse up
         handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(2, 0)});
-        t.eq(log.length, 6, "[mouseup] called back twice");
-        t.eq(log[4].type, "done", "[mouseup] done called");
-        t.geom_eq(log[4].args[0], new OpenLayers.Geometry.Point(-148, 75),
+        t.eq(logs.length, 2, "[mouseup] called back twice");
+        log = logs.shift();
+        t.eq(log.type, "done", "[mouseup] done called");
+        t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-148, 75),
                   "[mouseup] correct point");
-        t.eq(log[5].type, "create", "[mouseup] create called");
-        t.geom_eq(log[5].args[0], new OpenLayers.Geometry.Point(-200, 125),
+        log = logs.shift();
+        t.eq(log.type, "create", "[mouseup] create called");
+        t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-200, 125),
                   "[activate] correct point");
         // mouse up on same pixel
         handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(2, 0)});
-        t.eq(log.length, 6, "[mouseup] not called back");
+        t.eq(logs.length, 0, "[mouseup] not called back");
         // cancel
         handler.cancel();
-        t.eq(log.length, 7, "[cancel] called back");
-        t.eq(log[6].type, "cancel", "[cancel] canced called");
-        t.geom_eq(log[6].args[0], new OpenLayers.Geometry.Point(-200, 125),
+        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.Point(-200, 125),
                   "[cancel] correct point");
 
         map.destroy();



More information about the Commits mailing list