@@ -360,7 +360,32 @@ exports["Animation -- Servo"] = {
360
360
) ;
361
361
362
362
test . done ( ) ;
363
- }
363
+ } ,
364
+
365
+ enqueueOnSameTick : function ( test ) {
366
+
367
+ test . expect ( 7 ) ;
368
+
369
+ this . animation = new Animation ( this . a ) ;
370
+
371
+ this . normalizeKeyframes = this . sandbox . spy ( this . animation , "normalizeKeyframes" ) ;
372
+
373
+ test . equal ( this . animation . isRunning , false ) ;
374
+ test . equal ( this . animation . segments . length , 0 ) ;
375
+
376
+ // This is the first segment so it should be immediately shifted off the queue
377
+ test . equal ( this . animation . enqueue ( this . segment . single ) , this . animation ) ;
378
+ test . equal ( this . animation . segments . length , 0 ) ;
379
+ test . equal ( this . animation . isRunning , true ) ;
380
+
381
+ // This is the second segment so it should stay in the queue
382
+ test . equal ( this . animation . enqueue ( this . segment . single ) , this . animation ) ;
383
+ test . equal ( this . animation . segments . length , 1 ) ;
384
+
385
+ this . normalizeKeyframes . restore ( ) ;
386
+ test . done ( ) ;
387
+
388
+ }
364
389
365
390
} ;
366
391
@@ -436,6 +461,7 @@ exports["Animation"] = {
436
461
test . equal ( this . animation . segments . length , 1 ) ;
437
462
test . done ( ) ;
438
463
} ,
464
+
439
465
next : function ( test ) {
440
466
test . expect ( 12 ) ;
441
467
@@ -687,78 +713,6 @@ exports["Animation"] = {
687
713
test . done ( ) ;
688
714
} ,
689
715
690
- loopFunctiononcomplete : function ( test ) {
691
- test . expect ( 2 ) ;
692
-
693
- this . clock = this . sandbox . useFakeTimers ( ) ;
694
- this . tfb = this . sandbox . stub ( Animation , "TemporalFallback" , function ( ) { } ) ;
695
-
696
- var startTime = Date . now ( ) ;
697
- var loop = {
698
- calledAt : startTime + 1000
699
- } ;
700
-
701
- this . animation . startTime = startTime ;
702
- this . animation . fallBackTime = 500 ;
703
- this . animation . speed ( 1 ) ;
704
-
705
-
706
- this . animation . normalizedKeyFrames = [ ] ;
707
- this . animation . target = { } ;
708
- this . animation . target [ Animation . render ] = function ( ) { } ;
709
- this . animation . playLoop = null ;
710
- this . animation . onloop = this . sandbox . stub ( ) ;
711
- this . animation . next = this . sandbox . stub ( ) ;
712
-
713
- var animation = this . animation ;
714
-
715
- this . sandbox . stub ( Animation . prototype , "stop" ) ;
716
- this . animation . oncomplete = function ( ) {
717
- test . equal ( Animation . TemporalFallback . callCount , 1 ) ;
718
- test . equal ( this , animation ) ;
719
-
720
- animation . oncomplete = null ;
721
- test . done ( ) ;
722
- } ;
723
-
724
- this . animation . loopFunction ( loop ) ;
725
- } ,
726
-
727
- loopFunctionNOoncompleteSegmentsRemaining : function ( test ) {
728
- test . expect ( 1 ) ;
729
-
730
- this . clock = this . sandbox . useFakeTimers ( ) ;
731
- this . tfb = this . sandbox . stub ( Animation , "TemporalFallback" , function ( ) { } ) ;
732
- this . stop = this . sandbox . stub ( Animation . prototype , "stop" ) ;
733
-
734
- var startTime = Date . now ( ) ;
735
- var loop = {
736
- calledAt : startTime + 1000
737
- } ;
738
-
739
- this . animation . startTime = startTime ;
740
- this . animation . fallBackTime = 500 ;
741
- this . animation . speed ( 1 ) ;
742
-
743
-
744
- this . animation . normalizedKeyFrames = [ ] ;
745
- this . animation . target = { } ;
746
- this . animation . target [ Animation . render ] = function ( ) { } ;
747
- this . animation . playLoop = null ;
748
- this . animation . onloop = this . sandbox . stub ( ) ;
749
- this . animation . next = this . sandbox . stub ( ) ;
750
-
751
- this . nextTick = this . sandbox . stub ( process , "nextTick" ) ;
752
-
753
- this . animation . next = function ( ) {
754
- test . equal ( this . stop . callCount , 1 ) ;
755
- test . done ( ) ;
756
- } . bind ( this ) ;
757
-
758
- this . animation . segments = [ 1 , 2 , 3 , 4 ] ;
759
- this . animation . loopFunction ( loop ) ;
760
- } ,
761
-
762
716
loopFunctionfallBackTimeWithPlayLoop : function ( test ) {
763
717
test . expect ( 1 ) ;
764
718
@@ -794,8 +748,14 @@ exports["Animation"] = {
794
748
test . expect ( 1 ) ;
795
749
796
750
this . clock = this . sandbox . useFakeTimers ( ) ;
797
- this . normalizeKeyframes = this . sandbox . stub ( Animation . prototype , "normalizeKeyframes" , function ( ) {
798
- this . loopback = 1 ;
751
+ this . animation . normalizeKeyframes = this . sandbox . stub ( Animation . prototype , "normalizeKeyframes" , function ( ) {
752
+ this . animation . loopback = 1 ;
753
+ this . animation . normalizedKeyFrames = [ [
754
+ { value : 90 , easing : "linear" } ,
755
+ { step : false , easing : "linear" , value : 90 } ,
756
+ { value : 45 , easing : "linear" } ,
757
+ { step : 33 , easing : "linear" , value : 78 }
758
+ ] ] ;
799
759
} . bind ( this ) ) ;
800
760
801
761
var startTime = Date . now ( ) ;
@@ -804,18 +764,20 @@ exports["Animation"] = {
804
764
} ;
805
765
806
766
this . animation . startTime = startTime ;
807
- this . animation . normalizedKeyFrames = [ ] ;
808
767
this . animation . target = { } ;
809
768
this . animation . target [ Animation . render ] = function ( ) { } ;
810
769
this . animation . speed ( 1 ) ;
811
770
812
771
this . animation . metronomic = true ;
813
772
this . animation . reverse = false ;
814
773
this . animation . loop = true ;
774
+ this . animation . fps = 10 ;
815
775
this . animation . onloop = this . sandbox . spy ( ) ;
776
+ this . animation . normalizeKeyframes ( ) ;
816
777
this . animation . loopFunction ( loop ) ;
817
778
818
779
test . equal ( this . animation . onloop . callCount , 1 ) ;
780
+ this . animation . stop ( ) ;
819
781
test . done ( ) ;
820
782
} ,
821
783
@@ -1021,8 +983,9 @@ exports["Animation.Segment"] = {
1021
983
} ,
1022
984
1023
985
instanceof : function ( test ) {
1024
- test . expect ( 1 ) ;
986
+ test . expect ( 2 ) ;
1025
987
test . equal ( Animation ( { } ) instanceof Animation , true ) ;
988
+ test . equal ( Animation ( ) instanceof Animation , true ) ;
1026
989
test . done ( ) ;
1027
990
} ,
1028
991
0 commit comments