[OpenLayers-Commits] r11127 -
sandbox/elemoine/draw-feature/tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Feb 16 15:43:09 EST 2011
Author: erilem
Date: 2011-02-16 12:43:09 -0800 (Wed, 16 Feb 2011)
New Revision: 11127
Modified:
sandbox/elemoine/draw-feature/tests/Handler/Path.html
sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
Log:
make the Path and Polygon tests pass again
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-16 20:43:01 UTC (rev 11126)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-16 20:43:09 UTC (rev 11127)
@@ -78,7 +78,7 @@
map.destroy();
}
- function test_Handler_Path_bounds(t) {
+ function test_bounds_stopDown_true(t) {
t.plan(2);
var geometry;
var map = new OpenLayers.Map('map');
@@ -86,27 +86,29 @@
map.zoomToMaxExtent();
var control = new OpenLayers.Control();
map.addControl(control);
- var handler = new OpenLayers.Handler.Path(control, {
- modify: function(g, f) {
- geometry = f.geometry;
- }
- });
+ var handler = new OpenLayers.Handler.Path(control, {},
+ {stopDown: true, stopUp: true});
var activated = handler.activate();
+ // click on (150, 75)
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
- var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
+ // click on (175, 100)
+ evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
- t.ok(geometry.getBounds().equals(
+ t.ok(handler.line.geometry.getBounds().equals(
new OpenLayers.Bounds(0,-35.15625,35.15625,0)),
"Correct bounds");
- var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
+ // mousedown on (175, 100)
+ evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
handler.mousedown(evt);
- var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
+ // mousemove to (125, 100)
+ evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
handler.mousemove(evt);
+ // test that the bounds have changed
t.ok(!handler.line.geometry.getBounds().equals(
new OpenLayers.Bounds(0,-35.15625,35.15625,0)),
"Correct bounds after dragging without letting go. " +
@@ -517,7 +519,6 @@
t.geom_eq(log.geometry,
new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(-150, 75), // (0, 0)
- new OpenLayers.Geometry.Point(-149, 74), // (1, 1)
new OpenLayers.Geometry.Point(-140, 65) // (10, 10)
]), "geometry is correct");
}
Modified: sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-16 20:43:01 UTC (rev 11126)
+++ sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-16 20:43:09 UTC (rev 11127)
@@ -80,29 +80,34 @@
map.destroy();
}
- function test_Handler_Polygon_bounds(t) {
+ function test_bounds_stopDown_true(t) {
t.plan(2);
var map = new OpenLayers.Map('map');
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
map.zoomToMaxExtent();
var control = new OpenLayers.Control();
map.addControl(control);
- var handler = new OpenLayers.Handler.Polygon(control, {});
+ var handler = new OpenLayers.Handler.Polygon(control, {},
+ {stopDown: true, stopUp: true});
var activated = handler.activate();
-
+ // click on (150, 75)
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
- var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
+ // click on (175, 100)
+ evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
t.ok(handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds");
- var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
+ // mousedown on (175, 100)
+ evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
handler.mousedown(evt);
- var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
+ // mousemove to (125, 100)
+ evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
handler.mousemove(evt);
+ // test that the bounds have changed
t.ok(!handler.polygon.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)),
"Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
map.destroy();
@@ -737,7 +742,6 @@
new OpenLayers.Geometry.Polygon([
new OpenLayers.Geometry.LinearRing([
new OpenLayers.Geometry.Point(-150, 75), // (0, 0)
- new OpenLayers.Geometry.Point(-149, 74), // (1, 1)
new OpenLayers.Geometry.Point(-150, 65), // (0, 10)
new OpenLayers.Geometry.Point(-140, 65) // (10, 10)
])
More information about the Commits
mailing list