Pullup r2999:3087 for RC2.

svn merge trunk/openlayers/@2999 trunk/openlayers/@HEAD branches/openlayers/2.4/



git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-04-20 01:10:43 +00:00
parent b6fb16153c
commit b5103eb8ce
58 changed files with 1399 additions and 503 deletions

View File

@@ -0,0 +1,107 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var map;
function test_01_Control_KeyboardDefaults_constructor (t) {
t.plan( 1 );
control = new OpenLayers.Control.KeyboardDefaults();
t.ok( control instanceof OpenLayers.Control.KeyboardDefaults,
"new OpenLayers.Control.KeyboardDefaults returns object" );
}
function test_02_Control_KeyboardDefaults_addControl (t) {
t.plan( 4 );
map = new OpenLayers.Map('map');
control = new OpenLayers.Control.KeyboardDefaults();
t.ok( control instanceof OpenLayers.Control.KeyboardDefaults,
"new OpenLayers.Control.KeyboardDefaults 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[3] === control, "map.controls contains control" );
}
function test_03_Control_KeyboardDefaults_KeyDownEvent (t) {
t.plan( 10 );
var evt = {which: 1};
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);
control = new OpenLayers.Control.KeyboardDefaults();
map.addControl(control);
var centerLL = new OpenLayers.LonLat(0,0);
map.setCenter(centerLL,4);
evt.keyCode = OpenLayers.Event.KEY_LEFT;
control.defaultKeyDown(evt);
t.delay_call(
1, function() {
t.ok( map.getCenter().lon < centerLL.lon, "key left works correctly" );
evt.keyCode = OpenLayers.Event.KEY_RIGHT;
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lon == centerLL.lon, "key right works correctly" );
evt.keyCode = OpenLayers.Event.KEY_UP;
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lat > centerLL.lat, "key up works correctly" );
evt.keyCode = OpenLayers.Event.KEY_DOWN;
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lat == centerLL.lat, "key down works correctly" );
evt.keyCode = 33; //page up
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lat > centerLL.lat, "key page up works correctly" );
evt.keyCode = 34; //page down
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lat == centerLL.lat, "key page down works correctly" );
evt.keyCode = 35; //end
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lon > centerLL.lon, "key end works correctly" );
evt.keyCode = 36; //pos1
control.defaultKeyDown(evt);
},
1, function() {
t.ok( map.getCenter().lon == centerLL.lon, "key pos1 works correctly" );
evt.charCode = 43; //+
control.defaultKeyDown(evt);
},
1, function() {
t.eq( map.getZoom(), 5, "key + works correctly" );
// set zoomanimation flag manually,
// reason: loadend event in layers.js will not achieved in unittests
map.zoomanimationActive = false;
evt.charCode = 45; //-
control.defaultKeyDown(evt);
},
1, function() {
t.eq( map.getZoom(), 4, "key - works correctly" );
}
);
}
// -->
</script>
</head>
<body>
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>

View File

@@ -36,29 +36,84 @@
//ie can't simulate mouseclicks
t.plan(0)
} else {
t.plan( 7 );
t.plan(35);
t.open_window( "Control/test_PanZoom.html", function( wnd ) {
t.delay_call( 3, function() {
simulateClick(wnd, wnd.control.buttons[0]);
var flag;
function setFlag(evt) {
flag[evt.type] = true;
}
function resetFlags() {
flag = {
mousedown: false,
mouseup: false,
click: false,
dblclick: false
};
}
resetFlags();
wnd.mapper.events.register("mousedown", mapper, setFlag);
wnd.mapper.events.register("mouseup", mapper, setFlag);
wnd.mapper.events.register("click", mapper, setFlag);
wnd.mapper.events.register("dblclick", mapper, setFlag);
simulateClick(wnd, wnd.control.buttons[0]);
t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[1]);
t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[2]);
t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[3]);
t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[4]);
t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[6]);
t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[5]);
t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(!flag.mouseup, "mouseup does not get to the map");
t.ok(!flag.click, "click does not get to the map");
t.ok(!flag.dblclick, "dblclick does not get to the map");
resetFlags();
});
});
}
@@ -67,7 +122,19 @@
function simulateClick(wnd, elem) {
var evt = wnd.document.createEvent("MouseEvents");
evt.initMouseEvent("mousedown", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var canceled = !elem.dispatchEvent(evt);
elem.dispatchEvent(evt);
evt = wnd.document.createEvent("MouseEvents");
evt.initMouseEvent("mouseup", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt);
evt = wnd.document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt);
evt = wnd.document.createEvent("MouseEvents");
evt.initMouseEvent("dblclick", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt);
}
function loader() {