summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Layer/EventPane.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/Layer/EventPane.html
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Layer/EventPane.html')
-rw-r--r--misc/openlayers/tests/Layer/EventPane.html172
1 files changed, 172 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Layer/EventPane.html b/misc/openlayers/tests/Layer/EventPane.html
new file mode 100644
index 0000000..8d8e180
--- /dev/null
+++ b/misc/openlayers/tests/Layer/EventPane.html
@@ -0,0 +1,172 @@
+<html>
+<head>
+ <script src="../OLLoader.js"></script>
+ <script type="text/javascript">
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
+ var layer;
+
+ function test_Layer_EventPane_constructor (t) {
+ t.plan( 5 );
+
+ var layer = new OpenLayers.Layer.EventPane('Test Layer');
+
+ t.ok( layer instanceof OpenLayers.Layer.EventPane, "new OpenLayers.Layer.EventPane returns object" );
+ t.eq( layer.CLASS_NAME, "OpenLayers.Layer.EventPane", "CLASS_NAME variable set correctly");
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ t.eq( layer.isBaseLayer, true, "EventPane layer is always base layer" );
+ if (!isMozilla) {
+ t.ok( true, "skipping element test outside of Mozilla");
+ } else {
+ t.ok( layer.pane instanceof HTMLDivElement, "layer.pane is an HTMLDivElement" );
+ }
+ }
+
+ function test_Layer_EventPane_clone (t) {
+ t.plan( 1 );
+ t.ok( true, "need to actually write some tests here" );
+ return;
+
+ /// FIX ME FIX ME: fix this later
+
+ var map = new OpenLayers.Map('map');
+ var options = { chicken: 151, foo: "bar" };
+ var layer = new OpenLayers.Layer('Test Layer', options);
+ map.addLayer(layer);
+
+ // randomly assigned property
+ layer.chocolate = 5;
+
+ var clone = layer.clone();
+
+ t.ok( clone instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
+ t.eq( clone.name, "Test Layer", "default clone.name is correct" );
+ t.ok( ((clone.options["chicken"] == 151) && (clone.options["foo"] == "bar")), "clone.options correctly set" );
+ t.eq(clone.chocolate, 5, "correctly copied randomly assigned property");
+
+ layer.addOptions({chicken:152});
+ t.eq(clone.options["chicken"], 151, "made a clean copy of options");
+
+
+ t.ok( clone.map == null, "cloned layer has map property set to null")
+
+ }
+
+ function test_Layer_EventPane_setMap (t) {
+
+// MOUSEMOVE test does not seem to work...
+// t.plan( 2 );
+
+ if (OpenLayers.BROWSER_NAME != "firefox" && OpenLayers.BROWSER_NAME != "mozilla") {
+ t.plan(4);
+ } else {
+ t.plan(0);
+ t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.")
+ return;
+ }
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.EventPane('Test Layer');
+
+ //give dummy function so test wont bomb on layer.setMap()
+ layer.loadMapObject = function() { };
+ layer.getWarningHTML = function() { this.warning = true; return ""; };
+ map.addLayer(layer);
+ t.eq( parseInt(layer.pane.style.zIndex) - parseInt(layer.div.style.zIndex),
+ 1, "layer pane is 1 z-level above its div" );
+
+ t.ok( layer.warning, "warning correctly registered on no mapObject load" );
+
+ layer2 = new OpenLayers.Layer.EventPane('Test Layer');
+
+ //give dummy function so test wont bomb on layer.setMap()
+ layer2.loadMapObject = function() { this.mapObject = {}; };
+ layer2.getWarningHTML = function() { this.warning = true; return ""; }
+
+ map.addLayer(layer2);
+ t.ok(!layer2.warning, "warning not registered on mapObject load");
+
+ var log = [];
+ map.events.register("mousemove", map, function(event) {
+ log.push(event);
+ });
+
+ if (document.createEvent) { // Mozilla
+ var evObj = document.createEvent('MouseEvents');
+ evObj.initEvent('mousemove', true, false);
+ map.viewPortDiv.dispatchEvent(evObj);
+ } else if(document.createEventObject) { // IE
+ map.viewPortDiv.fireEvent('onmousemove');
+ }
+
+ t.eq(log.length, 1, "got one event");
+
+ }
+
+ function test_Layer_EventPane_setVisibility (t) {
+ t.plan( 2 );
+ layer = new OpenLayers.Layer.EventPane('Test Layer');
+ layer.setVisibility(false);
+ t.eq(layer.visibility, false, "layer pane is now invisible");
+ layer.setVisibility(true);
+ t.eq(layer.visibility, true, "layer pane is now visible");
+ }
+
+
+ function test_Layer_EventPane_removeLayer(t) {
+ t.plan(1);
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.EventPane('Test Layer');
+ layer.loadMapObject = function() { };
+ layer.getWarningHTML = function() { this.warning = true; return ""; };
+ map.addLayer(layer);
+ map.removeLayer(layer);
+ var parent = layer.pane.parentNode;
+ // IE creates a DOCUMENT_FRAGMENT_NODE for the parent
+ t.ok(!parent || parent.nodeType == 11, "Layer.pane removed from dom.");
+ }
+
+ function test_repeat_add(t) {
+
+ t.plan(1);
+ var map = new OpenLayers.Map("map");
+
+ layer = new OpenLayers.Layer.EventPane();
+ layer.loadMapObject = function() {};
+ layer.getWarningHTML = function() {this.warning = true; return "";};
+
+ map.addLayer(layer);
+ map.removeLayer(layer);
+
+ // try adding the layer a second time
+ var msg = "layer successfully added after being removed";
+ var pass = true;
+ try {
+ map.addLayer(layer);
+ } catch (err) {
+ msg = "couldn't add layer after removing: " + err;
+ pass = false;
+ }
+ t.ok(pass, msg);
+
+ }
+
+ function test_destroy(t) {
+
+ t.plan(2);
+ layer = new OpenLayers.Layer.EventPane();
+ t.ok(layer.pane, "pane created on initialize");
+
+ layer.destroy();
+ t.ok(!layer.pane, "pane deleted on destroy");
+
+ }
+
+
+ </script>
+</head>
+<body>
+ <div id="map" style="height:500px;width:500px"></div>
+</body>
+</html>