Files
openlayers/tests/Animation.html
ahocevar 720c49c040 Re-introducing tileLoadingDelay.
Only use it if no native requestAnimationFrame function is available. This should improve performance on mobile devices.
2012-01-29 18:50:03 +01:00

85 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Animation.js Tests</title>
<script>
// dependencies for tests
var OpenLayers = [
"OpenLayers/Animation.js"
];
</script>
<script src="OLLoader.js"></script>
<script>
function test_all(t) {
t.plan(8);
t.ok(OpenLayers.Animation.isNative !== undefined, "isNative is set.");
t.open_window("Animation.html", function(win) {
win.requestFrame(t);
win.start(t);
win.startDuration(t);
win.stop(t);
});
}
function requestFrame(t) {
t.eq(typeof OpenLayers.Animation.requestFrame, "function", "requestFrame is a function");
var calls = 0;
OpenLayers.Animation.requestFrame(function() {
++calls;
});
t.delay_call(0.1, function() {
t.ok(calls > 0, "callback called: " + calls);
});
}
function start(t) {
var calls = 0;
var id = OpenLayers.Animation.start(function() {
++calls;
});
t.delay_call(0.1, function() {
t.ok(calls > 1, "looped: " + calls);
OpenLayers.Animation.stop(id);
});
}
function startDuration(t) {
var calls = 0;
var id = OpenLayers.Animation.start(function() {
++calls;
}, 100);
var first;
t.delay_call(0.2, function() {
first = calls;
t.ok(calls > 1, "looped: " + calls);
});
t.delay_call(0.3, function() {
t.eq(calls, first, "not being called any more");
});
}
function stop(t) {
var calls = 0;
var id = OpenLayers.Animation.start(function() {
++calls;
});
var first;
t.delay_call(0.2, function() {
first = calls;
t.ok(calls > 1, "looped: " + calls);
OpenLayers.Animation.stop(id);
});
t.delay_call(0.3, function() {
t.eq(calls, first, "not being called any more");
});
}
</script>