3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
5 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
6 var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
9 function test_Layer_EventPane_constructor (t) {
12 var layer = new OpenLayers.Layer.EventPane('Test Layer');
14 t.ok( layer instanceof OpenLayers.Layer.EventPane, "new OpenLayers.Layer.EventPane returns object" );
15 t.eq( layer.CLASS_NAME, "OpenLayers.Layer.EventPane", "CLASS_NAME variable set correctly");
16 t.eq( layer.name, "Test Layer", "layer.name is correct" );
17 t.eq( layer.isBaseLayer, true, "EventPane layer is always base layer" );
19 t.ok( true, "skipping element test outside of Mozilla");
21 t.ok( layer.pane instanceof HTMLDivElement, "layer.pane is an HTMLDivElement" );
25 function test_Layer_EventPane_clone (t) {
27 t.ok( true, "need to actually write some tests here" );
30 /// FIX ME FIX ME: fix this later
32 var map = new OpenLayers.Map('map');
33 var options = { chicken: 151, foo: "bar" };
34 var layer = new OpenLayers.Layer('Test Layer', options);
37 // randomly assigned property
40 var clone = layer.clone();
42 t.ok( clone instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
43 t.eq( clone.name, "Test Layer", "default clone.name is correct" );
44 t.ok( ((clone.options["chicken"] == 151) && (clone.options["foo"] == "bar")), "clone.options correctly set" );
45 t.eq(clone.chocolate, 5, "correctly copied randomly assigned property");
47 layer.addOptions({chicken:152});
48 t.eq(clone.options["chicken"], 151, "made a clean copy of options");
51 t.ok( clone.map == null, "cloned layer has map property set to null")
55 function test_Layer_EventPane_setMap (t) {
57 // MOUSEMOVE test does not seem to work...
60 if (OpenLayers.Util.getBrowserName() != "firefox" && OpenLayers.Util.getBrowserName() != "mozilla") {
64 t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.")
67 var map = new OpenLayers.Map('map');
69 layer = new OpenLayers.Layer.EventPane('Test Layer');
71 //give dummy function so test wont bomb on layer.setMap()
72 layer.loadMapObject = function() { };
73 layer.getWarningHTML = function() { this.warning = true; return ""; };
75 t.eq( parseInt(layer.pane.style.zIndex) - parseInt(layer.div.style.zIndex),
76 1, "layer pane is 1 z-level above its div" );
78 t.ok( layer.warning, "warning correctly registered on no mapObject load" );
80 layer2 = new OpenLayers.Layer.EventPane('Test Layer');
82 //give dummy function so test wont bomb on layer.setMap()
83 layer2.loadMapObject = function() { this.mapObject = {}; };
84 layer2.getWarningHTML = function() { this.warning = true; return ""; }
87 t.ok( !layer2.warning, "warning not registered on mapObject load" );
89 map.events.register("mousemove", map, function () {
90 t.ok(true, "got mouse move");
93 if( document.createEvent ) { // Mozilla
94 var evObj = document.createEvent('MouseEvents');
95 evObj.initEvent( 'mousemove', true, false );
96 layer.pane.dispatchEvent(evObj);
97 } else if( document.createEventObject ) { // IE
98 layer.pane.fireEvent('onmousemove');
102 function test_Layer_EventPane_setVisibility (t) {
104 layer = new OpenLayers.Layer.EventPane('Test Layer');
105 layer.setVisibility(false);
106 t.eq(layer.visibility, false, "layer pane is now invisible");
107 layer.setVisibility(true);
108 t.eq(layer.visibility, true, "layer pane is now visible");
112 function test_Layer_EventPane_removeLayer(t) {
114 var map = new OpenLayers.Map('map');
116 layer = new OpenLayers.Layer.EventPane('Test Layer');
117 layer.loadMapObject = function() { };
118 layer.getWarningHTML = function() { this.warning = true; return ""; };
120 map.removeLayer(layer);
121 t.eq(layer.pane, null, "Layer.pane is null after being removed.");
128 <div id="map" style="height:500px;width:500px"></div>