add a touch device-specific navigation control, p=bbinet, r=me (closes #3068)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11208 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
109
tests/Control/TouchNavigation.html
Normal file
109
tests/Control/TouchNavigation.html
Normal file
@@ -0,0 +1,109 @@
|
||||
<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();
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user