summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Control/DrawFeature.html
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/tests/Control/DrawFeature.html')
-rw-r--r--misc/openlayers/tests/Control/DrawFeature.html160
1 files changed, 0 insertions, 160 deletions
diff --git a/misc/openlayers/tests/Control/DrawFeature.html b/misc/openlayers/tests/Control/DrawFeature.html
deleted file mode 100644
index ef0be5a..0000000
--- a/misc/openlayers/tests/Control/DrawFeature.html
+++ /dev/null
@@ -1,160 +0,0 @@
-<html>
-<head>
- <script src="../OLLoader.js"></script>
- <script type="text/javascript">
-
- function test_initialize(t) {
- t.plan(1);
- var control = new OpenLayers.Control.DrawFeature("foo", function() {});
- t.ok(control instanceof OpenLayers.Control.DrawFeature,
- "constructor returns an instance");
- }
-
- function test_multi(t) {
- t.plan(4);
-
- var layer = new OpenLayers.Layer.Vector();
- var control;
-
- // multi false by default
- control = new OpenLayers.Control.DrawFeature(
- layer, OpenLayers.Handler.Polygon
- );
- t.ok(!control.multi, "control.multi false by default");
- t.ok(!control.handler.multi, "handler.multi false by default");
-
- // set on handler
- control = new OpenLayers.Control.DrawFeature(
- layer, OpenLayers.Handler.Polygon, {multi: true}
- );
- t.ok(control.handler.multi, "handler.multi set from control options");
-
- // respect handlerOptions
- control = new OpenLayers.Control.DrawFeature(
- layer, OpenLayers.Handler.Polygon,
- {multi: true, handlerOptions: {multi: false}}
- );
- t.ok(!control.handler.multi, "handlerOptions.multi respected");
-
- }
-
- function test_rendererOptions(t) {
- t.plan(2);
-
- var map = new OpenLayers.Map("map");
- var renderers = ["Canvas", "VML"];
-
- var layer = new OpenLayers.Layer.Vector(null, {
- renderers: renderers,
- rendererOptions: {zIndexing: true},
- isBaseLayer: true
- });
- map.addLayer(layer);
-
- var control = new OpenLayers.Control.DrawFeature(
- layer, OpenLayers.Handler.Polygon, {autoActivate: true}
- );
- map.addControl(control);
-
- var sketchLayer = control.handler.layer;
-
- t.eq(sketchLayer.renderers, renderers, "Preferred renderers");
- t.eq(sketchLayer.rendererOptions.zIndexing, true, "renderer options");
-
- map.destroy();
-
- }
-
- function test_drawFeature(t) {
- t.plan(3);
- var layer = new OpenLayers.Layer.Vector();
- var control = new OpenLayers.Control.DrawFeature(layer, function() {});
- var geom = {};
-
- layer.addFeatures = function(features) {
- t.ok(features[0].geometry == geom, "layer.addFeatures called");
- t.eq(features[0].state, OpenLayers.State.INSERT, "layer state set");
- };
- function handlefeatureadded(event) {
- t.ok(event.feature.geometry == geom, "featureadded triggered");
- }
- control.events.on({"featureadded": handlefeatureadded});
- control.drawFeature(geom);
- control.events.un({"featureadded": handlefeatureadded});
-
- }
-
- function test_sketch_events(t) {
- t.plan(11);
- 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
- });
- var control = new OpenLayers.Control.DrawFeature(
- layer, OpenLayers.Handler.Path, {
- handlerOptions: {persist: true}
- }
- );
- map.addLayer(layer);
- map.addControl(control);
- map.zoomToMaxExtent();
-
- var log;
- layer.events.on({
- sketchstarted: function(event) {
- log['sketchstarted'] = event;
- },
- sketchmodified: function(event) {
- log['sketchmodified'] = event;
- },
- sketchcomplete: function(event) {
- log['sketchcomplete'] = event;
- }
- });
-
- // mock up draw/modify of a point
- log = {};
- control.activate();
- t.eq(log, {}, "[activate] no event triggered");
-
- log = {};
- map.events.triggerEvent("mousemove", {xy: new OpenLayers.Pixel(0, 0)});
- t.eq(log.sketchstarted.type, "sketchstarted", "[mousemove] sketchstarted triggered");
- t.geom_eq(log.sketchstarted.vertex, new OpenLayers.Geometry.Point(-200, 125), "[mousemove] correct vertex");
- t.eq(log.sketchmodified.type, "sketchmodified", "[mousemove] sketchmodified triggered");
- t.geom_eq(log.sketchmodified.vertex, new OpenLayers.Geometry.Point(-200, 125), "[mousemove] correct vertex");
-
- map.events.triggerEvent("mousedown", {xy: new OpenLayers.Pixel(0, 0)});
-
- log = {};
- map.events.triggerEvent("mouseup", {xy: new OpenLayers.Pixel(0, 0)});
- t.eq(log.sketchmodified.type, "sketchmodified", "[mouseup] sketchmodified triggered");
- t.geom_eq(log.sketchmodified.vertex, new OpenLayers.Geometry.Point(-200, 125), "[mouseup] correct vertex");
-
- log = {};
- map.events.triggerEvent("mousemove", {xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.sketchmodified.type, "sketchmodified", "[mousemove] sketchmodified triggered");
- t.geom_eq(log.sketchmodified.vertex, new OpenLayers.Geometry.Point(-190, 115), "[mousemove] correct vertex");
-
- log = {};
- map.events.triggerEvent("dblclick", {xy: new OpenLayers.Pixel(10, 10)});
- t.eq(log.sketchcomplete.type, "sketchcomplete", "[dblclick] sketchcomplete triggered");
- t.geom_eq(log.sketchcomplete.feature.geometry,
- new OpenLayers.Geometry.LineString([
- new OpenLayers.Geometry.Point(-200, 125),
- new OpenLayers.Geometry.Point(-190, 115)
- ]),
- "[dblclick] correct geometry");
-
- map.destroy();
- }
-
- </script>
-</head>
-<body>
- <div id="map" style="width: 400px; height: 250px;"/>
-</body>
-</html>