@@ -489,7 +489,36 @@ public static void ClipPropertyTest (AnimationClip animClipExpected, AnimationCl
489
489
Assert . That ( animClipActual . wrapMode , Is . EqualTo ( animClipExpected . wrapMode ) ) ;
490
490
491
491
// TODO: Uni-34489
492
- Assert . That ( animClipActual . length , Is . EqualTo ( animClipExpected . length ) . Within ( Mathf . Epsilon ) , "animClip length doesn't match" ) ;
492
+ Assert . That ( animClipActual . length , Is . EqualTo ( animClipExpected . length ) . Within ( 0.0001f ) , "animClip length doesn't match" ) ;
493
+ }
494
+
495
+ /// <summary>
496
+ /// Compares the properties and curves of two animation clips.
497
+ /// </summary>
498
+ /// <param name="animClipOriginal">Animation clip original.</param>
499
+ /// <param name="animClipImported">Animation clip imported.</param>
500
+ public static void ClipTest ( AnimationClip animClipOriginal , AnimationClip animClipImported ) {
501
+ // check clip properties match
502
+ AnimTester . ClipPropertyTest ( animClipOriginal , animClipImported ) ;
503
+
504
+ foreach ( EditorCurveBinding curveBinding in AnimationUtility . GetCurveBindings ( animClipOriginal ) ) {
505
+ foreach ( EditorCurveBinding impCurveBinding in AnimationUtility . GetCurveBindings ( animClipImported ) ) {
506
+
507
+ // only compare if the path and property names match
508
+ if ( curveBinding . path != impCurveBinding . path || curveBinding . propertyName != impCurveBinding . propertyName ) {
509
+ continue ;
510
+ }
511
+
512
+ AnimationCurve animCurveOrig = AnimationUtility . GetEditorCurve ( animClipOriginal , curveBinding ) ;
513
+ Assert . That ( animCurveOrig , Is . Not . Null ) ;
514
+
515
+ AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( animClipImported , impCurveBinding ) ;
516
+ Assert . That ( animCurveImported , Is . Not . Null ) ;
517
+
518
+ AnimTester . KeyValuesTest ( animCurveImported , animCurveOrig ,
519
+ string . Format ( "path: {0}, property: {1}" , curveBinding . path , curveBinding . propertyName ) ) ;
520
+ }
521
+ }
493
522
}
494
523
495
524
public static void KeysTest ( AnimationCurve expectedAnimCurve , AnimationCurve actualAnimCurve , string message , IComparer < Keyframe > keyComparer = null )
@@ -645,26 +674,7 @@ public void LegacySkinnedMeshAnimTest (string fbxPath)
645
674
646
675
var animClipImported = AnimTester . GetClipFromFbx ( filename ) ;
647
676
648
- // check clip properties match
649
- AnimTester . ClipPropertyTest ( animClipOriginal , animClipImported ) ;
650
-
651
- foreach ( EditorCurveBinding curveBinding in AnimationUtility . GetCurveBindings ( animClipOriginal ) ) {
652
- foreach ( EditorCurveBinding impCurveBinding in AnimationUtility . GetCurveBindings ( animClipImported ) ) {
653
-
654
- // only compare if the path and property names match
655
- if ( curveBinding . path != impCurveBinding . path || curveBinding . propertyName != impCurveBinding . propertyName ) {
656
- continue ;
657
- }
658
-
659
- AnimationCurve animCurveOrig = AnimationUtility . GetEditorCurve ( animClipOriginal , curveBinding ) ;
660
- Assert . That ( animCurveOrig , Is . Not . Null ) ;
661
-
662
- AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( animClipImported , impCurveBinding ) ;
663
- Assert . That ( animCurveImported , Is . Not . Null ) ;
664
-
665
- AnimTester . CurveTest ( animCurveImported , animCurveOrig , curveBinding . propertyName ) ;
666
- }
667
- }
677
+ AnimTester . ClipTest ( animClipOriginal , animClipImported ) ;
668
678
}
669
679
670
680
[ Test , TestCaseSource ( typeof ( AnimationTestDataClass ) , "TransformIndependantComponentTestCases" ) ]
@@ -848,28 +858,8 @@ public void AnimOnlyExportTest(string prefabPath)
848
858
849
859
foreach ( var clip in animClips ) {
850
860
Assert . That ( fbxAnimClips . ContainsKey ( clip . name ) ) ;
851
-
852
861
var fbxClip = fbxAnimClips [ clip . name ] ;
853
-
854
- AnimTester . ClipPropertyTest ( clip , fbxClip ) ;
855
-
856
- foreach ( EditorCurveBinding curveBinding in AnimationUtility . GetCurveBindings ( clip ) ) {
857
- foreach ( EditorCurveBinding impCurveBinding in AnimationUtility . GetCurveBindings ( fbxClip ) ) {
858
-
859
- // only compare if the path and property names match
860
- if ( curveBinding . path != impCurveBinding . path || curveBinding . propertyName != impCurveBinding . propertyName ) {
861
- continue ;
862
- }
863
-
864
- AnimationCurve animCurveOrig = AnimationUtility . GetEditorCurve ( clip , curveBinding ) ;
865
- Assert . That ( animCurveOrig , Is . Not . Null ) ;
866
-
867
- AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( fbxClip , impCurveBinding ) ;
868
- Assert . That ( animCurveImported , Is . Not . Null ) ;
869
-
870
- AnimTester . CurveTest ( animCurveImported , animCurveOrig , curveBinding . propertyName ) ;
871
- }
872
- }
862
+ AnimTester . ClipTest ( clip , fbxClip ) ;
873
863
}
874
864
}
875
865
0 commit comments