Making TouchNavigation tests work in Firefox

This commit is contained in:
ahocevar
2013-04-24 01:01:56 +02:00
parent 3ef69b967d
commit acc497bf3c
+8 -7
View File
@@ -128,27 +128,28 @@
function test_zoomOut(t) { function test_zoomOut(t) {
t.plan(1); t.plan(1);
var map = new OpenLayers.Map(document.body); var map = new OpenLayers.Map('map', {zoomMethod: null});
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", "http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} ); {layers: 'basic'} );
map.addLayer(layer); map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 5); map.setCenter(new OpenLayers.LonLat(0, 0), 5);
var origSetTimeout = window.setTimeout;
window.setTimeout = function(fn) { fn(); return 'id'; };
var control = new OpenLayers.Control.TouchNavigation(); var control = new OpenLayers.Control.TouchNavigation();
map.addControl(control); map.addControl(control);
var handler = control.handlers.click; var handler = control.handlers.click;
handler.touchstart({xy: new OpenLayers.Pixel(1 ,1), touches: ["foo", "bar"]}); handler.touchstart({xy: new OpenLayers.Pixel(1 ,1), touches: ["foo", "bar"]});
handler.touchend({}); handler.touchend({});
t.delay_call(1, function() { t.eq(map.getZoom(), 4, "Did we zoom out?");
t.eq(map.getZoom(), 4, "Did we zoom out?"); // tear down
// tear down map.destroy();
map.destroy(); window.setTimeout = origSetTimeout;
});
} }
</script> </script>
</head> </head>
<body> <body>
<div id="map" style="width:512px;height:256px"></div>
</body> </body>
</html> </html>