don't open a new window: we don't need to in order to run this test.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5463 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-12-17 06:29:46 +00:00
parent 29f2280fb8
commit dc05a91d4a

View File

@@ -32,14 +32,13 @@
}
function test_03_Control_PanZoom_control_events (t) {
loader();
if ( !window.document.createEvent ) {
//ie can't simulate mouseclicks
t.plan(0)
} else {
t.plan(35);
t.open_window( "Control/test_PanZoom.html", function( wnd ) {
t.delay_call( 3, function() {
t.delay_call( 1, function() {
var flag;
function setFlag(evt) {
flag[evt.type] = true;
@@ -54,61 +53,61 @@
}
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);
window.mapper.events.register("mousedown", mapper, setFlag);
window.mapper.events.register("mouseup", mapper, setFlag);
window.mapper.events.register("click", mapper, setFlag);
window.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" );
simulateClick(window, window.control.buttons[0]);
t.ok( window.mapper.getCenter().lat > window.centerLL.lat, "Pan up works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[1]);
t.ok( window.mapper.getCenter().lon < window.centerLL.lon, "Pan left works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[2]);
t.ok( window.mapper.getCenter().lon == window.centerLL.lon, "Pan right works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[3]);
t.ok( window.mapper.getCenter().lat == window.centerLL.lat, "Pan down works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[4]);
t.eq( window.mapper.getZoom(), 6, "zoomin works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[6]);
t.eq( window.mapper.getZoom(), 5, "zoomout works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does 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" );
simulateClick(window, window.control.buttons[5]);
t.eq( window.mapper.getZoom(), 2, "zoomworld works correctly" );
t.ok(!flag.mousedown, "mousedown does not get to the map");
t.ok(flag.mouseup, "mouseup does get to the map");
t.ok(!flag.click, "click does not get to the map");
@@ -116,25 +115,24 @@
resetFlags();
});
});
}
}
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);
function simulateClick(window, elem) {
var evt = window.document.createEvent("MouseEvents");
evt.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
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);
evt = window.document.createEvent("MouseEvents");
evt.initMouseEvent("mouseup", true, true, window, 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);
evt = window.document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 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);
evt = window.document.createEvent("MouseEvents");
evt.initMouseEvent("dblclick", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt);
}
@@ -156,7 +154,7 @@
</script>
</head>
<body onload="loader()">
<body>
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>