git-svn-id: http://svn.openlayers.org/trunk/openlayers@11695 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
155 lines
4.8 KiB
HTML
155 lines
4.8 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../OLLoader.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
function test_Control_TouchNavigation_constructor (t) {
|
|
t.plan( 2 );
|
|
var options = {bar: "foo"};
|
|
var temp = OpenLayers.Control.prototype.initialize;
|
|
OpenLayers.Control.prototype.initialize = function(opt) {
|
|
t.eq(opt, options,
|
|
"constructor calls parent with the correct options");
|
|
};
|
|
|
|
var control = new OpenLayers.Control.TouchNavigation(options);
|
|
t.ok(control instanceof OpenLayers.Control.TouchNavigation,
|
|
"new OpenLayers.Control returns object");
|
|
|
|
OpenLayers.Control.prototype.initialize = temp;
|
|
}
|
|
|
|
function test_Control_TouchNavigation_destroy(t) {
|
|
t.plan(6);
|
|
|
|
var control = {
|
|
events: {
|
|
destroy: function() {
|
|
t.ok(true, "events destroyed");
|
|
}
|
|
},
|
|
deactivate: function() {
|
|
t.ok(true, "navigation control deactivated before being destroyed");
|
|
},
|
|
dragPan: {
|
|
destroy: function() {
|
|
t.ok(true, "dragPan destroyed");
|
|
}
|
|
},
|
|
handlers: {
|
|
click: {
|
|
destroy: function() {
|
|
t.ok(true, "clickHandler destroyed");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
//this will also trigger one test by calling OpenLayers.Control's destroy
|
|
// and three more for the destruction of dragPan, zoomBox, and wheelHandler
|
|
OpenLayers.Control.TouchNavigation.prototype.destroy.apply(control, []);
|
|
|
|
t.eq(control.dragPan, null, "'dragPan' set to null");
|
|
t.eq(control.handlers, null, "handlers set to null");
|
|
}
|
|
|
|
function test_documentDrag(t) {
|
|
|
|
t.plan(2);
|
|
|
|
/**
|
|
* These tests confirm that the documentDrag property is false by
|
|
* default and is passed on to the DragPan control. Tests of panning
|
|
* while dragging outside the viewport should go in the DragPan tests.
|
|
* Tests of the document events and appropriate callbacks from the
|
|
* handler should go in the Drag handler tests.
|
|
*/
|
|
|
|
var nav = new OpenLayers.Control.TouchNavigation();
|
|
t.eq(nav.documentDrag, false, "documentDrag false by default");
|
|
|
|
var map = new OpenLayers.Map({
|
|
div: document.body,
|
|
controls: [new OpenLayers.Control.TouchNavigation({documentDrag: true})]
|
|
});
|
|
nav = map.controls[0];
|
|
|
|
t.eq(nav.dragPan.documentDrag, true, "documentDrag set on the DragPan control");
|
|
map.destroy();
|
|
|
|
}
|
|
|
|
function test_dragPanOptions(t) {
|
|
|
|
t.plan(2);
|
|
|
|
var nav = new OpenLayers.Control.TouchNavigation();
|
|
t.eq(nav.dragPanOptions, null, "dragPanOptions null by default");
|
|
|
|
var map = new OpenLayers.Map({
|
|
div: document.body,
|
|
controls: [
|
|
new OpenLayers.Control.TouchNavigation({
|
|
dragPanOptions: {foo: 'bar'}
|
|
})
|
|
]
|
|
});
|
|
nav = map.controls[0];
|
|
|
|
t.eq(nav.dragPan.foo, 'bar',
|
|
"foo property is set on the DragPan control");
|
|
map.destroy();
|
|
|
|
}
|
|
|
|
function test_clickHandlerOptions(t) {
|
|
|
|
t.plan(3);
|
|
|
|
var nav = new OpenLayers.Control.TouchNavigation();
|
|
t.eq(nav.clickHandlerOptions, null, "clickHandlerOptions null by default");
|
|
|
|
var map = new OpenLayers.Map({
|
|
div: document.body,
|
|
controls: [
|
|
new OpenLayers.Control.TouchNavigation({
|
|
clickHandlerOptions: {foo: "bar"}
|
|
})
|
|
]
|
|
});
|
|
nav = map.controls[0];
|
|
|
|
t.eq(nav.handlers.click.foo, "bar", "foo property is set on the click handler");
|
|
t.eq(nav.handlers.click.pixelTolerance, 2, "pixelTolerance is 2 by default");
|
|
map.destroy();
|
|
|
|
}
|
|
|
|
function test_zoomOut(t) {
|
|
t.plan(1);
|
|
|
|
var map = new OpenLayers.Map(document.body);
|
|
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
|
"http://labs.metacarta.com/wms/vmap0",
|
|
{layers: 'basic'} );
|
|
map.addLayer(layer);
|
|
map.setCenter(new OpenLayers.LonLat(0, 0), 5);
|
|
var control = new OpenLayers.Control.TouchNavigation();
|
|
map.addControl(control);
|
|
var handler = control.handlers.click;
|
|
handler.touchstart({xy: new OpenLayers.Pixel(1 ,1), touches: ["foo", "bar"]});
|
|
handler.touchend({});
|
|
t.delay_call(1, function() {
|
|
t.eq(map.getZoom(), 4, "Did we zoom out?");
|
|
// tear down
|
|
map.destroy();
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|