diff options
author | Chris Schlaeger <chris@linux.com> | 2015-10-17 21:36:38 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2015-10-17 21:36:38 +0200 |
commit | e30f267181d990947e67909de4809fa941698c85 (patch) | |
tree | 46e9f94c2b3699ed378963b420b8a8d361286ea1 /misc/openlayers/tests/Control/LayerSwitcher.html | |
parent | e763ceb183f389fcd314a4a6a712d87c9d4cdb32 (diff) | |
download | postrunner-e30f267181d990947e67909de4809fa941698c85.zip |
Upgrading openlayers to 3.x
Diffstat (limited to 'misc/openlayers/tests/Control/LayerSwitcher.html')
-rw-r--r-- | misc/openlayers/tests/Control/LayerSwitcher.html | 249 |
1 files changed, 0 insertions, 249 deletions
diff --git a/misc/openlayers/tests/Control/LayerSwitcher.html b/misc/openlayers/tests/Control/LayerSwitcher.html deleted file mode 100644 index c81a779..0000000 --- a/misc/openlayers/tests/Control/LayerSwitcher.html +++ /dev/null @@ -1,249 +0,0 @@ -<html> -<head> - <script src="../OLLoader.js"></script> - <script type="text/javascript"> - var map; - OpenLayers.Lang.setCode('en'); - - function test_Control_LayerSwitcher_constructor (t) { - t.plan( 2 ); - - control = new OpenLayers.Control.LayerSwitcher(); - t.ok( control instanceof OpenLayers.Control.LayerSwitcher, "new OpenLayers.Control.LayerSwitcher returns object" ); - t.eq( control.displayClass, "olControlLayerSwitcher", "displayClass is correct" ); - } - - function test_Control_LayerSwitcher_draw (t) { - t.plan( 2 ); - - map = new OpenLayers.Map('map'); - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - - var div = control.draw(); - t.ok( control.div != null, "draw makes a div" ); - t.ok( div != null, "draw returns its div" ); - } - function test_Control_LayerSwitcher_outsideViewport (t) { - t.plan( 4 ); - - map = new OpenLayers.Map('map'); - control = new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')}); - map.addControl(control); - t.eq(control.div.style.width, "250px", "Div is not minimized when added."); - t.ok(control.events.element && control.events.listeners.buttonclick, "[outside] Events instance attached to div and has buttonclick event"); - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - t.eq(control.div.style.width, "0px", "Div is minimized when added."); - t.ok(!control.events.element && map.events.listeners.buttonclick, "[inside] Events instance not attached to div and buttonclick event registered on map"); - } - - function test_Control_LayerSwitcher_loadContents(t) { - - t.plan( 10 ); - - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("WMS", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}); - map.addLayer(layer); - - markers = new OpenLayers.Layer.Markers("markers"); - map.addLayer(markers); - - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - - t.ok(control.layersDiv != null, "correctly makes layers div"); - t.ok(OpenLayers.Element.hasClass(control.layersDiv, "layersDiv"), - "layers div has class layersDiv"); - t.ok(control.baseLayersDiv != null, "correctly makes layers div"); - t.ok(OpenLayers.Element.hasClass(control.baseLayersDiv, "baseLayersDiv"), - "base layers div has class baseLayersDiv"); - t.ok(control.dataLayersDiv != null, "correctly makes layers div"); - t.ok(OpenLayers.Element.hasClass(control.dataLayersDiv, "dataLayersDiv"), - "data layers div has class dataLayersDiv"); - t.ok(control.maximizeDiv != null, "correctly makes resize div"); - t.ok(OpenLayers.Element.hasClass(control.maximizeDiv, "maximizeDiv"), - "maximize div has class maximizeDiv"); - t.ok(control.minimizeDiv != null, "correctly makes resize div"); - t.ok(OpenLayers.Element.hasClass(control.minimizeDiv, "minimizeDiv"), - "minimize div has class minmizeDiv"); - } - - - function test_Control_LayerSwitcher_redraw (t) { - - t.plan( (OpenLayers.BROWSER_NAME == "opera" ? 9 : 19 ) ); - - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("WMS", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}); - map.addLayer(layer); - - markers = new OpenLayers.Layer.Markers("markers"); - map.addLayer(markers); - - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - - var wmsInput = control.div.childNodes[0].childNodes[1].childNodes[0]; - t.ok(wmsInput != null, "correctly makes an input for wms layer"); - t.eq(wmsInput.type, "radio", "wms correctly made a radio button"); - t.eq(wmsInput.name, control.id + "_baseLayers", "wms correctly named"); - t.eq(wmsInput.value, layer.name, "wms correctly valued"); - - var markersInput = control.div.childNodes[0].childNodes[3].childNodes[0]; - t.ok(markersInput != null, "correctly makes an input for markers layer"); - t.eq(markersInput.type, "checkbox", "wms correctly made a radio button"); - t.eq(markersInput.name, markers.name, "wms correctly named"); - t.eq(markersInput.value, markers.name, "wms correctly valued"); - - t.eq(false, control.checkRedraw(), "check redraw is false"); - if (OpenLayers.BROWSER_NAME != "opera") { - control = new OpenLayers.Control.LayerSwitcher(); - var myredraw = control.redraw; - control.redraw = function() { - t.ok(true, "redraw called when setting vis"); - } - map.addControl(control); - var func = OpenLayers.Function.bind(myredraw, control); - func(); - markers.setVisibility(false); - t.eq(control.checkRedraw(), true, "check redraw is true after changing layer and not letting redraw happen."); - map.removeControl(control); - - control = new OpenLayers.Control.LayerSwitcher(); - var myredraw = control.redraw; - control.redraw = function() { - t.ok(true, "redraw called when setting inRange"); - } - map.addControl(control); - var func = OpenLayers.Function.bind(myredraw, control); - func(); - markers.inRange = false; - t.eq(control.checkRedraw(), true, "check redraw is true after changing layer.inRange and not letting redraw happen."); - map.removeControl(control); - - control = new OpenLayers.Control.LayerSwitcher(); - var myredraw = control.redraw; - control.redraw = function() { - t.ok(true, "redraw called when raising base layer "); - } - - map.addControl(control); - var func = OpenLayers.Function.bind(myredraw, control); - func(); - map.raiseLayer(layer, 1); - t.eq(control.checkRedraw(), true, "check redraw is true after changing layer.inRange and not letting redraw happen."); - map.removeControl(control); - } else { - t.debug_print("FIXME: Some LayerSwitcher tests fail in Opera."); - } - - } - function test_Control_LayerSwitcher_ascending (t) { - - t.plan( 4 ); - - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("WMS", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}); - map.addLayer(layer); - - markers = new OpenLayers.Layer.Markers("markers"); - map.addLayer(markers); - - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - control2 = new OpenLayers.Control.LayerSwitcher({'ascending':false}); - map.addControl(control2); - t.ok(control.div.childNodes[0].childNodes[0].innerHTML.match("Base Layer"), "Base Layers first in LayerSwitcher with ascending true"); - t.ok(control.div.childNodes[0].childNodes[2].innerHTML.match("Overlays"), "Overlays in LayerSwitcher with ascending true"); - t.ok(control2.div.childNodes[0].childNodes[2].innerHTML.match("Base Layer"), "Base Layers last in LayerSwitcher with ascending false"); - t.ok(control2.div.childNodes[0].childNodes[0].innerHTML.match("Overlays"), "Base Layers last in LayerSwitcher with ascending false"); - } - - function test_Control_LayerSwitcher_displayInLayerSwitcher (t) { - - t.plan( 2 ); - - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("WMS", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}, {'displayInLayerSwitcher': false}); - map.addLayer(layer); - - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - t.eq(control.div.childNodes[0].childNodes[0].style.display, "none" , "Base layer display off when no visble base layer"); - - map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("WMS", - "http://octo.metacarta.com/cgi-bin/mapserv?", - {map: "/mapdata/vmap_wms.map", layers: "basic"}); - map.addLayer(layer); - - control = new OpenLayers.Control.LayerSwitcher(); - map.addControl(control); - t.eq(control.div.childNodes[0].childNodes[0].style.display, "" , "Base layer display on when visble base layer"); - } - - // See e.g. https://github.com/openlayers/openlayers/issues/866 - function test_Control_LayerSwitcher_validIds(t){ - t.plan(2); - - // setup - var layername = "Name with spaces & illegal characters * + ~ ` ' ? )", - map = new OpenLayers.Map("map", { - controls: [ - new OpenLayers.Control.LayerSwitcher() - ], - layers: [ - new OpenLayers.Layer.WMS( - layername, - "../../img/blank.gif" - ), - // add another layer with the same name, the generated id - // must be different - new OpenLayers.Layer.WMS( - layername, - "../../img/blank.gif" - ) - ] - }); - - var baselayerDiv = map.controls[0].div.childNodes[0].childNodes[1], - firstGeneratedInputId = baselayerDiv.childNodes[0].id, - secondGeneratedInputId = baselayerDiv.childNodes[1].id, - // legal ids start with a letter and are followed only by word - // characters (letters, digits, and underscores) plus the dash (-) - // This is only a subset of all allowed charcters inside of ids. - allowedIdChars = (/^[a-zA-Z]{1}[\w-]*$/g); - - // tests - // validity - t.ok( - allowedIdChars.test(firstGeneratedInputId), - "id only contains letters, digits, underscores and dashes. It " + - "starts with a letter." - ); - // uniqueness - t.ok( - firstGeneratedInputId !== secondGeneratedInputId, - "generated ids are different even for equal layernames" - ); - - // teardown - map.destroy(); - } - - </script> -</head> -<body> - <div id="map" style="width: 1024px; height: 512px;"/> - <div id="layerswitcher" style="width:250px; height:256px;" /> -</body> -</html> |