Merge branch 'master' of https://github.com/openlayers/openlayers
Conflicts: tests/list-tests.html
This commit is contained in:
@@ -33,6 +33,31 @@
|
||||
map.addControl(control2, new OpenLayers.Pixel(100,100));
|
||||
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
|
||||
}
|
||||
|
||||
function test_draw(t) {
|
||||
t.plan(3);
|
||||
map = new OpenLayers.Map('map', {controls:[]});
|
||||
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.zoomToMaxExtent();
|
||||
control = new OpenLayers.Control.PanZoomBar();
|
||||
map.addControl(control);
|
||||
t.eq(control.zoombarDiv.style.height, '176px', "Bar's height is correct.");
|
||||
|
||||
map.baseLayer.wrapDateLine = true;
|
||||
|
||||
control.redraw();
|
||||
t.eq(control.zoombarDiv.style.height, '154px', "Bar's height is correct after minZoom restriction.");
|
||||
|
||||
map.div.style.width = "512px";
|
||||
map.updateSize();
|
||||
t.eq(control.zoombarDiv.style.height, '165px', "Bar's height is correct after resize and minZoom restriction.");
|
||||
|
||||
map.div.style.width = "1024px";
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_PanZoomBar_clearDiv(t) {
|
||||
t.plan(2);
|
||||
|
||||
@@ -104,13 +104,18 @@
|
||||
|
||||
t.plan(7);
|
||||
|
||||
var layer = new OpenLayers.Layer.Vector("foo", {
|
||||
var layer1 = new OpenLayers.Layer.Vector("foo", {
|
||||
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
|
||||
isBaseLayer: true
|
||||
});
|
||||
var control = new OpenLayers.Control.Split({layer: layer});
|
||||
var layer2 = new OpenLayers.Layer.Vector("bar", {
|
||||
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
|
||||
isBaseLayer: false
|
||||
});
|
||||
var control = new OpenLayers.Control.Split({layer: layer1});
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(layer);
|
||||
map.addLayer(layer1);
|
||||
map.addLayer(layer2);
|
||||
map.zoomToMaxExtent();
|
||||
map.addControl(control);
|
||||
|
||||
@@ -124,17 +129,17 @@
|
||||
t.eq(control.handler.active, false, "sketch handler deactivated");
|
||||
|
||||
// set a source layer
|
||||
control.setSource(layer);
|
||||
control.setSource(layer2);
|
||||
|
||||
// activate and check that listeners are registered
|
||||
control.activate();
|
||||
t.ok(layer.events.listeners.sketchcomplete, "sketchcomplete listener registered");
|
||||
t.ok(layer.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered");
|
||||
t.ok(layer2.events.listeners.sketchcomplete, "sketchcomplete listener registered");
|
||||
t.ok(layer2.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered");
|
||||
|
||||
// deactivate and confirm no draw related events
|
||||
control.deactivate();
|
||||
t.eq(layer.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners");
|
||||
t.eq(layer.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners");
|
||||
t.eq(layer2.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners");
|
||||
t.eq(layer2.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
52
tests/Control/ZoomBox.html
Normal file
52
tests/Control/ZoomBox.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_constructor(t) {
|
||||
t.plan(4);
|
||||
|
||||
var control = new OpenLayers.Control.ZoomBox();
|
||||
t.ok(control instanceof OpenLayers.Control, "instance of Control");
|
||||
t.ok(control instanceof OpenLayers.Control.ZoomBox, "instance of ZoomBox");
|
||||
t.eq(control.displayClass, "olControlZoomBox", "displayClass");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.ZoomBox({
|
||||
zoomOnClick: false
|
||||
});
|
||||
t.eq(control.zoomOnClick, false, "zoomOnClick");
|
||||
control.destroy();
|
||||
}
|
||||
|
||||
function test_zoomBox(t) {
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map("map", {
|
||||
layers: [new OpenLayers.Layer("", {isBaseLayer: true})],
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
});
|
||||
var control = new OpenLayers.Control.ZoomBox();
|
||||
map.addControl(control);
|
||||
control.zoomBox(new OpenLayers.Pixel(50, 60));
|
||||
t.eq(map.getZoom(), 2, "zoomed on click");
|
||||
|
||||
control.zoomOnClick = false;
|
||||
control.zoomBox(new OpenLayers.Pixel(-50, -60));
|
||||
t.eq(map.getZoom(), 2, "not zoomed with zoomOnClick set to false");
|
||||
|
||||
map.zoomToMaxExtent();
|
||||
control.zoomBox(new OpenLayers.Bounds(128, 64, 256, 128));
|
||||
t.eq(map.getCenter().toShortString(), "-45, 22.5", "centered to box center");
|
||||
t.eq(map.getZoom(), 3, "zoomed to box extent");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 512px; height: 256px;"/>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user