]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Tween.html
initial commit
[syp.git] / openlayers / tests / Tween.html
1 <html> 
2 <head> 
3     <script src="../lib/OpenLayers.js"></script> 
4     <script type="text/javascript">
5
6     function test_Tween_constructor(t) { 
7         t.plan(3);
8         
9         var tween = new OpenLayers.Tween();
10         t.ok(tween instanceof OpenLayers.Tween, 
11              "new OpenLayers.Tween returns object" );
12         t.eq(typeof tween.easing, "function", 
13             "constructor sets easing correctly"); 
14         t.eq(typeof tween.start, "function", "tween has a start function"); 
15     }
16     
17     function test_Tween_start(t) {
18         t.plan(5);
19         
20         var tween = new OpenLayers.Tween();
21
22         var start = {foo: 0, bar: 10};
23         var finish = {foo: 10, bar: 0};
24         var _start = false;
25         var _done = false;
26         var _eachStep = false;
27         var callbacks = {
28             start: function() {
29                 _start = true;
30             },
31             done: function() {
32                 _done = true;
33             },
34             eachStep: function() {
35                 _eachStep = true;
36             }
37         }
38         tween.start(start, finish, 10, {callbacks: callbacks});
39         t.ok(tween.interval != null, "interval correctly set");
40         t.delay_call(0.8, function() {
41             t.eq(_start, true, "start callback called");
42             t.eq(_done, true, "finish callback called");
43             t.eq(_eachStep, true, "eachStep callback called");
44             t.eq(tween.time, 11, "Number of steps reached is correct");
45         });
46     }
47
48     function test_Tween_stop(t) {
49         t.plan(2);
50         
51         var tween = new OpenLayers.Tween();
52         tween.interval = window.setInterval(function() {}, 10);
53         tween.playing = true;
54         tween.stop();
55         t.eq(tween.interval, null, "tween correctly stopped");
56         
57         tween.interval = window.setInterval(function() {}, 10);
58         tween.playing = false;
59         tween.stop();
60         t.ok(tween.interval != null, "stop method doesn't do anything if tween isn't running");
61     }
62
63     </script> 
64 </head> 
65 <body> 
66   <div id="map" style="width:500px;height:500px"></div>
67 </body> 
68 </html>