summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Animation.html
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/tests/Animation.html')
-rw-r--r--misc/openlayers/tests/Animation.html96
1 files changed, 96 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Animation.html b/misc/openlayers/tests/Animation.html
new file mode 100644
index 0000000..c24ae49
--- /dev/null
+++ b/misc/openlayers/tests/Animation.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Animation.js Tests</title>
+ <script>
+
+ // dependencies for tests
+ var OpenLayers = [
+ "OpenLayers/Util/vendorPrefix.js",
+ "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.");
+
+ function doIt(win) {
+ win.requestFrame(t);
+ win.start(t);
+ win.startDuration(t);
+ win.stop(t);
+ }
+
+ // Test in an extra window in Firefox, and directly in other browsers.
+ // This is needed because requestAnimationFrame does not work
+ // correctly in Firefox in a hidden IFrame.
+ if (window.mozRequestAnimationFrame) {
+ t.open_window("Animation.html", doIt);
+ } else {
+ doIt(window);
+ }
+ }
+
+ 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> \ No newline at end of file