Merge branch 'master' of github.com:openlayers/openlayers into utfgrid
This commit is contained in:
@@ -25,15 +25,17 @@
|
||||
t.ok( div != null, "draw returns its div" );
|
||||
}
|
||||
function test_Control_LayerSwitcher_outsideViewport (t) {
|
||||
t.plan( 2 );
|
||||
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.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) {
|
||||
|
||||
@@ -289,16 +289,16 @@
|
||||
// move 10 pixels
|
||||
trigger("mousemove", 0, 10);
|
||||
|
||||
t.eq(log.length, 0, "a) no event fired yet");
|
||||
t.eq(log.length, 1, "a) has fired an event");
|
||||
|
||||
t.delay_call(
|
||||
delay, function() {
|
||||
// confirm measurepartial is fired
|
||||
t.eq(log.length, 1, "a) event logged");
|
||||
t.eq(log.length, 1, "a) one event logged");
|
||||
t.ok(log[0] && log[0].type == "measurepartial", "a) correct type");
|
||||
// mousemove within the partialDelay fires no event, so the
|
||||
// measure below is the one of the initial point
|
||||
t.ok(log[0] && log[0].measure == 0, "a) correct measure");
|
||||
t.eq(log[0]?log[0].measure:-1 , 10, "a) correct measure");
|
||||
|
||||
// b) move 10 pixels
|
||||
trigger("mousemove", 0, 20);
|
||||
|
||||
@@ -3,19 +3,23 @@
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, control;
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan( 2 );
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap();
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.eq( control.displayClass, "olControlOverviewMap", "displayClass is correct" );
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap,
|
||||
"new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.eq( control.displayClass,
|
||||
"olControlOverviewMap", "displayClass is correct" );
|
||||
}
|
||||
|
||||
function test_setMap(t) {
|
||||
t.plan(4);
|
||||
|
||||
var setMapTest = function(map) {
|
||||
t.ok(true, "Handler.setMap called for " + this.CLASS_NAME);
|
||||
t.ok(true,
|
||||
"Handler.setMap called for " + this.CLASS_NAME);
|
||||
this.map = map;
|
||||
};
|
||||
var drag_setMap = OpenLayers.Handler.Drag.prototype.setMap;
|
||||
@@ -32,8 +36,10 @@
|
||||
map.addControl(control);
|
||||
|
||||
map.zoomToMaxExtent();
|
||||
t.eq(control.handlers.drag.map.id, control.ovmap.id, "drag.map is correct");
|
||||
t.eq(control.handlers.click.map.id, control.ovmap.id, "click.map is correct");
|
||||
t.eq(control.handlers.drag.map.id, control.ovmap.id,
|
||||
"drag.map is correct");
|
||||
t.eq(control.handlers.click.map.id, control.ovmap.id,
|
||||
"click.map is correct");
|
||||
|
||||
map.destroy();
|
||||
OpenLayers.Handler.Drag.prototype.setMap = drag_setMap;
|
||||
@@ -66,85 +72,112 @@
|
||||
|
||||
control.destroy();
|
||||
t.eq(log_drag.length, 2,
|
||||
"destroy() destroys drag handler twice, expected");
|
||||
"destroy() destroys drag handler twice, expected");
|
||||
if (log_drag.length == 2) {
|
||||
t.eq(log_drag[0].map, true,
|
||||
"destroy() destroys drag handler before ovmap is destroyed (0)");
|
||||
"destroy() destroys drag handler before ovmap is destroyed (0)");
|
||||
t.eq(log_drag[1].map, false,
|
||||
"destroy() destroys drag handler after ovmap is destroyed (1)");
|
||||
"destroy() destroys drag handler after ovmap is destroyed (1)");
|
||||
}
|
||||
t.eq(log_click.length, 2,
|
||||
"destroy() destroys click handler twice, expected");
|
||||
"destroy() destroys click handler twice, expected");
|
||||
if (log_click.length == 2) {
|
||||
t.eq(log_click[0].map, true,
|
||||
"destroy() destroys click handler before ovmap is destroyed (0)");
|
||||
"destroy() destroys click handler before ovmap is destroyed (0)");
|
||||
t.eq(log_click[1].map, false,
|
||||
"destroy() destroys click handler after ovmap is destroyed (1)");
|
||||
"destroy() destroys click handler after ovmap is destroyed (1)");
|
||||
}
|
||||
|
||||
// tear down
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_addControl (t) {
|
||||
t.plan( 6 );
|
||||
map = new OpenLayers.Map('map');
|
||||
control = new OpenLayers.Control.OverviewMap();
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap,
|
||||
"new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.ok( map instanceof OpenLayers.Map,
|
||||
"new OpenLayers.Map creates map" );
|
||||
map.addControl(control);
|
||||
t.ok( control.map === map, "Control.map is set to the map object" );
|
||||
t.ok( map.controls[4] === control, "map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div" );
|
||||
t.ok( control.map === map,
|
||||
"Control.map is set to the map object" );
|
||||
t.ok( map.controls[4] === control,
|
||||
"map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
|
||||
"Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
|
||||
"Viewport div contains control div" );
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_control_events (t) {
|
||||
t.plan( 10 );
|
||||
var evt = {which: 1}; // control expects left-click
|
||||
map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
|
||||
map = new OpenLayers.Map('map', {
|
||||
// when we recenter, don't waste time animating the panning
|
||||
// without this, the test fails in Firefox 10.0.1 on Linux
|
||||
panMethod: null,
|
||||
layers: [ new OpenLayers.Layer('Test Layer', {isBaseLayer: true}) ]
|
||||
});
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap();
|
||||
map.addControl(control, new OpenLayers.Pixel(20,20));
|
||||
|
||||
var centerLL = new OpenLayers.LonLat(-71,42);
|
||||
map.setCenter(centerLL, 11);
|
||||
t.delay_call(1, function() {
|
||||
var overviewCenter = control.ovmap.getCenter();
|
||||
var overviewZoom = control.ovmap.getZoom();
|
||||
t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
|
||||
t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
|
||||
t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
|
||||
|
||||
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
|
||||
}, 2, function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
|
||||
t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
|
||||
|
||||
control.handlers.drag = {
|
||||
last: new OpenLayers.Pixel(5,5),
|
||||
destroy: function() {}
|
||||
};
|
||||
control.rectDrag(new OpenLayers.Pixel(15, 15));
|
||||
control.updateMapToRect();
|
||||
}, 2, function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
|
||||
t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
|
||||
t.delay_call(
|
||||
0.1,
|
||||
function() {
|
||||
var overviewCenter = control.ovmap.getCenter();
|
||||
var overviewZoom = control.ovmap.getZoom();
|
||||
t.eq(overviewCenter.lon, -71,
|
||||
"OverviewMap center lon correct");
|
||||
t.eq(overviewCenter.lat, 42,
|
||||
"OverviewMap center lat correct");
|
||||
t.eq(overviewZoom, 8,
|
||||
"OverviewMap zoom correct");
|
||||
|
||||
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
|
||||
},
|
||||
0.1,
|
||||
function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.3515625,
|
||||
"Clicking on OverviewMap has correct effect on map lon");
|
||||
t.eq(cent.lat, 42.17578125,
|
||||
"Clicking on OverviewMap has correct effect on map lat");
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 0);
|
||||
var overviewCenter = control.ovmap.getCenter();
|
||||
var overviewZoom = control.ovmap.getZoom();
|
||||
t.eq(overviewCenter.lon, 0, "Overviewmap center lon correct -- second zoom");
|
||||
t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom");
|
||||
t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom");
|
||||
map.destroy();
|
||||
});
|
||||
control.handlers.drag = {
|
||||
last: new OpenLayers.Pixel(5,5),
|
||||
destroy: function() {}
|
||||
};
|
||||
control.rectDrag(new OpenLayers.Pixel(15, 15));
|
||||
control.updateMapToRect();
|
||||
},
|
||||
0.1,
|
||||
function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.2734375,
|
||||
"Dragging on OverviewMap has correct effect on map lon");
|
||||
t.eq(cent.lat, 42.09765625,
|
||||
"Dragging on OverviewMap has correct effect on map lat");
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 0);
|
||||
var overviewCenter = control.ovmap.getCenter();
|
||||
var overviewZoom = control.ovmap.getZoom();
|
||||
t.eq(overviewCenter.lon, 0,
|
||||
"OverviewMap center lon correct -- second zoom");
|
||||
t.eq(overviewCenter.lat, 0,
|
||||
"OverviewMap center lat correct -- second zoom");
|
||||
t.eq(overviewZoom, 0,
|
||||
"OverviewMap zoomcorrect -- second zoom");
|
||||
map.destroy();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function test_initialize_maximized(t) {
|
||||
@@ -156,8 +189,10 @@
|
||||
controls: [control]
|
||||
});
|
||||
|
||||
t.eq(control.maximized, false, "OverviewMap is not maximized by default");
|
||||
t.eq(control.element.style.display, 'none', "OverviewMap.element is not visible");
|
||||
t.eq(control.maximized, false,
|
||||
"OverviewMap is not maximized by default");
|
||||
t.eq(control.element.style.display, 'none',
|
||||
"OverviewMap.element is not visible");
|
||||
map.destroy();
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap({
|
||||
@@ -167,8 +202,10 @@
|
||||
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
|
||||
controls: [control]
|
||||
});
|
||||
t.eq(control.maximized, true, "OverviewMap.maximized is set");
|
||||
t.eq(control.element.style.display, '', "OverviewMap.element is visible");
|
||||
t.eq(control.maximized, true,
|
||||
"OverviewMap.maximized is set");
|
||||
t.eq(control.element.style.display, '',
|
||||
"OverviewMap.element is visible");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
@@ -176,6 +213,6 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
<div id="map" style="width: 1024px; height: 512px;"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink('permalink', 'test.html');
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -18,6 +19,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink('permalink');
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -25,6 +27,7 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -32,6 +35,7 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({anchor: true});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -39,18 +43,21 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(control.element == null, "element is null");
|
||||
t.ok(control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({anchor: false});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -58,6 +65,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -65,6 +73,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
}
|
||||
function test_Control_Permalink_uncentered (t) {
|
||||
t.plan( 1 );
|
||||
@@ -74,12 +83,14 @@
|
||||
map.addControl(control);
|
||||
map.events.triggerEvent("changelayer", {});
|
||||
t.ok(true, "permalink didn't bomb out.");
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_initwithelem (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
|
||||
t.ok(true, "If the above line doesn't throw an error, we're safe.");
|
||||
control.destroy();
|
||||
}
|
||||
function test_Control_Permalink_updateLinks (t) {
|
||||
t.plan( 3 );
|
||||
@@ -100,6 +111,7 @@
|
||||
map.layers[1].setVisibility(false);
|
||||
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_updateLinksBase (t) {
|
||||
t.plan( 2 );
|
||||
@@ -114,6 +126,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_noElement (t) {
|
||||
t.plan( 2 );
|
||||
@@ -122,6 +135,7 @@
|
||||
map = new OpenLayers.Map('map');
|
||||
map.addControl(control);
|
||||
t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_base_with_query (t) {
|
||||
t.plan( 3 );
|
||||
@@ -147,6 +161,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
map.pan(-5, 0, {animate:false});
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
|
||||
map.destroy();
|
||||
|
||||
}
|
||||
|
||||
@@ -163,6 +178,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_customized(t) {
|
||||
@@ -189,6 +205,7 @@
|
||||
|
||||
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
|
||||
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_createParams(t) {
|
||||
@@ -300,6 +317,7 @@
|
||||
|
||||
map.layers[1].setVisibility(false);
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_AnchorBaseElement (t) {
|
||||
@@ -320,7 +338,80 @@
|
||||
|
||||
map.layers[1].setVisibility(false);
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_center_from_map(t) {
|
||||
t.plan(7);
|
||||
|
||||
var previous = window.location.hash;
|
||||
window.location.hash = "";
|
||||
|
||||
var err;
|
||||
try {
|
||||
var map = new OpenLayers.Map({
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
|
||||
controls: [
|
||||
new OpenLayers.Control.Permalink({anchor: true})
|
||||
],
|
||||
center: [1, 2],
|
||||
zoom: 3
|
||||
});
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
if (err) {
|
||||
t.fail("Map construction failure: " + err.message);
|
||||
} else {
|
||||
t.ok(true, "Map construction works");
|
||||
}
|
||||
|
||||
// confirm that map center is correctly set
|
||||
var center = map.getCenter();
|
||||
t.eq(center.lon, 1, "map x");
|
||||
t.eq(center.lat, 2, "map y")
|
||||
t.eq(map.getZoom(), 3, "map z");
|
||||
|
||||
// confirm that location from map options has been added to url
|
||||
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
|
||||
t.eq(params.lon, "1", "url x");
|
||||
t.eq(params.lat, "2", "url y");
|
||||
t.eq(params.zoom, "3", "url z");
|
||||
|
||||
map.destroy();
|
||||
window.location.hash = previous;
|
||||
}
|
||||
|
||||
function test_center_from_url(t) {
|
||||
t.plan(6);
|
||||
|
||||
// In cases where the location is specified in the URL and given in
|
||||
// the map options, we respect the location in the URL.
|
||||
var previous = window.location.hash;
|
||||
window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
|
||||
controls: [new OpenLayers.Control.Permalink({anchor: true})],
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
});
|
||||
|
||||
// confirm that map center is correctly set
|
||||
var center = map.getCenter();
|
||||
t.eq(center.lon, 4, "map x");
|
||||
t.eq(center.lat, 5, "map y")
|
||||
t.eq(map.getZoom(), 6, "map z");
|
||||
|
||||
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
|
||||
t.eq(params.lon, "4", "x set");
|
||||
t.eq(params.lat, "5", "y set");
|
||||
t.eq(params.zoom, "6", "z set");
|
||||
|
||||
map.destroy();
|
||||
window.location.hash = previous;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -475,6 +475,35 @@
|
||||
|
||||
}
|
||||
|
||||
function test_exceptions(t) {
|
||||
t.plan(1);
|
||||
var map = new OpenLayers.Map("map", {
|
||||
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
|
||||
}
|
||||
);
|
||||
|
||||
var a = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", {
|
||||
layers: "x",
|
||||
exceptions: "text/xml"
|
||||
});
|
||||
|
||||
map.addLayer(a);
|
||||
|
||||
var click = new OpenLayers.Control.WMSGetFeatureInfo({
|
||||
});
|
||||
|
||||
map.addControl(click);
|
||||
|
||||
var _request = OpenLayers.Request.GET;
|
||||
OpenLayers.Request.GET = function(options) {
|
||||
t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter taken from the WMS layer if provided");
|
||||
};
|
||||
click.activate();
|
||||
click.getInfoForClick({xy: {x: 50, y: 50}});
|
||||
OpenLayers.Request.GET = _request;
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_drillDown(t) {
|
||||
t.plan(6);
|
||||
var map = new OpenLayers.Map("map", {
|
||||
|
||||
81
tests/Control/Zoom.html
Normal file
81
tests/Control/Zoom.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_constructor(t) {
|
||||
t.plan(5);
|
||||
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
t.ok(control instanceof OpenLayers.Control, "instance of Control");
|
||||
t.ok(control instanceof OpenLayers.Control.Zoom, "instance of Zoom");
|
||||
t.eq(control.displayClass, "olControlZoom", "displayClass");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Zoom({
|
||||
zoomInText: "zoom in!",
|
||||
zoomOutText: "zoom out!"
|
||||
});
|
||||
t.eq(control.zoomInText, "zoom in!", "zoomInText");
|
||||
t.eq(control.zoomOutText, "zoom out!", "zoomOutText");
|
||||
control.destroy();
|
||||
}
|
||||
|
||||
function test_addControl(t) {
|
||||
t.plan(3);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
t.ok(control.map === map, "Control.map set");
|
||||
t.ok(!!~OpenLayers.Util.indexOf(map.controls, control), "map.controls contains control");
|
||||
|
||||
control = new OpenLayers.Control.Zoom({zoomInId: "in", zoomOutId: "out"});
|
||||
map.addControl(control);
|
||||
var eventsEl = document.getElementById("out").parentNode;
|
||||
t.ok(control.events.element === eventsEl, "Events instance listens to custom div's parentNode");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_zoomIn(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||
});
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
map.setCenter([0, 0], 0);
|
||||
|
||||
t.eq(map.getZoom(), 0, "initial center");
|
||||
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomInLink});
|
||||
t.eq(map.getZoom(), 1, "after zoom in");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_zoomOut(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||
});
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
map.setCenter([0, 0], 1);
|
||||
|
||||
t.eq(map.getZoom(), 1, "initial center");
|
||||
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomOutLink});
|
||||
t.eq(map.getZoom(), 0, "after zoom out");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 512px; height: 256px;"/>
|
||||
<div id="in">in</div><div id="out">out</out>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user