[OpenLayers-Commits] r11152 -
sandbox/elemoine/draw-feature/tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Sun Feb 20 11:43:45 EST 2011
Author: erilem
Date: 2011-02-20 08:43:45 -0800 (Sun, 20 Feb 2011)
New Revision: 11152
Modified:
sandbox/elemoine/draw-feature/tests/Handler/Path.html
Log:
add some structure in the path handler tests, and add a new failing test
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-20 15:25:24 UTC (rev 11151)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-20 16:43:45 UTC (rev 11152)
@@ -78,7 +78,7 @@
map.destroy();
}
- function test_bounds_stopDown_true(t) {
+ function test_bounds(t) {
t.plan(2);
var geometry;
var map = new OpenLayers.Map('map');
@@ -468,7 +468,51 @@
map.destroy();
}
- function test_stopDown_true(t) {
+ function test_Handler_Path_destroy(t) {
+ t.plan(6);
+ 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.Path(control, {foo: 'bar'});
+
+ handler.activate();
+ var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
+ handler.mousedown(evt);
+
+ t.ok(handler.layer,
+ "handler has a layer prior to destroy");
+ t.ok(handler.point,
+ "handler has a point prior to destroy");
+ t.ok(handler.line,
+ "handler has a line prior to destroy");
+ handler.destroy();
+ t.eq(handler.layer, null,
+ "handler.layer is null after destroy");
+ t.eq(handler.point, null,
+ "handler.point is null after destroy");
+ t.eq(handler.line, null,
+ "handler.line is null after destroy");
+ map.destroy();
+ }
+
+ //
+ // Sequence tests
+ //
+ // Sequence tests basically involve executing a sequence of events
+ // and testing the resulting geometry.
+ //
+ // Below are tests for various drawing sequences. Tests can be
+ // added here each a non-working sequence is found.
+ //
+
+ // stopDown:true, stopUp:true
+ // a) click on (0, 0)
+ // b) mousedown on (0.5, 0.5)
+ // c) mouseup on (1, 1)
+ // d) dblclick on (10, 10)
+ function test_sequence1(t) {
t.plan(1);
var map = new OpenLayers.Map("map", {
resolutions: [1]
@@ -523,7 +567,12 @@
]), "geometry is correct");
}
- function test_stopDown_false(t) {
+ // stopDown:false, stopUp:false
+ // a) click on (0, 0)
+ // b) mousedown on (0.5, 0.5)
+ // c) mouseup on (1, 1)
+ // d) dblclick on (10, 10)
+ function test_sequence2(t) {
t.plan(1);
var map = new OpenLayers.Map("map", {
resolutions: [1]
@@ -578,12 +627,65 @@
]), "geometry is correct");
}
- // test for this sequence
// a) click
// b) dblclick
// c) mousedown holding shift key
// d) mousemove holding shift key
- function test_freehand_sequence1(t) {
+ function test_sequence3(t) {
+ t.plan(1);
+ var map = new OpenLayers.Map("map", {
+ resolutions: [1]
+ });
+ var layer = new OpenLayers.Layer.Vector("foo", {
+ maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
+ isBaseLayer: true
+ });
+ map.addLayer(layer);
+ var control = new OpenLayers.Control({});
+ var handler = new OpenLayers.Handler.Path(control, {});
+ control.handler = handler;
+ map.addControl(control);
+ map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+
+ handler.activate();
+
+ // a) click on (0, 0)
+ 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)});
+ // b) click on (1, 1)
+ 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)});
+ // c) click on (1, 1)
+ 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)});
+ // d) mousemove to (10, 10)
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(10, 10), shiftKey: true});
+ t.geom_eq(handler.line.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 after mousemove");
+ }
+
+ // a) click
+ // b) dblclick
+ // c) mousedown holding shift key
+ // d) mousemove holding shift key
+ function test_sequence4(t) {
t.plan(2);
var map = new OpenLayers.Map("map", {
resolutions: [1]
@@ -639,37 +741,6 @@
]), "geometry is correct after mousemove");
}
- function test_Handler_Path_destroy(t) {
- t.plan(6);
- 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.Path(control, {foo: 'bar'});
-
- handler.activate();
- var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
- handler.mousedown(evt);
-
- t.ok(handler.layer,
- "handler has a layer prior to destroy");
- t.ok(handler.point,
- "handler has a point prior to destroy");
- t.ok(handler.line,
- "handler has a line prior to destroy");
- handler.destroy();
- t.eq(handler.layer, null,
- "handler.layer is null after destroy");
- t.eq(handler.point, null,
- "handler.point is null after destroy");
- t.eq(handler.line, null,
- "handler.line is null after destroy");
- map.destroy();
- }
-
-
-
</script>
</head>
<body>
More information about the Commits
mailing list