summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Tile.html
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/Tile.html
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-0.0.4.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Tile.html')
-rw-r--r--misc/openlayers/tests/Tile.html130
1 files changed, 130 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Tile.html b/misc/openlayers/tests/Tile.html
new file mode 100644
index 0000000..087b320
--- /dev/null
+++ b/misc/openlayers/tests/Tile.html
@@ -0,0 +1,130 @@
+<html>
+<head>
+ <script src="OLLoader.js"></script>
+ <script type="text/javascript">
+ var tile;
+
+ var map, layer;
+ function setUp() {
+ map = new OpenLayers.Map("map");
+ layer = new OpenLayers.Layer(null, {
+ isBaseLayer: true
+ });
+ map.addLayer(layer)
+ map.setCenter(new OpenLayers.LonLat(0, 0));
+ }
+
+ function tearDown() {
+ map.destroy();
+ map = null;
+ layer = null;
+ }
+
+
+ function test_Tile_constructor (t) {
+ t.plan( 13 );
+
+ setUp();
+
+ var dummy = {};
+
+ var position = new OpenLayers.Pixel(10,20);
+ var bounds = new OpenLayers.Bounds(1,2,3,4);
+ var url = "bobob";
+ var size = new OpenLayers.Size(5,6);
+
+ tile = new OpenLayers.Tile(layer, position, bounds, url, size, {
+ eventListeners: {
+ loadstart: OpenLayers.Function.False
+ }
+ });
+
+ t.ok(tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object");
+ t.ok(tile.layer === layer, "tile.layer set correctly");
+ t.ok(tile.position.equals(position), "tile.position set correctly");
+ t.ok(tile.position != position, "tile.position set not by reference");
+ t.ok(tile.bounds.equals(bounds), "tile.bounds set correctly");
+ t.ok(tile.bounds != bounds, "tile.bounds set not by reference");
+ t.eq(tile.url, url, "tile.url set correctly");
+ t.ok(tile.size.equals(size), "tile.size is set correctly");
+ t.ok(tile.size != size, "tile.size set not by reference");
+
+ t.ok(tile.id != null, "tile is given an id");
+ t.ok(OpenLayers.String.startsWith(tile.id, "Tile_"),
+ "tile's id starts correctly");
+ t.ok(tile.events != null, "tile's events initialized");
+ t.ok(tile.events.listeners.loadstart.length == 1,
+ "tile's events initialized from eventListeners option");
+
+ tearDown();
+
+ }
+
+ function test_Tile_draw(t) {
+ t.plan(6);
+ setUp();
+
+ var position = new OpenLayers.Pixel(10,20);
+ var bounds = new OpenLayers.Bounds(1,2,3,4);
+ var url = "bobob";
+ var size = new OpenLayers.Size(5,6);
+
+ tile = new OpenLayers.Tile(layer, position, bounds, url, size);
+ var log = [];
+ tile.clear = function() {
+ log.push("clear");
+ }
+ tile.draw();
+ t.eq(log.length, 1, "Tile cleared before drawing");
+
+ log = [];
+ tile.events.register("beforedraw", this, function() {
+ log.push("beforedraw");
+ return false;
+ });
+ var drawn = tile.draw();
+ t.eq(log[0], "clear", "tile cleared");
+ t.eq(log[1], "beforedraw", "beforedraw event fired");
+ t.eq(drawn, null, "tile not drawn when beforedraw listener returns false");
+ drawn = tile.draw(true);
+ t.eq(log.length, 2, "no beforedraw event fired and tile not cleared when draw called with 'deferred' argument set to true");
+ t.eq(drawn, true, "tile drawn when draw called with 'deferred' argument set to true");
+
+ tearDown();
+ }
+
+ function test_Tile_destroy(t) {
+ t.plan( 6 );
+
+ setUp();
+
+ var position = new OpenLayers.Pixel(10,20);
+ var bounds = new OpenLayers.Bounds(1,2,3,4);
+ var url = "bobob";
+ var size = new OpenLayers.Size(5,6);
+
+ tile = new OpenLayers.Tile(layer, position, bounds, url, size);
+ tile.events.destroy = function() {
+ t.ok(true, "tile events destroy() called");
+ };
+
+
+ tile.destroy();
+
+ t.ok(tile.layer == null, "tile.layer set to null");
+ t.ok(tile.bounds == null, "tile.bounds set to null");
+ t.ok(tile.size == null, "tile.size set to null");
+ t.ok(tile.position == null, "tile.position set to null");
+
+ t.ok(tile.events == null, "tile.events set to null");
+
+ tearDown();
+
+ }
+
+ </script>
+</head>
+<body>
+</body>
+</html>
+