summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Renderer
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2015-10-17 21:36:38 +0200
committerChris Schlaeger <chris@linux.com>2015-10-17 21:36:38 +0200
commite30f267181d990947e67909de4809fa941698c85 (patch)
tree46e9f94c2b3699ed378963b420b8a8d361286ea1 /misc/openlayers/tests/Renderer
parente763ceb183f389fcd314a4a6a712d87c9d4cdb32 (diff)
downloadpostrunner-e30f267181d990947e67909de4809fa941698c85.zip
Upgrading openlayers to 3.x
Diffstat (limited to 'misc/openlayers/tests/Renderer')
-rw-r--r--misc/openlayers/tests/Renderer/Canvas.html501
-rw-r--r--misc/openlayers/tests/Renderer/Elements.html651
-rw-r--r--misc/openlayers/tests/Renderer/SVG.html441
-rw-r--r--misc/openlayers/tests/Renderer/VML.html454
4 files changed, 0 insertions, 2047 deletions
diff --git a/misc/openlayers/tests/Renderer/Canvas.html b/misc/openlayers/tests/Renderer/Canvas.html
deleted file mode 100644
index f9a4c31..0000000
--- a/misc/openlayers/tests/Renderer/Canvas.html
+++ /dev/null
@@ -1,501 +0,0 @@
-<html>
-<head>
-<script src="../OLLoader.js"></script>
- <script type="text/javascript">
- var supported = OpenLayers.Renderer.Canvas.prototype.supported();
-
- var map, layer;
- function setUp() {
- map = new OpenLayers.Map("map");
- layer = new OpenLayers.Layer.Vector(null, {
- isBaseLayer: true,
- renderers: ["Canvas"]
- });
- map.addLayer(layer);
- map.setCenter(new OpenLayers.LonLat(0, 0));
- }
-
- function tearDown() {
- map.destroy();
- map = null;
- layer = null;
- }
-
- function test_Renderer_Canvas_constructor(t) {
- if (!supported) { t.plan(0); return; }
- t.plan(2);
- var el = document.body;
- el.id = "foo";
- var r = new OpenLayers.Renderer.Canvas(el.id);
-
- t.ok(r instanceof OpenLayers.Renderer.Canvas, "new OpenLayers.Renderer.Canvas returns Renderer.Canvas object" );
- t.ok(r.container == el, "renderer container is correctly set");
- r.destroy();
- }
-
- function test_Renderer_Canvas_setextent(t) {
- if (!supported) { t.plan(0); return; }
- t.plan(2);
-
- setUp();
-
- var r = layer.renderer;
- var extent = new OpenLayers.Bounds(1,2,3,4);
- r.resolution = 1;
- r.setExtent(extent, true);
- t.ok(r.extent.equals(extent), "extent is correctly set");
- t.eq(r.resolution, null, "resolution nullified");
-
- tearDown();
- }
-
- function test_Renderer_Canvas_setsize(t) {
- if (!supported) { t.plan(0); return; }
- t.plan(2);
-
- var el = document.body;
- el.id = "foo";
- var r = new OpenLayers.Renderer.Canvas(el.id);
- var size = new OpenLayers.Size(1,2);
- r.resolution = 1;
- r.setSize(size);
- t.ok(r.size.equals(size), "size is correctly set");
- t.eq(r.resolution, null, "resolution nullified");
- r.destroy();
- }
-
- function test_Renderer_Canvas_getresolution(t) {
- if (!supported) { t.plan(0); return; }
- t.plan(2);
-
- var el = document.body;
- el.id = "foo";
- var r = new OpenLayers.Renderer.Canvas(el.id);
- var map = new OpenLayers.Map("map");
- r.map = map;
- var resolution = r.getResolution();
- t.eq(resolution, map.getResolution(), "resolution matches the map resolution");
- t.eq(r.resolution, resolution, "resolution is correctly set");
- map.destroy();
- }
-
- function test_featureIdToHex(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
- t.plan(2);
- var el = document.body;
- el.id = "foo";
- var renderer = new OpenLayers.Renderer.Canvas(el.id);
-
- var cases = [{
- id: "foo_0", hex: "#000001"
- }, {
- id: "foo_10", hex: "#00000b"
- }, {
- id: "foo_100", hex: "#000065"
- }, {
- id: "foo_1000000", hex: "#0f4241"
- }, {
- id: "foo_16777214", hex: "#ffffff"
- }, {
- id: "foo_16777215", hex: "#000001"
- }];
- t.plan(cases.length);
-
- var c;
- for (var i=0; i<cases.length; ++i) {
- c = cases[i];
- t.eq(renderer.featureIdToHex(c.id), c.hex, c.id);
- }
-
- renderer.destroy();
- }
-
-
- function test_Renderer_Canvas_destroy(t) {
- if (!supported) { t.plan(0); return; }
- t.plan(5);
-
- var el = document.body;
- el.id = "foo";
- var r = new OpenLayers.Renderer.Canvas(el.id);
- r.container = document.createElement("div");
- r.extent = new OpenLayers.Bounds(1,2,3,4);
- r.size = new OpenLayers.Size(1,2);
- r.resolution = 1;
- r.map = {};
-
- r.destroy();
-
- t.eq(r.container, null, "container nullified");
- t.eq(r.extent, null, "extent nullified");
- t.eq(r.size, null, "size nullified");
- t.eq(r.resolution, null, "resolution nullified");
- t.eq(r.map, null, "map nullified");
- }
-
- function test_drawFeature(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
-
- t.plan(10);
-
- setUp();
-
- var renderer = layer.renderer;
- var count = 0;
- var redraw = layer.renderer.redraw;
- renderer.redraw = function() {
- ++count;
- redraw.apply(this, arguments);
- }
- var exp;
-
- // a) draw a point feature
- count = 0;
- exp = renderer.drawFeature(
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 0)), {}
- );
- t.eq(exp, true, "a) drawFeature returns true");
- t.eq(count, 1, "a) redraw called once after drawing a point feature");
- renderer.clear();
-
- // b) draw one feature with no geometry
- count = 0;
- exp = renderer.drawFeature(
- new OpenLayers.Feature.Vector(), {}
- );
- t.eq(exp, undefined, "b) drawFeature returns undefined");
- t.eq(count, 0, "b) redraw is not called when drawing a feature with no geometry");
- renderer.clear();
-
- // c) draw a point feature with display "none"
- count = 0;
- exp = renderer.drawFeature(
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1, 0)),
- {display: "none"}
- );
- t.eq(exp, false, "c) drawFeature returns false");
- t.eq(count, 1, "c) redraw is called when drawing a feature with display 'none'");
- renderer.clear();
-
- // d) draw a point feature outside renderer extent
- count = 0;
- exp = renderer.drawFeature(
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-1000, 0)), {}
- );
- t.eq(exp, false, "d) drawFeature returns false");
- t.eq(count, 1, "d) redraw is called when drawing a feature outside renderer extent");
- renderer.clear();
-
- // e) draw a polygon feature without bounds
- count = 0;
- exp = renderer.drawFeature(
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon()), {}
- );
- t.eq(exp, false, "d) drawFeature returns false");
- t.eq(count, 1, "d) redraw is called when drawing a feature without bounds");
- renderer.clear();
-
- tearDown();
- }
-
-
- function test_pendingRedraw(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
- var layer = new OpenLayers.Layer.Vector(null, {
- isBaseLayer: true,
- renderers: ["Canvas"]
- });
-
- var map = new OpenLayers.Map({
- div: "map",
- controls: [],
- layers: [layer],
- center: new OpenLayers.LonLat(0, 0),
- zoom: 0
- });
-
- var count = 0;
- var redraw = layer.renderer.redraw;
- layer.renderer.redraw = function() {
- ++count;
- redraw.apply(this, arguments);
- }
-
- // add one point feature and confirm redraw is called once
- count = 0;
- layer.addFeatures([
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 0))
- ]);
- t.eq(count, 1, "redraw called once after adding one point feature");
-
- // add one feature with no geometry and confirm redraw is not called
- count = 0;
- layer.addFeatures([
- new OpenLayers.Feature.Vector()
- ]);
- t.eq(count, 0, "redraw is not called when adding a feature with no geometry");
-
- // add one point feature, one feature with no geom, and one point feature and confirm redraw is called once
- count = 0;
- layer.addFeatures([
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1, 0)),
- new OpenLayers.Feature.Vector(),
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1))
- ]);
- t.eq(count, 1, "redraw called once after adding three features where middle one has no geometry");
-
- // add two point features and one feature with no geom, and confirm redraw is called once
- count = 0;
- layer.addFeatures([
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1, 0)),
- new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1)),
- new OpenLayers.Feature.Vector()
- ]);
- t.eq(count, 1, "redraw called once after adding three features where last one has no geometry");
-
- map.destroy();
- }
-
- function test_hitDetection(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
-
- var layer = new OpenLayers.Layer.Vector(null, {
- isBaseLayer: true,
- resolutions: [1],
- styleMap: new OpenLayers.StyleMap({
- pointRadius: 5,
- strokeWidth: 3,
- fillColor: "red",
- fillOpacity: 0.5,
- strokeColor: "blue",
- strokeOpacity: 0.75
- }),
- renderers: ["Canvas"]
- });
-
- var map = new OpenLayers.Map({
- div: "map",
- controls: [],
- layers: [layer],
- center: new OpenLayers.LonLat(0, 0),
- zoom: 0
- });
-
- layer.addFeatures([
- new OpenLayers.Feature.Vector(
- new OpenLayers.Geometry.Point(-100, 0)
- ),
- new OpenLayers.Feature.Vector(
- OpenLayers.Geometry.fromWKT("LINESTRING(-50 0, 50 0)")
- ),
- new OpenLayers.Feature.Vector(
- OpenLayers.Geometry.fromWKT("POLYGON((100 -25, 150 -25, 150 25, 100 25, 100 -25), (120 -5, 130 -5, 130 5, 120 5, 120 -5))")
- ),
- new OpenLayers.Feature.Vector(
- new OpenLayers.Geometry.Point(80, 0), {}, {
- graphicName: "square",
- pointRadius: 8,
- strokeWidth: 4,
- fillColor: "red",
- fillOpacity: 0.5,
- strokeColor: "blue",
- strokeOpacity: 0.75
- }
- )
- ]);
-
- var cases = [{
- msg: "center of point", x: -100, y: 0, id: layer.features[0].id
- }, {
- msg: "edge of point", x: -106, y: 0, id: layer.features[0].id
- }, {
- msg: "outside point", x: -110, y: 0, id: null
- }, {
- msg: "center of line", x: 0, y: 0, id: layer.features[1].id
- }, {
- msg: "edge of line", x: 0, y: 1, id: layer.features[1].id
- }, {
- msg: "outside line", x: 0, y: 5, id: null
- }, {
- msg: "inside polygon", x: 110, y: 0, id: layer.features[2].id
- }, {
- msg: "edge of polygon", x: 99, y: 0, id: layer.features[2].id
- }, {
- msg: "inside polygon hole", x: 125, y: 0, id: null
- }, {
- msg: "outside polygon", x: 155, y: 0, id: null
- }, {
- msg: "inside symbol", x: 80, y: 0, id: layer.features[3].id
- }, {
- msg: "outside symbol interior, inside symbol edge", x: 90, y: 8, id: layer.features[3].id
- }, {
- msg: "outside symbol", x: 94, y: 0, id: null
- }];
-
- function px(x, y) {
- return map.getPixelFromLonLat(
- new OpenLayers.LonLat(x, y)
- );
- }
-
- var num = cases.length;
- t.plan(2 * num);
- var c, feature;
- for (var i=0; i<num; ++i) {
- c = cases[i];
- feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
- t.eq(feature && feature.id, c.id, c.msg);
-
- // Extra test: hit detection on an invisible canvas should return undefined
- layer.setVisibility(false);
- feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
- t.eq(feature, undefined, c.msg + ' (invisible)');
- layer.setVisibility(true);
- }
-
- map.destroy();
-
- }
-
- // see http://trac.osgeo.org/openlayers/ticket/3264
- function test_externalGraphic_destroyFeatures(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- // set up
-
- var layer = new OpenLayers.Layer.Vector(null, {
- isBaseLayer: true,
- renderers: ["Canvas"]
- });
-
- var map = new OpenLayers.Map({
- div: "map",
- controls: [],
- layers: [layer],
- center: new OpenLayers.LonLat(0, 0),
- zoom: 0
- });
-
- layer.addFeatures([
- new OpenLayers.Feature.Vector(
- new OpenLayers.Geometry.Point(0, 0),
- null,
- {
- externalGraphic: '../../img/marker.png',
- graphicHeight: 20,
- graphicWidth: 20
- }
- )
- ]);
-
- var called = false;
- layer.renderer.canvas.drawImage = function(img, x, y, w, h) {
- called = true;
- };
-
- // test
-
- // schedule a canvas.drawImage
- layer.renderer.redraw();
-
- // destroy the feature before drawImage gets called
- layer.destroyFeatures();
-
- t.delay_call(0.1, function() {
- t.ok(!called,
- 'canvas.drawImage not called if feature is destroyed');
-
- // tear down
- map.destroy();
- });
- }
-
- // see http://trac.osgeo.org/openlayers/ticket/3264
- function test_externalGraphic_moveTo(t) {
- if (!supported) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- // set up
-
- var layer = new OpenLayers.Layer.Vector(null, {
- isBaseLayer: true,
- renderers: ["Canvas"]
- });
-
- var map = new OpenLayers.Map({
- div: "map",
- controls: [],
- layers: [layer],
- center: new OpenLayers.LonLat(0, 0),
- zoom: 0
- });
-
- var feature = new OpenLayers.Feature.Vector(
- new OpenLayers.Geometry.Point(0, 0),
- null,
- {
- externalGraphic: '../../img/marker.png',
- graphicHeight: 20,
- graphicWidth: 20,
- graphicXOffset: 0,
- graphicYOffset: 0
- }
- );
-
- layer.addFeatures([feature]);
-
- // test
-
- // delay_call to let the first drawImage (the one
- // resulting from addFeatures) run
- t.delay_call(0.1, function() {
-
- var log = [];
- layer.renderer.canvas.drawImage = function(img, x, y, w, h) {
- log.push({x: x, y: y});
- };
-
- layer.renderer.redraw();
- map.setCenter(new OpenLayers.LonLat(45, 0), 0);
-
- t.delay_call(0.1, function() {
- t.eq(log.length, 2,
- "canvas.drawImage called twice");
- t.ok(log[0].x == log[1].x && log[0].y == log[1].y,
- "image drawn at the same location");
-
- // tear down
- map.destroy();
- });
- });
- }
-
- </script>
-</head>
-<body>
-<div id="map" style="width:500px;height:550px"></div>
-</body>
-</html>
diff --git a/misc/openlayers/tests/Renderer/Elements.html b/misc/openlayers/tests/Renderer/Elements.html
deleted file mode 100644
index 53590e2..0000000
--- a/misc/openlayers/tests/Renderer/Elements.html
+++ /dev/null
@@ -1,651 +0,0 @@
-<html>
-<head>
-<script src="../OLLoader.js"></script>
- <script type="text/javascript">
-
- function setUp() {
- // Stub out functions that are meant to be overridden by
- // subclasses.
- OpenLayers.Renderer.Elements.prototype._createRenderRoot =
- OpenLayers.Renderer.Elements.prototype.createRenderRoot;
-
- var rendererRoot = document.createElement("div");
- OpenLayers.Renderer.Elements.prototype.createRenderRoot = function() {
- return rendererRoot;
- };
-
- OpenLayers.Renderer.Elements.prototype._createRoot =
- OpenLayers.Renderer.Elements.prototype.createRoot;
-
- OpenLayers.Renderer.Elements.prototype.createRoot = function() {
- return document.createElement("div");
- };
-
- OpenLayers.Renderer.Elements.prototype._createNode =
- OpenLayers.Renderer.Elements.prototype.createNode;
-
- OpenLayers.Renderer.Elements.prototype.createNode = function() {
- return document.createElement("div");
- };
- }
-
- // Create a new Elements renderer based on an id and an ordering
- // type. For these tests, both of these parameters are optional.
- function create_renderer(id, options) {
-
- rendererRoot = null;
-
- if (id == null) {
- var el = document.createElement('div');
- document.body.appendChild(el);
- el.id = OpenLayers.Util.createUniqueID();
- id = el.id;
- }
-
- return new OpenLayers.Renderer.Elements(id, options);
- }
-
- // Cleanup stubs made in the function above.
- function tearDown() {
- OpenLayers.Renderer.Elements.prototype.createRenderRoot =
- OpenLayers.Renderer.Elements.prototype._createRenderRoot;
- OpenLayers.Renderer.Elements.prototype.createRoot =
- OpenLayers.Renderer.Elements.prototype._createRoot;
- OpenLayers.Renderer.Elements.prototype.createNode =
- OpenLayers.Renderer.Elements.prototype._createNode;
- }
-
- function test_Elements_constructor(t) {
- t.plan(6);
-
- setUp();
-
- var r = create_renderer();
-
- t.ok(r instanceof OpenLayers.Renderer.Elements, "new OpenLayers.Renderer.Elements returns Elements object" );
- t.ok(r.rendererRoot != null, "elements rendererRoot is not null");
- t.ok(r.root != null, "elements root is not null");
- t.ok(r.indexer == null, "indexer is null if unused.");
-
- t.ok(r.root.parentNode == r.rendererRoot, "elements root is correctly appended to rendererRoot");
- t.ok(r.rendererRoot.parentNode == r.container, "elements rendererRoot is correctly appended to container");
-
- tearDown();
- }
-
- function test_Elements_destroy(t) {
- t.plan(5);
-
- var elems = {
- 'clear': function() {
- t.ok(true, "clear called");
- },
- 'rendererRoot': {},
- 'root': {},
- 'xmlns': {}
- };
-
- OpenLayers.Renderer.prototype._destroy =
- OpenLayers.Renderer.prototype.destroy;
-
- var args = [{}, {}, {}];
- OpenLayers.Renderer.prototype.destroy = function() {
- t.ok((arguments[0] == args[0]) &&
- (arguments[1] == args[1]) &&
- (arguments[2] == args[2]), "correct arguments passed to OpenLayers.Renderer.destroy()");
- };
-
- OpenLayers.Renderer.Elements.prototype.destroy.apply(elems, args);
-
- t.ok(elems.rendererRoot == null, "rendererRoot nullified");
- t.ok(elems.root == null, "root nullified");
- t.ok(elems.xmlns == null, "xmlns nullified");
-
- OpenLayers.Renderer.prototype.destroy =
- OpenLayers.Renderer.prototype._destroy;
-
- }
-
- function test_Elements_clear(t) {
- t.plan(2);
-
- setUp();
-
- var r = create_renderer();
- var element = document.createElement("div");
- r.root = element;
-
- var node = document.createElement("div");
- element.appendChild(node);
-
- r.clear();
-
- t.ok(r.vectorRoot.childNodes.length == 0, "vector root is correctly cleared");
- t.ok(r.textRoot.childNodes.length == 0, "text root is correctly cleared");
-
- tearDown();
- }
-
- function test_Elements_drawGeometry(t) {
- t.plan(7);
-
- setUp();
-
- var r = create_renderer();
-
- var element = document.createElement("div");
- r.vectorRoot = element;
-
- r.nodeFactory = function(id, type) {
- var element = document.createElement("div");
- return element;
- };
- var g_Node = null;
- var b_Node = null;
- r.drawGeometryNode = function(node, geometry, style) {
- g_Node = node;
- return {node: node, complete: true};
- };
- r.redrawBackgroundNode = function(id, geometry, style, featureId) {
- b_Node = r.nodeFactory();
- b_Node.id = "foo_background";
- element.appendChild(b_Node);
- };
-
- r.getNodeType = function(geometry, style) {
- return "div";
- };
- var geometry = {
- id: 'foo',
- CLASS_NAME: 'bar',
- getBounds: function() {return {bottom: 0}}
- };
- var style = {'backgroundGraphic': 'foo'};
- var featureId = 'dude';
- r.drawGeometry(geometry, style, featureId);
- t.ok(g_Node.parentNode == element, "node is correctly appended to root");
- t.ok(b_Node.parentNode == element, "redrawBackgroundNode appended background node");
- t.eq(g_Node._featureId, 'dude', "_featureId is correct");
- t.eq(g_Node._style.backgroundGraphic, "foo", "_style is correct");
- t.eq(g_Node._geometryClass, 'bar', "_geometryClass is correct");
-
- var returnNode = function(id) {
- return id == "foo_background" ? b_Node : g_Node;
- }
-
- var _getElement = document.getElementById;
- document.getElementById = returnNode;
- OpenLayers.Util.getElement = returnNode;
-
- style = {'display':'none'};
- r.drawGeometry(geometry, style, featureId);
- t.ok(g_Node.parentNode != element, "node is correctly removed");
- t.ok(b_Node.parentNode != element, "background node correctly removed")
-
- document.getElementById = _getElement;
-
- tearDown();
- }
-
- function test_Elements_drawGeometry_2(t) {
- t.plan(8);
-
- setUp();
-
- var geometry = {
- getBounds: function() {return {bottom: 0}}
- }
-
- var r = create_renderer();
-
- var element = document.createElement("div");
- r.root = element;
-
- r.nodeFactory = function(id, type) {
- var element = document.createElement("div");
- return element;
- };
- r.setStyle = function(node, style, options, geometry) {
- return node;
- };
-
- // point
- var properDraw = false;
- r.drawPoint = function(node, geometry) {
- properDraw = true;
- return {};
- };
- var point = OpenLayers.Util.applyDefaults({CLASS_NAME: 'OpenLayers.Geometry.Point'}, geometry);
- style = true;
- r.drawGeometry(point, style);
- t.ok(properDraw, "drawGeometry called drawPoint when passed a point");
-
- // line string
- var properDraw = false;
- r.drawLineString = function(g) {
- properDraw = true;
- return {};
- };
- var linestring = OpenLayers.Util.applyDefaults({id: "foo", CLASS_NAME: 'OpenLayers.Geometry.LineString'}, geometry);
- style = true;
- r.drawGeometry(linestring, style);
- t.ok(properDraw, "drawGeometry called drawLineString when passed a line string");
-
- // linear ring
- var properDraw = false;
- r.drawLinearRing = function(g) {
- properDraw = true;
- return {};
- };
- var linearring = OpenLayers.Util.applyDefaults({CLASS_NAME: 'OpenLayers.Geometry.LinearRing'}, geometry);
- style = true;
- r.drawGeometry(linearring, style);
- t.ok(properDraw, "drawGeometry called drawLinearRing when passed a linear ring");
-
- // polygon
- var properDraw = false;
- r.drawPolygon = function(g) {
- properDraw = true;
- return {};
- };
- var polygon = OpenLayers.Util.applyDefaults({CLASS_NAME: 'OpenLayers.Geometry.Polygon'}, geometry);
- style = true;
- r.drawGeometry(polygon, style);
- t.ok(properDraw, "drawGeometry called drawPolygon when passed a polygon");
-
- // rectangle
- var properDraw = false;
- r.drawRectangle = function(g) {
- properDraw = true;
- return {};
- };
- var rectangle = OpenLayers.Util.applyDefaults({CLASS_NAME: 'OpenLayers.Geometry.Rectangle'}, geometry);
- style = true;
- r.drawGeometry(rectangle, style);
- t.ok(properDraw, "drawGeometry called drawRectangle when passed a rectangle");
-
- // multi-point
- var properDraw = false;
- r.drawPoint = function(g) {
- properDraw = true;
- return {};
- };
- var multipoint = OpenLayers.Util.applyDefaults({
- CLASS_NAME: 'OpenLayers.Geometry.MultiPoint',
- components: [point]
- }, geometry);
- style = true;
- r.drawGeometry(multipoint, style);
- t.ok(properDraw, "drawGeometry called drawPoint when passed a multi-point");
-
- // multi-linestring
- var properDraw = false;
- r.drawLineString = function(g) {
- properDraw = true;
- return {};
- };
- var multilinestring = OpenLayers.Util.applyDefaults({
- CLASS_NAME: 'OpenLayers.Geometry.MultiLineString',
- components: [linestring]
- }, geometry);
- style = true;
- r.drawGeometry(multilinestring, style);
- t.ok(properDraw, "drawGeometry called drawLineString when passed a multi-linestring");
-
- // multi-polygon
- var properDraw = false;
- r.drawPolygon = function(g) {
- properDraw = true;
- return {};
- };
- var multipolygon = OpenLayers.Util.applyDefaults({
- CLASS_NAME: 'OpenLayers.Geometry.MultiPolygon',
- components: [polygon]
- }, geometry);
- style = true;
- r.drawGeometry(multipolygon, style);
- t.ok(properDraw, "drawGeometry called drawPolygon when passed a multi-polygon");
-
- tearDown();
- }
-
- function test_Elements_getfeatureidfromevent(t) {
- t.plan(2);
-
- var node = {
- _featureId: 'foo'
- };
- var event = {
- target: node
- };
-
- var id = OpenLayers.Renderer.Elements.prototype.getFeatureIdFromEvent(event);
- t.eq(id, 'foo', "returned id is correct when event with target is passed");
-
- var event = {
- srcElement: node
- };
-
- var id = OpenLayers.Renderer.Elements.prototype.getFeatureIdFromEvent(event);
- t.eq(id, 'foo', "returned id is correct when event with srcElement is passed");
- }
-
- function test_Elements_erasegeometry(t) {
- t.plan(15);
-
- var elements = {
- 'eraseGeometry': function(geometry) {
- gErased.push(geometry);
- }
- };
-
- var geometry = {
- 'components': [{}, {}, {}]
- };
-
- //multipoint
- geometry.CLASS_NAME = "OpenLayers.Geometry.MultiPoint";
- gErased = [];
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gErased[0] == geometry.components[0]) &&
- (gErased[1] == geometry.components[1]) &&
- (gErased[2] == geometry.components[2]), "multipoint all components of geometry correctly erased.");
-
- //multilinestring
- geometry.CLASS_NAME = "OpenLayers.Geometry.MultiLineString";
- gErased = [];
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gErased[0] == geometry.components[0]) &&
- (gErased[1] == geometry.components[1]) &&
- (gErased[2] == geometry.components[2]), "multilinestring all components of geometry correctly erased.");
-
- //multipolygon
- geometry.CLASS_NAME = "OpenLayers.Geometry.MultiPolygon";
- gErased = [];
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gErased[0] == geometry.components[0]) &&
- (gErased[1] == geometry.components[1]) &&
- (gErased[2] == geometry.components[2]), "multipolygon all components of geometry correctly erased.");
-
- //collection
- geometry.CLASS_NAME = "OpenLayers.Geometry.Collection";
- gErased = [];
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gErased[0] == geometry.components[0]) &&
- (gErased[1] == geometry.components[1]) &&
- (gErased[2] == geometry.components[2]), "collection all components of geometry correctly erased.");
-
-
- // OTHERS
- //
- geometry.CLASS_NAME = {};
-
- gElement = null;
- gBackElement = null;
-
- OpenLayers.Util._getElement = OpenLayers.Util.getElement;
- OpenLayers.Util.getElement = function(id) {
- var retVal = null;
- if (id != null) {
- var hasBack = (id.indexOf(elements.BACKGROUND_ID_SUFFIX) != -1);
- retVal = hasBack ? gBackElement : gElement;
- }
- return retVal;
- };
-
- //element null
- geometry.id = null;
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- // (no tests here, just make sure it doesn't bomb)
-
- //element.parentNode null
- elements.BACKGROUND_ID_SUFFIX = 'BLAHBLAHBLAH';
- geometry.id = "foo";
- gElement = {};
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- // (no tests here, just make sure it doesn't bomb)
-
- //valid element.parentNode, element.geometry
- elements.indexer = {
- 'remove': function(elem) {
- gIndexerRemoved = elem;
- }
- };
-
- gElement = {
- 'geometry': {
- 'destroy': function() {
- t.ok(true, "geometry destroyed");
- }
- },
- 'parentNode': {
- 'removeChild': function(elem) {
- gElemRemoved = elem;
- }
- },
- '_style' : {backgroundGraphic: "foo"}
- };
- gBackElement = {
- 'parentNode': {
- 'removeChild': function(elem) {
- gBackRemoved = elem;
- }
- }
- };
-
- gElemRemoved = gBackRemoved = gIndexerRemoved = null;
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gElement.geometry == null), "all normal: element's 'geometry' property nullified");
- t.ok( (gElemRemoved == gElement), "all normal: main element properly removed from parent node");
- t.ok( (gBackRemoved == gBackElement), "all normal: back element properly removed from parent node");
- t.ok( (gIndexerRemoved == gElement), "all normal: main element properly removed from the indexer");
-
- //valid element.parentNode, no element.geometry, no bElem
- gBackElement = null;
- gElement.geometry = null;
- gElemRemoved = gBackRemoved = gIndexerRemoved = null;
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gElemRemoved == gElement), "no bElem: main element properly removed from parent node");
- t.ok( (gBackRemoved == null), "no bElem: back element not tried to remove from parent node when it doesn't exist");
- t.ok( (gIndexerRemoved == gElement), "no bElem: main element properly removed from the indexer");
-
- //valid element.parentNode, no element.geometry, valid bElem, no bElem.parentNode
- gBackElement = {};
- gElemRemoved = gBackRemoved = gIndexerRemoved = null;
- OpenLayers.Renderer.Elements.prototype.eraseGeometry.apply(elements, [geometry]);
- t.ok( (gElemRemoved == gElement), "no bElem.parentNode: main element properly removed from parent node");
- t.ok( (gBackRemoved == null), "no bElem.parentNode: back element not tried to remove from parent node when it has no parent node");
- t.ok( (gIndexerRemoved == gElement), "no bElem.parentNode: main element properly removed from the indexer");
-
-
- OpenLayers.Util.getElement = OpenLayers.Util._getElement;
- }
-
- function test_Elements_drawAndErase(t) {
- t.plan(20);
-
- setUp();
-
- var r = create_renderer(null, {zIndexing: true});
- var element = document.createElement("div");
- r.vectorRoot = element;
- document.body.appendChild(element);
-
- r.createNode = function(type, id) {
- var element = document.createElement("div");
- element.id = id;
- return element;
- };
- r.nodeTypeCompare = function() {return true};
- r.setStyle = function(node, style, options, geometry) {
- return node;
- };
-
- var geometry = {
- id: 'foo',
- CLASS_NAME: 'bar',
- getBounds: function() {return {bottom: 0}}
- };
- var style = {
- graphicZIndex: 10
- };
- var featureId = 'foo';
- r.drawGeometry(geometry, style, featureId);
-
- function count(obj) {
- var result = 0;
- for (var i in obj) {
- result++;
- }
- return result;
- }
-
- t.eq(element.childNodes.length, 1, "root is correctly filled");
- t.eq(r.indexer.maxZIndex, 10, "indexer.maxZIndex is correctly filled");
- t.eq(r.indexer.order.length, 1, "indexer.order is correctly filled");
- t.eq(count(r.indexer.indices), 1, "indexer.indices is correctly filled");
-
- r.eraseGeometry(geometry);
-
- t.eq(element.childNodes.length, 0, "root is correctly cleared");
- t.eq(r.indexer.maxZIndex, 0, "indexer.maxZIndex is correctly reset");
- t.eq(r.indexer.order.length, 0, "indexer.order is correctly reset");
- t.eq(count(r.indexer.indices), 0, "indexer.indices is correctly reset");
-
- delete(style.graphicZIndex);
- r.drawGeometry(geometry, style, featureId);
-
- t.eq(element.childNodes.length, 1, "root is correctly filled");
- t.eq(r.indexer.maxZIndex, 0, "indexer.maxZIndex is correctly filled");
- t.eq(r.indexer.order.length, 1, "indexer.order is correctly filled");
- t.eq(count(r.indexer.indices), 1, "indexer.indices is correctly filled");
-
- r.clear();
-
- t.eq(element.childNodes.length, 0, "root is correctly cleared");
- t.eq(r.indexer.maxZIndex, 0, "indexer.maxZIndex is correctly reset");
- t.eq(r.indexer.order.length, 0, "indexer.order is correctly reset");
- t.eq(count(r.indexer.indices), 0, "indexer.indices is correctly reset");
-
- style.graphicZIndex = 12;
- r.drawGeometry(geometry, style, featureId);
-
- t.eq(element.childNodes.length, 1, "root is correctly filled");
- t.eq(r.indexer.maxZIndex, 12, "indexer.maxZIndex is correctly filled");
- t.eq(r.indexer.order.length, 1, "indexer.order is correctly filled");
- t.eq(count(r.indexer.indices), 1, "indexer.indices is correctly filled");
-
- tearDown();
- }
-
- function test_Elements_moveRoot(t) {
- t.plan(2);
- setUp();
- var r1 = create_renderer();
- var r2 = create_renderer();
- r1.moveRoot(r2);
- t.xml_eq(r1.root.parentNode, r2.root.parentNode, "root moved successfully");
- r1.moveRoot(r1);
- t.xml_eq(r1.root.parentNode, r1.rendererRoot, "root moved back successfully");
- tearDown();
- }
-
- function test_Elements_drawGeometry_3(t) {
- t.plan(2);
-
- setUp();
-
- var r = create_renderer();
-
- var element = document.createElement("div");
- r.vectorRoot = element;
-
- r.nodeFactory = function(id, type) {
- return document.createElement("div");
- };
- var g_Node = null;
- var b_Node = null;
- r.drawGeometryNode = function(node, geometry, style) {
- g_Node = node;
- return {node: node, complete: true};
- };
- r.redrawBackgroundNode = function(id, geometry, style, featureId) {
- b_Node = r.nodeFactory();
- b_Node.id = "foo_background";
- element.appendChild(b_Node);
- };
-
- r.getNodeType = function(geometry, style) {
- return "div";
- };
- var geometry = {
- id: 'foo',
- CLASS_NAME: 'bar',
- getBounds: function() {return {bottom: 0}}
- };
- var style = {'backgroundGraphic': 'foo'};
- var featureId = 'dude';
- r.drawGeometry(geometry, style, featureId);
- t.ok(b_Node.parentNode == element, "redrawBackgroundNode appended background node");
-
- var returnNode = function(id) {
- return id == "foo_background" ? b_Node : g_Node;
- }
-
- var _getElement = document.getElementById;
- document.getElementById = returnNode;
- OpenLayers.Util.getElement = returnNode;
-
- style = {};
- r.drawGeometry(geometry, style, featureId);
- t.ok(b_Node.parentNode != element, "background node correctly removed")
-
- document.getElementById = _getElement;
-
- tearDown();
- }
-
- function test_setExtent(t) {
- t.plan(10);
- setUp();
- var resolution = 1;
- var r = create_renderer();
- r.map = {
- getMaxExtent: function() {
- return new OpenLayers.Bounds(-180,-90,180,90);
- },
- getExtent: function() {
- return r.extent;
- },
- getResolution: function() {
- return resolution;
- },
- baseLayer: {wrapDateLine: true}
- }
-
- r.setExtent(new OpenLayers.Bounds(179, -1, 182, 1), true);
- t.eq(r.rightOfDateLine, true, "on the right side of the dateline");
- t.eq(r.xOffset, r.map.getMaxExtent().getWidth(), "correct xOffset");
- r.setExtent(new OpenLayers.Bounds(179.5, -1, 182.5, 1), false);
- t.eq(r.rightOfDateLine, true, "still on the right side of the dateline");
- t.eq(r.xOffset, r.map.getMaxExtent().getWidth(), "still correct xOffset");
- resolution = 2;
- r.setExtent(new OpenLayers.Bounds(178, -2, 184, 2), true);
- t.eq(r.rightOfDateLine, true, "still on the right side of the dateline");
- t.eq(r.xOffset, r.map.getMaxExtent().getWidth() / resolution, "xOffset adjusted for new resolution");
- r.setExtent(new OpenLayers.Bounds(-184, -2, 178, 2), false);
- t.eq(r.rightOfDateLine, false, "on the left side of the dateline");
- t.eq(r.xOffset, 0, "no xOffset");
- r.setExtent(new OpenLayers.Bounds(178, -2, 184, 2), true);
- t.eq(r.rightOfDateLine, true, "back on the right side of the dateline");
- t.eq(r.xOffset, r.map.getMaxExtent().getWidth() / resolution, "correct xOffset");
-
- tearDown();
- }
-
- </script>
-</head>
-<body>
-<div id="map" style="width:500px;height:550px"></div>
-</body>
-</html>
diff --git a/misc/openlayers/tests/Renderer/SVG.html b/misc/openlayers/tests/Renderer/SVG.html
deleted file mode 100644
index 31eb058..0000000
--- a/misc/openlayers/tests/Renderer/SVG.html
+++ /dev/null
@@ -1,441 +0,0 @@
-<html>
-<head>
-<script src="../OLLoader.js"></script>
- <script type="text/javascript">
-
- var geometry = null, node = null;
-
- function test_SVG_constructor(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
- var r = new OpenLayers.Renderer.SVG(document.body);
- t.ok(r instanceof OpenLayers.Renderer.SVG, "new OpenLayers.Renderer.SVG returns SVG object" );
- }
-
- function test_SVG_destroy(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var g_Destroy = false;
-
- OpenLayers.Renderer.Elements.prototype._destroy =
- OpenLayers.Renderer.Elements.prototype.destroy;
-
- OpenLayers.Renderer.prototype.destroy = function() {
- g_Destroy = true;
- }
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.destroy();
-
- t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called");
-
- OpenLayers.Renderer.prototype.destroy =
- OpenLayers.Renderer.prototype._destroy;
- }
-
- function test_SVG_setextent(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(5);
-
- OpenLayers.Renderer.Elements.prototype._setExtent =
- OpenLayers.Renderer.Elements.prototype.setExtent;
-
- var g_SetExtent = false;
- OpenLayers.Renderer.Elements.prototype.setExtent = function() {
- g_SetExtent = true;
- }
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.setSize(new OpenLayers.Size(4,4));
- r.map = {
- getResolution: function() {
- return 0.5;
- }
- }
-
- var extent = new OpenLayers.Bounds(1,2,3,4);
- r.setExtent(extent);
-
- t.eq(g_SetExtent, true, "Elements.setExtent() called");
-
- t.eq(r.left, -2, "left is correct");
- t.eq(r.top, 8, "top is correct");
-
- t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "0 0 4 4", "rendererRoot viewBox is correct");
-
- // test extent changes
- var extent = new OpenLayers.Bounds(4,3,2,1);
- r.setExtent(extent);
- var el = r.createNode("g");
- el.setAttributeNS(null, "transform", "translate(-6,-6)");
- t.eq(r.root.getAttributeNS(null, "transform"), el.getAttributeNS(null, "transform"), "rendererRoot viewBox is correct after a new setExtent");
-
- OpenLayers.Renderer.Elements.prototype.setExtent =
- OpenLayers.Renderer.Elements.prototype._setExtent;
- }
-
- function test_SVG_setsize(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- var size = new OpenLayers.Size(1,2);
- r.setSize(size);
- t.eq(r.rendererRoot.getAttributeNS(null, "width"), size.w.toString(), "width is correct");
- t.eq(r.rendererRoot.getAttributeNS(null, "height"), size.h.toString(), "height is correct");
- }
-
- function test_SVG_drawpoint(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- var properDraw = false;
- var g_Radius = null;
- r.drawCircle = function(n, g, r) {
- properDraw = true;
- g_Radius = 1;
- }
- r.drawPoint();
-
- t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1");
- }
-
- function test_SVG_drawcircle(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(5);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.resolution = 0.5;
- r.left = 0;
- r.top = 0;
-
- var node = document.createElement('div');
-
- var geometry = {
- x: 1,
- y: 2
- }
-
- r.drawCircle(node, geometry, 3);
-
- t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct");
- t.eq(node.getAttributeNS(null, 'cy'), '-4', "cy is correct");
- t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct");
-
- // #1274: out of bound node fails when first added
- var geometry = {
- x: 10000000,
- y: 200000000,
- CLASS_NAME: "OpenLayers.Geometry.Point",
- id: "foo",
- getBounds: function() {return {bottom: 0}}
- }
- node.id = geometry.id;
- r.root.appendChild(node);
-
- var drawCircleCalled = false;
- r.drawCircle = function() {
- drawCircleCalled = true;
- return OpenLayers.Renderer.SVG.prototype.drawCircle.apply(r, arguments);
- }
-
- r.drawGeometry(geometry, {pointRadius: 3}, "blah_4000");
- t.eq(drawCircleCalled, true, "drawCircle called on drawGeometry for a point geometry.")
- t.ok(node.parentNode != r.root, "circle will not be drawn when coordinates are outside the valid range");
- }
-
- function test_SVG_drawlinestring(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- var node = document.createElement('div');
-
- var geometry = {
- components: "foo"
- }
- g_GetString = false;
- g_Components = null;
- r.getComponentsString = function(c) {
- g_GetString = true;
- g_Components = c;
- return {path: "bar", complete: true};
- }
-
- r.drawLineString(node, geometry);
-
- t.ok(g_GetString && g_Components == "foo", "getComponentString is called with valid arguments");
- t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct");
- }
-
- function test_SVG_drawlinearring(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- var node = document.createElement('div');
-
- var geometry = {
- components: "foo"
- }
- g_GetString = false;
- g_Components = null;
- r.getComponentsString = function(c) {
- g_GetString = true;
- g_Components = c;
- return {path: "bar", complete: true};
- }
-
- r.drawLinearRing(node, geometry);
-
- t.ok(g_GetString, "getComponentString is called with valid arguments");
- t.eq(node.getAttributeNS(null, "points"), "bar", "points attribute is correct");
- }
-
- function test_SVG_drawpolygon(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- var node = document.createElement('div');
-
- var linearRings = [{
- components: ["foo"]
- },{
- components: ["bar"]
- }]
-
- var geometry = {
- components: linearRings
- }
- g_GetString = false;
- r.getShortString = function(c) {
- g_GetString = true;
- return c;
- }
-
- r.drawPolygon(node, geometry);
-
- t.ok(g_GetString, "getShortString is called");
- t.eq(node.getAttributeNS(null, "d"), " M foo M bar z", "d attribute is correctly set");
- t.eq(node.getAttributeNS(null, "fill-rule"), "evenodd", "fill-rule attribute is correctly set");
-
- r.getShortString = function(c) {
- return false;
- }
- t.eq(r.drawPolygon(node, geometry), false, "drawPolygon returns false if one linearRing cannot be drawn");
- }
-
- function test_SVG_drawrectangle(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.resolution = 0.5;
- r.left = 0;
- r.top = 0;
-
- var node = document.createElement('div');
-
- var geometry = {
- x: 1,
- y: 2,
- width: 3,
- height: 4
- }
-
- r.drawRectangle(node, geometry);
-
- t.eq(node.getAttributeNS(null, "x"), "2", "x attribute is correctly set");
- t.eq(node.getAttributeNS(null, "y"), "-4", "y attribute is correctly set");
- t.eq(node.getAttributeNS(null, "width"), "6", "width attribute is correctly set");
- t.eq(node.getAttributeNS(null, "height"), "8", "height attribute is correctly set");
- }
-
- function test_SVG_getcomponentsstring(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var components = ['foo', 'bar'];
-
- OpenLayers.Renderer.SVG.prototype._getShortString =
- OpenLayers.Renderer.SVG.prototype.getShortString;
-
- OpenLayers.Renderer.SVG.prototype.getShortString = function(p) {
- return p;
- };
-
- var string = OpenLayers.Renderer.SVG.prototype.getComponentsString(components).path;
- t.eq(string, "foo,bar", "returned string is correct");
-
- OpenLayers.Renderer.SVG.prototype.getShortString =
- OpenLayers.Renderer.SVG.prototype._getShortString;
- }
-
-
-
- function test_SVG_getshortstring(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.resolution = 0.5;
- r.left = 0;
- r.top = 0;
-
- var point = {
- x: 1,
- y: 2
- };
-
- var string = r.getShortString(point);
- t.eq(string, "2,-4", "returned string is correct");
- }
-
- function test_svg_importsymbol(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- r.importSymbol("square");
-
- var polygon = document.getElementById(r.container.id + "_defs").firstChild.firstChild;
-
- var pass = false;
- for (var i = 0; i < polygon.points.numberOfItems; i++) {
- var p = polygon.points.getItem(i);
- pass = p.x === OpenLayers.Renderer.symbol.square[2*i] &&
- p.y === OpenLayers.Renderer.symbol.square[2*i+1];
- if (!pass) {
- break;
- }
- }
- t.ok(pass, "Square symbol rendered correctly");
- t.ok(r.symbolMetrics["-square"], "Symbol metrics cached correctly.");
- }
-
- function test_svg_dashstyle(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(5);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
-
- t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dot"}, 1), "1,4", "dot dasharray created correctly");
- t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dash"}, 1), "4,4", "dash dasharray created correctly");
- t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "longdash"}, 1), "8,4", "longdash dasharray created correctly");
- t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dashdot"}, 1), "4,4,1,4", "dashdot dasharray created correctly");
- t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "longdashdot"}, 1), "8,4,1,4", "dashdot dasharray created correctly");
- }
-
- function test_svg_clipline(t) {
- if (!OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(3);
-
- var r = new OpenLayers.Renderer.SVG(document.body);
- r.setSize(new OpenLayers.Size(0, 0));
- r.map = {
- getResolution: function() {
- return 0.5;
- }
- }
- r.setExtent(new OpenLayers.Bounds(0, 0, 0, 0));
-
- var node = document.createElement('div');
-
- var geometry = new OpenLayers.Geometry.LineString([
- new OpenLayers.Geometry.Point(0, -5000),
- new OpenLayers.Geometry.Point(10000, 0),
- new OpenLayers.Geometry.Point(0, 5000)
- ]);
- r.drawLineString(node, geometry);
- t.eq(node.getAttribute("points"), "0,10000,15000,2500,15000,-2500,0,-10000", "Line with 3 points correctly clipped at inValidRange bounds");
-
- geometry = new OpenLayers.Geometry.LineString([
- new OpenLayers.Geometry.Point(0, -5000),
- new OpenLayers.Geometry.Point(10000, 0)
- ]);
- r.drawLineString(node, geometry);
- t.eq(node.getAttribute("points"), "0,10000,15000,2500", "2-point line with 2nd point outside range correctly clipped at inValidRange bounds");
-
- var geometry = new OpenLayers.Geometry.LineString([
- new OpenLayers.Geometry.Point(10000, 0),
- new OpenLayers.Geometry.Point(0, 5000)
- ]);
- r.drawLineString(node, geometry);
- t.eq(node.getAttribute("points"), "15000,-2500,0,-10000", "2-point line with 1st point outside range correctly clipped at inValidRange bounds");
- }
-
- </script>
-</head>
-<body>
-<div id="map" style="width:500px;height:550px"></div>
-</body>
-</html>
diff --git a/misc/openlayers/tests/Renderer/VML.html b/misc/openlayers/tests/Renderer/VML.html
deleted file mode 100644
index 2bdc876..0000000
--- a/misc/openlayers/tests/Renderer/VML.html
+++ /dev/null
@@ -1,454 +0,0 @@
-<html>
-<head>
-<script src="../OLLoader.js"></script>
- <script type="text/javascript">
-
- var geometry = null, node = null;
-
- function test_VML_constructor(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
- var r = new OpenLayers.Renderer.VML(document.body);
- t.ok(r instanceof OpenLayers.Renderer.VML, "new OpenLayers.Renderer.VML returns VML object" );
- }
-
- function test_VML_destroy(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var g_Destroy = false;
-
- OpenLayers.Renderer.Elements.prototype._destroy =
- OpenLayers.Renderer.Elements.prototype.destroy;
-
- OpenLayers.Renderer.prototype.destroy = function() {
- g_Destroy = true;
- }
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.destroy();
-
- t.eq(g_Destroy, true, "OpenLayers.Renderer.Elements.destroy() called");
-
- OpenLayers.Renderer.prototype.destroy =
- OpenLayers.Renderer.prototype._destroy;
- }
-
- function test_VML_setextent(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- OpenLayers.Renderer.Elements.prototype._setExtent =
- OpenLayers.Renderer.Elements.prototype.setExtent;
-
- var g_SetExtent = false;
- OpenLayers.Renderer.Elements.prototype.setExtent = function() {
- g_SetExtent = true;
- }
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.setSize(new OpenLayers.Size(4,4));
- r.map = {
- getResolution: function() {
- return 0.5;
- }
- }
-
- var extent = new OpenLayers.Bounds(1,2,3,4);
- r.setExtent(extent);
-
- t.eq(g_SetExtent, true, "Elements.setExtent() called");
-
- t.ok(r.root.coordorigin == "0,0", "coordorigin is correct");
- t.ok(r.root.coordsize == "4,4", "coordsize is correct");
- t.eq(r.offset, {x:2, y:4}, "offset is correct");
-
- OpenLayers.Renderer.Elements.prototype.setExtent =
- OpenLayers.Renderer.Elements.prototype._setExtent;
- }
-
- function test_VML_setsize(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- var size = new OpenLayers.Size(1,2);
- r.setSize(size);
- t.eq(r.rendererRoot.style.width, "1px", "rendererRoot width is correct");
- t.eq(r.rendererRoot.style.height, "2px", "rendererRoot height is correct");
-
- t.eq(r.root.style.width, "1px", "root width is correct");
- t.eq(r.root.style.height, "2px", "root height is correct");
- }
-
- function test_VML_drawText(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(2);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
-
- r.LABEL_ID_SUFFIX = "";
- r.getResolution = function() {
- return 1;
- };
-
- var style = {
- label: "myText",
- fontColor: "blue"
- }
-
- r.drawText("feature1", style, new OpenLayers.Geometry.Point(1,1));
-
- var textbox = document.getElementById("feature1_textbox");
-
- t.eq(textbox.innerText, style.label, "label set correctly");
- t.eq(textbox.style.color, style.fontColor, "font color of label set correctly");
- }
-
- function test_VML_drawpoint(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- var properDraw = false;
- var g_Radius = null;
- r.drawCircle = function(n, g, r) {
- properDraw = true;
- g_Radius = 1;
- }
- r.drawPoint();
-
- t.ok(properDraw && g_Radius == 1, "drawPoint called drawCircle with radius set to 1");
- }
-
- function test_VML_drawcircle(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
- r.resolution = 0.5;
-
- var node = document.createElement('div');
-
- var geometry = {
- x: 1,
- y: 2
- }
-
- var radius = 3;
- r.drawCircle(node, geometry, radius);
-
- t.eq(node.style.left, '-1px', "left is correct");
- t.eq(node.style.top, '1px', "top is correct");
- t.eq(node.style.width, (2 * radius) + "px", "width is correct");
- t.eq(node.style.height, (2 * radius) + "px", "height is correct");
- }
-
- function test_VML_drawGraphic(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(6);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
- r.resolution = 1;
-
- var node = document.createElement('div');
- node.id = "test"
- node._geometryClass = "OpenLayers.Geometry.Point";
-
- var geometry = {
- x: 1,
- y: 2
- }
-
- var style = {
- externalGraphic: "foo.png",
- graphicWidth: 7,
- graphicHeight: 10
- }
-
- r.drawGeometryNode(node, geometry, style);
-
- t.eq(node.childNodes[0].id, "test_fill", "fill child node correctly created");
- t.eq(node.style.left, "-2px", "x of insertion point with calculated xOffset correct");
- t.eq(node.style.top, "-3px", "y of insertion point with calculated yOffset correct");
-
- style.rotation = 90;
-
- r.drawGeometryNode(node, geometry, style);
-
- t.eq(node.childNodes[1].id, "test_image", "image child node correctly created");
- t.eq(node.style.left, "-3px", "x of insertion point of rotated image correct");
- t.eq(node.style.top, "-4px", "y of insertion point of rotated image correct");
- }
-
- function test_VML_drawlinestring(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- g_DrawLine = false;
- r.drawLine = function(c) {
- g_DrawLine = true;
- }
-
- r.drawLineString(node, geometry);
-
- t.ok(g_DrawLine, "drawLine is called");
- }
-
- function test_VML_drawlinearring(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- g_DrawLine = false;
- r.drawLine = function(c) {
- g_DrawLine = true;
- }
-
- r.drawLinearRing(node, geometry);
-
- t.ok(g_DrawLine, "drawLine is called");
- }
-
- function test_VML_drawline(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(8);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
- r.resolution = 0.5;
-
- var node = document.createElement('div');
-
- var geometry = {
- components: [{
- x: 1,
- y: 2
- },{
- x: 3,
- y: 4
- }],
- getBounds: function() {
- return new OpenLayers.Bounds(5,6,7,8);
- }
- };
-
- r.drawLine(node, geometry, true);
- t.ok(node.path.indexOf("x") != -1, "path attribute is correct when passed closeLine = true");
-
-
- r.drawLine(node, geometry, false);
- t.eq(node.path, "m 2,4 l 6,8 l e", "path attribute is correct");
- t.eq(node.style.left, "10px", "node.style.left is correct");
- t.eq(node.style.top, "16px", "node.style.top is correct");
- t.eq(node.style.width, "4px", "node.style.width is correct");
- t.eq(node.style.height, "4px", "node.style.height is correct");
- t.eq(node.coordorigin, "10 16", "node.coordorigin is correct");
- t.eq(node.coordsize, "4 4", "node.coordsize is correct");
- }
-
- function test_VML_drawpolygon(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(3);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
- r.resolution = 0.5;
-
- g_SetNodeDimension = false;
- r.setNodeDimension = function(){
- g_SetNodeDimension = true;
- };
-
- var node = document.createElement('div');
-
- var geometry = OpenLayers.Geometry.fromWKT(
- "POLYGON((1 2, 3 4), (5 6, 7 8))"
- );
- r.drawPolygon(node, geometry, true);
- t.ok(g_SetNodeDimension, "setNodeDimension is called");
- t.eq(node.path, "m 2,4 l 6,8 2,4 x m 10,12 l 14,16 10,12 e", "path attribute is correct - inner ring has no area and is not closed");
-
- geometry.components[1].addComponent(new OpenLayers.Geometry.Point(8, 7));
- r.drawPolygon(node, geometry, true);
- t.eq(node.path, "m 2,4 l 6,8 2,4 x m 10,12 l 14,16 16,14 10,12 x e", "path attribute is correct - inner ring has an area and is closed");
- }
-
- function test_VML_drawrectangle(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- var r = new OpenLayers.Renderer.VML(document.body);
- r.offset = {x: 0, y: 0};
- r.resolution = 0.5;
-
- var node = document.createElement('div');
-
- var geometry = {
- x: 1,
- y: 2,
- width: 3,
- height: 4
- }
-
- r.drawRectangle(node, geometry);
-
- t.eq(node.style.left, "2px", "node.style.left is correct");
- t.eq(node.style.top, "4px", "node.style.top is correct");
- t.eq(node.style.width, "6px", "node.style.width is correct");
- t.eq(node.style.height, "8px", "node.style.height is correct");
- }
-
- function test_vml_getnodetype(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(1);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- var g = {CLASS_NAME: "OpenLayers.Geometry.Point"}
- var s = {graphicName: "square"};
-
- t.eq(r.getNodeType(g, s), "olv:shape", "Correct node type for well known symbols");
- }
-
- function test_vml_importsymbol(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(4);
-
- OpenLayers.Renderer.symbol.rect1 = [0,0, 10,0, 10,4, 0,4, 0,0];
- OpenLayers.Renderer.symbol.rect2 = [0,0, 4,0, 4,10, 0,10, 0,0];
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- var cache = r.importSymbol("square");
-
- t.eq(cache.path, "m 0 0 l 0 1 1 1 1 0 0 0 x e", "Square symbol rendered correctly");
- t.ok(r.symbolCache["-square"], "Symbol has been cached correctly.");
-
- cache = r.importSymbol("rect1");
- t.eq(cache.bottom, -3, "coordorigin bottom of landscape symbol set to -3 to move topmost part to the bottom (we are flipping y!)");
-
- cache = r.importSymbol("rect2");
- t.eq(cache.left, -3, "coordorigin left of portrait symbol set to -3 to move leftmost part to the right");
-
- delete OpenLayers.Renderer.symbol.rect1;
- delete OpenLayers.Renderer.symbol.rect2;
-
- }
-
- function test_vml_dashstyle(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
-
- t.plan(5);
-
- var r = new OpenLayers.Renderer.VML(document.body);
-
- t.eq(r.dashStyle({strokeDashstyle: "1 4"}), "dot", "dot pattern recognized correctly.");
- t.eq(r.dashStyle({strokeDashstyle: "4 4"}), "dash", "dash pattern recognized correctly.");
- t.eq(r.dashStyle({strokeDashstyle: "8 4"}), "longdash", "longdash pattern recognized correctly.");
- t.eq(r.dashStyle({strokeDashstyle: "4 4 1 4"}), "dashdot", "dashdot pattern recognized correctly.");
- t.eq(r.dashStyle({strokeDashstyle: "8 4 1 4"}), "longdashdot", "longdashdot pattern recognized correctly.");
- }
-
- function test_vml_moveRoot(t) {
- if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) {
- t.plan(0);
- return;
- }
- t.plan(2);
-
- var map = new OpenLayers.Map("map");
- var l1 = new OpenLayers.Layer.Vector("vector");
- map.addLayer(l1);
- var l2 = new OpenLayers.Layer.Vector.RootContainer("rootcontainer", {layers: [l1]});
-
- var clear = l1.renderer.clear;
- l1.renderer.clear = function() {
- // this should be called twice, once when l2 is added to the map,
- // and once when removed from the map.
- t.ok(true, "Clearing original layer");
- };
- map.addLayer(l2);
- map.removeLayer(l2);
- l1.renderer.clear = clear;
-
- map.removeLayer(l1);
- }
-
- </script>
-</head>
-<body>
-<div id="map" style="width:500px;height:550px"></div>
-</body>
-</html>