summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Tween.html
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/Tween.html
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Tween.html')
-rw-r--r--misc/openlayers/tests/Tween.html116
1 files changed, 116 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Tween.html b/misc/openlayers/tests/Tween.html
new file mode 100644
index 0000000..1fbfa3c
--- /dev/null
+++ b/misc/openlayers/tests/Tween.html
@@ -0,0 +1,116 @@
+<html>
+<head>
+ <script>
+ /**
+ * Because browsers that implement requestAnimationFrame may not execute
+ * animation functions while a window is not displayed (e.g. in a hidden
+ * iframe as in these tests), we mask the native implementations here. The
+ * native requestAnimationFrame functionality is tested in Util.html and
+ * in PanZoom.html (where a popup is opened before panning). The panTo tests
+ * here will test the fallback setTimeout implementation for animation.
+ */
+ window.requestAnimationFrame =
+ window.webkitRequestAnimationFrame =
+ window.mozRequestAnimationFrame =
+ window.oRequestAnimationFrame =
+ window.msRequestAnimationFrame = null;
+ </script>
+ <script src="OLLoader.js"></script>
+ <script type="text/javascript">
+
+ function test_Tween_constructor(t) {
+ t.plan(3);
+
+ var tween = new OpenLayers.Tween();
+ t.ok(tween instanceof OpenLayers.Tween,
+ "new OpenLayers.Tween returns object" );
+ t.eq(typeof tween.easing, "function",
+ "constructor sets easing correctly");
+ t.eq(typeof tween.start, "function", "tween has a start function");
+ }
+
+ function test_Tween_start(t) {
+ t.plan(5);
+
+ var tween = new OpenLayers.Tween();
+
+ var start = {foo: 0, bar: 10};
+ var finish = {foo: 10, bar: 0};
+ var _start = false;
+ var _done = false;
+ var _eachStep = false;
+ var callbacks = {
+ start: function() {
+ _start = true;
+ },
+ done: function() {
+ _done = true;
+ },
+ eachStep: function() {
+ _eachStep = true;
+ }
+ }
+ tween.start(start, finish, 10, {callbacks: callbacks});
+ t.ok(tween.animationId != null, "animationId correctly set");
+ t.delay_call(0.8, function() {
+ t.eq(_start, true, "start callback called");
+ t.eq(_done, true, "finish callback called");
+ t.eq(_eachStep, true, "eachStep callback called");
+ t.eq(tween.time, 11, "Number of steps reached is correct");
+ });
+ }
+
+ function test_Tween_stop(t) {
+ t.plan(2);
+
+ var tween = new OpenLayers.Tween();
+ tween.animationId = OpenLayers.Animation.start(function() {});
+ tween.playing = true;
+ tween.stop();
+ t.eq(tween.animationId, null, "tween correctly stopped");
+
+ tween.animationId = OpenLayers.Animation.start(function() {});
+ tween.playing = false;
+ tween.stop();
+ t.ok(tween.animationId != null, "stop method doesn't do anything if tween isn't running");
+ }
+
+ function test_Tween_skip(t) {
+ t.plan(2);
+
+ var tween = new OpenLayers.Tween();
+ var log = 0;
+ tween.start({count: 0}, {count: 10}, 10, {
+ callbacks: {
+ eachStep: function() {
+ log++;
+ }
+ },
+ minFrameRate: 10000
+ });
+
+ t.delay_call(0.8, function() {
+ t.eq(log, 0, 'all frames skipped at a frame rate of 10000');
+
+ log = 0;
+ tween.start({count: 0}, {count: 10}, 10, {
+ callbacks: {
+ eachStep: function() {
+ log++;
+ }
+ },
+ minFrameRate: 1
+ });
+ });
+
+ t.delay_call(1.6, function() {
+ t.eq(log, 11, 'no frames skipped at a frame rate of 1');
+ });
+ }
+
+ </script>
+</head>
+<body>
+ <div id="map" style="width:500px;height:500px"></div>
+</body>
+</html>