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